From 2be7728872e6178d75911f0dd6788cbe925cdae4 Mon Sep 17 00:00:00 2001 From: Rafael Soares <893971+rafasoares@users.noreply.github.com> Date: Mon, 27 May 2024 12:15:48 +0200 Subject: [PATCH] ci: :construction_worker: improve test result and coverage reporting --- .github/workflows/publish.yml | 2 +- .github/workflows/reports.yml | 40 +++++++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 33 +++++++++++++++++------------ 3 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/reports.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2a08024..b0db031 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,4 @@ -name: Publish gem +name: publish on: push: diff --git a/.github/workflows/reports.yml b/.github/workflows/reports.yml new file mode 100644 index 0000000..5bbc72d --- /dev/null +++ b/.github/workflows/reports.yml @@ -0,0 +1,40 @@ +name: reports + +on: + workflow_run: + workflows: ["tests"] + types: + - completed + +permissions: + contents: read + actions: read + checks: write + +jobs: + report: + name: Report test results + + runs-on: ubuntu-latest + + steps: + - uses: dorny/test-reporter@v1 + with: + name: rspec + path: spec/reports + artifact: test-results + reporter: rspec-json + + coverage: + name: Report code coverage + runs-on: ubuntu-latest + + steps: + - uses: actions/download-artifact@v4 + with: + name: code-coverage + path: coverage + + - uses: paambaati/codeclimate-action@v6 + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 686f86f..02ed428 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,16 +1,19 @@ +name: tests + on: push: - branches: [main, develop] + branches: [main] pull_request: - branches: [main, develop] + branches: [main] workflow_call: permissions: contents: read jobs: - test: - name: Run specs + test-matrix: + name: Test against Ruby ${{ matrix.ruby }} and Rails ${{ matrix.rails }} + runs-on: ubuntu-latest strategy: @@ -33,11 +36,12 @@ jobs: - name: Run specs env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - run: bin/rspec + run: bin/rspec --no-profile + + test-current: + name: Run specs against current Ruby and Rails + needs: test-matrix - coverage: - name: Report code coverage - needs: test runs-on: ubuntu-latest steps: @@ -48,13 +52,16 @@ jobs: rubygems: latest bundler-cache: true - - uses: paambaati/codeclimate-action@v6 + - run: bin/rspec --format json --out spec/reports/rspec.json + + - name: Upload test reports + uses: actions/upload-artifact@v4 with: - coverageCommand: bin/rspec - env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + name: test-results + path: spec/reports - - uses: actions/upload-artifact@v4 + - name: Upload code coverage + uses: actions/upload-artifact@v4 with: name: code-coverage path: coverage