From b297f0fbc021b0235cf720e39508a4a405105646 Mon Sep 17 00:00:00 2001 From: pat-s Date: Tue, 16 Jun 2026 09:33:13 +0000 Subject: [PATCH] refactor(ci): consolidate build-all-versions workflows into 2 files (#93) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Consolidate the four `build-all-versions*` files into two, mirroring the matrix approach used for the process-updates / weekly families: | Before | After | |---|---| | `build-all-versions-amd64.yaml` + `build-all-versions-arm64.yaml` | `build-all-versions.yaml` | | `build-all-versions-install-deps-amd64.yaml` + `-arm64.yaml` | `build-all-versions-install-deps.yaml` | `ARCH` becomes a matrix axis carrying the per-arch differences: `agent` (artemis/gaia), `BACKEND` (kubernetes/docker), and `R_PKG_CACHE_DIR`. Build-all keeps its `SPLIT_INDEX` parallelism, so its matrix is ARCH x SPLIT = 8 rows; only the rows matching the selected arch run. **Invocation unchanged.** Routing uses the existing task selector `task == "build-all-${ARCH}"`, so `--var task=build-all-amd64 ...` still runs exactly the amd64 rows. `OS` / `OS_VERSION` / `R_VERSION` / `K8S_INSTANCE_TYPE` are still passed via `--var`. (You can drop `--var ARCH=...` now — arch comes from the matrix/task.) **No cron.** These pipelines are manual-only, so there are no scheduled runs to affect. ## Validation before merge Same matrix-interpolation-in-`when`/`labels` mechanism validated for #92, plus it now relies on per-row `agent`/`BACKEND` selecting the right execution backend (kubernetes for amd64, docker for arm64). Before merge, on this branch trigger a small `task=build-all-arm64` run and confirm it lands on the gaia/docker backend (and amd64 on artemis/kubernetes). Originals are in git history for rollback. Note: `archive-missed-packages.yaml` was already a single consolidated matrix file (cron + manual) and is left untouched. Reviewed-on: https://git.devxy.io/devxy/build-cran-binaries/pulls/93 --- .crow/build-all-versions-arm64.yaml | 167 ------------------ ...build-all-versions-install-deps-arm64.yaml | 56 ------ ...l => build-all-versions-install-deps.yaml} | 48 +++-- ...ons-amd64.yaml => build-all-versions.yaml} | 124 +++++++------ 4 files changed, 100 insertions(+), 295 deletions(-) delete mode 100644 .crow/build-all-versions-arm64.yaml delete mode 100644 .crow/build-all-versions-install-deps-arm64.yaml rename .crow/{build-all-versions-install-deps-amd64.yaml => build-all-versions-install-deps.yaml} (66%) rename .crow/{build-all-versions-amd64.yaml => build-all-versions.yaml} (69%) diff --git a/.crow/build-all-versions-arm64.yaml b/.crow/build-all-versions-arm64.yaml deleted file mode 100644 index be45659..0000000 --- a/.crow/build-all-versions-arm64.yaml +++ /dev/null @@ -1,167 +0,0 @@ -### Required extra vars -# ARCH (amd64) -# OS (alpine) -# OS_VERSION (3.22) -# R_VERSION (4.5.3) -# Skip list lives in local/excluded-packages.json (read by local/build-all.R). -# crow pipeline create --var ARCH=arm64 --var OS=alpine --var OS_VERSION=3.24 --var R_VERSION=4.5.3 --var task=build-all-arm64 --branch=main --log-level=info 5 -# crow pipeline create --var ARCH=arm64 --var OS=alpine --var OS_VERSION=3.24 --var R_VERSION=4.5.3 --var task=build-all-arm64 --branch=main --log-level=info 5 -when: - - event: manual - evaluate: 'task == "build-all-arm64"' - -skip_clone: true - -labels: - agent: gaia - -matrix: - include: - # - SPLIT_INTO: 5 - # SPLIT_INDEX: 1 - # BACKEND: kubernetes - # - SPLIT_INTO: 5 - # SPLIT_INDEX: 2 - # BACKEND: kubernetes - # - SPLIT_INTO: 5 - # SPLIT_INDEX: 3 - # BACKEND: kubernetes - # - SPLIT_INTO: 5 - # SPLIT_INDEX: 4 - # BACKEND: kubernetes - # - SPLIT_INTO: 5 - # SPLIT_INDEX: 5 - # BACKEND: kubernetes - - SPLIT_INTO: 4 - SPLIT_INDEX: 1 - BACKEND: docker - - SPLIT_INTO: 4 - SPLIT_INDEX: 2 - BACKEND: docker - - SPLIT_INTO: 4 - SPLIT_INDEX: 3 - BACKEND: docker - - SPLIT_INTO: 4 - SPLIT_INDEX: 4 - BACKEND: docker - # - SPLIT_INTO: 5 - # SPLIT_INDEX: 5 - # BACKEND: docker - -depends_on: - - build-all-versions-install-deps-arm64 - -steps: - - name: 'Build binaries' - image: 'reg.devxy.io/rpkgs/build-env-${OS}:${OS_VERSION}' - pull: true - environment: - RED_HAT_DEV_PW: - from_secret: RED_HAT_DEV_PW - B2_S3_ACCESS_KEY: - from_secret: B2_S3_ACCESS_KEY - B2_S3_SECRET_KEY: - from_secret: B2_S3_SECRET_KEY - PGPASS: - from_secret: PGPASS - REPO_RO_TOKEN: - from_secret: REPO_RO_TOKEN - GITHUB_PAT: - from_secret: GITHUB_PAT - # normal env vars - GIT_USER: pat-s - # set the location of the 'pkgcache' cache dir which persists the R package dependencies needed to install the packages themselves - R_PKG_CACHE_DIR: /mnt/cache/pkgcache - R_LIBS_USER: /mnt/cache/R-pkgs - CCACHE_DIR: /mnt/cache/ccache - NCPUS: 2 - volumes: - - ${ARCH}-binaries-r-dep-cache-${OS}-${OS_VERSION//./}:/mnt/cache - commands: - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages - - XVFB=$(command -v xwfb-run 2>/dev/null || command -v xvfb-run); XVFB_ARGS=""; if command -v xwfb-run >/dev/null 2>&1; then dnf install -y -q weston 2>/dev/null; XVFB_ARGS="-c weston"; fi - - $XVFB $XVFB_ARGS -n $SPLIT_INDEX -- /opt/R/$R_VERSION/bin/Rscript local/build-all.R $SPLIT_INTO $SPLIT_INDEX $NCPUS 2>&1 - - | - PRIMARY_MINOR=$(echo "$R_VERSION" | cut -d. -f1-2) - for RBIN in /opt/R/[0-9]*/bin/R; do - RV=$(basename "$(dirname "$(dirname "$RBIN")")") - RMINOR=$(echo "$RV" | cut -d. -f1-2) - [ "$RMINOR" = "$PRIMARY_MINOR" ] && continue - echo "=== R-minor-sensitive pass under R $RV ===" - LIB="/mnt/cache/R-pkgs-$RMINOR" - mkdir -p "$LIB" - R_LIBS_USER="$LIB" "$(dirname "$RBIN")/R" -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.2.2") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.2.2")' || true - R_LIBS_USER="$LIB" $XVFB $XVFB_ARGS -n $SPLIT_INDEX -- "$(dirname "$RBIN")/Rscript" local/build-all.R --sensitive-only $SPLIT_INTO $SPLIT_INDEX $NCPUS 2>&1 || true - done - # archive missed packages - - /opt/R/$R_VERSION/bin/R -q -e "bincraft::process_unarchived_pkgs(paste(Sys.getenv('OS'), Sys.getenv('OS_VERSION')), Sys.getenv('ARCH'), workers = $NCPUS)" - backend_options: - docker: - resources: - requests: - memory: 5Gi - cpu: 1000m - limits: - memory: 20Gi - cpu: 2000m - kubernetes: - resources: - requests: - memory: 5Gi - cpu: 1000m - limits: - memory: 20Gi - cpu: 2000m - nodeSelector: - kubernetes.io/arch: ${ARCH} - node.kubernetes.io/instance-type: ${K8S_INSTANCE_TYPE} - tolerations: - - key: 'CI' - operator: 'Equal' - value: 'true' - effect: 'NoSchedule' - - name: 'Upload package indexes' - image: 'reg.devxy.io/rpkgs/build-env-${OS}:${OS_VERSION}' - pull: true - environment: - B2_S3_ACCESS_KEY: - from_secret: B2_S3_ACCESS_KEY - B2_S3_SECRET_KEY: - from_secret: B2_S3_SECRET_KEY - R_LIBS_USER: /mnt/cache/R-pkgs - volumes: - - ${ARCH}-binaries-r-dep-cache-${OS}-${OS_VERSION//./}:/mnt/cache - commands: - - | - CODENAME=$(/opt/R/$R_VERSION/bin/Rscript -e "cat(bincraft::set_codename(NULL))") - /opt/R/$R_VERSION/bin/R -q -e "bincraft::upload_package_index(codename = '$CODENAME', s3_endpoint = 'https://s3.eu-central-003.backblazeb2.com', s3_region = 'eu-central-003', s3_bucket = 'devxy-rpkgs-binaries', s3_access_key_id = Sys.getenv('B2_S3_ACCESS_KEY'), s3_secret_access_key = Sys.getenv('B2_S3_SECRET_KEY'))" - for RBIN in /opt/R/[0-9]*/bin/R; do - RMINOR=$(basename "$(dirname "$(dirname "$RBIN")")" | cut -d. -f1-2) - /opt/R/$R_VERSION/bin/R -q -e "bincraft::upload_package_index(codename = '$CODENAME', r_minor = '$RMINOR', s3_endpoint = 'https://s3.eu-central-003.backblazeb2.com', s3_region = 'eu-central-003', s3_bucket = 'devxy-rpkgs-binaries', s3_access_key_id = Sys.getenv('B2_S3_ACCESS_KEY'), s3_secret_access_key = Sys.getenv('B2_S3_SECRET_KEY'))" || true - done - backend_options: - docker: - resources: - requests: - memory: 5Gi - cpu: 1000m - limits: - memory: 20Gi - cpu: 2000m - kubernetes: - resources: - requests: - memory: 5Gi - cpu: 1000m - limits: - memory: 20Gi - cpu: 2000m - nodeSelector: - kubernetes.io/arch: ${ARCH} - node.kubernetes.io/instance-type: ${K8S_INSTANCE_TYPE} - tolerations: - - key: 'CI' - operator: 'Equal' - value: 'true' - effect: 'NoSchedule' diff --git a/.crow/build-all-versions-install-deps-arm64.yaml b/.crow/build-all-versions-install-deps-arm64.yaml deleted file mode 100644 index 98decea..0000000 --- a/.crow/build-all-versions-install-deps-arm64.yaml +++ /dev/null @@ -1,56 +0,0 @@ -when: - - event: manual - evaluate: 'task == "build-all-arm64"' - -skip_clone: true - -labels: - agent: gaia - -steps: - - name: 'Install deps and bincraft' - image: 'reg.devxy.io/rpkgs/build-env-${OS}:${OS_VERSION}' - pull: true - environment: - REPO_RO_TOKEN: - from_secret: REPO_RO_TOKEN - GITHUB_PAT: - from_secret: GITHUB_PAT - B2_S3_ACCESS_KEY: - from_secret: B2_S3_ACCESS_KEY - B2_S3_SECRET_KEY: - from_secret: B2_S3_SECRET_KEY - PGPASS: - from_secret: PGPASS - R_PKG_CACHE_DIR: /mnt/cache/pkgcache - R_LIBS_USER: /mnt/cache/R-pkgs - CCACHE_DIR: /mnt/cache/ccache - volumes: - - ${ARCH}-binaries-r-dep-cache-${OS}-${OS_VERSION//./}:/mnt/cache - commands: - # one-time full wipe to fix corrupted .so files from previous failed builds - # - rm -rf /mnt/cache/R-pkgs - - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - git clone -q https://codefloe.com/rpkgs/bincraft.git /tmp/bincraft - - /opt/R/$R_VERSION/bin/R -q -e 'pak::sysreqs_db_update(); pak::local_install("/tmp/bincraft"); pak::pak(c("RPostgres", "s3fs", "data.table", "future", "jsonlite")); packageVersion("bincraft")' - - /opt/R/$R_VERSION/bin/R -q -e "source('local/packages-to-build.R'); saveRDS(pkgs, '/mnt/cache/packages/pkgs_to_build.rds'); saveRDS(pkgs[r_minor_sensitive == TRUE], '/mnt/cache/packages/r_minor_sensitive_pkgs.rds'); sprintf('Precomputed %s package versions (%s r-minor-sensitive)', nrow(pkgs), nrow(pkgs[r_minor_sensitive == TRUE]))" - backend_options: - docker: - resources: - requests: - memory: 5Gi - cpu: 1000m - kubernetes: - resources: - requests: - memory: 5Gi - cpu: 1000m - nodeSelector: - kubernetes.io/arch: ${ARCH} - node.kubernetes.io/instance-type: ${K8S_INSTANCE_TYPE} - tolerations: - - key: 'CI' - operator: 'Equal' - value: 'true' - effect: 'NoSchedule' diff --git a/.crow/build-all-versions-install-deps-amd64.yaml b/.crow/build-all-versions-install-deps.yaml similarity index 66% rename from .crow/build-all-versions-install-deps-amd64.yaml rename to .crow/build-all-versions-install-deps.yaml index 285a4e2..11738ce 100644 --- a/.crow/build-all-versions-install-deps-amd64.yaml +++ b/.crow/build-all-versions-install-deps.yaml @@ -1,12 +1,43 @@ +# Consolidated install-deps for build-all (both arches in one file). +# Triggered together with build-all-versions; `target_arch` routes the matrix. +# Variables are declared so the manual-run form exposes them (crow #1165); +# they are merged with build-all-versions' identical declarations. +variables: + target_arch: + description: "Architecture to build." + options: + - amd64 + - arm64 + default: amd64 + OS: + description: "Base OS image name (e.g. alpine, redhat, ubuntu)." + default: alpine + OS_VERSION: + description: "OS version / image tag (e.g. 3.24, 9, jammy, noble)." + default: "3.24" + R_VERSION: + description: "Primary R version under /opt/R." + options: + - 4.5.3 + - 4.4.3 + default: 4.5.3 + when: - event: manual - evaluate: 'task == "build-all-amd64"' + evaluate: 'target_arch == "${ARCH}"' skip_clone: true labels: platform: linux/${ARCH} - agent: artemis + agent: ${AGENT} + +matrix: + include: + - ARCH: amd64 + AGENT: artemis + - ARCH: arm64 + AGENT: gaia steps: - name: 'Install deps and bincraft' @@ -42,16 +73,3 @@ steps: requests: memory: 5Gi cpu: 1000m - kubernetes: - resources: - requests: - memory: 5Gi - cpu: 1000m - nodeSelector: - kubernetes.io/arch: ${ARCH} - node.kubernetes.io/instance-type: ${K8S_INSTANCE_TYPE} - tolerations: - - key: 'CI' - operator: 'Equal' - value: 'true' - effect: 'NoSchedule' diff --git a/.crow/build-all-versions-amd64.yaml b/.crow/build-all-versions.yaml similarity index 69% rename from .crow/build-all-versions-amd64.yaml rename to .crow/build-all-versions.yaml index be356fb..479c8d6 100644 --- a/.crow/build-all-versions-amd64.yaml +++ b/.crow/build-all-versions.yaml @@ -1,39 +1,83 @@ -### Required extra vars -# ARCH (amd64) -# OS (alpine) -# OS_VERSION (3.22) -# R_VERSION (4.5.3) -# crow pipeline create --var ARCH=amd64 --var OS=alpine --var OS_VERSION=3.24 --var R_VERSION=4.5.3 --var task=build-all-amd64 --branch=main --log-level=info 5 +### Manual full rebuild of all CRAN binaries for one OS/arch. +# Set the variables below in the manual-run form (or via --var on the CLI). +# `target_arch` routes the matrix; OS/OS_VERSION/R_VERSION select the platform +# image and cache volume. Placement is via the agent label (artemis/gaia). +# Skip list lives in local/excluded-packages.json (read by local/build-all.R). +variables: + target_arch: + description: "Architecture to build." + options: + - amd64 + - arm64 + default: amd64 + OS: + description: "Base OS image name (e.g. alpine, redhat, ubuntu)." + default: alpine + OS_VERSION: + description: "OS version / image tag (e.g. 3.24, 9, jammy, noble)." + default: "3.24" + R_VERSION: + description: "Primary R version under /opt/R." + options: + - 4.5.3 + - 4.4.3 + default: 4.5.3 + when: - event: manual - evaluate: 'task == "build-all-amd64"' + evaluate: 'target_arch == "${ARCH}"' skip_clone: true labels: - platform: linux/amd64 - agent: artemis + platform: linux/${ARCH} + agent: ${AGENT} matrix: include: - - SPLIT_INTO: 4 + - ARCH: amd64 + AGENT: artemis + R_PKG_CACHE_DIR: '' + SPLIT_INTO: 4 SPLIT_INDEX: 1 - BACKEND: kubernetes - - SPLIT_INTO: 4 + - ARCH: amd64 + AGENT: artemis + R_PKG_CACHE_DIR: '' + SPLIT_INTO: 4 SPLIT_INDEX: 2 - BACKEND: kubernetes - - SPLIT_INTO: 4 + - ARCH: amd64 + AGENT: artemis + R_PKG_CACHE_DIR: '' + SPLIT_INTO: 4 SPLIT_INDEX: 3 - BACKEND: kubernetes - - SPLIT_INTO: 4 + - ARCH: amd64 + AGENT: artemis + R_PKG_CACHE_DIR: '' + SPLIT_INTO: 4 + SPLIT_INDEX: 4 + - ARCH: arm64 + AGENT: gaia + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + SPLIT_INTO: 4 + SPLIT_INDEX: 1 + - ARCH: arm64 + AGENT: gaia + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + SPLIT_INTO: 4 + SPLIT_INDEX: 2 + - ARCH: arm64 + AGENT: gaia + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + SPLIT_INTO: 4 + SPLIT_INDEX: 3 + - ARCH: arm64 + AGENT: gaia + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + SPLIT_INTO: 4 SPLIT_INDEX: 4 - BACKEND: kubernetes - # - SPLIT_INTO: 4 - # SPLIT_INDEX: 5 - # BACKEND: kubernetes depends_on: - - build-all-versions-install-deps-amd64 + - build-all-versions-install-deps steps: - name: 'Build binaries' @@ -55,7 +99,7 @@ steps: # normal env vars GIT_USER: pat-s # set the location of the 'pkgcache' cache dir which persists the R package dependencies needed to install the packages themselves - R_PKG_CACHE_DIR: '' + R_PKG_CACHE_DIR: ${R_PKG_CACHE_DIR} R_LIBS_USER: /mnt/cache/R-pkgs CCACHE_DIR: /mnt/cache/ccache NCPUS: 2 @@ -64,8 +108,6 @@ steps: commands: - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages - # Windows-only: 'RInno', 'KeyboardSimulator', 'R2PPT', 'RWinEdt', 'blatr', 'excel.link', 'spectrino', 'taskscheduleR', 'MDSGUI', 'BiplotGUI', 'R2wd', 'rFUSION', 'MediaNews', 'rFUSION', 'MediaNews' - # pkgs = readRDS('/mnt/cache/pkgs_amd64.rds'); - XVFB=$(command -v xwfb-run 2>/dev/null || command -v xvfb-run); XVFB_ARGS=""; if command -v xwfb-run >/dev/null 2>&1; then dnf install -y -q weston 2>/dev/null; XVFB_ARGS="-c weston"; fi - $XVFB $XVFB_ARGS -n $SPLIT_INDEX -- /opt/R/$R_VERSION/bin/Rscript local/build-all.R $SPLIT_INTO $SPLIT_INDEX $NCPUS 2>&1 - | @@ -91,22 +133,6 @@ steps: limits: memory: 20Gi cpu: 2000m - kubernetes: - resources: - requests: - memory: 5Gi - cpu: 1000m - limits: - memory: 20Gi - cpu: 2000m - nodeSelector: - kubernetes.io/arch: ${ARCH} - node.kubernetes.io/instance-type: ${K8S_INSTANCE_TYPE} - tolerations: - - key: 'CI' - operator: 'Equal' - value: 'true' - effect: 'NoSchedule' - name: 'Upload package indexes' image: 'reg.devxy.io/rpkgs/build-env-${OS}:${OS_VERSION}' pull: true @@ -134,20 +160,4 @@ steps: cpu: 1000m limits: memory: 20Gi - cpu: 2000m - kubernetes: - resources: - requests: - memory: 5Gi - cpu: 1000m - limits: - memory: 20Gi - cpu: 2000m - nodeSelector: - kubernetes.io/arch: ${ARCH} - node.kubernetes.io/instance-type: ${K8S_INSTANCE_TYPE} - tolerations: - - key: 'CI' - operator: 'Equal' - value: 'true' - effect: 'NoSchedule' + cpu: 2000m \ No newline at end of file