chore: add back allure (#2247)

This commit is contained in:
fbarbu15 2025-02-03 10:29:55 +02:00 committed by GitHub
parent 62f93dc842
commit 2a7f4b6e86
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 270 additions and 75 deletions

27
.github/actions/prune-vm/action.yml vendored Normal file
View File

@ -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

View File

@ -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

View File

@ -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
@ -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 }}
@ -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: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
- 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:
name: Test Report - ${{ inputs.test_type }}
path: 'packages/tests/reports/mocha-*.json'
reporter: mocha-json
fail-on-error: true
repository: waku-org/allure-jswaku
ref: gh-pages
path: gh-pages
token: ${{ env.GITHUB_TOKEN }}
- name: Setup allure report
if: always() && env.ALLURE_REPORTS == 'true'
uses: simple-elf/allure-report-action@master
id: allure-report
with:
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
@ -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
ci/mergeAllureResults.cjs Normal file
View File

@ -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
package-lock.json generated
View File

@ -11923,6 +11923,59 @@
"ajv": "^6.9.1"
}
},
"node_modules/allure-commandline": {
"version": "2.32.0",
"resolved": "https://registry.npmjs.org/allure-commandline/-/allure-commandline-2.32.0.tgz",
"integrity": "sha512-W03ors+ks8uy0SgQILHQvtvR0iadAfDYmTFC3p8Pk4pi8KXUW1cF+z8FN2+7deH3FE2cuYgjhhA+CdLdJfzOMQ==",
"dev": true,
"bin": {
"allure": "bin/allure"
}
},
"node_modules/allure-js-commons": {
"version": "2.15.1",
"resolved": "https://registry.npmjs.org/allure-js-commons/-/allure-js-commons-2.15.1.tgz",
"integrity": "sha512-5V/VINplbu0APnfSZOkYpKOzucO36Q2EtTD1kqjWjl7n6tj7Hh+IHCZsH3Vpk/LXRDfj9RuXugBBvwYKV5YMJw==",
"dev": true,
"dependencies": {
"md5": "^2.3.0",
"properties": "^1.2.1",
"strip-ansi": "^5.2.0"
}
},
"node_modules/allure-js-commons/node_modules/ansi-regex": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz",
"integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==",
"dev": true,
"engines": {
"node": ">=6"
}
},
"node_modules/allure-js-commons/node_modules/strip-ansi": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
"integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
"dev": true,
"dependencies": {
"ansi-regex": "^4.1.0"
},
"engines": {
"node": ">=6"
}
},
"node_modules/allure-mocha": {
"version": "2.15.1",
"resolved": "https://registry.npmjs.org/allure-mocha/-/allure-mocha-2.15.1.tgz",
"integrity": "sha512-4Hk2qUR6LdAUXNpPe73MV3DPKrBH7zy57lbAdb/D0poNIkdGEkzUYkpVPtW1imYfjqFXKBFEPOSJWqznGuiyjg==",
"dev": true,
"dependencies": {
"allure-js-commons": "2.15.1"
},
"peerDependencies": {
"mocha": ">=6.2.x"
}
},
"node_modules/anser": {
"version": "1.4.10",
"resolved": "https://registry.npmjs.org/anser/-/anser-1.4.10.tgz",
@ -26336,6 +26389,22 @@
"node": ">= 14.0.0"
}
},
"node_modules/mocha-multi-reporters": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/mocha-multi-reporters/-/mocha-multi-reporters-1.5.1.tgz",
"integrity": "sha512-Yb4QJOaGLIcmB0VY7Wif5AjvLMUFAdV57D2TWEva1Y0kU/3LjKpeRVmlMIfuO1SVbauve459kgtIizADqxMWPg==",
"dev": true,
"dependencies": {
"debug": "^4.1.1",
"lodash": "^4.17.15"
},
"engines": {
"node": ">=6.0.0"
},
"peerDependencies": {
"mocha": ">=3.1.2"
}
},
"node_modules/mocha/node_modules/cliui": {
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz",
@ -33098,6 +33167,15 @@
"integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==",
"license": "ISC"
},
"node_modules/properties": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/properties/-/properties-1.2.1.tgz",
"integrity": "sha512-qYNxyMj1JeW54i/EWEFsM1cVwxJbtgPp8+0Wg9XjNaK6VE/c4oRi6PNu5p7w1mNXEIQIjV5Wwn8v8Gz82/QzdQ==",
"dev": true,
"engines": {
"node": ">=0.10"
}
},
"node_modules/proto-list": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz",
@ -41554,6 +41632,8 @@
"@waku/message-encryption": "*",
"@waku/relay": "*",
"@waku/sdk": "*",
"allure-commandline": "^2.27.0",
"allure-mocha": "^2.9.2",
"chai": "^4.3.10",
"cspell": "^8.6.1",
"datastore-core": "^10.0.2",
@ -41561,6 +41641,7 @@
"interface-datastore": "^8.2.10",
"libp2p": "2.1.8",
"mocha": "^10.3.0",
"mocha-multi-reporters": "^1.5.1",
"npm-run-all": "^4.1.5"
},
"engines": {

View File

@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, allure-mocha",
"allureMochaReporter": {
"outputDir": "allure-results"
}
}

