diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 25cb2c5e..efb3807e 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -28,7 +28,7 @@ jobs: steps: - uses: actions/checkout@v6 - - uses: ./.github/workflows/install + - uses: api2r/actions/install@v1 with: use-container: "${{ matrix.config.container != '' }}" token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index ae9a04bb..e1907e16 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -22,7 +22,7 @@ jobs: steps: - uses: actions/checkout@v6 - - uses: ./.github/workflows/install + - uses: api2r/actions/install@v1 with: token: ${{ secrets.GITHUB_TOKEN }} cache-version: copilot @@ -45,6 +45,7 @@ jobs: any::testthat any::usethis any::withr + Gilead-BioStats/qcthat local::. - name: Install air diff --git a/.github/workflows/install/action.yml b/.github/workflows/install/action.yml deleted file mode 100644 index ff4ba5e1..00000000 --- a/.github/workflows/install/action.yml +++ /dev/null @@ -1,118 +0,0 @@ -name: "Install R and dependencies" -description: "Set up pandoc, R, and package dependencies" -inputs: - token: - description: "GitHub token, set to secrets.GITHUB_TOKEN" - required: true - r-version: - description: "R version, passed to r-lib/actions/setup-r@v2" - required: false - default: release - http-user-agent: - description: "HTTP user agent, passed to r-lib/actions/setup-r@v2" - required: false - default: "" - needs: - description: "Config/Needs tag(s), passed to r-lib/actions/setup-r-dependencies@v2" - required: false - default: "" - extra-packages: - description: "Extra packages, passed to r-lib/actions/setup-r-dependencies@v2" - required: false - default: any::rcmdcheck - optional-packages: - description: "Optional extra packages; installed individually, warn (not error) on failure" - required: false - default: "" - cache-version: - description: "Cache version for r-lib/actions/setup-r-dependencies@v2" - required: false - default: "1" - use-container: - description: "Set to 'true' when running inside a pre-warmed container (skips R and pandoc setup)" - required: false - default: "false" - -runs: - using: "composite" - steps: - - if: inputs.use-container != 'true' - uses: r-lib/actions/setup-pandoc@v2 - - - uses: r-lib/actions/setup-r@v2 - with: - install-r: ${{ inputs.use-container != 'true' }} - r-version: ${{ inputs.r-version }} - http-user-agent: ${{ inputs.http-user-agent }} - use-public-rspm: true - - # In pre-warmed containers every package may already be in the system - # library, so nothing is ever written to R_LIBS_USER. Ensure the - # directory exists with a sentinel so the actions/cache glob matches - # and the "Path Validation Error" warning doesn't fire at cache-save. - - if: inputs.use-container == 'true' - name: Ensure R_LIBS_USER exists - shell: bash - run: | - lib="$(Rscript -e 'cat(Sys.getenv("R_LIBS_USER"))')" - mkdir -p "$lib" - touch "$lib/.keep" - - # Container path: call pak::pak() directly so it checks .libPaths() and - # only installs/updates packages that are genuinely missing or outdated. - # setup-r-dependencies always runs a full lockfile-create → lockfile-install - # cycle which reinstalls everything even when the container already has it. - - if: inputs.use-container == 'true' - name: Update R package dependencies (container) - shell: Rscript {0} - env: - GITHUB_PAT: ${{ inputs.token }} - run: | - # Replicate needs → Config/Needs/ expansion from r-lib/actions - needs_parts <- strsplit("${{ inputs.needs }}", "[[:space:],]+")[[1]] - needs_parts <- needs_parts[nzchar(needs_parts)] - needs <- sprintf("Config/Needs/%s", needs_parts) - - extra_deps <- strsplit("${{ inputs.extra-packages }}", "[[:space:],]+")[[1]] - extra_deps <- extra_deps[nzchar(extra_deps)] - - # Over-protect for strangeness in the container - if (!requireNamespace("pak", quietly = TRUE)) { - install.packages("pak") - } - - pak::pak( - c("deps::.", extra_deps), - dependencies = c(needs, "all"), - upgrade = TRUE, - ask = FALSE - ) - - # Non-container path: standard setup-r-dependencies flow with caching. - - if: inputs.use-container != 'true' - uses: r-lib/actions/setup-r-dependencies@v2 - env: - GITHUB_PAT: ${{ inputs.token }} - with: - needs: ${{ inputs.needs }} - extra-packages: ${{ inputs.extra-packages }} - cache-version: ${{ inputs.cache-version }} - - - if: inputs.optional-packages != '' - name: Install optional packages - shell: Rscript {0} - env: - GITHUB_PAT: ${{ inputs.token }} - run: | - pkgs <- strsplit("${{ inputs.optional-packages }}", "\\s+")[[1]] - pkgs <- pkgs[nzchar(pkgs)] - for (pkg in pkgs) { - tryCatch( - pak::pak(pkg), - error = function(e) { - msg <- sprintf("Failed to install optional package %s: %s", pkg, conditionMessage(e)) - msg <- gsub("[\r\n]+", " ", msg) - cat("::warning::", msg, "\n", sep = "") - } - ) - } diff --git a/.github/workflows/pkgdown-cleanup.yaml b/.github/workflows/pkgdown-cleanup.yaml new file mode 100644 index 00000000..d8ea7c2b --- /dev/null +++ b/.github/workflows/pkgdown-cleanup.yaml @@ -0,0 +1,33 @@ +# This workflow removes the pkgdown preview directory when a PR is closed. +name: Clean up pkgdown preview + +on: + pull_request: + types: [closed] + +permissions: + contents: write + +jobs: + clean-pr-preview: + runs-on: ubuntu-latest + steps: + - name: Checkout gh-pages branch + uses: actions/checkout@v6 + with: + repository: ${{ github.repository }} + token: ${{ secrets.GITHUB_TOKEN }} + ref: gh-pages + + - name: Remove PR preview directory + run: | + pr_dir="pr/${{ github.event.number }}" + if [ -d "$pr_dir" ]; then + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git rm -rf "$pr_dir" + git commit -m "Remove preview for PR #${{ github.event.number }}" + git push + else + echo "Directory $pr_dir does not exist, skipping cleanup." + fi diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index afc5f447..7f4f411e 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -27,7 +27,7 @@ jobs: steps: - uses: actions/checkout@v6 - - uses: ./.github/workflows/install + - uses: api2r/actions/install@v1 with: use-container: "true" token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml index 8c94262a..8c2f575f 100644 --- a/.github/workflows/pr-commands.yaml +++ b/.github/workflows/pr-commands.yaml @@ -22,7 +22,7 @@ jobs: with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - uses: ./.github/workflows/install + - uses: api2r/actions/install@v1 with: use-container: "true" token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/qcthat.yaml b/.github/workflows/qcthat.yaml index a6ea54c7..2adec848 100644 --- a/.github/workflows/qcthat.yaml +++ b/.github/workflows/qcthat.yaml @@ -58,7 +58,7 @@ jobs: steps: - uses: actions/checkout@v6 - - uses: ./.github/workflows/install + - uses: api2r/actions/install@v1 with: use-container: "true" token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 6878a499..8b7a5f30 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -16,7 +16,7 @@ jobs: steps: - uses: actions/checkout@v6 - - uses: ./.github/workflows/install + - uses: api2r/actions/install@v1 with: use-container: "true" token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 5af056fc..746f277f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ inst/doc docs /.positai/ conversation-export*.json +.positai