From dca0ae7979697b8906a7ce70875f1dcd19d16830 Mon Sep 17 00:00:00 2001 From: Diede Exterkate <5352634+diedexx@users.noreply.github.com> Date: Tue, 5 Dec 2023 09:21:15 +0100 Subject: [PATCH] Send JS packages' coverage to coveralls --- .github/workflows/finish-coveralls.yml | 49 ++++++++++++++++++++++++++ .github/workflows/jstest.yml | 16 +++++++-- .github/workflows/test.yml | 10 ------ 3 files changed, 63 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/finish-coveralls.yml diff --git a/.github/workflows/finish-coveralls.yml b/.github/workflows/finish-coveralls.yml new file mode 100644 index 00000000000..d8be67dfefe --- /dev/null +++ b/.github/workflows/finish-coveralls.yml @@ -0,0 +1,49 @@ +name: Finish Coveralls build +on: + workflow_run: + workflows: + - Test + - TestJS + types: + - completed + +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +jobs: + finish_coveralls_build: + name: "Finish coveralls build" + runs-on: ubuntu-latest + steps: + + # Wait for the PHP and JS tests to finish. + # NOTE: The ref value should be different when triggered by pull_request event. + # See: https://github.com/lewagon/wait-on-check-action/issues/25. + - name: "Wait on tests (PR)" + uses: lewagon/wait-on-check-action@e106e5c43e8ca1edea6383a39a01c5ca495fd812 # lewagon/wait-on-check-action@v1.3.1 + if: github.event_name == 'pull_request' + with: + ref: ${{ github.event.pull_request.head.sha }} + repo-token: ${{ secrets.GITHUB_TOKEN }} + check-regexp: Test|TestJS + + - name: "Wait on tests (push)" + if: github.event_name != 'pull_request' + uses: lewagon/wait-on-check-action@e106e5c43e8ca1edea6383a39a01c5ca495fd812 # lewagon/wait-on-check-action@v1.3.1 + with: + ref: ${{ github.sha }} + repo-token: ${{ secrets.GITHUB_TOKEN }} + check-regexp: Test|TestJS + + + - name: "Coveralls Finished" + uses: coverallsapp/github-action@v2 + env: + COVERALLS_SERVICE_NUMBER: ${{ github.sha }} # Connect all builds together. + with: + github-token: ${{ secrets.COVERALLS_TOKEN }} + carryforward: "unit-php-7.2,unit-php-8.3,php-7.2-wp-6.2,php-7.2-wp-6.2-ms,php-8.3-wp-trunk,php-8.3-wp-trunk-ms,package-analysis-report,package-browserslist-config,package-components,package-feature-flag,package-helpers,package-js,package-replacement-variable-editor,package-search-metadata-previews,package-social-metadata-forms,package-social-metadata-previews,package-yoast-components" + parallel-finished: true diff --git a/.github/workflows/jstest.yml b/.github/workflows/jstest.yml index 6e11487559e..011c5eb467d 100644 --- a/.github/workflows/jstest.yml +++ b/.github/workflows/jstest.yml @@ -110,9 +110,15 @@ jobs: working-directory: packages/${{ matrix.package }} - name: Run Javascript tests - run: yarn test --ci + run: yarn test --ci --coverage working-directory: packages/${{ matrix.package }} + - name: Upload coverage results to Coveralls + uses: coverallsapp/github-action@v2 + with: + flag-name: package-${{ matrix.package }} + parallel: true + ######################################################################################### # For packages in this job, PRs will only run the tests related to changed files @@ -198,5 +204,11 @@ jobs: - name: Run Javascript tests if: ${{ steps.checks-run.outputs.should == 'true' }} - run: yarn test --ci + run: yarn test --ci --coverage working-directory: packages/${{ matrix.package }} + + - name: Upload coverage results to Coveralls + uses: coverallsapp/github-action@v2 + with: + flag-name: package-${{ matrix.package }} + parallel: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0abff593655..145f22d9db1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -273,13 +273,3 @@ jobs: file: build/logs/clover-wp-ms.xml flag-name: php-${{ matrix.php_version }}-wp-${{ matrix.wp_version }}-ms parallel: true - - coveralls-finish: - needs: [unit-test, wp-test] - runs-on: ubuntu-latest - - steps: - - name: Coveralls Finished - uses: coverallsapp/github-action@v2 - with: - parallel-finished: true