View File

@ -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;

View File

@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, allure-mocha",
"allureMochaReporter": {
"outputDir": "allure-results"
}
}

View File

@ -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");

View File

@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, allure-mocha",
"allureMochaReporter": {
"outputDir": "allure-results"
}
}

View File

@ -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;

View File

@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, allure-mocha",
"allureMochaReporter": {
"outputDir": "allure-results"
}
}

View File

@ -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;

View File

@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, allure-mocha",
"allureMochaReporter": {
"outputDir": "allure-results"
}
}

View File

@ -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;

View File

@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, allure-mocha",
"allureMochaReporter": {
"outputDir": "allure-results"
}
}

View File

@ -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;

View File

@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, allure-mocha",
"allureMochaReporter": {
"outputDir": "allure-results"
}
}

View File

@ -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;
module.exports = config;

View File

@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, allure-mocha",
"allureMochaReporter": {
"outputDir": "allure-results"
}
}

View File

@ -14,13 +14,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;
module.exports = config;

View File

@ -42,8 +42,8 @@
"check:spelling": "cspell \"{README.md,{tests,src}/**/*.ts}\"",
"check:tsc": "tsc -p tsconfig.dev.json",
"test": "NODE_ENV=test run-s test:*",
"test:node": "NODE_ENV=test mkdir -p reports && node ./src/run-tests.js \"tests/**/!(*.optional).spec.ts\"",
"test:optional": "NODE_ENV=test mkdir -p reports && node ./src/run-tests.js \"tests/**/@(*.optional).spec.ts\"",
"test:node": "NODE_ENV=test node ./src/run-tests.js \"tests/**/!(*.optional).spec.ts\"",
"test:optional": "NODE_ENV=test node ./src/run-tests.js \"tests/**/@(*.optional).spec.ts\"",
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build"
},
"engines": {
@ -79,6 +79,8 @@
"@waku/message-encryption": "*",
"@waku/relay": "*",
"@waku/sdk": "*",
"allure-commandline": "^2.27.0",
"allure-mocha": "^2.9.2",
"chai": "^4.3.10",
"cspell": "^8.6.1",
"datastore-core": "^10.0.2",
@ -86,6 +88,7 @@
"interface-datastore": "^8.2.10",
"libp2p": "2.1.8",
"mocha": "^10.3.0",
"mocha-multi-reporters": "^1.5.1",
"npm-run-all": "^4.1.5"
}
}

View File

@ -1,6 +1,4 @@
import { exec, spawn } from "child_process";
import { mkdir } from "fs/promises";
import { dirname } from "path";
import { promisify } from "util";
const execAsync = promisify(exec);
@ -22,34 +20,10 @@ async function main() {
"--require",
"ts-node/register",
"--project",
"./tsconfig.dev.json"
"./tsconfig.dev.json",
...process.argv.slice(2)
];
if (process.env.CI) {
const reportPath = "reports/mocha-results.json";
await mkdir(dirname(reportPath), { recursive: true });
mochaArgs.push(
"--reporter",
"json",
"--reporter-option",
`output=${reportPath}`,
"--parallel",
"--jobs",
"6"
);
}
// Add test files
const testFiles = process.argv.slice(2);
if (testFiles.length === 0) {
// Default to all test files if none specified
testFiles.push("tests/**/*.spec.ts");
}
mochaArgs.push(...testFiles);
console.log("Running mocha with args:", mochaArgs);
// Run mocha tests
const mocha = spawn("npx", mochaArgs, {
stdio: "inherit",

View File

@ -0,0 +1,6 @@
{
"reporterEnabled": "spec, allure-mocha",
"allureMochaReporter": {
"outputDir": "allure-results"
}
}

View File

@ -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;