Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions .github/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,20 @@ ENV LANG=en_US.UTF-8
RUN git config --global --add safe.directory '*'


# Install latest stable Rust toolchain (rocker images may ship an outdated version)
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# Install latest stable Rust toolchain into fixed, $HOME-independent paths so
# that pak can find cargo regardless of the HOME GitHub Actions injects at runtime.
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --no-modify-path
ENV PATH="/usr/local/cargo/bin:${PATH}"

# Register Rust with dpkg so pkgdepends' bundled sysreqs DB treats it as
# already installed and skips any apt/rustup install attempts at runtime.
RUN RUSTC_VER=$(rustc --version | awk '{print $2}') \
&& CARGO_VER=$(cargo --version | awk '{print $2}') \
&& printf 'Package: rustc\nStatus: install ok installed\nArchitecture: amd64\nVersion: %s\nDescription: stub; real Rust managed by rustup\n\nPackage: cargo\nStatus: install ok installed\nArchitecture: amd64\nVersion: %s\nDescription: stub; real Rust managed by rustup\n\n' \
"$RUSTC_VER" "$CARGO_VER" >> /var/lib/dpkg/status

# Rocker images configure repos to PPM's Linux binary endpoint, which doesn't
# index packages needing non-standard build tools (e.g. Rust). Add CRAN source
Expand All @@ -71,6 +82,13 @@ RUN Rscript -e 'install.packages("pak")'
COPY install-packages.R /tmp/install-packages.R
RUN Rscript /tmp/install-packages.R && rm /tmp/install-packages.R

# Use pkgdepends' bundled sysreqs DB at runtime rather than downloading the
# live r-hub DB. The live DB's Rust rule runs rustup unconditionally (empty
# packages list bypasses the dpkg check), which fails inside GHA containers
# where HOME is remapped. The bundled DB uses a proper dpkg-based check.
# Rebuild the image with a newer pkgdepends to pick up bundled DB updates.
ENV PKG_SYSREQS_DB_UPDATE=false

# GitHub Copilot's injected "Prepare Copilot" step uses `set -o pipefail` via
# `shell: sh`, which dash (Debian's default /bin/sh) doesn't support. Redirect
# /bin/sh to bash, which is already installed and is a superset of POSIX sh.
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
copilot-setup-steps:
runs-on: ubuntu-latest
container: ghcr.io/api2r/pkgskills-ci:release

permissions:
contents: read
Expand All @@ -25,7 +24,6 @@ jobs:

- uses: ./.github/workflows/install
with:
use-container: "true"
token: ${{ secrets.GITHUB_TOKEN }}
cache-version: copilot
needs: build, check, website
Expand Down
33 changes: 28 additions & 5 deletions .github/workflows/install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ runs:
- if: inputs.use-container != 'true'
uses: r-lib/actions/setup-pandoc@v2

# Always run setup-r, even in containers. With install-r: false it
# skips the R download but still sets R_LIBS_USER, TZ, NOT_CRAN, etc.
# in GITHUB_ENV — the official way to align the environment for
# setup-r-dependencies and actions/cache.
- uses: r-lib/actions/setup-r@v2
with:
install-r: ${{ inputs.use-container != 'true' }}
Expand All @@ -62,7 +58,34 @@ runs:
mkdir -p "$lib"
touch "$lib/.keep"

- uses: r-lib/actions/setup-r-dependencies@v2
# 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/<field> 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)]

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:
Expand Down
1 change: 0 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# pkgskills (development version)

* `use_github_copilot()` now installs a container-based `copilot-setup-steps.yml` for faster agent startup (#67).
* `AGENTS.md` and `tdd-workflow` skill instructions now explicitly explain how to determine the GitHub issue number and warn agents never to guess or invent one (@copilot, #61).
* `use_agent()` template is reconciled with this package's `AGENTS.md` file (#59).
* `tdd-workflow` skill now documents `stbl::expect_pkg_error_snapshot()` with an explicit `package` argument instead of a helper-defined version (#51).
Expand Down
2 changes: 0 additions & 2 deletions inst/templates/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
copilot-setup-steps:
runs-on: ubuntu-latest
container: ghcr.io/api2r/pkgskills-ci:release

permissions:
contents: read
Expand All @@ -25,7 +24,6 @@ jobs:

- uses: ./.github/workflows/install
with:
use-container: "true"
token: ${{ secrets.GITHUB_TOKEN }}
cache-version: copilot
needs: build, check, website
Expand Down
Loading