From 3c841563606be8fc03f144265f613f4754ddb79e Mon Sep 17 00:00:00 2001 From: Felix MIL Date: Fri, 19 Jul 2024 11:10:40 +0200 Subject: [PATCH 1/7] rename rClr based reusable workflows --- .../{R-CMD-check-build.yml => R-CMD-check-build-rClr.yml} | 0 .github/workflows/{pkgdown.yml => pkgdown-rClr.yml} | 0 .../{test-pkg-and-coverage.yml => test-coverage-rClr.yml} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{R-CMD-check-build.yml => R-CMD-check-build-rClr.yml} (100%) rename .github/workflows/{pkgdown.yml => pkgdown-rClr.yml} (100%) rename .github/workflows/{test-pkg-and-coverage.yml => test-coverage-rClr.yml} (100%) diff --git a/.github/workflows/R-CMD-check-build.yml b/.github/workflows/R-CMD-check-build-rClr.yml similarity index 100% rename from .github/workflows/R-CMD-check-build.yml rename to .github/workflows/R-CMD-check-build-rClr.yml diff --git a/.github/workflows/pkgdown.yml b/.github/workflows/pkgdown-rClr.yml similarity index 100% rename from .github/workflows/pkgdown.yml rename to .github/workflows/pkgdown-rClr.yml diff --git a/.github/workflows/test-pkg-and-coverage.yml b/.github/workflows/test-coverage-rClr.yml similarity index 100% rename from .github/workflows/test-pkg-and-coverage.yml rename to .github/workflows/test-coverage-rClr.yml From 89a6be8b88826950f7eacacec12b0f9a88bd3e72 Mon Sep 17 00:00:00 2001 From: Felix MIL Date: Fri, 19 Jul 2024 11:12:08 +0200 Subject: [PATCH 2/7] Add new reusable workflows for R packages + Do not install PKSim + Do not install rClr + use linux os --- .github/workflows/R-CMD-check-build.yaml | 68 +++++++++++++++++++ .../bump_dev_version_tag_branch.yaml | 65 ++++++++++++++++++ .github/workflows/pkgdown.yaml | 45 ++++++++++++ .github/workflows/test-coverage.yaml | 59 ++++++++++++++++ 4 files changed, 237 insertions(+) create mode 100644 .github/workflows/R-CMD-check-build.yaml create mode 100644 .github/workflows/bump_dev_version_tag_branch.yaml create mode 100644 .github/workflows/pkgdown.yaml create mode 100644 .github/workflows/test-coverage.yaml diff --git a/.github/workflows/R-CMD-check-build.yaml b/.github/workflows/R-CMD-check-build.yaml new file mode 100644 index 0000000..3762c5c --- /dev/null +++ b/.github/workflows/R-CMD-check-build.yaml @@ -0,0 +1,68 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples + +on: + workflow_call: + +name: R-CMD-check + +permissions: read-all + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'release'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' + error-on: 'c("error")' + + - name: Build package + if: ${{ success() }} + run: | + output_dir <- file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "built_package") + dir.create(output_dir) + devtools::build(binary = TRUE, path = output_dir) + shell: Rscript {0} + + - name: Get package package and R versions and store in environment + run: | + echo "PKG_VERSION=$(Rscript -e 'desc::desc_get_version()')" >> $GITHUB_ENV + echo "R_VERSION=$(Rscript -e 'cat(R.version$major, R.version$minor, sep = ".")')" >> $GITHUB_ENV + shell: bash + + - name: Upload built package + if: ${{ success() }} + uses: actions/upload-artifact@v4 + with: + name: ospsuite-v${{ env.PKG_VERSION }}-${{runner.os}}-r_${{ env.R_VERSION }} + path: ${{ runner.temp }}/built_package/* diff --git a/.github/workflows/bump_dev_version_tag_branch.yaml b/.github/workflows/bump_dev_version_tag_branch.yaml new file mode 100644 index 0000000..a26b920 --- /dev/null +++ b/.github/workflows/bump_dev_version_tag_branch.yaml @@ -0,0 +1,65 @@ +# This reusable workflow will, if triggered by a merge: +# - Bump version if the current version is development (x.y.z.9000+) +# - Tag the target branch with version number +name: bump-dev-version + +on: + workflow_call: + inputs: + app-id: + type: string + required: true + secrets: + private-key: + type: string + require: true + +jobs: + bump-dev-version: + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: write-all + steps: + + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ inputs.app-id }} + private-key: ${{ secrets.private-key }} + + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ steps.app-token.outputs.token }} + + - name: Setup R + uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - name: Install packages + run: | + install.packages("usethis") + shell: Rscript {0} + + - name: Change DESCRIPTION file + run: | + if(usethis:::is_dev_version()){ + desc::desc_set_version(version = usethis:::bump_version()[["dev"]]) + } + shell: Rscript {0} + + - name: Get package version from DESCRIPTION file and set as environment variable + run: | + echo "PKG_VERSION=$(Rscript -e 'desc::desc_get_version()')" >> $GITHUB_ENV + shell: bash + + - uses: EndBug/add-and-commit@v9 + if: ${{ success() }} + with: + message: '🤖 Bump version. [skip actions]' + default_author: github_actions + add: 'DESCRIPTION' + tag: 'v${{ env.PKG_VERSION }}' diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 0000000..216b2a5 --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,45 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples + +on: + workflow_call: + + name: pkgdown + + permissions: read-all + + jobs: + pkgdown: + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::pkgdown, local::. + needs: website + + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + shell: Rscript {0} + + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4.5.0 + with: + clean: false + branch: gh-pages + folder: docs + \ No newline at end of file diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..164e8b3 --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,59 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples + +on: + workflow_call: + + name: test-coverage + + 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 + \ No newline at end of file From 12dc24940641eda70c44ebd13562d38b8b870946 Mon Sep 17 00:00:00 2001 From: Felix MIL Date: Fri, 19 Jul 2024 11:15:53 +0200 Subject: [PATCH 3/7] fix typo --- .github/workflows/bump_dev_version_tag_branch.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bump_dev_version_tag_branch.yaml b/.github/workflows/bump_dev_version_tag_branch.yaml index a26b920..59e21ec 100644 --- a/.github/workflows/bump_dev_version_tag_branch.yaml +++ b/.github/workflows/bump_dev_version_tag_branch.yaml @@ -12,7 +12,7 @@ on: secrets: private-key: type: string - require: true + required: true jobs: bump-dev-version: From 15c1c6f4fd518e0d319008921bad58754d962550 Mon Sep 17 00:00:00 2001 From: Felix MIL Date: Fri, 19 Jul 2024 11:17:01 +0200 Subject: [PATCH 4/7] fix indentation --- .github/workflows/bump_dev_version_tag_branch.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bump_dev_version_tag_branch.yaml b/.github/workflows/bump_dev_version_tag_branch.yaml index 59e21ec..4cc3bab 100644 --- a/.github/workflows/bump_dev_version_tag_branch.yaml +++ b/.github/workflows/bump_dev_version_tag_branch.yaml @@ -6,13 +6,13 @@ name: bump-dev-version on: workflow_call: inputs: - app-id: + app-id: + type: string + required: true + secrets: + private-key: type: string required: true - secrets: - private-key: - type: string - required: true jobs: bump-dev-version: From ce9fedc405702a8195725c8d5a54e95b7f58e6c6 Mon Sep 17 00:00:00 2001 From: Felix MIL Date: Fri, 19 Jul 2024 11:19:22 +0200 Subject: [PATCH 5/7] remove type argument for secret --- .github/workflows/bump_dev_version_tag_branch.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/bump_dev_version_tag_branch.yaml b/.github/workflows/bump_dev_version_tag_branch.yaml index 4cc3bab..d47e919 100644 --- a/.github/workflows/bump_dev_version_tag_branch.yaml +++ b/.github/workflows/bump_dev_version_tag_branch.yaml @@ -11,7 +11,6 @@ on: required: true secrets: private-key: - type: string required: true jobs: From 15f9ac5b33ceccacec7dd0ea5bb8749569dddc65 Mon Sep 17 00:00:00 2001 From: Felix MIL Date: Fri, 19 Jul 2024 11:21:02 +0200 Subject: [PATCH 6/7] fix indentation --- .github/workflows/test-coverage.yaml | 107 +++++++++++++-------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 164e8b3..78250f4 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -3,57 +3,56 @@ on: workflow_call: - name: test-coverage - - 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 - \ No newline at end of file +name: test-coverage + +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 71788d651d1f5a63daf706682e93c048a3fafde1 Mon Sep 17 00:00:00 2001 From: Felix MIL Date: Fri, 19 Jul 2024 11:21:47 +0200 Subject: [PATCH 7/7] fix indentation --- .github/workflows/pkgdown.yaml | 79 +++++++++++++++++----------------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 216b2a5..96323df 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -3,43 +3,42 @@ on: workflow_call: - name: pkgdown - - permissions: read-all - - jobs: - pkgdown: - runs-on: ubuntu-latest - # Only restrict concurrency for non-PR jobs - concurrency: - group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - permissions: - contents: write - steps: - - uses: actions/checkout@v4 - - - uses: r-lib/actions/setup-pandoc@v2 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::pkgdown, local::. - needs: website - - - name: Build site - run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) - shell: Rscript {0} - - - name: Deploy to GitHub pages 🚀 - if: github.event_name != 'pull_request' - uses: JamesIves/github-pages-deploy-action@v4.5.0 - with: - clean: false - branch: gh-pages - folder: docs - \ No newline at end of file +name: pkgdown + +permissions: read-all + +jobs: + pkgdown: + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::pkgdown, local::. + needs: website + + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + shell: Rscript {0} + + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4.5.0 + with: + clean: false + branch: gh-pages + folder: docs