From 55dec46cf459fb3aaa4d709e5f78c5531051c9ca Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 4 May 2024 12:16:37 +0200 Subject: [PATCH 01/10] Mark PHP v8.4 tests as experimental As per this doc: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#handling-failures Workaround for https://github.com/PrivateBin/PrivateBin/issues/1301 for now. I hope this ignores failures? --- .github/workflows/tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 730de26e..af9b7d8a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,6 +20,10 @@ jobs: strategy: matrix: php-versions: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] + include: + # 8.4 is experimental due to Guzzle causing failures https://github.com/PrivateBin/PrivateBin/issues/1301 + - php-versions: '8.4' + experimental: true name: PHP ${{ matrix.php-versions }} unit tests on ${{ matrix.operating-system }} env: extensions: gd, sqlite3 From 04822aa643bc255567b40ca980844bd1a5a67126 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 4 May 2024 12:40:44 +0200 Subject: [PATCH 02/10] Actually make tests continue on experimental builds --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index af9b7d8a..67aaebb6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,6 +7,8 @@ jobs: Composer: runs-on: ubuntu-latest + # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#handling-failures + continue-on-error: ${{ matrix.experimental }} steps: - name: Checkout uses: actions/checkout@v4 From 91957838be445790a332b66e288cfa826b673ea7 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 4 May 2024 13:07:53 +0200 Subject: [PATCH 03/10] Add upload test results job As per https://github.com/marketplace/actions/publish-test-results#use-with-matrix-strategy only one job should upload all results. --- .github/workflows/tests.yml | 44 +++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 67aaebb6..55a87b94 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,6 +9,7 @@ jobs: runs-on: ubuntu-latest # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#handling-failures continue-on-error: ${{ matrix.experimental }} + steps: - name: Checkout uses: actions/checkout@v4 @@ -97,9 +98,16 @@ jobs: # testing - name: Run unit tests - run: ../vendor/bin/phpunit --no-coverage + run: ../vendor/bin/phpunit --no-coverage --log-junit results.xml working-directory: tst + - name: Upload Test Results + if: always() + uses: actions/upload-artifact@v4 + with: + name: Test Results (PHP ${{ matrix.php-versions }}) + path: tst/results.xml + Mocha: runs-on: ubuntu-latest steps: @@ -122,5 +130,37 @@ jobs: working-directory: js - name: Run unit tests - run: npm test + run: npm test --reporter-option output=mocha-results.xml working-directory: js + + - name: Upload Test Results + if: always() + uses: actions/upload-artifact@v4 + with: + name: Test Results (Mocha) + path: tst/mocha-results.xml + + publish-test-results: + name: "Publish Tests Results" + needs: ['PHPunit', 'Mocha'] + runs-on: ubuntu-latest + permissions: + checks: write + # only needed unless run with comment_mode: off + pull-requests: write + if: always() + + steps: + - name: Download Artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + check_name: "Test Results (${{ github.event.workflow_run.event || github.event_name }})" + files: | + artifacts/**/*.xml + artifacts/**/*.trx + artifacts/**/*.json From 8443d3e39791463ad70602d22cd90137eace2b09 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 4 May 2024 13:12:23 +0200 Subject: [PATCH 04/10] Add CI test script to package.json --- js/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/package.json b/js/package.json index a0b4899b..e0bb8865 100644 --- a/js/package.json +++ b/js/package.json @@ -15,7 +15,8 @@ "@peculiar/webcrypto": "^1.1.1" }, "scripts": { - "test": "mocha" + "test": "mocha", + "ci-test": "mocha --reporter-option output=mocha-results.xml" }, "repository": { "type": "git", From f92edf00262c6223b137f8f2697a9a34ecac3b66 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 4 May 2024 13:13:22 +0200 Subject: [PATCH 05/10] Run mocha tests properly --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 55a87b94..45a78c7b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -130,7 +130,7 @@ jobs: working-directory: js - name: Run unit tests - run: npm test --reporter-option output=mocha-results.xml + run: npm ci-test working-directory: js - name: Upload Test Results @@ -138,7 +138,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: Test Results (Mocha) - path: tst/mocha-results.xml + path: js/mocha-results.xml publish-test-results: name: "Publish Tests Results" From 00fca449861531b8a2c3b609d35267c0f5a88ebd Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 4 May 2024 13:14:25 +0200 Subject: [PATCH 06/10] Fix npm syntax --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 45a78c7b..588df715 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -130,7 +130,7 @@ jobs: working-directory: js - name: Run unit tests - run: npm ci-test + run: npm run ci-test working-directory: js - name: Upload Test Results From 93f59d645697323529ba5a0b7098bce15d746b76 Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 4 May 2024 13:21:57 +0200 Subject: [PATCH 07/10] Upload and use event file, too, for test runs To support forked repos: https://github.com/marketplace/actions/publish-test-results#support-fork-repositories-and-dependabot-branches **NOTE:** Do _not_ use with `pull_request_target` as that causes issues! --- .github/workflows/tests.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 588df715..9c778b3b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -139,7 +139,17 @@ jobs: with: name: Test Results (Mocha) path: js/mocha-results.xml - + + event_file: + name: "Event File" + runs-on: ubuntu-latest + steps: + - name: Upload + uses: actions/upload-artifact@v4 + with: + name: Event File + path: ${{ github.event_path }} + publish-test-results: name: "Publish Tests Results" needs: ['PHPunit', 'Mocha'] @@ -160,6 +170,9 @@ jobs: uses: EnricoMi/publish-unit-test-result-action@v2 with: check_name: "Test Results (${{ github.event.workflow_run.event || github.event_name }})" + commit: ${{ github.event.workflow_run.head_sha }} + event_file: artifacts/Event File/event.json + event_name: ${{ github.event.workflow_run.event }} files: | artifacts/**/*.xml artifacts/**/*.trx From 1d6a14ba1477975dd86d2d53e02e215a922fa9de Mon Sep 17 00:00:00 2001 From: rugk Date: Sat, 4 May 2024 13:29:58 +0200 Subject: [PATCH 08/10] Switch to better artifact download action --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9c778b3b..9aad9e0b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -162,8 +162,9 @@ jobs: steps: - name: Download Artifacts - uses: actions/download-artifact@v4 + uses: dawidd6/action-download-artifact@v3 with: + run_id: ${{ github.event.workflow_run.id }} path: artifacts - name: Publish Test Results From 6144caae85a055e751a880ce20678d0ceb7e25ce Mon Sep 17 00:00:00 2001 From: rugk Date: Sun, 5 May 2024 15:01:47 +0200 Subject: [PATCH 09/10] ci: fix test results publishing being a totally separate action --- .github/workflows/test-results.yml | 42 ++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 28 -------------------- 2 files changed, 42 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/test-results.yml diff --git a/.github/workflows/test-results.yml b/.github/workflows/test-results.yml new file mode 100644 index 00000000..a7b96f5a --- /dev/null +++ b/.github/workflows/test-results.yml @@ -0,0 +1,42 @@ +name: Test Results + +on: + workflow_run: + workflows: ["Tests"] + types: + - completed +permissions: {} + +jobs: + test-results: + name: Test Results + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion != 'skipped' + + permissions: + checks: write + + # needed unless run with comment_mode: off + pull-requests: write + + # required by download step to access artifacts API + actions: read + + steps: + - name: Download and Extract Artifacts + uses: dawidd6/action-download-artifact@e7466d1a7587ed14867642c2ca74b5bcc1e19a2d + with: + run_id: ${{ github.event.workflow_run.id }} + path: artifacts + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + check_name: "Test Results (${{ github.event.workflow_run.event || github.event_name }})" + commit: ${{ github.event.workflow_run.head_sha }} + event_file: artifacts/Event File/event.json + event_name: ${{ github.event.workflow_run.event }} + files: | + artifacts/**/*.xml + artifacts/**/*.trx + artifacts/**/*.json \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9aad9e0b..408c1ba4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -149,32 +149,4 @@ jobs: with: name: Event File path: ${{ github.event_path }} - - publish-test-results: - name: "Publish Tests Results" - needs: ['PHPunit', 'Mocha'] - runs-on: ubuntu-latest - permissions: - checks: write - # only needed unless run with comment_mode: off - pull-requests: write - if: always() - steps: - - name: Download Artifacts - uses: dawidd6/action-download-artifact@v3 - with: - run_id: ${{ github.event.workflow_run.id }} - path: artifacts - - - name: Publish Test Results - uses: EnricoMi/publish-unit-test-result-action@v2 - with: - check_name: "Test Results (${{ github.event.workflow_run.event || github.event_name }})" - commit: ${{ github.event.workflow_run.head_sha }} - event_file: artifacts/Event File/event.json - event_name: ${{ github.event.workflow_run.event }} - files: | - artifacts/**/*.xml - artifacts/**/*.trx - artifacts/**/*.json From 4ff9dea9cf0481899c98982c3755052eb796b337 Mon Sep 17 00:00:00 2001 From: rugk Date: Sun, 5 May 2024 15:10:00 +0200 Subject: [PATCH 10/10] ci: try fixing intendation --- .github/workflows/test-results.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test-results.yml b/.github/workflows/test-results.yml index a7b96f5a..26429607 100644 --- a/.github/workflows/test-results.yml +++ b/.github/workflows/test-results.yml @@ -26,17 +26,17 @@ jobs: - name: Download and Extract Artifacts uses: dawidd6/action-download-artifact@e7466d1a7587ed14867642c2ca74b5bcc1e19a2d with: - run_id: ${{ github.event.workflow_run.id }} - path: artifacts + run_id: ${{ github.event.workflow_run.id }} + path: artifacts - name: Publish Test Results uses: EnricoMi/publish-unit-test-result-action@v2 with: - check_name: "Test Results (${{ github.event.workflow_run.event || github.event_name }})" - commit: ${{ github.event.workflow_run.head_sha }} - event_file: artifacts/Event File/event.json - event_name: ${{ github.event.workflow_run.event }} - files: | - artifacts/**/*.xml - artifacts/**/*.trx - artifacts/**/*.json \ No newline at end of file + check_name: "Test Results (${{ github.event.workflow_run.event || github.event_name }})" + commit: ${{ github.event.workflow_run.head_sha }} + event_file: artifacts/Event File/event.json + event_name: ${{ github.event.workflow_run.event }} + files: | + artifacts/**/*.xml + artifacts/**/*.trx + artifacts/**/*.json