diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 2520146..562a991 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,4 +1,4 @@ -name: "Test" +name: 'Coverage Test' on: pull_request: @@ -7,9 +7,9 @@ jobs: runs-on: ubuntu-latest permissions: - # Required to checkout the code + # Required to checkout the code. contents: read - # Required to put a comment into the pull-request + # Required to put a comment into the pull-request. pull-requests: write steps: @@ -22,6 +22,19 @@ jobs: run: npm install - name: "Test" run: npx vitest --coverage - - name: "Report Coverage" - if: always() # Also generate the report if tests are failing - uses: davelosert/vitest-coverage-report-action@v2 + + + - name: Save PR number + env: + PR_NUMBER: ${{ github.event.number }} + run: | + echo $PR_NUMBER > ./pr_number + - uses: actions/upload-artifact@v3 + if: success() || failure() + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + name: test-results + path: | + test-results.json + coverage + pr_number diff --git a/.github/workflows/report.yml b/.github/workflows/report.yml new file mode 100644 index 0000000..77d3e49 --- /dev/null +++ b/.github/workflows/report.yml @@ -0,0 +1,33 @@ +name: 'Test Report' +on: + workflow_run: + workflows: ['Coverage Test'] + types: + - completed +jobs: + report: + runs-on: ubuntu-latest + steps: + - name: Download workflow artifact + uses: dawidd6/action-download-artifact@v2.27.0 + with: + workflow: run-tests.yml + name: test-results + run_id: ${{ github.event.workflow_run.id }} + - name: Set pr number env + run: | + PR_NUMBER=$(cat pr_number) + echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV + - name: Test Report + uses: phoenix-actions/test-reporting@v12 + id: test-report + with: + artifact: test-results + name: Mocha Tests + path: test-results.json + reporter: mocha-json + - name: c8 coverage report + uses: Nef10/lcov-reporter-action@v0.4.0 + with: + pr-number: ${{ env.PR_NUMBER }} + github-token: ${{ secrets.GITHUB_TOKEN }}