From 1aad0ff845aaf52c3fc2dea37b1a3343bcec51fb Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Mon, 9 Sep 2024 12:14:20 +0200 Subject: [PATCH] feat: add an option to choose between staged-dependencies and setup-r-dependencies --- .github/workflows/bioccheck.yaml | 25 +++++++++++++++++++++ .github/workflows/build-check-install.yaml | 26 ++++++++++++++++++++++ .github/workflows/pkgdown.yaml | 25 +++++++++++++++++++++ .github/workflows/roxygen.yaml | 25 +++++++++++++++++++++ .github/workflows/test-coverage.yaml | 25 +++++++++++++++++++++ .github/workflows/validation.yaml | 25 +++++++++++++++++++++ 6 files changed, 151 insertions(+) diff --git a/.github/workflows/bioccheck.yaml b/.github/workflows/bioccheck.yaml index e86dd6967..d49f68d0e 100644 --- a/.github/workflows/bioccheck.yaml +++ b/.github/workflows/bioccheck.yaml @@ -53,6 +53,19 @@ on: required: false type: string default: "." + deps-installation-method: + description: Which method for installing R package dependencies to use? + required: true + type: choice + default: staged-dependencies + options: + - staged-dependencies + - setup-r-dependencies + lookup-refs: + description: | + List of package references to be used by setup-r-dependencies action if deps-installation-method == 'setup-r-dependencies'. + required: false + default: "" concurrency: group: bioccheck-${{ github.event.pull_request.number || github.ref }} @@ -122,12 +135,16 @@ jobs: SKIP_INSTRUCTION: "[skip bioccheck]" - name: Restore SD cache 💰 + if: >- + inputs.deps-installation-method == 'staged-dependencies' uses: actions/cache@v4 with: key: sd-${{ runner.os }}-${{ github.event.repository.name }} path: ~/.staged.dependencies - name: Run Staged dependencies 🎦 + if: >- + inputs.deps-installation-method == 'staged-dependencies' uses: insightsengineering/staged-dependencies-action@v2 env: GITHUB_PAT: ${{ steps.github-token.outputs.token }} @@ -137,6 +154,14 @@ jobs: run-system-dependencies: ${{ inputs.install-system-dependencies }} direction: ${{ inputs.sd-direction }} + - name: Setup R dependencies 🎦 + if: >- + inputs.deps-installation-method == 'setup-r-dependencies' + uses: insightsengineering/setup-r-dependencies@v1 + with: + lookup-refs: ${{ inputs.lookup-refs }} + github-token: ${{ steps.github-token.outputs.token }} + - name: Run BiocCheck ☣️ uses: insightsengineering/bioc-check-action@v1 with: diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index edab16731..f30372413 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -126,9 +126,23 @@ on: description: | Set this to a comma-separated named list of R packages repositories to use for installing dependencies. Example: "R-universe=https://insightsengineering.r-universe.dev/,CRAN=https://cloud.r-project.org/" + If the value is non-empty, it takes precedence over deps-installation-method. required: false type: string default: "" + deps-installation-method: + description: Which method for installing R package dependencies to use? + required: true + type: choice + default: staged-dependencies + options: + - staged-dependencies + - setup-r-dependencies + lookup-refs: + description: | + List of package references to be used by setup-r-dependencies action if deps-installation-method == 'setup-r-dependencies'. + required: false + default: "" unit-test-report-brand: description: Image URL to use in unit test report for branding. If empty, the default xunit-viewer brand will be used. required: false @@ -177,6 +191,8 @@ on: enable-sd: description: | Whether the installation of package dependencies via staged.dependencies should be enabled. + Has no effect if deps-installation-method == 'setup-r-dependencies' or + install-deps-from-package-repositories is set to non-empty value. required: false type: boolean default: true @@ -373,6 +389,7 @@ jobs: if: >- env.enable_sd == 'true' && inputs.install-deps-from-package-repositories == '' + && inputs.deps-installation-method == 'staged-dependencies' uses: insightsengineering/staged-dependencies-action@v2 env: GITHUB_PAT: ${{ steps.github-token.outputs.token }} @@ -382,6 +399,15 @@ jobs: run-system-dependencies: ${{ inputs.install-system-dependencies }} direction: ${{ inputs.sd-direction }} + - name: Setup R dependencies 🎦 + if: >- + inputs.deps-installation-method == 'setup-r-dependencies' + inputs.install-deps-from-package-repositories == '' + uses: insightsengineering/setup-r-dependencies@v1 + with: + lookup-refs: ${{ inputs.lookup-refs }} + github-token: ${{ steps.github-token.outputs.token }} + - name: Install dependencies from package repositories 🗄️ if: inputs.install-deps-from-package-repositories != '' run: | diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index e1b20ab9f..16ec2d94b 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -120,6 +120,19 @@ on: required: false type: string default: "" + deps-installation-method: + description: Which method for installing R package dependencies to use? + required: true + type: choice + default: staged-dependencies + options: + - staged-dependencies + - setup-r-dependencies + lookup-refs: + description: | + List of package references to be used by setup-r-dependencies action if deps-installation-method == 'setup-r-dependencies'. + required: false + default: "" concurrency: group: docs-${{ github.event.pull_request.number || github.ref }} @@ -194,12 +207,16 @@ jobs: SKIP_INSTRUCTION: "[skip docs]" - name: Restore SD cache 💰 + if: >- + inputs.deps-installation-method == 'staged-dependencies' uses: actions/cache@v4 with: key: sd-${{ runner.os }}-${{ github.event.repository.name }} path: ~/.staged.dependencies - name: Run Staged dependencies 🎦 + if: >- + inputs.deps-installation-method == 'staged-dependencies' uses: insightsengineering/staged-dependencies-action@v2 env: GITHUB_PAT: ${{ steps.github-token.outputs.token }} @@ -209,6 +226,14 @@ jobs: run-system-dependencies: ${{ inputs.install-system-dependencies }} direction: ${{ inputs.sd-direction }} + - name: Setup R dependencies 🎦 + if: >- + inputs.deps-installation-method == 'setup-r-dependencies' + uses: insightsengineering/setup-r-dependencies@v1 + with: + lookup-refs: ${{ inputs.lookup-refs }} + github-token: ${{ steps.github-token.outputs.token }} + - name: Install R package 🚧 run: | if (file.exists("renv.lock")) renv::restore() diff --git a/.github/workflows/roxygen.yaml b/.github/workflows/roxygen.yaml index e79d4c44c..478e9470e 100644 --- a/.github/workflows/roxygen.yaml +++ b/.github/workflows/roxygen.yaml @@ -41,6 +41,19 @@ on: required: false type: string default: "." + deps-installation-method: + description: Which method for installing R package dependencies to use? + required: true + type: choice + default: staged-dependencies + options: + - staged-dependencies + - setup-r-dependencies + lookup-refs: + description: | + List of package references to be used by setup-r-dependencies action if deps-installation-method == 'setup-r-dependencies'. + required: false + default: "" secrets: REPO_GITHUB_TOKEN: description: | @@ -109,12 +122,16 @@ jobs: SKIP_INSTRUCTION: "[skip roxygen]" - name: Restore SD cache 💰 + if: >- + inputs.deps-installation-method == 'staged-dependencies' uses: actions/cache@v4 with: key: sd-${{ runner.os }}-${{ github.event.repository.name }} path: ~/.staged.dependencies - name: Run Staged dependencies 🎦 + if: >- + inputs.deps-installation-method == 'staged-dependencies' uses: insightsengineering/staged-dependencies-action@v2 env: GITHUB_PAT: ${{ steps.github-token.outputs.token }} @@ -124,6 +141,14 @@ jobs: run-system-dependencies: ${{ inputs.install-system-dependencies }} direction: ${{ inputs.sd-direction }} + - name: Setup R dependencies 🎦 + if: >- + inputs.deps-installation-method == 'setup-r-dependencies' + uses: insightsengineering/setup-r-dependencies@v1 + with: + lookup-refs: ${{ inputs.lookup-refs }} + github-token: ${{ steps.github-token.outputs.token }} + - name: Generate man pages 📄 run: | logfile <- "roxygen_${{ github.event.repository.name }}.log" diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 1a7eda3f1..3676335da 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -82,6 +82,19 @@ on: required: false type: string default: "" + deps-installation-method: + description: Which method for installing R package dependencies to use? + required: true + type: choice + default: staged-dependencies + options: + - staged-dependencies + - setup-r-dependencies + lookup-refs: + description: | + List of package references to be used by setup-r-dependencies action if deps-installation-method == 'setup-r-dependencies'. + required: false + default: "" secrets: REPO_GITHUB_TOKEN: description: | @@ -207,12 +220,16 @@ jobs: fi - name: Restore SD cache 💰 + if: >- + inputs.deps-installation-method == 'staged-dependencies' uses: actions/cache@v4 with: key: sd-${{ runner.os }}-${{ github.event.repository.name }} path: ~/.staged.dependencies - name: Run Staged dependencies 🎦 + if: >- + inputs.deps-installation-method == 'staged-dependencies' uses: insightsengineering/staged-dependencies-action@v2 env: GITHUB_PAT: ${{ secrets.REPO_GITHUB_TOKEN }} @@ -222,6 +239,14 @@ jobs: run-system-dependencies: ${{ inputs.install-system-dependencies }} direction: ${{ inputs.sd-direction }} + - name: Setup R dependencies 🎦 + if: >- + inputs.deps-installation-method == 'setup-r-dependencies' + uses: insightsengineering/setup-r-dependencies@v1 + with: + lookup-refs: ${{ inputs.lookup-refs }} + github-token: ${{ steps.github-token.outputs.token }} + - name: Install R package 🚧 run: | if (file.exists("renv.lock")) renv::restore() diff --git a/.github/workflows/validation.yaml b/.github/workflows/validation.yaml index 655a5fb5b..55292e099 100644 --- a/.github/workflows/validation.yaml +++ b/.github/workflows/validation.yaml @@ -38,6 +38,19 @@ on: required: false type: string default: "." + deps-installation-method: + description: Which method for installing R package dependencies to use? + required: true + type: choice + default: staged-dependencies + options: + - staged-dependencies + - setup-r-dependencies + lookup-refs: + description: | + List of package references to be used by setup-r-dependencies action if deps-installation-method == 'setup-r-dependencies'. + required: false + default: "" secrets: REPO_GITHUB_TOKEN: description: | @@ -111,12 +124,16 @@ jobs: shell: bash - name: Restore SD cache 💰 + if: >- + inputs.deps-installation-method == 'staged-dependencies' uses: actions/cache@v4 with: key: sd-${{ runner.os }}-${{ github.event.repository.name }} path: ~/.staged.dependencies - name: Run Staged dependencies 🎦 + if: >- + inputs.deps-installation-method == 'staged-dependencies' uses: insightsengineering/staged-dependencies-action@v2 env: GITHUB_PAT: ${{ steps.github-token.outputs.token }} @@ -126,6 +143,14 @@ jobs: run-system-dependencies: ${{ inputs.install-system-dependencies }} direction: ${{ inputs.sd-direction }} + - name: Setup R dependencies 🎦 + if: >- + inputs.deps-installation-method == 'setup-r-dependencies' + uses: insightsengineering/setup-r-dependencies@v1 + with: + lookup-refs: ${{ inputs.lookup-refs }} + github-token: ${{ steps.github-token.outputs.token }} + - name: Build report 🏗 uses: insightsengineering/thevalidatoR@v2 env: