Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add back allure #2247

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/actions/prune-vm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Inspired by https://github.com/AdityaGarg8/remove-unwanted-software
# to free up disk space. Currently removes Dotnet, Android and Haskell.
name: Remove unwanted software
description: Default GitHub runners come with a lot of unnecessary software
runs:
using: "composite"
steps:
- name: Disk space report before modification
shell: bash
run: |
echo "==> Available space before cleanup"
echo
df -h
- name: Maximize build disk space
shell: bash
run: |
set -euo pipefail
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/.ghcup
- name: Disk space report after modification
shell: bash
run: |
echo "==> Available space after cleanup"
echo
df -h
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ jobs:
with:
nim_wakunode_image: ${{ inputs.nim_wakunode_image || 'wakuorg/nwaku:v0.31.0' }}
test_type: node
allure_reports: true

node_optional:
uses: ./.github/workflows/test-node.yml
Expand Down
59 changes: 51 additions & 8 deletions .github/workflows/test-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,24 @@ on:
required: false
type: string
default: ''
allure_reports:
required: false
type: boolean
default: false

env:
NODE_JS: "20"
# Ensure test type conditions remain consistent.
WAKU_SERVICE_NODE_PARAMS: ${{ (inputs.test_type == 'go-waku-master') && '--min-relay-peers-to-publish=0' || '' }}
DEBUG: ${{ inputs.debug }}
GITHUB_TOKEN: ${{ secrets.DEPLOY_TEST_REPORTS_PAT }}

jobs:
node:
runs-on: ubuntu-latest
env:
WAKUNODE_IMAGE: ${{ inputs.nim_wakunode_image }}
ALLURE_REPORTS: ${{ inputs.allure_reports }}
permissions:
contents: read
actions: read
Expand All @@ -39,6 +45,9 @@ jobs:
with:
repository: waku-org/js-waku

- name: Remove unwanted software
uses: ./.github/actions/prune-vm

- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_JS }}
Expand All @@ -47,16 +56,42 @@ jobs:

- run: npm run build:esm

- run: ${{ (inputs.test_type == 'node-optional') && 'npm run test:optional --workspace=@waku/tests' || 'npm run test:node' }}
- name: Run tests
timeout-minutes: 30
run: ${{ (inputs.test_type == 'node-optional') && 'npm run test:optional --workspace=@waku/tests' || 'npm run test:node' }}

- name: Merge allure reports
if: always() && env.ALLURE_REPORTS == 'true'
run: node ci/mergeAllureResults.cjs

- name: Get allure history
if: always() && env.ALLURE_REPORTS == 'true'
uses: actions/checkout@v3
continue-on-error: true
with:
repository: waku-org/allure-jswaku
ref: gh-pages
path: gh-pages
token: ${{ env.GITHUB_TOKEN }}

- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
- name: Setup allure report
if: always() && env.ALLURE_REPORTS == 'true'
uses: simple-elf/allure-report-action@master
id: allure-report
with:
name: Test Report - ${{ inputs.test_type }}
path: 'packages/tests/reports/mocha-*.json'
reporter: mocha-json
fail-on-error: true
allure_results: allure-results
gh_pages: gh-pages
allure_history: allure-history
keep_reports: 30

- name: Deploy report to Github Pages
if: always() && env.ALLURE_REPORTS == 'true'
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ env.GITHUB_TOKEN }}
external_repository: waku-org/allure-jswaku
publish_branch: gh-pages
publish_dir: allure-history

- name: Upload debug logs on failure
uses: actions/upload-artifact@v4
Expand All @@ -83,3 +118,11 @@ jobs:
with:
name: ${{ inputs.test_type }}-logs
path: packages/tests/log/

- name: Create test summary
if: always() && env.ALLURE_REPORTS == 'true'
run: |
echo "## Run Information" >> $GITHUB_STEP_SUMMARY
echo "- **NWAKU**: ${{ env.WAKUNODE_IMAGE }}" >> $GITHUB_STEP_SUMMARY
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
echo "Allure report will be available at: https://waku-org.github.io/allure-jswaku/${{ github.run_number }}" >> $GITHUB_STEP_SUMMARY
19 changes: 19 additions & 0 deletions ci/mergeAllureResults.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const fs = require("fs-extra");
const glob = require("glob");

