From 6ea9ae422c5266ae31a942236e8cf5a6b31711c0 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 18 Oct 2024 11:55:14 +1100 Subject: [PATCH 1/4] try usethis to set up new --- .Rbuildignore | 1 + .github/.gitignore | 1 + .github/workflows/test-coverage.yaml | 64 ++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 .github/.gitignore create mode 100644 .github/workflows/test-coverage.yaml diff --git a/.Rbuildignore b/.Rbuildignore index 99b2ab2b..73b4cd7e 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -26,3 +26,4 @@ Library ignore .Renviron ^codecov\.yml$ +^\.github$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 00000000..2d19fc76 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 00000000..b2b53778 --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,64 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches-ignore: + - updateREADME + pull_request: + branches: + - master + workflow_dispatch: # Allow manual triggers + +name: test-coverage.yaml + +permissions: read-all + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::covr, any::xml2 + needs: coverage + + - name: Test coverage + run: | + cov <- covr::package_coverage( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) + covr::to_cobertura(cov) + shell: Rscript {0} + + - uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }} + file: ./cobertura.xml + plugin: 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 From 027484041cd79cf4d841f4ad68023941b0dff1a3 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 18 Oct 2024 14:03:45 +1100 Subject: [PATCH 2/4] only run coverage report on master branch - workflow now exactly as in r-ib github action --- .github/workflows/test-coverage.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index b2b53778..98822609 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -2,12 +2,9 @@ # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches-ignore: - - updateREADME + branches: [main, master] pull_request: - branches: - - master - workflow_dispatch: # Allow manual triggers + branches: [main, master] name: test-coverage.yaml From b3461db7374f6ce667c1347e21669ec1d6015112 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 18 Oct 2024 14:04:47 +1100 Subject: [PATCH 3/4] remove test coverage and slack notify from actions --- .github/workflows/actions.yml | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 9e04f259..c509c4de 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -205,20 +205,4 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} repository: mixomicsteam/mixomics tags: ${{ needs.versions.outputs.docker_tag }} - build_args: BIOC_VERSION=${{ needs.versions.outputs.bioc }} - - - name: Test coverage 🔍 - if: (runner.os == 'Linux' && github.event_name == 'schedule' && github.repository == 'mixOmicsTeam/mixOmics') || (runner.os == 'Linux' && github.event_name == 'workflow_dispatch' && github.repository == 'mixOmicsTeam/mixOmics') - # the commands between 'set +e' and 'set -e' are run without throwing any error - run: | - set +e - Rscript -e "covr::codecov(type = c('tests', 'examples'))" - set -e - - # - name: Notify Slack 📣 - # uses: 8398a7/action-slack@v3 - # with: - # status: ${{ job.status }} - # fields: repo,message,commit,author,action,eventName,ref,workflow,job,took # selectable (default: repo,message) - # env: - # SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # set in rep's setting >> secrets + build_args: BIOC_VERSION=${{ needs.versions.outputs.bioc }} \ No newline at end of file From 0f632919e176bc4208f0ce94cbc79c24e8c8f541 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Fri, 18 Oct 2024 15:45:34 +1100 Subject: [PATCH 4/4] rename coverage workflow --- .github/workflows/test-coverage.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 98822609..8db86ae3 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -6,7 +6,7 @@ on: pull_request: branches: [main, master] -name: test-coverage.yaml +name: Code Coverage permissions: read-all