diff --git a/.github/workflows/Test-coverage.yaml b/.github/workflows/Test-coverage.yaml index 0bae9dbf..e997e6b9 100644 --- a/.github/workflows/Test-coverage.yaml +++ b/.github/workflows/Test-coverage.yaml @@ -2,15 +2,15 @@ # Github Actions workflow to analyze CmdStanR code, test coverage # yamllint disable rule:line-length -name: Test coverage - -'on': +on: push: branches: - master pull_request: - branches: - - master + +name: Test coverage + +permissions: read-all jobs: test-coverage: @@ -38,16 +38,18 @@ jobs: - uses: n1hility/cancel-previous-runs@v3 with: token: ${{ secrets.GITHUB_TOKEN }} - workflow: Test-coverage.yml + workflow: Test-coverage.yaml if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" + - uses: actions/checkout@v4 - - uses: r-lib/actions/setup-r@v2.11.3 - - uses: r-lib/actions/setup-pandoc@v2.11.3 + - uses: r-lib/actions/setup-r@v2 + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r-dependencies@v2.11.3 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: any::rcmdcheck, local::., any::covr, any::gridExtra + extra-packages: any::rcmdcheck, local::., any::covr, any::gridExtra, any::xml2 + needs: coverage - name: Install cmdstan run: | @@ -57,16 +59,55 @@ jobs: - name: Test coverage (Linux) if: runner.os == 'Linux' - run: covr::codecov(type = "tests") + run: | + cov <- covr::package_coverage( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package"), + type = "tests" + ) + print(cov) + covr::to_cobertura(cov) shell: Rscript {0} env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - name: Test coverage (Windows) if: runner.os == 'Windows' run: | options(covr.gcov = 'C:/rtools44/mingw64/bin/gcov.exe'); - covr::codecov(type = "tests", function_exclusions = "sample_mpi") + cov <- covr::package_coverage( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package"), + type = "tests", + function_exclusions = "sample_mpi" + ) + print(cov) + covr::to_cobertura(cov) shell: Rscript {0} env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + - uses: codecov/codecov-action@v5 + with: + # Fail if error if not on PR, or if on PR and token is given + fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }} + files: ./cobertura.xml + plugins: noop + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v4 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package