const ROOT_ALLURE_RESULTS = "./allure-results"; // Target directory in the root

fs.ensureDirSync(ROOT_ALLURE_RESULTS);

const directories = glob.sync("packages/**/allure-results");

directories.forEach((dir) => {
const files = fs.readdirSync(dir);
files.forEach((file) => {
const sourcePath = `${dir}/${file}`;
const targetPath = `${ROOT_ALLURE_RESULTS}/${file}`;
fs.copyFileSync(sourcePath, targetPath);
});
});

console.log("All allure-results directories merged successfully!");
81 changes: 81 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/core/.mocha.reporters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, allure-mocha",
"allureMochaReporter": {
"outputDir": "allure-results"
}
}
8 changes: 4 additions & 4 deletions packages/core/.mocharc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ if (process.env.CI) {
console.log("Running tests in parallel");
config.parallel = true;
config.jobs = 6;
console.log("Using JSON reporter for test results");
config.reporter = 'json';
console.log("Activating allure reporting");
config.reporter = 'mocha-multi-reporters';
config.reporterOptions = {
output: 'reports/mocha-results.json'
configFile: '.mocha.reporters.json'
};
} else {
console.log("Running tests serially. To enable parallel execution update mocha config");
}

module.exports = config;
module.exports = config;
6 changes: 6 additions & 0 deletions packages/discovery/.mocha.reporters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, allure-mocha",
"allureMochaReporter": {
"outputDir": "allure-results"
}
}
6 changes: 3 additions & 3 deletions packages/discovery/.mocharc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ if (process.env.CI) {
console.log("Running tests in parallel");
config.parallel = true;
config.jobs = 6;
console.log("Using JSON reporter for test results");
config.reporter = 'json';
console.log("Activating allure reporting");
config.reporter = 'mocha-multi-reporters';
config.reporterOptions = {
output: 'reports/mocha-results.json'
configFile: '.mocha.reporters.json'
};
} else {
console.log("Running tests serially. To enable parallel execution update mocha config");
Expand Down
6 changes: 6 additions & 0 deletions packages/enr/.mocha.reporters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, allure-mocha",
"allureMochaReporter": {
"outputDir": "allure-results"
}
}
7 changes: 3 additions & 4 deletions packages/enr/.mocharc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ if (process.env.CI) {
console.log("Running tests in parallel");
config.parallel = true;
config.jobs = 6;
console.log("Using JSON reporter for test results");
config.reporter = 'json';
console.log("Activating allure reporting");
config.reporter = 'mocha-multi-reporters';
config.reporterOptions = {
output: 'reports/mocha-results.json'
configFile: '.mocha.reporters.json'
};
} else {
console.log("Running tests serially. To enable parallel execution update mocha config");
}

module.exports = config;
6 changes: 6 additions & 0 deletions packages/message-encryption/.mocha.reporters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, allure-mocha",
"allureMochaReporter": {
"outputDir": "allure-results"
}
}
7 changes: 3 additions & 4 deletions packages/message-encryption/.mocharc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ if (process.env.CI) {
console.log("Running tests in parallel");
config.parallel = true;
config.jobs = 6;
console.log("Using JSON reporter for test results");
config.reporter = 'json';
console.log("Activating allure reporting");
config.reporter = 'mocha-multi-reporters';
config.reporterOptions = {
output: 'reports/mocha-results.json'
configFile: '.mocha.reporters.json'
};
} else {
console.log("Running tests serially. To enable parallel execution update mocha config");
}

module.exports = config;
6 changes: 6 additions & 0 deletions packages/message-hash/.mocha.reporters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, allure-mocha",
"allureMochaReporter": {
"outputDir": "allure-results"
}
}
7 changes: 3 additions & 4 deletions packages/message-hash/.mocharc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ if (process.env.CI) {
console.log("Running tests in parallel");
config.parallel = true;
config.jobs = 6;
console.log("Using JSON reporter for test results");
config.reporter = 'json';
console.log("Activating allure reporting");
config.reporter = 'mocha-multi-reporters';
config.reporterOptions = {
output: 'reports/mocha-results.json'
configFile: '.mocha.reporters.json'
};
} else {
console.log("Running tests serially. To enable parallel execution update mocha config");
}

module.exports = config;
Loading
Loading