diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a12df18f8..2a74e8fb08 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -124,7 +124,7 @@ jobs: with: nim_wakunode_image: ${{ inputs.nim_wakunode_image || 'wakuorg/nwaku:v0.31.0' }} test_type: node - allure_reports: true + debug: waku* node_optional: uses: ./.github/workflows/test-node.yml diff --git a/.github/workflows/test-node.yml b/.github/workflows/test-node.yml index b1801bf4b0..961990a36d 100644 --- a/.github/workflows/test-node.yml +++ b/.github/workflows/test-node.yml @@ -18,24 +18,22 @@ 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 + checks: write steps: - uses: actions/checkout@v3 with: @@ -51,38 +49,14 @@ jobs: - 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 + - name: Test Report + uses: dorny/test-reporter@v1 + if: success() || failure() with: - 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: ${{ inputs.test_type }} Tests + path: 'packages/tests/reports/mocha-*.json' + reporter: mocha-json + fail-on-error: true - name: Upload debug logs on failure uses: actions/upload-artifact@v3 @@ -109,11 +83,3 @@ 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 diff --git a/.gitignore b/.gitignore index ebcefbd801..e9b7959725 100644 --- a/.gitignore +++ b/.gitignore @@ -12,5 +12,4 @@ docs test-results playwright-report example -allure-results packages/discovery/mock_local_storage \ No newline at end of file diff --git a/ci/mergeAllureResults.cjs b/ci/mergeAllureResults.cjs deleted file mode 100644 index afb414cb55..0000000000 --- a/ci/mergeAllureResults.cjs +++ /dev/null @@ -1,19 +0,0 @@ -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!"); diff --git a/packages/core/.mocha.reporters.json b/packages/core/.mocha.reporters.json deleted file mode 100644 index 8c00e441fc..0000000000 --- a/packages/core/.mocha.reporters.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "reporterEnabled": "spec, allure-mocha", - "allureMochaReporter": { - "outputDir": "allure-results" - } -} diff --git a/packages/core/.mocharc.cjs b/packages/core/.mocharc.cjs index dc72692443..050314c578 100644 --- a/packages/core/.mocharc.cjs +++ b/packages/core/.mocharc.cjs @@ -3,21 +3,22 @@ const config = { spec: 'src/**/*.spec.ts', require: ['ts-node/register', 'isomorphic-fetch'], loader: 'ts-node/esm', - nodeOptions: [ + 'node-option': [ 'experimental-specifier-resolution=node', 'loader=ts-node/esm' ], - exit: true + exit: true, + retries: 4, }; if (process.env.CI) { console.log("Running tests in parallel"); config.parallel = true; config.jobs = 6; - console.log("Activating allure reporting"); - config.reporter = 'mocha-multi-reporters'; + console.log("Using JSON reporter for test results"); + config.reporter = 'json'; config.reporterOptions = { - configFile: '.mocha.reporters.json' + output: 'reports/mocha-results.json' }; } else { console.log("Running tests serially. To enable parallel execution update mocha config"); diff --git a/packages/discovery/.mocha.reporters.json b/packages/discovery/.mocha.reporters.json deleted file mode 100644 index 8c00e441fc..0000000000 --- a/packages/discovery/.mocha.reporters.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "reporterEnabled": "spec, allure-mocha", - "allureMochaReporter": { - "outputDir": "allure-results" - } -} diff --git a/packages/discovery/.mocharc.cjs b/packages/discovery/.mocharc.cjs index 423c0517bd..77cc8af51b 100644 --- a/packages/discovery/.mocharc.cjs +++ b/packages/discovery/.mocharc.cjs @@ -7,17 +7,18 @@ const config = { 'experimental-specifier-resolution=node', 'loader=ts-node/esm' ], - exit: true + exit: true, + retries: 4 }; if (process.env.CI) { console.log("Running tests in parallel"); config.parallel = true; config.jobs = 6; - console.log("Activating allure reporting"); - config.reporter = 'mocha-multi-reporters'; + console.log("Using JSON reporter for test results"); + config.reporter = 'json'; config.reporterOptions = { - configFile: '.mocha.reporters.json' + output: 'reports/mocha-results.json' }; } else { console.log("Running tests serially. To enable parallel execution update mocha config"); diff --git a/packages/discovery/package.json b/packages/discovery/package.json index 45dd462d64..4757f0dfc6 100644 --- a/packages/discovery/package.json +++ b/packages/discovery/package.json @@ -44,7 +44,7 @@ "prepublish": "npm run build", "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build", "test": "NODE_ENV=test run-s test:*", - "test:node": "NODE_ENV=test TS_NODE_PROJECT=./tsconfig.dev.json mocha", + "test:node": "NODE_ENV=test TS_NODE_PROJECT=./tsconfig.dev.json mocha 'src/**/*.spec.ts'", "test:browser": "NODE_ENV=test karma start karma.conf.cjs" }, "engines": { diff --git a/packages/enr/.mocha.reporters.json b/packages/enr/.mocha.reporters.json deleted file mode 100644 index 8c00e441fc..0000000000 --- a/packages/enr/.mocha.reporters.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "reporterEnabled": "spec, allure-mocha", - "allureMochaReporter": { - "outputDir": "allure-results" - } -} diff --git a/packages/enr/.mocharc.cjs b/packages/enr/.mocharc.cjs index 423c0517bd..77cc8af51b 100644 --- a/packages/enr/.mocharc.cjs +++ b/packages/enr/.mocharc.cjs @@ -7,17 +7,18 @@ const config = { 'experimental-specifier-resolution=node', 'loader=ts-node/esm' ], - exit: true + exit: true, + retries: 4 }; if (process.env.CI) { console.log("Running tests in parallel"); config.parallel = true; config.jobs = 6; - console.log("Activating allure reporting"); - config.reporter = 'mocha-multi-reporters'; + console.log("Using JSON reporter for test results"); + config.reporter = 'json'; config.reporterOptions = { - configFile: '.mocha.reporters.json' + output: 'reports/mocha-results.json' }; } else { console.log("Running tests serially. To enable parallel execution update mocha config"); diff --git a/packages/message-encryption/.mocha.reporters.json b/packages/message-encryption/.mocha.reporters.json deleted file mode 100644 index 8c00e441fc..0000000000 --- a/packages/message-encryption/.mocha.reporters.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "reporterEnabled": "spec, allure-mocha", - "allureMochaReporter": { - "outputDir": "allure-results" - } -} diff --git a/packages/message-encryption/.mocharc.cjs b/packages/message-encryption/.mocharc.cjs index 423c0517bd..77cc8af51b 100644 --- a/packages/message-encryption/.mocharc.cjs +++ b/packages/message-encryption/.mocharc.cjs @@ -7,17 +7,18 @@ const config = { 'experimental-specifier-resolution=node', 'loader=ts-node/esm' ], - exit: true + exit: true, + retries: 4 }; if (process.env.CI) { console.log("Running tests in parallel"); config.parallel = true; config.jobs = 6; - console.log("Activating allure reporting"); - config.reporter = 'mocha-multi-reporters'; + console.log("Using JSON reporter for test results"); + config.reporter = 'json'; config.reporterOptions = { - configFile: '.mocha.reporters.json' + output: 'reports/mocha-results.json' }; } else { console.log("Running tests serially. To enable parallel execution update mocha config"); diff --git a/packages/message-hash/.mocha.reporters.json b/packages/message-hash/.mocha.reporters.json deleted file mode 100644 index 8c00e441fc..0000000000 --- a/packages/message-hash/.mocha.reporters.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "reporterEnabled": "spec, allure-mocha", - "allureMochaReporter": { - "outputDir": "allure-results" - } -} diff --git a/packages/message-hash/.mocharc.cjs b/packages/message-hash/.mocharc.cjs index 423c0517bd..77cc8af51b 100644 --- a/packages/message-hash/.mocharc.cjs +++ b/packages/message-hash/.mocharc.cjs @@ -7,17 +7,18 @@ const config = { 'experimental-specifier-resolution=node', 'loader=ts-node/esm' ], - exit: true + exit: true, + retries: 4 }; if (process.env.CI) { console.log("Running tests in parallel"); config.parallel = true; config.jobs = 6; - console.log("Activating allure reporting"); - config.reporter = 'mocha-multi-reporters'; + console.log("Using JSON reporter for test results"); + config.reporter = 'json'; config.reporterOptions = { - configFile: '.mocha.reporters.json' + output: 'reports/mocha-results.json' }; } else { console.log("Running tests serially. To enable parallel execution update mocha config"); diff --git a/packages/relay/.mocha.reporters.json b/packages/relay/.mocha.reporters.json deleted file mode 100644 index 8c00e441fc..0000000000 --- a/packages/relay/.mocha.reporters.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "reporterEnabled": "spec, allure-mocha", - "allureMochaReporter": { - "outputDir": "allure-results" - } -} diff --git a/packages/relay/.mocharc.cjs b/packages/relay/.mocharc.cjs index 423c0517bd..77cc8af51b 100644 --- a/packages/relay/.mocharc.cjs +++ b/packages/relay/.mocharc.cjs @@ -7,17 +7,18 @@ const config = { 'experimental-specifier-resolution=node', 'loader=ts-node/esm' ], - exit: true + exit: true, + retries: 4 }; if (process.env.CI) { console.log("Running tests in parallel"); config.parallel = true; config.jobs = 6; - console.log("Activating allure reporting"); - config.reporter = 'mocha-multi-reporters'; + console.log("Using JSON reporter for test results"); + config.reporter = 'json'; config.reporterOptions = { - configFile: '.mocha.reporters.json' + output: 'reports/mocha-results.json' }; } else { console.log("Running tests serially. To enable parallel execution update mocha config"); diff --git a/packages/relay/package.json b/packages/relay/package.json index 09393f50b7..166dd2d454 100644 --- a/packages/relay/package.json +++ b/packages/relay/package.json @@ -39,7 +39,7 @@ "check:lint": "eslint src *.js", "check:spelling": "cspell \"{README.md,src/**/*.ts}\"", "test": "NODE_ENV=test run-s test:*", - "test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha", + "test:node": "NODE_ENV=test TS_NODE_PROJECT=./tsconfig.dev.json mocha", "watch:build": "tsc -p tsconfig.json -w", "watch:test": "mocha --watch", "prepublish": "npm run build", diff --git a/packages/sdk/.mocha.reporters.json b/packages/sdk/.mocha.reporters.json deleted file mode 100644 index 8c00e441fc..0000000000 --- a/packages/sdk/.mocha.reporters.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "reporterEnabled": "spec, allure-mocha", - "allureMochaReporter": { - "outputDir": "allure-results" - } -} diff --git a/packages/sdk/.mocharc.cjs b/packages/sdk/.mocharc.cjs index dc72692443..77cc8af51b 100644 --- a/packages/sdk/.mocharc.cjs +++ b/packages/sdk/.mocharc.cjs @@ -3,21 +3,22 @@ const config = { spec: 'src/**/*.spec.ts', require: ['ts-node/register', 'isomorphic-fetch'], loader: 'ts-node/esm', - nodeOptions: [ + 'node-option': [ 'experimental-specifier-resolution=node', 'loader=ts-node/esm' ], - exit: true + exit: true, + retries: 4 }; if (process.env.CI) { console.log("Running tests in parallel"); config.parallel = true; config.jobs = 6; - console.log("Activating allure reporting"); - config.reporter = 'mocha-multi-reporters'; + console.log("Using JSON reporter for test results"); + config.reporter = 'json'; config.reporterOptions = { - configFile: '.mocha.reporters.json' + output: 'reports/mocha-results.json' }; } else { console.log("Running tests serially. To enable parallel execution update mocha config"); diff --git a/packages/tests/.mocha.reporters.json b/packages/tests/.mocha.reporters.json deleted file mode 100644 index 8c00e441fc..0000000000 --- a/packages/tests/.mocha.reporters.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "reporterEnabled": "spec, allure-mocha", - "allureMochaReporter": { - "outputDir": "allure-results" - } -} diff --git a/packages/tests/.mocharc.cjs b/packages/tests/.mocharc.cjs index fa745afd21..78120b5e32 100644 --- a/packages/tests/.mocharc.cjs +++ b/packages/tests/.mocharc.cjs @@ -14,10 +14,10 @@ if (process.env.CI) { console.log("Running tests in parallel"); config.parallel = true; config.jobs = 6; - console.log("Activating allure reporting"); - config.reporter = 'mocha-multi-reporters'; + console.log("Using JSON reporter for test results"); + config.reporter = 'json'; config.reporterOptions = { - configFile: '.mocha.reporters.json' + output: 'reports/mocha-results.json' }; } else { console.log("Running tests serially. To enable parallel execution update mocha config"); diff --git a/packages/tests/package.json b/packages/tests/package.json index c1e3385009..06c6e97f42 100644 --- a/packages/tests/package.json +++ b/packages/tests/package.json @@ -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 node ./src/run-tests.js \"tests/**/!(*.optional).spec.ts\"", - "test:optional": "NODE_ENV=test node ./src/run-tests.js \"tests/**/@(*.optional).spec.ts\"", + "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\"", "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build" }, "engines": { @@ -79,8 +79,6 @@ "@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", @@ -88,7 +86,6 @@ "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" } } diff --git a/packages/tests/src/run-tests.js b/packages/tests/src/run-tests.js index b468bdc00e..db9547f876 100644 --- a/packages/tests/src/run-tests.js +++ b/packages/tests/src/run-tests.js @@ -1,4 +1,6 @@ import { exec, spawn } from "child_process"; +import { mkdir } from "fs/promises"; +import { dirname } from "path"; import { promisify } from "util"; const execAsync = promisify(exec); @@ -20,10 +22,34 @@ async function main() { "--require", "ts-node/register", "--project", - "./tsconfig.dev.json", - ...process.argv.slice(2) + "./tsconfig.dev.json" ]; + 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", diff --git a/packages/utils/.mocha.reporters.json b/packages/utils/.mocha.reporters.json deleted file mode 100644 index 8c00e441fc..0000000000 --- a/packages/utils/.mocha.reporters.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "reporterEnabled": "spec, allure-mocha", - "allureMochaReporter": { - "outputDir": "allure-results" - } -} diff --git a/packages/utils/.mocharc.cjs b/packages/utils/.mocharc.cjs index 423c0517bd..77cc8af51b 100644 --- a/packages/utils/.mocharc.cjs +++ b/packages/utils/.mocharc.cjs @@ -7,17 +7,18 @@ const config = { 'experimental-specifier-resolution=node', 'loader=ts-node/esm' ], - exit: true + exit: true, + retries: 4 }; if (process.env.CI) { console.log("Running tests in parallel"); config.parallel = true; config.jobs = 6; - console.log("Activating allure reporting"); - config.reporter = 'mocha-multi-reporters'; + console.log("Using JSON reporter for test results"); + config.reporter = 'json'; config.reporterOptions = { - configFile: '.mocha.reporters.json' + output: 'reports/mocha-results.json' }; } else { console.log("Running tests serially. To enable parallel execution update mocha config");