diff --git a/.crow/archive-missed-packages.yaml b/.crow/archive-missed-packages.yaml index 71e263e..b1a3a8a 100644 --- a/.crow/archive-missed-packages.yaml +++ b/.crow/archive-missed-packages.yaml @@ -6,6 +6,7 @@ when: - event: cron cron: archive-missed-packages + matrix: include: - CODENAME: jammy @@ -24,18 +25,18 @@ matrix: ARCH: amd64 - CODENAME: redhat-9 ARCH: arm64 - - CODENAME: redhat-10 + - CODENAME: alpine321 ARCH: amd64 - - CODENAME: redhat-10 + - CODENAME: alpine321 ARCH: arm64 - - CODENAME: alpine323 + - CODENAME: alpine322 ARCH: amd64 - - CODENAME: alpine323 + - CODENAME: alpine322 ARCH: arm64 steps: - name: 'Archive missed packages' - image: reg.devxy.io/rpkgs/build-env-alpine:3.24 + image: reg.devxy.io/rpkgs/build-env-alpine:3.23 pull: true environment: RED_HAT_DEV_PW: @@ -54,9 +55,9 @@ steps: GIT_USER: pat-s R_VERSION: 4.5.3 commands: - - /opt/R/$R_VERSION/bin/Rscript local/install-bincraft.R + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0", dependencies = TRUE)' - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' - - /opt/R/$R_VERSION/bin/R -q -e 'bincraft::process_unarchived_pkgs(Sys.getenv("CODENAME"), Sys.getenv("ARCH"), 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"), workers = 2L)' + - /opt/R/$R_VERSION/bin/R -q -e 'bincraft::process_unarchived_pkgs(Sys.getenv("CODENAME"), Sys.getenv("ARCH"), workers = 2L)' backend_options: kubernetes: resources: diff --git a/.crow/auto-apply-patches.yaml b/.crow/auto-apply-patches.yaml deleted file mode 100644 index 5d6e6fe..0000000 --- a/.crow/auto-apply-patches.yaml +++ /dev/null @@ -1,76 +0,0 @@ -# Auto-apply registry patches (issue #115, step 3 automation). -# Classifies `single_builds` failures and, for the top-N auto-proposable -# candidates by failure volume, writes the registry entries onto the reused -# `auto/registry-patch-proposals` branch and opens/updates a single PR. -# Nothing merges: the `trial-build-registry` pipeline is the merge gate, and a -# human reviews the PR. Novel source diffs / unknown signatures are never -# proposed. Global across platforms, so a single job -- no matrix. -# -# FORGEJO_TOKEN is used for both the branch push and opening the PR (no separate -# write-scoped secret needed). Register the `auto-apply-patches` cron in the crow -# UI, or run manually: -# crow pipeline create --branch main \ -# --var auto_apply_patches=true devxy/build-cran-binaries -# -# The gate variable is `auto_apply_patches`, named after the pipeline: a manual -# run instantiates every pipeline in `.crow/`, so one without its own gate runs -# on *any* manual trigger in this repo. This one pushes a branch and opens a PR, -# so it must stay off unless it is what was asked for. -variables: - auto_apply_patches: - description: 'Run the auto-patch proposer. Also gates this pipeline.' - options: - - 'true' - - 'false' - default: 'false' - patch_limit: - description: 'Max candidates to propose per run (top by failure volume).' - default: '10' - -when: - - event: manual - evaluate: 'auto_apply_patches == "true"' - - event: cron - cron: auto-apply-patches - -skip_clone: true - -labels: - group: rpkgs-amd64 - -steps: - - name: 'Auto-apply registry patches' - image: reg.devxy.io/rpkgs/build-env-alpine:3.24 - pull: true - environment: - PGPASS: - from_secret: PGPASS - REPO_RO_TOKEN: - from_secret: REPO_RO_TOKEN - FORGEJO_TOKEN: - from_secret: FORGEJO_TOKEN - GIT_USER: devxy-bot - GIT_EMAIL: bot@devxy.io - PATCH_LIMIT: ${patch_limit} - R_VERSION: 4.5.3 - R_LIBS_USER: /mnt/cache/R-pkgs - commands: - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - mkdir -p /mnt/cache/R-pkgs - - rm -rf /mnt/cache/R-pkgs/00LOCK-* - - UVR_R_BIN=/opt/R/$R_VERSION/bin/R local/uvr-install.sh RPostgres httr2 jsonlite - - /opt/R/$R_VERSION/bin/Rscript local/propose-patches.R --open-pr --limit $PATCH_LIMIT - backend_options: - kubernetes: - resources: - requests: - memory: 1Gi - cpu: 2000m - limits: - memory: 2Gi - cpu: 2000m - tolerations: - - key: 'CI' - operator: 'Equal' - value: 'true' - effect: 'NoSchedule' diff --git a/.crow/backfill-abi-classification.yaml b/.crow/backfill-abi-classification.yaml deleted file mode 100644 index 6eef94d..0000000 --- a/.crow/backfill-abi-classification.yaml +++ /dev/null @@ -1,91 +0,0 @@ -# Populate the ABI classifier cache for packages that predate the per-minor scheme. -# -# bincraft decides whether a flat binary may be carried into a per-minor index -# from its risky-package set. That set is now the union of the per-minor tarball -# scan and the `abi_classification` cache, but the cache only holds verdicts for -# packages that passed through the build pipeline after the scheme existed. -# Everything older has no verdict, and no verdict means "carry it" - which is how -# a base64enc built under R 4.4.3 reached R 4.6 clients and died at dyn.load() -# on SETLENGTH. -# -# The verdict is computed from the package source, so it does not depend on OS, -# arch or R minor: one run populates the cache for every slot. The arch/codename -# below only choose which flat index to enumerate. -# -# Re-running is cheap. Cached verdicts are returned without touching the network, -# so a second run costs one query per package and downloads only what is still -# unclassified. -# -# crow pipeline create devxy/build-cran-binaries --var backfill_abi=run - -variables: - # A manual pipeline creation instantiates every file in .crow/, so the default - # must be a value the `when` clause rejects. - backfill_abi: - description: "Set to 'run' to classify the flat index into the ABI cache." - options: - - none - - run - default: none - BACKFILL_ARCH: - description: 'Arch of the flat index to enumerate.' - options: - - amd64 - - arm64 - default: amd64 - BACKFILL_CODENAME: - description: 'Codename of the flat index to enumerate.' - default: resolute - BACKFILL_LIMIT: - description: 'Classify at most this many packages (0 = no limit).' - default: '0' - -when: - - event: manual - evaluate: 'backfill_abi == "run"' - -skip_clone: true - -labels: - group: rpkgs-amd64 - -steps: - - name: 'Classify the flat index into the ABI cache' - image: reg.devxy.io/rpkgs/build-env-ubuntu:resolute - pull: true - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - PGPASS: - from_secret: PGPASS - REPO_RO_TOKEN: - from_secret: REPO_RO_TOKEN - GITHUB_PAT: - from_secret: GITHUB_PAT - GIT_USER: pat-s - # Pipeline variables are substituted into the YAML, not exported, so they - # have to be bound here to be readable as env vars in the script below. - BACKFILL_ARCH: ${BACKFILL_ARCH} - BACKFILL_CODENAME: ${BACKFILL_CODENAME} - BACKFILL_LIMIT: ${BACKFILL_LIMIT} - R_LIBS_USER: /tmp/R-pkgs - commands: - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - mkdir -p /tmp/R-pkgs - - /opt/R/4.5.3/bin/Rscript local/install-bincraft.R - - UVR_R_BIN=/opt/R/4.5.3/bin/R local/uvr-install.sh RPostgres - - | - set -eu - LIMIT="" - if [ "$$BACKFILL_LIMIT" != "0" ]; then - LIMIT="$$BACKFILL_LIMIT" - fi - /opt/R/4.5.3/bin/Rscript local/backfill-abi-classification.R \ - "$$BACKFILL_ARCH" "$$BACKFILL_CODENAME" $$LIMIT - backend_options: - docker: - resources: - requests: - memory: 4Gi - cpu: 1000m diff --git a/.crow/backfill-flat-safety.yaml b/.crow/backfill-flat-safety.yaml deleted file mode 100644 index 85c9462..0000000 --- a/.crow/backfill-flat-safety.yaml +++ /dev/null @@ -1,176 +0,0 @@ -# Record, per flat-slot object, whether it loads under every supported R minor. -# -# `union_index_records()` keeps a carried flat record when that object is -# recorded safe and drops it otherwise. Objects uploaded before that record -# existed have no verdict, so they are dropped: a full re-index removed roughly -# 2000 records per per-minor index (16398 across the 4.4 indexes, 20076 across -# 4.5, 15532 across 4.6), each one resolving to CRAN source for clients the -# routing serves correctly. -# -# This inspects what is already in the bucket and writes the verdict, which is -# what restores that coverage. Decided by symbols rather than heuristics: a -# binary fails at dyn.load() under minor M exactly when it references a symbol M -# does not export, and the volatile set is derived by diffing the R builds in -# the image. -# -# Re-running is cheap; recorded objects are skipped. -# -# crow pipeline create devxy/build-cran-binaries --var flat_safety=all - -variables: - # A manual pipeline creation instantiates every file in .crow/, so the default - # must match no matrix row. - flat_safety: - description: "Inspect target: a specific -, 'all' for every slot, or 'none'." - options: - - none - - all - - alpine-323-amd64 - - alpine-323-arm64 - - alpine-324-amd64 - - alpine-324-arm64 - - redhat-8-amd64 - - redhat-8-arm64 - - redhat-9-amd64 - - redhat-9-arm64 - - redhat-10-amd64 - - redhat-10-arm64 - - ubuntu-2204-amd64 - - ubuntu-2204-arm64 - - ubuntu-2404-amd64 - - ubuntu-2404-arm64 - - ubuntu-2604-amd64 - - ubuntu-2604-arm64 - default: none - FLAT_SAFETY_LIMIT: - description: 'Inspect at most this many objects per slot (0 = no limit).' - default: '0' - -when: - - event: manual - evaluate: 'flat_safety == "all" || flat_safety == "${OS}-${ARCH}"' - -skip_clone: true - -labels: - group: rpkgs-${ARCH} - -matrix: - include: - - OS: alpine-323 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - - OS: alpine-323 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - - OS: alpine-324 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - - OS: alpine-324 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - - OS: redhat-8 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:8 - - OS: redhat-8 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:8 - - OS: redhat-9 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:9 - - OS: redhat-9 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:9 - - OS: redhat-10 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: redhat:10 - - OS: redhat-10 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: redhat:10 - - OS: ubuntu-2204 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - - OS: ubuntu-2204 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - - OS: ubuntu-2404 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - - OS: ubuntu-2404 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - - OS: ubuntu-2604 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - - OS: ubuntu-2604 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - -steps: - - name: 'Inspect flat objects and record safety' - image: reg.devxy.io/rpkgs/build-env-${IMG} - pull: true - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - 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 - # bincraft reads the DESCRIPTION of every new or replaced tarball from - # the CRAN mirror on raw.githubusercontent.com, and authenticates with - # this token when it is set. A slot whose published index cannot be read - # is re-read in full, ~25k requests, which the anonymous rate limit would - # cut short. - GITHUB_PAT: - from_secret: GITHUB_PAT - GIT_USER: pat-s - R_LIBS_USER: /tmp/R-pkgs - FLAT_SAFETY_ARCH: ${ARCH} - FLAT_SAFETY_LIMIT: ${FLAT_SAFETY_LIMIT} - commands: - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - mkdir -p /tmp/R-pkgs - - /opt/R/$R_VERSION/bin/Rscript local/install-bincraft.R - - UVR_R_BIN=/opt/R/$R_VERSION/bin/R local/uvr-install.sh RPostgres - - | - set -eu - LIMIT="" - if [ "$$FLAT_SAFETY_LIMIT" != "0" ]; then - LIMIT="$$FLAT_SAFETY_LIMIT" - fi - # The codename comes from the image's /etc/os-release, exactly as the - # re-index step derives it, so it cannot drift from the matrix. - CODENAME=$(/opt/R/$R_VERSION/bin/Rscript -e 'cat(bincraft::set_codename(NULL))') - echo "slot: $$FLAT_SAFETY_ARCH/$$CODENAME" - /opt/R/$R_VERSION/bin/Rscript local/backfill-flat-safety.R \ - "$$FLAT_SAFETY_ARCH" "$$CODENAME" $$LIMIT - backend_options: - docker: - resources: - requests: - memory: 4Gi - cpu: 1000m diff --git a/.crow/build-all-versions-amd64.yaml b/.crow/build-all-versions-amd64.yaml new file mode 100644 index 0000000..796c812 --- /dev/null +++ b/.crow/build-all-versions-amd64.yaml @@ -0,0 +1,99 @@ +### Required extra vars +# ARCH (amd64) +# OS (alpine) +# OS_VERSION (3.22) +# R_VERSION (4.5.3) +# crow pipeline create --var ARCH=arm64 --var OS=alpine --var OS_VERSION=3.23 --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=redhat --var OS_VERSION=10 --var R_VERSION=4.5.3 --var task=build-all-arm64 --branch=main --log-level=info 5 +# crow pipeline create --var ARCH=amd64 --var OS=redhat --var OS_VERSION=10 --var R_VERSION=4.5.3 --var task=build-all-amd64 --branch=main --log-level=info 5 +when: + - event: manual + evaluate: 'task == "build-all-amd64"' + +skip_clone: true + +labels: + platform: linux/amd64 + agent: artemis + +matrix: + include: + - SPLIT_INTO: 4 + SPLIT_INDEX: 1 + BACKEND: kubernetes + - SPLIT_INTO: 4 + SPLIT_INDEX: 2 + BACKEND: kubernetes + - SPLIT_INTO: 4 + SPLIT_INDEX: 3 + BACKEND: kubernetes + - SPLIT_INTO: 4 + SPLIT_INDEX: 4 + BACKEND: kubernetes + # - SPLIT_INTO: 4 + # SPLIT_INDEX: 5 + # BACKEND: kubernetes + +depends_on: + - build-all-versions-install-deps-amd64 + +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: "" + 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 + # 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 + # 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' diff --git a/.crow/build-all-versions-arm64.yaml b/.crow/build-all-versions-arm64.yaml new file mode 100644 index 0000000..afa6e89 --- /dev/null +++ b/.crow/build-all-versions-arm64.yaml @@ -0,0 +1,112 @@ +### Required extra vars +# ARCH (amd64) +# OS (alpine) +# OS_VERSION (3.22) +# R_VERSION (4.5.3) +# echo "c('RInno','KeyboardSimulator','R2PPT','RWinEdt','blatr','excel.link','spectrino','taskscheduleR','MDSGUI','BiplotGUI','R2wd','rFUSION','MediaNews','doBy','IDPmisc','frailtypack','afex','FrF2','DoE.base','agricolae','doFuture','fscaret','PHYLOGR','seewave','pls','relaimpo','geepack','gggenes','NPCirc','repmis','PNDSIBGE','lidR','poismf','neonstore','MachineShop','mvst','MacBehaviour','mcmcderive','RGIFT','KnowBR','netmeta','spdep','sf','Rfast','compareGroups','ff','GsymPoint','RcppDynProg','comtradr','RcppDynProg','FD','PearsonDS','DCluster','gRc','mixlm','geospt','fdth','ffmanova','fiery','ffscrapr','cold','fiery','RcmdrPlugin.DoE','RcmdrPlugin.NMBU')" | base64 +# crow pipeline create --var ARCH=arm64 --var OS=alpine --var OS_VERSION=3.22 --var R_VERSION=4.5 --var task=build-all-arm64 --var K8S_INSTANCE_TYPE=cax41 --branch=main --var SKIP_PKGS=YygnUklubm8nLCdLZXlib2FyZFNpbXVsYXRvcicsJ1IyUFBUJywnUldpbkVkdCcsJ2JsYXRyJywnZXhjZWwubGluaycsJ3NwZWN0cmlubycsJ3Rhc2tzY2hlZHVsZVInLCdNRFNHVUknLCdCaXBsb3RHVUknLCdSMndkJywnckZVU0lPTicsJ01lZGlhTmV3cycsJ2RvQnknLCdJRFBtaXNjJywnZnJhaWx0eXBhY2snLCdhZmV4JywnRnJGMicsJ0RvRS5iYXNlJywnYWdyaWNvbGFlJywnZG9GdXR1cmUnLCdmc2NhcmV0JywnUEhZTE9HUicsJ3NlZXdhdmUnLCdwbHMnLCdyZWxhaW1wbycsJ2dlZXBhY2snLCdnZ2dlbmVzJywnTlBDaXJjJywncmVwbWlzJywnUE5EU0lCR0UnLCdsaWRSJywncG9pc21mJywnbmVvbnN0b3JlJywnTWFjaGluZVNob3AnLCdtdnN0JywnTWFjQmVoYXZpb3VyJywnbWNtY2Rlcml2ZScsJ1JHSUZUJywnS25vd0JSJywnbmV0bWV0YScsJ3NwZGVwJywnc2YnLCdSZmFzdCcsJ2NvbXBhcmVHcm91cHMnLCdmZicsJ0dzeW1Qb2ludCcsJ1JjcHBEeW5Qcm9nJywnY29tdHJhZHInLCdSY3BwRHluUHJvZycsJ0ZEJywnUGVhcnNvbkRTJywnRENsdXN0ZXInLCdnUmMnLCdtaXhsbScsJ2dlb3NwdCcsJ2ZkdGgnLCdmZm1hbm92YScsJ2ZpZXJ5JywnZmZzY3JhcHInLCdjb2xkJywnZmllcnknLCdSY21kclBsdWdpbi5Eb0UnLCdSY21kclBsdWdpbi5OTUJVJykK --log-level=info 7 +# crow pipeline create --var ARCH=arm64 --var OS=alpine --var OS_VERSION=3.23 --var R_VERSION=4.5 --var task=build-all-arm64 --var K8S_INSTANCE_TYPE=cax41 --branch=main --log-level=info 5 +# crow pipeline create --var ARCH=arm64 --var OS=redhat --var OS_VERSION=10 --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 + # 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' diff --git a/.crow/build-all-versions-install-deps-amd64.yaml b/.crow/build-all-versions-install-deps-amd64.yaml new file mode 100644 index 0000000..d5729be --- /dev/null +++ b/.crow/build-all-versions-install-deps-amd64.yaml @@ -0,0 +1,57 @@ +when: + - event: manual + evaluate: 'task == "build-all-amd64"' + +skip_clone: true + +labels: + platform: linux/${ARCH} + agent: artemis + +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")); 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'); sprintf('Precomputed %s package versions to build', nrow(pkgs))" + 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-arm64.yaml b/.crow/build-all-versions-install-deps-arm64.yaml new file mode 100644 index 0000000..1242172 --- /dev/null +++ b/.crow/build-all-versions-install-deps-arm64.yaml @@ -0,0 +1,56 @@ +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")); 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'); sprintf('Precomputed %s package versions to build', nrow(pkgs))" + 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.yaml b/.crow/build-all-versions-install-deps.yaml deleted file mode 100644 index c092c7a..0000000 --- a/.crow/build-all-versions-install-deps.yaml +++ /dev/null @@ -1,105 +0,0 @@ -# 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: - # Gates this pipeline. A manual pipeline creation instantiates every file in - # .crow/, and a declared default is applied even when the run never passed - # this variable, so the default must be a value that matches no matrix row. - target_arch: - description: 'Architecture to build, or "none" to run nothing.' - options: - - none - - amd64 - - arm64 - default: none - OS: - description: 'Base OS image name.' - options: - - alpine - - redhat - - ubuntu - default: alpine - OS_VERSION: - description: 'OS image tag. Must match OS (alpine: 3.24; redhat: 8/9/10; ubuntu: jammy/noble).' - options: - - '3.24' - - '8' - - '9' - - '10' - - '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 - SEED_FROM: - # Only for bootstrapping a new slot. Copies the pure-R binaries of these - # slots (same OS family and arch, same primary R minor; see - # local/seed-pure-r.R) before the build list is computed, so build-all only - # compiles what actually needs compiling. Space-separated, first wins. - description: 'Existing slots to copy pure-R binaries from, e.g. "alpine324 alpine323". Empty: no seeding.' - default: '' - -when: - - event: manual - evaluate: 'target_arch == "${ARCH}"' - -skip_clone: true - -labels: - platform: linux/${ARCH} - group: rpkgs-${ARCH} - -matrix: - include: - - ARCH: amd64 - - ARCH: arm64 - -steps: - - name: 'Install deps and bincraft' - image: 'reg.devxy.io/rpkgs/build-env-${OS}:${OS_VERSION}' - pull: true - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - 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_LIBS_USER: /mnt/cache/R-pkgs - # Keep uvr's downloads and extracted-package entries on the persistent - # volume instead of the container-local ~/.uvr default. - UVR_CACHE_DIR: /mnt/cache/uvr/cache - UVR_PACKAGES_DIR: /mnt/cache/uvr/packages - 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/uvr/cache /mnt/cache/uvr/packages /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 . - # Pin the same bincraft version the build steps use, so the precomputed - # snapshot and the per-agent library stay consistent across the pipeline. - - /opt/R/$R_VERSION/bin/Rscript local/install-bincraft.R - - UVR_R_BIN=/opt/R/$R_VERSION/bin/R local/uvr-install.sh RPostgres s3fs data.table future jsonlite purrr - - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' - - if [ -n "${SEED_FROM}" ]; then /opt/R/$R_VERSION/bin/Rscript local/seed-pure-r.R ${SEED_FROM}; fi - - /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 diff --git a/.crow/build-all-versions.yaml b/.crow/build-all-versions.yaml deleted file mode 100644 index ae5cd89..0000000 --- a/.crow/build-all-versions.yaml +++ /dev/null @@ -1,232 +0,0 @@ -### 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 group label (rpkgs-amd64/rpkgs-arm64). -# Skip list lives in local/excluded-packages.json (read by local/build-all.R). -variables: - # Gates this pipeline. A manual pipeline creation instantiates every file in - # .crow/, and a declared default is applied even when the run never passed - # this variable, so the default must be a value that matches no matrix row. - target_arch: - description: 'Architecture to build, or "none" to run nothing.' - options: - - none - - amd64 - - arm64 - default: none - OS: - description: 'Base OS image name.' - options: - - alpine - - redhat - - ubuntu - default: alpine - OS_VERSION: - description: 'OS image tag. Must match OS (alpine: 3.24; redhat: 8/9/10; ubuntu: jammy/noble).' - options: - - '3.23' - - '3.24' - - '8' - - '9' - - '10' - - 'jammy' - - 'noble' - - 'resolute' - default: '3.24' - R_VERSION: - # The slot's *primary* R minor: what `local/build-all.R` builds into the - # generic slot. The loop below already runs `--sensitive-only` for every - # other installed minor, so filling a non-primary minor's gap needs this - # left alone, not changed. - # - # 4.6.0 was briefly offered here (#183) and removed: selecting it for a - # slot whose generic binaries are 4.5-built would publish 4.6 binaries - # into the generic slot and break every 4.5 client. - description: 'Primary R version under /opt/R.' - options: - - 4.5.3 - - 4.4.3 - default: 4.5.3 - -when: - - event: manual - evaluate: 'target_arch == "${ARCH}"' - -skip_clone: true - -labels: - platform: linux/${ARCH} - group: rpkgs-${ARCH} - -# Empty UVR_CACHE_DIR/UVR_PACKAGES_DIR fall back to uvr's container-local -# ~/.uvr defaults; amd64 deliberately does not persist them (as with the -# pkgcache dir it replaces), arm64 does. -matrix: - include: - - ARCH: amd64 - UVR_CACHE_DIR: '' - UVR_PACKAGES_DIR: '' - SPLIT_INTO: 4 - SPLIT_INDEX: 1 - - ARCH: amd64 - UVR_CACHE_DIR: '' - UVR_PACKAGES_DIR: '' - SPLIT_INTO: 4 - SPLIT_INDEX: 2 - - ARCH: amd64 - UVR_CACHE_DIR: '' - UVR_PACKAGES_DIR: '' - SPLIT_INTO: 4 - SPLIT_INDEX: 3 - - ARCH: amd64 - UVR_CACHE_DIR: '' - UVR_PACKAGES_DIR: '' - SPLIT_INTO: 4 - SPLIT_INDEX: 4 - - ARCH: arm64 - UVR_CACHE_DIR: /mnt/cache/uvr/cache - UVR_PACKAGES_DIR: /mnt/cache/uvr/packages - SPLIT_INTO: 4 - SPLIT_INDEX: 1 - - ARCH: arm64 - UVR_CACHE_DIR: /mnt/cache/uvr/cache - UVR_PACKAGES_DIR: /mnt/cache/uvr/packages - SPLIT_INTO: 4 - SPLIT_INDEX: 2 - - ARCH: arm64 - UVR_CACHE_DIR: /mnt/cache/uvr/cache - UVR_PACKAGES_DIR: /mnt/cache/uvr/packages - SPLIT_INTO: 4 - SPLIT_INDEX: 3 - - ARCH: arm64 - UVR_CACHE_DIR: /mnt/cache/uvr/cache - UVR_PACKAGES_DIR: /mnt/cache/uvr/packages - SPLIT_INTO: 4 - SPLIT_INDEX: 4 - -depends_on: - - build-all-versions-install-deps - -steps: - - name: 'Build binaries' - image: 'reg.devxy.io/rpkgs/build-env-${OS}:${OS_VERSION}' - pull: true - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - 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 uvr's caches, which persist the R package - # dependencies needed to install the packages themselves - UVR_CACHE_DIR: ${UVR_CACHE_DIR} - UVR_PACKAGES_DIR: ${UVR_PACKAGES_DIR} - R_LIBS_USER: /mnt/cache/R-pkgs - CCACHE_DIR: /mnt/cache/ccache - NCPUS: 2 - # Whole hours the build passes below may use, measured from the step's - # start. The repo timeout is 50h; the remainder is left for archiving the - # missed packages, so a long run ends cleanly instead of being killed. - BUILD_BUDGET_HOURS: 44 - 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 . - - . local/compiler-cache.sh - # One deadline shared by every build pass in this step, read by - # local/build-all.R and local/build-newer-r.R before each package. - - export BUILD_DEADLINE=$(( $(date +%s) + BUILD_BUDGET_HOURS * 3600 )) - - mkdir -p /mnt/cache/uvr/cache /mnt/cache/uvr/packages /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages - # The primary pass must not rely on build-all-versions-install-deps having - # run on *this* agent: depends_on only orders the steps, but the cache - # volume is per-agent, so a job landing on an agent where install-deps did - # not run would otherwise use a stale bincraft (which resolves `platform` - # to a zero-length value and breaks every metadata query and the sysdeps - # install). Pin bincraft here, exactly like the R-minor pass below. - - rm -rf /mnt/cache/R-pkgs/00LOCK-* - - /opt/R/$R_VERSION/bin/Rscript local/install-bincraft.R - # The dependency-prep job may run on another agent whose cache volume is - # not visible here. Install the packages needed to recompute the snapshot - # and query build metadata in every build job. - - UVR_R_BIN=/opt/R/$R_VERSION/bin/R local/uvr-install.sh RPostgres s3fs data.table future jsonlite purrr - - XVFB=$(command -v xwfb-run 2>/dev/null || command -v xvfb-run); XVFB_ARGS="-a"; 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")/Rscript" local/install-bincraft.R || true - R_LIBS_USER="$LIB" UVR_R_BIN="$RBIN" local/uvr-install.sh RPostgres || 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 - # Also build current packages whose required dependency tree needs a newer R. - R_LIBS_USER="$LIB" $XVFB $XVFB_ARGS -n $SPLIT_INDEX -- "$(dirname "$RBIN")/Rscript" local/build-newer-r.R "$R_VERSION" $SPLIT_INTO $SPLIT_INDEX - done - # archive missed packages; first arg is the codename (e.g. "alpine324"), - # derived via bincraft like the upload step, not paste(OS, OS_VERSION). - - /opt/R/$R_VERSION/bin/R -q -e "bincraft::process_unarchived_pkgs(bincraft::set_codename(NULL), Sys.getenv('ARCH'), 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'), workers = $NCPUS)" - backend_options: - docker: - resources: - requests: - memory: 5Gi - cpu: 1000m - limits: - memory: 20Gi - cpu: 2000m - - name: 'Upload package indexes' - image: 'reg.devxy.io/rpkgs/build-env-${OS}:${OS_VERSION}' - pull: true - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - B2_S3_ACCESS_KEY: - from_secret: B2_S3_ACCESS_KEY - B2_S3_SECRET_KEY: - from_secret: B2_S3_SECRET_KEY - # A per-minor index reads the ABI classifier cache and the flat-object - # safety table from the build database, and is not republished without it. - PGPASS: - from_secret: PGPASS - 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'))" - FAILED_MINORS="" - 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_port = 15432L, metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'verify-full')" || FAILED_MINORS="$FAILED_MINORS $RMINOR" - done - if [ -n "$FAILED_MINORS" ]; then - echo "Could not republish the per-minor index for:$FAILED_MINORS" >&2 - exit 1 - fi - backend_options: - docker: - resources: - requests: - memory: 5Gi - cpu: 1000m - limits: - memory: 20Gi - cpu: 2000m diff --git a/.crow/build-r-minor-sensitive-packages.yaml b/.crow/build-r-minor-sensitive-packages.yaml new file mode 100644 index 0000000..a0c3c2d --- /dev/null +++ b/.crow/build-r-minor-sensitive-packages.yaml @@ -0,0 +1,80 @@ +when: + - event: manual + evaluate: 'build == "r-minor"' +# - event: manual +# evaluate: 'build == "alpine-322-arm64"' +# - event: manual +# evaluate: 'build == "alpine-322-arm64-1"' +# - event: manual +# evaluate: 'build == "all-arm64"' + +# skip_clone: true + +# depends_on: +# - alpine-322-arm64-install-deps + +matrix: + include: + - os: alpine + os_version: 3.21 + r_version: 4.5.3 + - os: alpine + os_version: 3.21 + r_version: 4.4.3 + # - os: alpine + # os_version: 3.21 + # r_version: 4.3 +steps: + - name: 'Build R-minor-sensitive binaries' + image: "docker.io/devxygmbh/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 + NTFY_SERVER: + from_secret: NTFY_SERVER + NTFY_TOPIC: + from_secret: NTFY_TOPIC + NTFY_AUTH: TRUE + NTFY_PASSWORD: + from_secret: ntfy_token + # 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: /tmp/R-libs:/mnt/cache/R-pkgs + CCACHE_DIR: /mnt/cache/ccache + NCPUS: 2 + STRATEGY: sequential + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - mkdir -p /tmp/R-libs + - git clone -q https://codefloe.com/rpkgs/bincraft.git /tmp/bincraft && /opt/R/$R_VERSION/bin/R CMD INSTALL --library=/tmp/R-libs /tmp/bincraft && /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - 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 -- /opt/R/$R_VERSION/bin/R -q -e "options(crayon.enabled = TRUE, Ncpus = $NCPUS, future.globals.onReference = NULL); pak::sysreqs_db_update(); pkgs = bincraft::get_r_minor_sensitive_packages(r_minor_packages_issue_url = 'https://git.devxy.io/api/v1/repos/devxy/build-cran-binaries/issues/29'); foo = lapply(pkgs, function(x) bincraft::build_binary_package(x, is_debug = FALSE, is_r_minor_sensitive = TRUE, force = FALSE, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE))" 2>&1 + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 1000m + limits: + memory: 20Gi + cpu: 2000m + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/download-stats.yaml b/.crow/download-stats.yaml deleted file mode 100644 index 4840ad3..0000000 --- a/.crow/download-stats.yaml +++ /dev/null @@ -1,79 +0,0 @@ -# Collect CDN access logs and publish the public download statistics. -# -# Each run reads the last 70 hours of cran-rpkgs access logs from Bunny into -# `download_stats.events` (build metadata Postgres), then rewrites -# https://cran.rpkgs.com/stats/downloads.json, which the rpkgs.com /stats page -# reads. Bunny keeps logs for only three days, so a run every hour leaves room -# for two days of failed runs before anything is lost. Re-reading the window is -# safe: events are keyed by Bunny's request id. -# -# The classification rules and what is excluded are documented in -# `stats/README.md`. -# -# Register the `download-stats` cron (hourly, `0 * * * *`) in the crow UI, or -# run manually: -# crow pipeline create --branch main --var download_stats=true devxy/build-cran-binaries -# -# Secrets: -# STATS_CLIENT_SALT HMAC key for the client hash. Rotating it resets -# distinct-client counts, so keep it stable. -# STATS_OWN_NETWORKS Comma-separated CIDRs of our own CI runners. -# Both live in OpenBao at development/agent-dev/rpkgs-download-stats. -variables: - download_stats: - description: 'Collect and publish download statistics. Also gates this pipeline.' - options: - - 'true' - - 'false' - default: 'false' - -when: - - event: manual - evaluate: 'download_stats == "true"' - - event: cron - cron: download-stats - -skip_clone: true - -labels: - group: rpkgs-amd64 - -steps: - - name: 'Collect and publish download stats' - image: oven/bun:1.4.5-alpine - pull: true - environment: - BUNNYNET_API_KEY: - from_secret: BUNNYNET_API_KEY - PGPASS: - from_secret: PGPASS - B2_S3_ACCESS_KEY: - from_secret: B2_S3_ACCESS_KEY - B2_S3_SECRET_KEY: - from_secret: B2_S3_SECRET_KEY - STATS_CLIENT_SALT: - from_secret: STATS_CLIENT_SALT - STATS_OWN_NETWORKS: - from_secret: STATS_OWN_NETWORKS - REPO_RO_TOKEN: - from_secret: REPO_RO_TOKEN - commands: - - apk add --no-cache -q git - - git clone -q --depth 1 --branch "$CI_COMMIT_BRANCH" https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - bun test stats - - bun stats/collect.ts - - bun stats/publish.ts - backend_options: - kubernetes: - resources: - requests: - memory: 256Mi - cpu: 250m - limits: - memory: 1Gi - cpu: 1000m - tolerations: - - key: 'CI' - operator: 'Equal' - value: 'true' - effect: 'NoSchedule' diff --git a/.crow/process-updates-alpine-322-amd64.yaml b/.crow/process-updates-alpine-322-amd64.yaml new file mode 100644 index 0000000..ef51448 --- /dev/null +++ b/.crow/process-updates-alpine-322-amd64.yaml @@ -0,0 +1,91 @@ +when: + - event: [cron] + cron: process-cran-updates-alpine-322-amd64 + - event: manual + evaluate: 'process_cran_updates == "all"' + - event: manual + evaluate: 'process_cran_updates == "alpine-322-amd64"' + +skip_clone: true + +labels: + agent: artemis + +steps: + - name: 'Processing Updates' + image: reg.devxy.io/rpkgs/build-env-alpine:3.22 + 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 + NTFY_SERVER: + from_secret: NTFY_SERVER + NTFY_TOPIC: + from_secret: NTFY_TOPIC + NTFY_AUTH: TRUE + NTFY_PASSWORD: + from_secret: ntfy_token + # 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 + R_VERSION: 4.5.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: alpine-322 + ARCH: amd64 + NCPUS: 2 + STRATEGY: sequential + INTERVAL: lubridate::interval(lubridate::today() - 6, lubridate::today() - 3) + # volumes: + # - amd64-binaries-r-dep-cache-alpine-322:/mnt/cache + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - rm -rf /mnt/cache/R-pkgs/00LOCK-r-pkg-binaries /mnt/cache/R-pkgs/00LOCK-bincraft /mnt/cache/R-pkgs/00LOCK-pak /mnt/cache/pkgcache/R/pkgcache /mnt/cache/pkgcache/R/pkgcache /mnt/cache/R-pkgs/pkgcache /mnt/cache/R-pkgs/00LOCK-pak/mnt/cache/R-pkgs/00LOCK-RPostgres /mnt/cache/R-pkgs/bincraft + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages + # options(future.globals.onReference = NULL): for some reason s3fs::file_delete() throws 'Error: Detected a non-exportable reference ('externalptr') in one of the globals ('FUN' of class 'function') used in the future expression' otherwise + - xvfb-run /opt/R/$R_VERSION/bin/R -q -e "options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = 'error', repos = structure(c(getOption('repos'),INLA='https://inla.r-inla-download.org/R/stable'))); progressr::handlers('cli'); progressr::handlers(global = TRUE); options(future.globals.onReference = NULL); bincraft::process_cran_updates(interval = $INTERVAL, platform = 'alpine-322', process_updated = TRUE, process_new = FALSE, process_removed = TRUE, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)" + - /opt/R/$R_VERSION/bin/R -q -e 'library(bincraft); upload_package_index(codename = "alpine322", 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"))' + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: amd64 + node.kubernetes.io/instance-type: AX42 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' + + - name: Purge CDN cache + image: reg.devxy.io/docker.io/library/alpine:3.23 + environment: + BUNNYNET_API_KEY: + from_secret: BUNNYNET_API_KEY + SUBDOMAIN1: 'cran.devxy.io' + SUBDOMAIN2: 'cran.allianceswisspass.devxy.io' + SUBDOMAIN3: 'cran.rpkgs.com' + OS_ID: alpine322 + ARCH: amd64 + commands: + - apk add --no-cache -q bash curl + - bash scripts/purge_cdn_cache.sh "$BUNNYNET_API_KEY" "$ARCH" "$OS_ID" "$SUBDOMAIN1" "$SUBDOMAIN2" "$SUBDOMAIN3" diff --git a/.crow/process-updates-alpine-322-arm64.yaml b/.crow/process-updates-alpine-322-arm64.yaml new file mode 100644 index 0000000..d7f3664 --- /dev/null +++ b/.crow/process-updates-alpine-322-arm64.yaml @@ -0,0 +1,73 @@ +when: + - event: [cron] + cron: process-cran-updates-alpine-322-arm64 + - event: manual + evaluate: 'process_cran_updates == "all"' + - event: manual + evaluate: 'process_cran_updates == "alpine-322-arm64"' + +skip_clone: true + +labels: + agent: gaia + +steps: + - name: 'Processing Updates' + image: reg.devxy.io/rpkgs/build-env-alpine:3.22 + 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 + NTFY_SERVER: + from_secret: NTFY_SERVER + NTFY_TOPIC: + from_secret: NTFY_TOPIC + NTFY_AUTH: TRUE + NTFY_PASSWORD: + from_secret: ntfy_token + # 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 + R_VERSION: 4.5.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: alpine-322 + ARCH: arm64 + NCPUS: 2 + INTERVAL: lubridate::interval(lubridate::today() - 6, lubridate::today() - 3) + # volumes: + # - arm64-binaries-r-dep-cache-alpine-321:/mnt/cache + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - rm -rf /mnt/cache/R-pkgs/00LOCK-r-pkg-binaries /mnt/cache/R-pkgs/00LOCK-bincraft /mnt/cache/R-pkgs/00LOCK-pak /mnt/cache/pkgcache/R/pkgcache /mnt/cache/pkgcache/R/pkgcache /mnt/cache/R-pkgs/pkgcache /mnt/cache/R-pkgs/00LOCK-pak/mnt/cache/R-pkgs/00LOCK-RPostgres /mnt/cache/R-pkgs/bincraft + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages + # options(future.globals.onReference = NULL): for some reason s3fs::file_delete() throws 'Error: Detected a non-exportable reference ('externalptr') in one of the globals ('FUN' of class 'function') used in the future expression' otherwise + - xvfb-run /opt/R/$R_VERSION/bin/R -q -e "options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = 'error', repos = structure(c(getOption('repos'),INLA='https://inla.r-inla-download.org/R/stable'))); progressr::handlers('cli'); progressr::handlers(global = TRUE); options(future.globals.onReference = NULL); bincraft::process_cran_updates(interval = $INTERVAL, platform = 'alpine-322', process_updated = TRUE, process_new = TRUE, process_removed = TRUE, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)" + - /opt/R/$R_VERSION/bin/R -q -e 'library(bincraft); upload_package_index(codename = "alpine322", 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"))' + + - name: Purge CDN cache + image: reg.devxy.io/docker.io/library/alpine:3.23 + environment: + BUNNYNET_API_KEY: + from_secret: BUNNYNET_API_KEY + SUBDOMAIN1: 'cran.devxy.io' + SUBDOMAIN2: 'cran.allianceswisspass.devxy.io' + SUBDOMAIN3: 'cran.rpkgs.com' + OS_ID: alpine322 + ARCH: arm64 + commands: + - apk add --no-cache -q bash curl + - bash scripts/purge_cdn_cache.sh "$BUNNYNET_API_KEY" "$ARCH" "$OS_ID" "$SUBDOMAIN1" "$SUBDOMAIN2" "$SUBDOMAIN3" diff --git a/.crow/process-updates-alpine-323-amd64.yaml b/.crow/process-updates-alpine-323-amd64.yaml new file mode 100644 index 0000000..2bf897b --- /dev/null +++ b/.crow/process-updates-alpine-323-amd64.yaml @@ -0,0 +1,91 @@ +when: + - event: [cron] + cron: process-cran-updates-alpine-323-amd64 + - event: manual + evaluate: 'process_cran_updates == "all"' + - event: manual + evaluate: 'process_cran_updates == "alpine-323-amd64"' + +skip_clone: true + +labels: + agent: artemis + +steps: + - name: 'Processing Updates' + image: reg.devxy.io/rpkgs/build-env-alpine:3.23 + 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 + NTFY_SERVER: + from_secret: NTFY_SERVER + NTFY_TOPIC: + from_secret: NTFY_TOPIC + NTFY_AUTH: TRUE + NTFY_PASSWORD: + from_secret: ntfy_token + # 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 + R_VERSION: 4.5.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: alpine-323 + ARCH: amd64 + NCPUS: 2 + STRATEGY: sequential + INTERVAL: lubridate::interval(lubridate::today() - 6, lubridate::today() - 3) + # volumes: + # - amd64-binaries-r-dep-cache-alpine-323:/mnt/cache + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - rm -rf /mnt/cache/R-pkgs/00LOCK-r-pkg-binaries /mnt/cache/R-pkgs/00LOCK-bincraft /mnt/cache/R-pkgs/00LOCK-pak /mnt/cache/pkgcache/R/pkgcache /mnt/cache/pkgcache/R/pkgcache /mnt/cache/R-pkgs/pkgcache /mnt/cache/R-pkgs/00LOCK-pak/mnt/cache/R-pkgs/00LOCK-RPostgres /mnt/cache/R-pkgs/bincraft + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages + # options(future.globals.onReference = NULL): for some reason s3fs::file_delete() throws 'Error: Detected a non-exportable reference ('externalptr') in one of the globals ('FUN' of class 'function') used in the future expression' otherwise + - xvfb-run /opt/R/$R_VERSION/bin/R -q -e "options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = 'error', repos = structure(c(getOption('repos'),INLA='https://inla.r-inla-download.org/R/stable'))); progressr::handlers('cli'); progressr::handlers(global = TRUE); options(future.globals.onReference = NULL); bincraft::process_cran_updates(interval = $INTERVAL, platform = 'alpine-323', process_updated = TRUE, process_new = FALSE, process_removed = TRUE, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)" + - /opt/R/$R_VERSION/bin/R -q -e 'library(bincraft); upload_package_index(codename = "alpine323", 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"))' + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: amd64 + node.kubernetes.io/instance-type: AX42 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' + + - name: Purge CDN cache + image: reg.devxy.io/docker.io/library/alpine:3.23 + environment: + BUNNYNET_API_KEY: + from_secret: BUNNYNET_API_KEY + SUBDOMAIN1: 'cran.devxy.io' + SUBDOMAIN2: 'cran.allianceswisspass.devxy.io' + SUBDOMAIN3: 'cran.rpkgs.com' + OS_ID: alpine323 + ARCH: amd64 + commands: + - apk add --no-cache -q bash curl + - bash scripts/purge_cdn_cache.sh "$BUNNYNET_API_KEY" "$ARCH" "$OS_ID" "$SUBDOMAIN1" "$SUBDOMAIN2" "$SUBDOMAIN3" diff --git a/.crow/process-updates-alpine-323-arm64.yaml b/.crow/process-updates-alpine-323-arm64.yaml new file mode 100644 index 0000000..1d18c9c --- /dev/null +++ b/.crow/process-updates-alpine-323-arm64.yaml @@ -0,0 +1,73 @@ +when: + - event: [cron] + cron: process-cran-updates-alpine-323-arm64 + - event: manual + evaluate: 'process_cran_updates == "all"' + - event: manual + evaluate: 'process_cran_updates == "alpine-323-arm64"' + +skip_clone: true + +labels: + agent: gaia + +steps: + - name: 'Processing Updates' + image: reg.devxy.io/rpkgs/build-env-alpine:3.23 + 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 + NTFY_SERVER: + from_secret: NTFY_SERVER + NTFY_TOPIC: + from_secret: NTFY_TOPIC + NTFY_AUTH: TRUE + NTFY_PASSWORD: + from_secret: ntfy_token + # 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 + R_VERSION: 4.5.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: alpine-323 + ARCH: arm64 + NCPUS: 2 + INTERVAL: lubridate::interval(lubridate::today() - 6, lubridate::today() - 3) + # volumes: + # - arm64-binaries-r-dep-cache-alpine-321:/mnt/cache + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - rm -rf /mnt/cache/R-pkgs/00LOCK-r-pkg-binaries /mnt/cache/R-pkgs/00LOCK-bincraft /mnt/cache/R-pkgs/00LOCK-pak /mnt/cache/pkgcache/R/pkgcache /mnt/cache/pkgcache/R/pkgcache /mnt/cache/R-pkgs/pkgcache /mnt/cache/R-pkgs/00LOCK-pak/mnt/cache/R-pkgs/00LOCK-RPostgres /mnt/cache/R-pkgs/bincraft + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages + # options(future.globals.onReference = NULL): for some reason s3fs::file_delete() throws 'Error: Detected a non-exportable reference ('externalptr') in one of the globals ('FUN' of class 'function') used in the future expression' otherwise + - xvfb-run /opt/R/$R_VERSION/bin/R -q -e "options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = 'error', repos = structure(c(getOption('repos'),INLA='https://inla.r-inla-download.org/R/stable'))); progressr::handlers('cli'); progressr::handlers(global = TRUE); options(future.globals.onReference = NULL); bincraft::process_cran_updates(interval = $INTERVAL, platform = 'alpine-323', process_updated = TRUE, process_new = TRUE, process_removed = TRUE, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)" + - /opt/R/$R_VERSION/bin/R -q -e 'library(bincraft); upload_package_index(codename = "alpine323", 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"))' + + - name: Purge CDN cache + image: reg.devxy.io/docker.io/library/alpine:3.23 + environment: + BUNNYNET_API_KEY: + from_secret: BUNNYNET_API_KEY + SUBDOMAIN1: 'cran.devxy.io' + SUBDOMAIN2: 'cran.allianceswisspass.devxy.io' + SUBDOMAIN3: 'cran.rpkgs.com' + OS_ID: alpine323 + ARCH: arm64 + commands: + - apk add --no-cache -q bash curl + - bash scripts/purge_cdn_cache.sh "$BUNNYNET_API_KEY" "$ARCH" "$OS_ID" "$SUBDOMAIN1" "$SUBDOMAIN2" "$SUBDOMAIN3" diff --git a/.crow/process-updates-redhat-10-amd64.yaml b/.crow/process-updates-redhat-10-amd64.yaml new file mode 100644 index 0000000..6fcd6ab --- /dev/null +++ b/.crow/process-updates-redhat-10-amd64.yaml @@ -0,0 +1,93 @@ +when: + - event: [cron] + cron: process-cran-updates-redhat-10-amd64 + - event: manual + evaluate: 'process_cran_updates == "all"' + - event: manual + evaluate: 'process_cran_updates == "redhat-10-amd64"' + +skip_clone: true + +labels: + agent: artemis + +steps: + - name: 'Processing Updates' + image: reg.devxy.io/rpkgs/build-env-redhat:10 + 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 + NTFY_SERVER: + from_secret: NTFY_SERVER + NTFY_TOPIC: + from_secret: NTFY_TOPIC + NTFY_AUTH: TRUE + NTFY_PASSWORD: + from_secret: ntfy_token + # 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 + R_VERSION: 4.5.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: redhat-10 + ARCH: amd64 + NCPUS: 2 + MEMORY: 18Gi + STRATEGY: sequential + INTERVAL: lubridate::interval(lubridate::today() - 6, lubridate::today() - 3) + # volumes: + # - amd64-binaries-r-dep-cache-redhat-10:/mnt/cache + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - rm -rf /mnt/cache/R-pkgs/00LOCK-r-pkg-binaries /mnt/cache/R-pkgs/00LOCK-bincraft /mnt/cache/R-pkgs/00LOCK-pak /mnt/cache/pkgcache/R/pkgcache /mnt/cache/pkgcache/R/pkgcache /mnt/cache/R-pkgs/pkgcache /mnt/cache/R-pkgs/00LOCK-pak/mnt/cache/R-pkgs/00LOCK-RPostgres /mnt/cache/R-pkgs/bincraft + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages + # options(future.globals.onReference = NULL): for some reason s3fs::file_delete() throws 'Error: Detected a non-exportable reference ('externalptr') in one of the globals ('FUN' of class 'function') used in the future expression' otherwise + - 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 -- /opt/R/$R_VERSION/bin/R -q -e "options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = 'error', repos = structure(c(getOption('repos'),INLA='https://inla.r-inla-download.org/R/stable'))); progressr::handlers('cli'); progressr::handlers(global = TRUE); options(future.globals.onReference = NULL); bincraft::process_cran_updates(interval = $INTERVAL, platform = 'redhat-10', process_updated = TRUE, process_new = TRUE, process_removed = TRUE, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)" + - /opt/R/$R_VERSION/bin/R -q -e 'library(bincraft); upload_package_index(codename = "rhel10", 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"))' + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: amd64 + node.kubernetes.io/instance-type: AX42 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' + + - name: Purge CDN cache + image: reg.devxy.io/docker.io/library/alpine:3.23 + environment: + BUNNYNET_API_KEY: + from_secret: BUNNYNET_API_KEY + SUBDOMAIN1: 'cran.devxy.io' + SUBDOMAIN2: 'cran.allianceswisspass.devxy.io' + SUBDOMAIN3: 'cran.rpkgs.com' + OS_ID: rhel10 + ARCH: amd64 + commands: + - apk add --no-cache -q bash curl + - bash scripts/purge_cdn_cache.sh "$BUNNYNET_API_KEY" "$ARCH" "$OS_ID" "$SUBDOMAIN1" "$SUBDOMAIN2" "$SUBDOMAIN3" diff --git a/.crow/process-updates-redhat-10-arm64.yaml b/.crow/process-updates-redhat-10-arm64.yaml new file mode 100644 index 0000000..8594fd3 --- /dev/null +++ b/.crow/process-updates-redhat-10-arm64.yaml @@ -0,0 +1,74 @@ +when: + - event: [cron] + cron: process-cran-updates-redhat-10-arm64 + - event: manual + evaluate: 'process_cran_updates == "all"' + - event: manual + evaluate: 'process_cran_updates == "redhat-10-arm64"' + +skip_clone: true + +labels: + agent: gaia + +steps: + - name: 'Processing Updates' + image: reg.devxy.io/rpkgs/build-env-redhat:10 + 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 + NTFY_SERVER: + from_secret: NTFY_SERVER + NTFY_TOPIC: + from_secret: NTFY_TOPIC + NTFY_AUTH: TRUE + NTFY_PASSWORD: + from_secret: ntfy_token + # 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 + R_VERSION: 4.5.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: redhat-10 + ARCH: arm64 + NCPUS: 2 + INTERVAL: lubridate::interval(lubridate::today() - 6, lubridate::today() - 3) + # volumes: + # - arm64-binaries-r-dep-cache-redhat-10:/mnt/cache + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - rm -rf /mnt/cache/R-pkgs/00LOCK-r-pkg-binaries /mnt/cache/R-pkgs/00LOCK-bincraft /mnt/cache/R-pkgs/00LOCK-pak /mnt/cache/pkgcache/R/pkgcache /mnt/cache/pkgcache/R/pkgcache /mnt/cache/R-pkgs/pkgcache /mnt/cache/R-pkgs/00LOCK-pak/mnt/cache/R-pkgs/00LOCK-RPostgres /mnt/cache/R-pkgs/bincraft + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages + # options(future.globals.onReference = NULL): for some reason s3fs::file_delete() throws 'Error: Detected a non-exportable reference ('externalptr') in one of the globals ('FUN' of class 'function') used in the future expression' otherwise + - 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 -- /opt/R/$R_VERSION/bin/R -q -e "options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = 'error', repos = structure(c(getOption('repos'),INLA='https://inla.r-inla-download.org/R/stable'))); progressr::handlers('cli'); progressr::handlers(global = TRUE); options(future.globals.onReference = NULL); bincraft::process_cran_updates(interval = $INTERVAL, platform = 'redhat-10', process_updated = TRUE, process_new = TRUE, process_removed = TRUE, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)" + - /opt/R/$R_VERSION/bin/R -q -e 'library(bincraft); upload_package_index(codename = "rhel10", 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"))' + + - name: Purge CDN cache + image: reg.devxy.io/docker.io/library/alpine:3.23 + environment: + BUNNYNET_API_KEY: + from_secret: BUNNYNET_API_KEY + SUBDOMAIN1: 'cran.devxy.io' + SUBDOMAIN2: 'cran.allianceswisspass.devxy.io' + SUBDOMAIN3: 'cran.rpkgs.com' + OS_ID: rhel10 + ARCH: arm64 + commands: + - apk add --no-cache -q bash curl + - bash scripts/purge_cdn_cache.sh "$BUNNYNET_API_KEY" "$ARCH" "$OS_ID" "$SUBDOMAIN1" "$SUBDOMAIN2" "$SUBDOMAIN3" diff --git a/.crow/process-updates-redhat-8-amd64.yaml b/.crow/process-updates-redhat-8-amd64.yaml new file mode 100644 index 0000000..446c8c4 --- /dev/null +++ b/.crow/process-updates-redhat-8-amd64.yaml @@ -0,0 +1,91 @@ +when: + - event: [cron] + cron: process-cran-updates-redhat-8-amd64 + - event: manual + evaluate: 'process_cran_updates == "all"' + - event: manual + evaluate: 'process_cran_updates == "redhat-8-amd64"' + +skip_clone: true + +labels: + agent: artemis + +steps: + - name: 'Processing Updates' + image: reg.devxy.io/rpkgs/build-env-redhat:8 + 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 + NTFY_SERVER: + from_secret: NTFY_SERVER + NTFY_TOPIC: + from_secret: NTFY_TOPIC + NTFY_AUTH: TRUE + NTFY_PASSWORD: + from_secret: ntfy_token + # 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 + R_VERSION: 4.4.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: redhat-8 + ARCH: amd64 + NCPUS: 2 + STRATEGY: sequential + INTERVAL: lubridate::interval(lubridate::today() - 6, lubridate::today() - 3) + # volumes: + # - amd64-binaries-r-dep-cache-redhat-8:/mnt/cache + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - rm -rf /mnt/cache/R-pkgs/00LOCK-r-pkg-binaries /mnt/cache/R-pkgs/00LOCK-bincraft /mnt/cache/R-pkgs/00LOCK-pak /mnt/cache/pkgcache/R/pkgcache /mnt/cache/pkgcache/R/pkgcache /mnt/cache/R-pkgs/pkgcache /mnt/cache/R-pkgs/00LOCK-pak/mnt/cache/R-pkgs/00LOCK-RPostgres /mnt/cache/R-pkgs/bincraft + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages + # options(future.globals.onReference = NULL): for some reason s3fs::file_delete() throws 'Error: Detected a non-exportable reference ('externalptr') in one of the globals ('FUN' of class 'function') used in the future expression' otherwise + - xvfb-run /opt/R/$R_VERSION/bin/R -q -e "options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = 'error', repos = structure(c(getOption('repos'),INLA='https://inla.r-inla-download.org/R/stable'))); progressr::handlers('cli'); progressr::handlers(global = TRUE); options(future.globals.onReference = NULL); bincraft::process_cran_updates(interval = $INTERVAL, platform = 'redhat-8', process_updated = TRUE, process_new = TRUE, process_removed = TRUE, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)" + - /opt/R/$R_VERSION/bin/R -q -e 'library(bincraft); upload_package_index(codename = "rhel8", 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"))' + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: amd64 + node.kubernetes.io/instance-type: AX42 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' + + - name: Purge CDN cache + image: reg.devxy.io/docker.io/library/alpine:3.23 + environment: + BUNNYNET_API_KEY: + from_secret: BUNNYNET_API_KEY + SUBDOMAIN1: 'cran.devxy.io' + SUBDOMAIN2: 'cran.allianceswisspass.devxy.io' + SUBDOMAIN3: 'cran.rpkgs.com' + OS_ID: rhel8 + ARCH: amd64 + commands: + - apk add --no-cache -q bash curl + - bash scripts/purge_cdn_cache.sh "$BUNNYNET_API_KEY" "$ARCH" "$OS_ID" "$SUBDOMAIN1" "$SUBDOMAIN2" "$SUBDOMAIN3" diff --git a/.crow/process-updates-redhat-8-arm64.yaml b/.crow/process-updates-redhat-8-arm64.yaml new file mode 100644 index 0000000..248693b --- /dev/null +++ b/.crow/process-updates-redhat-8-arm64.yaml @@ -0,0 +1,73 @@ +when: + - event: [cron] + cron: process-cran-updates-redhat-8-arm64 + - event: manual + evaluate: 'process_cran_updates == "all"' + - event: manual + evaluate: 'process_cran_updates == "redhat-8-arm64"' + +skip_clone: true + +labels: + agent: gaia + +steps: + - name: 'Processing Updates' + image: reg.devxy.io/rpkgs/build-env-redhat:8 + 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 + NTFY_SERVER: + from_secret: NTFY_SERVER + NTFY_TOPIC: + from_secret: NTFY_TOPIC + NTFY_AUTH: TRUE + NTFY_PASSWORD: + from_secret: ntfy_token + # 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 + R_VERSION: 4.4.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: redhat-8 + ARCH: arm64 + NCPUS: 2 + INTERVAL: lubridate::interval(lubridate::today() - 6, lubridate::today() - 3) + # volumes: + # - arm64-binaries-r-dep-cache-redhat-8:/mnt/cache + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - rm -rf /mnt/cache/R-pkgs/00LOCK-r-pkg-binaries /mnt/cache/R-pkgs/00LOCK-bincraft /mnt/cache/R-pkgs/00LOCK-pak /mnt/cache/pkgcache/R/pkgcache /mnt/cache/pkgcache/R/pkgcache /mnt/cache/R-pkgs/pkgcache /mnt/cache/R-pkgs/00LOCK-pak/mnt/cache/R-pkgs/00LOCK-RPostgres /mnt/cache/R-pkgs/bincraft + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages + # options(future.globals.onReference = NULL): for some reason s3fs::file_delete() throws 'Error: Detected a non-exportable reference ('externalptr') in one of the globals ('FUN' of class 'function') used in the future expression' otherwise + - xvfb-run /opt/R/$R_VERSION/bin/R -q -e "options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = 'error', repos = structure(c(getOption('repos'),INLA='https://inla.r-inla-download.org/R/stable'))); progressr::handlers('cli'); progressr::handlers(global = TRUE); options(future.globals.onReference = NULL); bincraft::process_cran_updates(interval = $INTERVAL, platform = 'redhat-8', process_updated = TRUE, process_new = TRUE, process_removed = TRUE, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)" + - /opt/R/$R_VERSION/bin/R -q -e 'library(bincraft); upload_package_index(codename = "rhel8", 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"))' + + - name: Purge CDN cache + image: reg.devxy.io/docker.io/library/alpine:3.23 + environment: + BUNNYNET_API_KEY: + from_secret: BUNNYNET_API_KEY + SUBDOMAIN1: 'cran.devxy.io' + SUBDOMAIN2: 'cran.allianceswisspass.devxy.io' + SUBDOMAIN3: 'cran.rpkgs.com' + OS_ID: rhel8 + ARCH: arm64 + commands: + - apk add --no-cache -q bash curl + - bash scripts/purge_cdn_cache.sh "$BUNNYNET_API_KEY" "$ARCH" "$OS_ID" "$SUBDOMAIN1" "$SUBDOMAIN2" "$SUBDOMAIN3" diff --git a/.crow/process-updates-redhat-9-amd64.yaml b/.crow/process-updates-redhat-9-amd64.yaml new file mode 100644 index 0000000..045a370 --- /dev/null +++ b/.crow/process-updates-redhat-9-amd64.yaml @@ -0,0 +1,92 @@ +when: + - event: [cron] + cron: process-cran-updates-redhat-9-amd64 + - event: manual + evaluate: 'process_cran_updates == "all"' + - event: manual + evaluate: 'process_cran_updates == "redhat-9-amd64"' + +skip_clone: true + +labels: + agent: artemis + +steps: + - name: 'Processing Updates' + image: reg.devxy.io/rpkgs/build-env-redhat:9 + 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 + NTFY_SERVER: + from_secret: NTFY_SERVER + NTFY_TOPIC: + from_secret: NTFY_TOPIC + NTFY_AUTH: TRUE + NTFY_PASSWORD: + from_secret: ntfy_token + # 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 + R_VERSION: 4.4.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: redhat-9 + ARCH: amd64 + NCPUS: 2 + MEMORY: 18Gi + STRATEGY: sequential + INTERVAL: lubridate::interval(lubridate::today() - 6, lubridate::today() - 3) + # volumes: + # - amd64-binaries-r-dep-cache-redhat-9:/mnt/cache + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - rm -rf /mnt/cache/R-pkgs/00LOCK-r-pkg-binaries /mnt/cache/R-pkgs/00LOCK-bincraft /mnt/cache/R-pkgs/00LOCK-pak /mnt/cache/pkgcache/R/pkgcache /mnt/cache/pkgcache/R/pkgcache /mnt/cache/R-pkgs/pkgcache /mnt/cache/R-pkgs/00LOCK-pak/mnt/cache/R-pkgs/00LOCK-RPostgres /mnt/cache/R-pkgs/bincraft + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages + # options(future.globals.onReference = NULL): for some reason s3fs::file_delete() throws 'Error: Detected a non-exportable reference ('externalptr') in one of the globals ('FUN' of class 'function') used in the future expression' otherwise + - xvfb-run /opt/R/$R_VERSION/bin/R -q -e "options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = 'error', repos = structure(c(getOption('repos'),INLA='https://inla.r-inla-download.org/R/stable'))); progressr::handlers('cli'); progressr::handlers(global = TRUE); options(future.globals.onReference = NULL); bincraft::process_cran_updates(interval = $INTERVAL, platform = 'redhat-9', process_updated = TRUE, process_new = TRUE, process_removed = TRUE, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)" + - /opt/R/$R_VERSION/bin/R -q -e 'library(bincraft); upload_package_index(codename = "rhel9", 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"))' + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: amd64 + node.kubernetes.io/instance-type: AX42 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' + + - name: Purge CDN cache + image: reg.devxy.io/docker.io/library/alpine:3.23 + environment: + BUNNYNET_API_KEY: + from_secret: BUNNYNET_API_KEY + SUBDOMAIN1: 'cran.devxy.io' + SUBDOMAIN2: 'cran.allianceswisspass.devxy.io' + SUBDOMAIN3: 'cran.rpkgs.com' + OS_ID: rhel9 + ARCH: amd64 + commands: + - apk add --no-cache -q bash curl + - bash scripts/purge_cdn_cache.sh "$BUNNYNET_API_KEY" "$ARCH" "$OS_ID" "$SUBDOMAIN1" "$SUBDOMAIN2" "$SUBDOMAIN3" diff --git a/.crow/process-updates-redhat-9-arm64.yaml b/.crow/process-updates-redhat-9-arm64.yaml new file mode 100644 index 0000000..1d1e04f --- /dev/null +++ b/.crow/process-updates-redhat-9-arm64.yaml @@ -0,0 +1,73 @@ +when: + - event: [cron] + cron: process-cran-updates-redhat-9-arm64 + - event: manual + evaluate: 'process_cran_updates == "all"' + - event: manual + evaluate: 'process_cran_updates == "redhat-9-arm64"' + +skip_clone: true + +labels: + agent: gaia + +steps: + - name: 'Processing Updates' + image: reg.devxy.io/rpkgs/build-env-redhat:9 + 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 + NTFY_SERVER: + from_secret: NTFY_SERVER + NTFY_TOPIC: + from_secret: NTFY_TOPIC + NTFY_AUTH: TRUE + NTFY_PASSWORD: + from_secret: ntfy_token + # 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 + R_VERSION: 4.4.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: redhat-9 + ARCH: arm64 + NCPUS: 2 + INTERVAL: lubridate::interval(lubridate::today() - 6, lubridate::today() - 3) + # volumes: + # - arm64-binaries-r-dep-cache-redhat-9:/mnt/cache + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - rm -rf /mnt/cache/R-pkgs/00LOCK-r-pkg-binaries /mnt/cache/R-pkgs/00LOCK-bincraft /mnt/cache/R-pkgs/00LOCK-pak /mnt/cache/pkgcache/R/pkgcache /mnt/cache/pkgcache/R/pkgcache /mnt/cache/R-pkgs/pkgcache /mnt/cache/R-pkgs/00LOCK-pak/mnt/cache/R-pkgs/00LOCK-RPostgres /mnt/cache/R-pkgs/bincraft + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages + # options(future.globals.onReference = NULL): for some reason s3fs::file_delete() throws 'Error: Detected a non-exportable reference ('externalptr') in one of the globals ('FUN' of class 'function') used in the future expression' otherwise + - xvfb-run /opt/R/$R_VERSION/bin/R -q -e "options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = 'error', repos = structure(c(getOption('repos'),INLA='https://inla.r-inla-download.org/R/stable'))); progressr::handlers('cli'); progressr::handlers(global = TRUE); options(future.globals.onReference = NULL); bincraft::process_cran_updates(interval = $INTERVAL, platform = 'redhat-9', process_updated = TRUE, process_new = TRUE, process_removed = TRUE, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)" + - /opt/R/$R_VERSION/bin/R -q -e 'library(bincraft); upload_package_index(codename = "rhel9", 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"))' + + - name: Purge CDN cache + image: reg.devxy.io/docker.io/library/alpine:3.23 + environment: + BUNNYNET_API_KEY: + from_secret: BUNNYNET_API_KEY + SUBDOMAIN1: 'cran.devxy.io' + SUBDOMAIN2: 'cran.allianceswisspass.devxy.io' + SUBDOMAIN3: 'cran.rpkgs.com' + OS_ID: rhel9 + ARCH: arm64 + commands: + - apk add --no-cache -q bash curl + - bash scripts/purge_cdn_cache.sh "$BUNNYNET_API_KEY" "$ARCH" "$OS_ID" "$SUBDOMAIN1" "$SUBDOMAIN2" "$SUBDOMAIN3" diff --git a/.crow/process-updates-ubuntu-2204-amd64.yaml b/.crow/process-updates-ubuntu-2204-amd64.yaml new file mode 100644 index 0000000..be7da88 --- /dev/null +++ b/.crow/process-updates-ubuntu-2204-amd64.yaml @@ -0,0 +1,92 @@ +when: + - event: [cron] + cron: process-cran-updates-ubuntu-2204-amd64 + - event: manual + evaluate: 'process_cran_updates == "all"' + - event: manual + evaluate: 'process_cran_updates == "ubuntu-2204-amd64"' + +skip_clone: true + +labels: + agent: artemis + +steps: + - name: 'Processing Updates' + image: reg.devxy.io/rpkgs/build-env-ubuntu:jammy + 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 + NTFY_SERVER: + from_secret: NTFY_SERVER + NTFY_TOPIC: + from_secret: NTFY_TOPIC + NTFY_AUTH: TRUE + NTFY_PASSWORD: + from_secret: ntfy_token + # 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 + R_VERSION: 4.4.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: ubuntu-2204 + ARCH: amd64 + NCPUS: 2 + MEMORY: 18Gi + STRATEGY: sequential + INTERVAL: lubridate::interval(lubridate::today() - 6, lubridate::today() - 3) + # volumes: + # - amd64-binaries-r-dep-cache-ubuntu-2204:/mnt/cache + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - rm -rf /mnt/cache/R-pkgs/00LOCK-r-pkg-binaries /mnt/cache/R-pkgs/00LOCK-bincraft /mnt/cache/R-pkgs/00LOCK-pak /mnt/cache/pkgcache/R/pkgcache /mnt/cache/pkgcache/R/pkgcache /mnt/cache/R-pkgs/pkgcache /mnt/cache/R-pkgs/00LOCK-pak/mnt/cache/R-pkgs/00LOCK-RPostgres /mnt/cache/R-pkgs/bincraft + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages + # options(future.globals.onReference = NULL): for some reason s3fs::file_delete() throws 'Error: Detected a non-exportable reference ('externalptr') in one of the globals ('FUN' of class 'function') used in the future expression' otherwise + - xvfb-run /opt/R/$R_VERSION/bin/R -q -e "options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = 'error', repos = structure(c(getOption('repos'),INLA='https://inla.r-inla-download.org/R/stable'))); progressr::handlers('cli'); progressr::handlers(global = TRUE); options(future.globals.onReference = NULL); bincraft::process_cran_updates(interval = $INTERVAL, platform = 'ubuntu-2204', process_updated = TRUE, process_new = TRUE, process_removed = TRUE, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)" + - /opt/R/$R_VERSION/bin/R -q -e 'library(bincraft); upload_package_index(codename = "jammy", 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"))' + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: amd64 + node.kubernetes.io/instance-type: AX42 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' + + - name: Purge CDN cache + image: reg.devxy.io/docker.io/library/alpine:3.23 + environment: + BUNNYNET_API_KEY: + from_secret: BUNNYNET_API_KEY + SUBDOMAIN1: 'cran.devxy.io' + SUBDOMAIN2: 'cran.allianceswisspass.devxy.io' + SUBDOMAIN3: 'cran.rpkgs.com' + OS_ID: jammy + ARCH: amd64 + commands: + - apk add --no-cache -q bash curl + - bash scripts/purge_cdn_cache.sh "$BUNNYNET_API_KEY" "$ARCH" "$OS_ID" "$SUBDOMAIN1" "$SUBDOMAIN2" "$SUBDOMAIN3" diff --git a/.crow/process-updates-ubuntu-2204-arm64.yaml b/.crow/process-updates-ubuntu-2204-arm64.yaml new file mode 100644 index 0000000..3726145 --- /dev/null +++ b/.crow/process-updates-ubuntu-2204-arm64.yaml @@ -0,0 +1,73 @@ +when: + - event: [cron] + cron: process-cran-updates-ubuntu-2204-arm64 + - event: manual + evaluate: 'process_cran_updates == "all"' + - event: manual + evaluate: 'process_cran_updates == "ubuntu-2204-arm64"' + +skip_clone: true + +labels: + agent: gaia + +steps: + - name: 'Processing Updates' + image: reg.devxy.io/rpkgs/build-env-ubuntu:jammy + 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 + NTFY_SERVER: + from_secret: NTFY_SERVER + NTFY_TOPIC: + from_secret: NTFY_TOPIC + NTFY_AUTH: TRUE + NTFY_PASSWORD: + from_secret: ntfy_token + # 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 + R_VERSION: 4.4.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: ubuntu-2204 + ARCH: arm64 + NCPUS: 2 + INTERVAL: lubridate::interval(lubridate::today() - 6, lubridate::today() - 3) + # volumes: + # - arm64-binaries-r-dep-cache-ubuntu-2204:/mnt/cache + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - rm -rf /mnt/cache/R-pkgs/00LOCK-r-pkg-binaries /mnt/cache/R-pkgs/00LOCK-bincraft /mnt/cache/R-pkgs/00LOCK-pak /mnt/cache/pkgcache/R/pkgcache /mnt/cache/pkgcache/R/pkgcache /mnt/cache/R-pkgs/pkgcache /mnt/cache/R-pkgs/00LOCK-pak/mnt/cache/R-pkgs/00LOCK-RPostgres /mnt/cache/R-pkgs/bincraft + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages + # options(future.globals.onReference = NULL): for some reason s3fs::file_delete() throws 'Error: Detected a non-exportable reference ('externalptr') in one of the globals ('FUN' of class 'function') used in the future expression' otherwise + - xvfb-run /opt/R/$R_VERSION/bin/R -q -e "options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = 'error', repos = structure(c(getOption('repos'),INLA='https://inla.r-inla-download.org/R/stable'))); progressr::handlers(global = TRUE); options(future.globals.onReference = NULL); bincraft::process_cran_updates(interval = $INTERVAL, platform = 'ubuntu-2204', process_updated = TRUE, process_new = TRUE, process_removed = TRUE, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)" + - /opt/R/$R_VERSION/bin/R -q -e 'library(bincraft); upload_package_index(codename = "jammy", 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"))' + + - name: Purge CDN cache + image: reg.devxy.io/docker.io/library/alpine:3.23 + environment: + BUNNYNET_API_KEY: + from_secret: BUNNYNET_API_KEY + SUBDOMAIN1: 'cran.devxy.io' + SUBDOMAIN2: 'cran.allianceswisspass.devxy.io' + SUBDOMAIN3: 'cran.rpkgs.com' + OS_ID: jammy + ARCH: arm64 + commands: + - apk add --no-cache -q bash curl + - bash scripts/purge_cdn_cache.sh "$BUNNYNET_API_KEY" "$ARCH" "$OS_ID" "$SUBDOMAIN1" "$SUBDOMAIN2" "$SUBDOMAIN3" diff --git a/.crow/process-updates-ubuntu-2404-amd64.yaml b/.crow/process-updates-ubuntu-2404-amd64.yaml new file mode 100644 index 0000000..f52137a --- /dev/null +++ b/.crow/process-updates-ubuntu-2404-amd64.yaml @@ -0,0 +1,91 @@ +when: + - event: [cron] + cron: process-cran-updates-ubuntu-2404-amd64 + - event: manual + evaluate: 'process_cran_updates == "all"' + - event: manual + evaluate: 'process_cran_updates == "ubuntu-2404-amd64"' + +skip_clone: true + +labels: + agent: artemis + +steps: + - name: 'Processing Updates' + image: reg.devxy.io/rpkgs/build-env-ubuntu:noble + 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 + NTFY_SERVER: + from_secret: NTFY_SERVER + NTFY_TOPIC: + from_secret: NTFY_TOPIC + NTFY_AUTH: TRUE + NTFY_PASSWORD: + from_secret: ntfy_token + # 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 + R_VERSION: 4.4.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: ubuntu-2404 + ARCH: amd64 + NCPUS: 1 + STRATEGY: sequential + INTERVAL: lubridate::interval(lubridate::today() - 6, lubridate::today() - 3) + # volumes: + # - amd64-binaries-r-dep-cache-ubuntu-2404:/mnt/cache + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - rm -rf /mnt/cache/R-pkgs/00LOCK-r-pkg-binaries /mnt/cache/R-pkgs/00LOCK-bincraft /mnt/cache/R-pkgs/00LOCK-pak /mnt/cache/pkgcache/R/pkgcache /mnt/cache/pkgcache/R/pkgcache /mnt/cache/R-pkgs/pkgcache /mnt/cache/R-pkgs/00LOCK-pak/mnt/cache/R-pkgs/00LOCK-RPostgres /mnt/cache/R-pkgs/bincraft + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages + # options(future.globals.onReference = NULL): for some reason s3fs::file_delete() throws 'Error: Detected a non-exportable reference ('externalptr') in one of the globals ('FUN' of class 'function') used in the future expression' otherwise + - xvfb-run /opt/R/$R_VERSION/bin/R -q -e "options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = 'error', repos = structure(c(getOption('repos'),INLA='https://inla.r-inla-download.org/R/stable'))); progressr::handlers(global = TRUE); options(future.globals.onReference = NULL); bincraft::process_cran_updates(interval = $INTERVAL, platform = 'ubuntu-2404', process_updated = TRUE, process_new = TRUE, process_removed = TRUE, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)" + - /opt/R/$R_VERSION/bin/R -q -e 'library(bincraft); upload_package_index(codename = "noble", 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"))' + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: amd64 + node.kubernetes.io/instance-type: AX42 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' + + - name: Purge CDN cache + image: reg.devxy.io/docker.io/library/alpine:3.23 + environment: + BUNNYNET_API_KEY: + from_secret: BUNNYNET_API_KEY + SUBDOMAIN1: 'cran.devxy.io' + SUBDOMAIN2: 'cran.allianceswisspass.devxy.io' + SUBDOMAIN3: 'cran.rpkgs.com' + OS_ID: noble + ARCH: amd64 + commands: + - apk add --no-cache -q bash curl + - bash scripts/purge_cdn_cache.sh "$BUNNYNET_API_KEY" "$ARCH" "$OS_ID" "$SUBDOMAIN1" "$SUBDOMAIN2" "$SUBDOMAIN3" diff --git a/.crow/process-updates-ubuntu-2404-arm64.yaml b/.crow/process-updates-ubuntu-2404-arm64.yaml new file mode 100644 index 0000000..5f8f3af --- /dev/null +++ b/.crow/process-updates-ubuntu-2404-arm64.yaml @@ -0,0 +1,73 @@ +when: + - event: [cron] + cron: process-cran-updates-ubuntu-2404-arm64 + - event: manual + evaluate: 'process_cran_updates == "all"' + - event: manual + evaluate: 'process_cran_updates == "ubuntu-2404-arm64"' + +skip_clone: true + +labels: + agent: gaia + +steps: + - name: 'Processing Updates' + image: reg.devxy.io/rpkgs/build-env-ubuntu:noble + 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 + NTFY_SERVER: + from_secret: NTFY_SERVER + NTFY_TOPIC: + from_secret: NTFY_TOPIC + NTFY_AUTH: TRUE + NTFY_PASSWORD: + from_secret: ntfy_token + # 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 + R_VERSION: 4.4.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: ubuntu-2404 + ARCH: arm64 + NCPUS: 2 + INTERVAL: lubridate::interval(lubridate::today() - 6, lubridate::today() - 3) + # volumes: + # - arm64-binaries-r-dep-cache-ubuntu-2404:/mnt/cache + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - rm -rf /mnt/cache/R-pkgs/00LOCK-r-pkg-binaries /mnt/cache/R-pkgs/00LOCK-bincraft /mnt/cache/R-pkgs/00LOCK-pak /mnt/cache/pkgcache/R/pkgcache /mnt/cache/pkgcache/R/pkgcache /mnt/cache/R-pkgs/pkgcache /mnt/cache/R-pkgs/00LOCK-pak/mnt/cache/R-pkgs/00LOCK-RPostgres /mnt/cache/R-pkgs/bincraft + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages + # options(future.globals.onReference = NULL): for some reason s3fs::file_delete() throws 'Error: Detected a non-exportable reference ('externalptr') in one of the globals ('FUN' of class 'function') used in the future expression' otherwise + - xvfb-run /opt/R/$R_VERSION/bin/R -q -e "options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = 'error', repos = structure(c(getOption('repos'),INLA='https://inla.r-inla-download.org/R/stable'))); progressr::handlers('cli'); progressr::handlers(global = TRUE); options(future.globals.onReference = NULL); bincraft::process_cran_updates(interval = $INTERVAL, platform = 'ubuntu-2404', process_updated = TRUE, process_new = TRUE, process_removed = TRUE, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)" + - /opt/R/$R_VERSION/bin/R -q -e 'library(bincraft); upload_package_index(codename = "noble", 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"))' + + - name: Purge CDN cache + image: reg.devxy.io/docker.io/library/alpine:3.23 + environment: + BUNNYNET_API_KEY: + from_secret: BUNNYNET_API_KEY + SUBDOMAIN1: 'cran.devxy.io' + SUBDOMAIN2: 'cran.allianceswisspass.devxy.io' + SUBDOMAIN3: 'cran.rpkgs.com' + OS_ID: noble + ARCH: arm64 + commands: + - apk add --no-cache -q bash curl + - bash scripts/purge_cdn_cache.sh "$BUNNYNET_API_KEY" "$ARCH" "$OS_ID" "$SUBDOMAIN1" "$SUBDOMAIN2" "$SUBDOMAIN3" diff --git a/.crow/process-updates.yaml b/.crow/process-updates.yaml deleted file mode 100644 index e4ef547..0000000 --- a/.crow/process-updates.yaml +++ /dev/null @@ -1,256 +0,0 @@ -# Consolidated process-updates pipeline (all platforms, both arches). -# One matrix row per OS/arch replaces the former per-platform files. -# Routing is preserved 1:1: -# - cron: each existing `process-cran-updates--` cron fires only -# its matching matrix row (via the per-row `cron:` name filter). -# - manual: pick a target from the `process_cran_updates` dropdown; -# "all" fans out every os/arch as parallel matrix workflows. -# Arch placement is handled by the group label (rpkgs-amd64, rpkgs-arm64). -variables: - # Gates this pipeline. A manual pipeline creation instantiates every file in - # .crow/, and a declared default is applied even when the run never passed - # this variable, so the default must be a value that matches no matrix row. - process_cran_updates: - description: "Manual run target: a specific -, 'all' to run every os/arch in parallel, or 'none' to run nothing." - options: - - none - - all - - alpine-323-amd64 - - alpine-323-arm64 - - alpine-324-amd64 - - alpine-324-arm64 - - redhat-8-amd64 - - redhat-8-arm64 - - redhat-9-amd64 - - redhat-9-arm64 - - redhat-10-amd64 - - redhat-10-arm64 - - ubuntu-2204-amd64 - - ubuntu-2204-arm64 - - ubuntu-2404-amd64 - - ubuntu-2404-arm64 - - ubuntu-2604-amd64 - - ubuntu-2604-arm64 - default: none - -when: - - event: cron - cron: process-cran-updates-${OS}-${ARCH} - - event: manual - evaluate: 'process_cran_updates == "all" || process_cran_updates == "${OS}-${ARCH}"' - -skip_clone: true - -labels: - group: rpkgs-${ARCH} - -matrix: - include: - - OS: alpine-323 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - OS_ID: alpine323 - PROCESS_NEW: 'FALSE' - - OS: alpine-323 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - OS_ID: alpine323 - PROCESS_NEW: 'FALSE' - - OS: alpine-324 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - OS_ID: alpine324 - PROCESS_NEW: 'FALSE' - - OS: alpine-324 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - OS_ID: alpine324 - PROCESS_NEW: 'FALSE' - - OS: redhat-8 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:8 - OS_ID: rhel8 - PROCESS_NEW: 'TRUE' - - OS: redhat-8 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:8 - OS_ID: rhel8 - PROCESS_NEW: 'TRUE' - - OS: redhat-9 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:9 - OS_ID: rhel9 - PROCESS_NEW: 'TRUE' - - OS: redhat-9 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:9 - OS_ID: rhel9 - PROCESS_NEW: 'TRUE' - - OS: redhat-10 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: redhat:10 - OS_ID: rhel10 - PROCESS_NEW: 'TRUE' - - OS: redhat-10 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: redhat:10 - OS_ID: rhel10 - PROCESS_NEW: 'TRUE' - - OS: ubuntu-2204 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - OS_ID: jammy - PROCESS_NEW: 'TRUE' - - OS: ubuntu-2204 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - OS_ID: jammy - PROCESS_NEW: 'TRUE' - - OS: ubuntu-2404 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - OS_ID: noble - PROCESS_NEW: 'TRUE' - - OS: ubuntu-2404 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - OS_ID: noble - PROCESS_NEW: 'TRUE' - - OS: ubuntu-2604 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: ubuntu:resolute - OS_ID: resolute - PROCESS_NEW: 'TRUE' - - OS: ubuntu-2604 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: ubuntu:resolute - OS_ID: resolute - PROCESS_NEW: 'TRUE' - -steps: - - name: 'Processing Updates' - image: reg.devxy.io/rpkgs/build-env-${IMG} - pull: true - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - 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 - NTFY_SERVER: - from_secret: NTFY_SERVER - NTFY_TOPIC: - from_secret: NTFY_TOPIC - NTFY_AUTH: TRUE - NTFY_PASSWORD: - from_secret: ntfy_token - # set the location of uvr's caches, which persist the R package - # dependencies needed to install the packages themselves - UVR_CACHE_DIR: /mnt/cache/uvr/cache - UVR_PACKAGES_DIR: /mnt/cache/uvr/packages - R_LIBS_USER: /mnt/cache/R-pkgs - R_VERSION: ${R_VERSION} - CCACHE_DIR: /mnt/cache/ccache - # parallel make within one package build, matched to the step's CPU limit - MAKE_JOBS: 3 - PLATFORM: ${OS} - OS_ID: ${OS_ID} - ARCH: ${ARCH} - NCPUS: 2 - INTERVAL: lubridate::interval(lubridate::today() - 6, lubridate::today() - 3) - commands: - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - . local/compiler-cache.sh - - rm -rf /mnt/cache/R-pkgs/00LOCK-* /mnt/cache/R-pkgs/bincraft - - mkdir -p /mnt/cache/uvr/cache /mnt/cache/uvr/packages /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages - - /opt/R/$R_VERSION/bin/Rscript local/install-bincraft.R - - UVR_R_BIN=/opt/R/$R_VERSION/bin/R local/uvr-install.sh RPostgres progressr lubridate - - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' - # rhel-10 ships xwfb-run (Xwayland) instead of xvfb-run; prefer it and start weston, else fall back to xvfb-run - - XVFB=$(command -v xwfb-run 2>/dev/null || command -v xvfb-run); XVFB_ARGS="-a"; if command -v xwfb-run >/dev/null 2>&1; then dnf install -y -q weston 2>/dev/null; XVFB_ARGS="-c weston"; fi - # options(future.globals.onReference = NULL): for some reason s3fs::file_delete() throws 'Error: Detected a non-exportable reference ('externalptr') in one of the globals ('FUN' of class 'function') used in the future expression' otherwise - - $XVFB $XVFB_ARGS -- /opt/R/$R_VERSION/bin/R -q -e "options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = 'error', repos = structure(c(getOption('repos'),INLA='https://inla.r-inla-download.org/R/stable'))); progressr::handlers('cli'); progressr::handlers(global = TRUE); options(future.globals.onReference = NULL); bincraft::process_cran_updates(interval = $INTERVAL, platform = '${OS}', process_updated = TRUE, process_new = ${PROCESS_NEW}, process_removed = TRUE, patches = 'local/patches', r_minor_detection = 'classifier',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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'verify-full', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)" - - | - 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 update pass under R $RV ===" - LIB="/mnt/cache/R-pkgs-$RMINOR" - mkdir -p "$LIB" - R_LIBS_USER="$LIB" "$(dirname "$RBIN")/Rscript" local/install-bincraft.R || true - R_LIBS_USER="$LIB" UVR_R_BIN="$RBIN" local/uvr-install.sh RPostgres lubridate || true - R_LIBS_USER="$LIB" $XVFB $XVFB_ARGS -- "$(dirname "$RBIN")/R" -q -e "options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = NULL); bincraft::process_cran_updates(interval = $INTERVAL, platform = '${OS}', process_updated = TRUE, process_new = FALSE, process_removed = FALSE, patches = 'local/patches', r_minor_detection = 'classifier',r_minor_sensitive_only = TRUE, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'verify-full', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)" || true - # Also build current packages whose required dependency tree needs a newer R. - R_LIBS_USER="$LIB" $XVFB $XVFB_ARGS -- "$(dirname "$RBIN")/Rscript" local/build-newer-r.R "$R_VERSION" - done - - /opt/R/$R_VERSION/bin/R -q -e 'library(bincraft); upload_package_index(codename = "${OS_ID}", 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"))' - - | - FAILED_MINORS="" - 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 "library(bincraft); upload_package_index(codename = '${OS_ID}', 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_port = 15432L, metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'verify-full')" || FAILED_MINORS="$FAILED_MINORS $RMINOR" - done - if [ -n "$FAILED_MINORS" ]; then - echo "Could not republish the per-minor index for:$FAILED_MINORS" >&2 - exit 1 - fi - backend_options: - docker: - resources: - requests: - memory: 5Gi - cpu: 3000m - limits: - memory: 18Gi - cpu: 3000m - - - name: Purge CDN cache - image: reg.devxy.io/docker.io/library/alpine:3.24 - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - BUNNYNET_API_KEY: - from_secret: BUNNYNET_API_KEY - SUBDOMAIN1: 'cran.devxy.io' - SUBDOMAIN2: 'cran.allianceswisspass.devxy.io' - SUBDOMAIN3: 'cran.rpkgs.com' - OS_ID: ${OS_ID} - ARCH: ${ARCH} - commands: - - apk add --no-cache -q bash curl - - bash scripts/purge_cdn_cache.sh "$BUNNYNET_API_KEY" "$ARCH" "$OS_ID" "$SUBDOMAIN1" "$SUBDOMAIN2" "$SUBDOMAIN3" - # Run it even when a per-minor re-index above failed: the generic index - # and the objects were still replaced, and a stale edge keeps them hidden. - when: - - status: [success, failure] diff --git a/.crow/prune-stale-flat-binaries.yaml b/.crow/prune-stale-flat-binaries.yaml deleted file mode 100644 index b010914..0000000 --- a/.crow/prune-stale-flat-binaries.yaml +++ /dev/null @@ -1,256 +0,0 @@ -# Remove flat-slot binaries recorded unable to load under some R minor, then -# re-index. -# -# The list comes from `abi_flat_safety`, so it names the objects the binaries -# themselves report as broken, not the ones a source heuristic suspects. That -# distinction is the whole cost of the operation: the heuristic calls 93% of -# compiled packages risky and would delete roughly 3000 objects per slot to fix -# about 230. -# -# `upload_single_binary()` has written a non-portable package only to the -# per-minor slot since v5.3.0, so this is a one-time cleanup of what was -# uploaded before that. The flat slot is what every client that cannot be -# routed by R minor receives, and such a binary was built under whichever R was -# primary at the time, so it dies at load under any minor that dropped a symbol -# it uses: -# -# base64enc.so: undefined symbol: SETLENGTH -# -# Deleting the flat object does not create a hole. The source fallback -# republishes the CRAN source under the same key, so the package stays -# installable everywhere and compiles against the client's own R, while routed -# clients keep getting the per-minor binary. -# -# Dry run unless PRUNE_APPLY is 'yes'. Start with an explicit package list: -# -# crow pipeline create devxy/build-cran-binaries \ -# --var prune_flat=ubuntu-2604-amd64 \ -# --var PRUNE_PACKAGES="base64enc lobstr" \ -# --var PRUNE_APPLY=yes - -variables: - # A manual pipeline creation instantiates every file in .crow/, so the default - # must match no matrix row. - prune_flat: - description: "Prune target: a specific -, 'all' for every slot, or 'none'." - options: - - none - - all - - alpine-323-amd64 - - alpine-323-arm64 - - alpine-324-amd64 - - alpine-324-arm64 - - redhat-8-amd64 - - redhat-8-arm64 - - redhat-9-amd64 - - redhat-9-arm64 - - redhat-10-amd64 - - redhat-10-arm64 - - ubuntu-2204-amd64 - - ubuntu-2204-arm64 - - ubuntu-2404-amd64 - - ubuntu-2404-arm64 - - ubuntu-2604-amd64 - - ubuntu-2604-arm64 - default: none - PRUNE_PACKAGES: - description: 'Space-separated package names. Empty means every package the classifier cache calls risky.' - default: '' - PRUNE_APPLY: - description: "Set to 'yes' to actually delete. Anything else is a dry run." - options: - - 'no' - - 'yes' - default: 'no' - -when: - - event: manual - evaluate: 'prune_flat == "all" || prune_flat == "${OS}-${ARCH}"' - -skip_clone: true - -labels: - group: rpkgs-${ARCH} - -matrix: - include: - - OS: alpine-323 - ARCH: amd64 - CODENAME: alpine323 - IMG: alpine:3.23 - - OS: alpine-323 - ARCH: arm64 - CODENAME: alpine323 - IMG: alpine:3.23 - - OS: alpine-324 - ARCH: amd64 - CODENAME: alpine324 - IMG: alpine:3.24 - - OS: alpine-324 - ARCH: arm64 - CODENAME: alpine324 - IMG: alpine:3.24 - - OS: redhat-8 - ARCH: amd64 - CODENAME: rhel8 - IMG: redhat:8 - - OS: redhat-8 - ARCH: arm64 - CODENAME: rhel8 - IMG: redhat:8 - - OS: redhat-9 - ARCH: amd64 - CODENAME: rhel9 - IMG: redhat:9 - - OS: redhat-9 - ARCH: arm64 - CODENAME: rhel9 - IMG: redhat:9 - - OS: redhat-10 - ARCH: amd64 - CODENAME: rhel10 - IMG: redhat:10 - - OS: redhat-10 - ARCH: arm64 - CODENAME: rhel10 - IMG: redhat:10 - - OS: ubuntu-2204 - ARCH: amd64 - CODENAME: jammy - IMG: ubuntu:jammy - - OS: ubuntu-2204 - ARCH: arm64 - CODENAME: jammy - IMG: ubuntu:jammy - - OS: ubuntu-2404 - ARCH: amd64 - CODENAME: noble - IMG: ubuntu:noble - - OS: ubuntu-2404 - ARCH: arm64 - CODENAME: noble - IMG: ubuntu:noble - - OS: ubuntu-2604 - ARCH: amd64 - CODENAME: resolute - IMG: ubuntu:resolute - - OS: ubuntu-2604 - ARCH: arm64 - CODENAME: resolute - IMG: ubuntu:resolute - -steps: - - name: 'Prune stale flat binaries' - image: reg.devxy.io/rpkgs/build-env-${IMG} - pull: true - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - 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 - GIT_USER: pat-s - R_LIBS_USER: /tmp/R-pkgs - # Pipeline variables are substituted into the YAML, not exported, so they - # have to be bound here to be readable as env vars in the script below. - PRUNE_ARCH: ${ARCH} - PRUNE_CODENAME: ${CODENAME} - PRUNE_PACKAGES: ${PRUNE_PACKAGES} - PRUNE_APPLY: ${PRUNE_APPLY} - commands: - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - mkdir -p /tmp/R-pkgs - - /opt/R/4.5.3/bin/Rscript local/install-bincraft.R - - UVR_R_BIN=/opt/R/4.5.3/bin/R local/uvr-install.sh RPostgres - - | - set -eu - APPLY="" - if [ "$$PRUNE_APPLY" = "yes" ]; then - APPLY="--apply" - fi - /opt/R/4.5.3/bin/Rscript local/prune-stale-flat-binaries.R \ - "$$PRUNE_ARCH" "$$PRUNE_CODENAME" $$APPLY $$PRUNE_PACKAGES - backend_options: - docker: - resources: - requests: - memory: 3Gi - cpu: 1000m - - # Deleting objects without re-indexing is worse than leaving them: the - # published index keeps naming files that no longer exist, so every client - # gets a 404 instead of a working source fallback. The re-index is what - # republishes them as CRAN source, so it belongs in the same run. - - name: 'Re-index the slot' - image: reg.devxy.io/rpkgs/build-env-${IMG} - pull: true - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - 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_LIBS_USER: /tmp/R-pkgs - PRUNE_APPLY: ${PRUNE_APPLY} - commands: - - | - set -eu - if [ "$$PRUNE_APPLY" != "yes" ]; then - echo "Dry run: nothing was deleted, so there is nothing to re-index." - exit 0 - fi - # /tmp is container-local, so the library installed by the prune step is gone here. - mkdir -p /tmp/R-pkgs - /opt/R/4.5.3/bin/Rscript local/install-bincraft.R - UVR_R_BIN=/opt/R/4.5.3/bin/R local/uvr-install.sh RPostgres - /opt/R/4.5.3/bin/R -q -e 'library(bincraft); upload_package_index(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"))' - FAILED_MINORS="" - for RBIN in /opt/R/[0-9]*/bin/R; do - RMINOR=$(basename "$(dirname "$(dirname "$RBIN")")" | cut -d. -f1-2) - /opt/R/4.5.3/bin/R -q -e "library(bincraft); upload_package_index(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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_port = 15432L, metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'verify-full')" || FAILED_MINORS="$FAILED_MINORS $RMINOR" - done - if [ -n "$FAILED_MINORS" ]; then - echo "Could not republish the per-minor index for:$FAILED_MINORS" >&2 - exit 1 - fi - backend_options: - docker: - resources: - requests: - memory: 3Gi - cpu: 1000m - - # The edge caches indexes for ~370 days, so without this the deletion is - # invisible to clients and they keep being handed the removed binary. - - name: 'Purge CDN cache' - image: reg.devxy.io/docker.io/library/alpine:3.24 - environment: - BUNNYNET_API_KEY: - from_secret: BUNNYNET_API_KEY - # Same zones as reindex.yaml: the production pull zone id, the alliance - # hostname and the staging zone, which shares the B2 origin. - BUNNY_PULLZONES: '3857050 cran.allianceswisspass.devxy.io cran-rpkgs-test.b-cdn.net' - PRUNE_APPLY: ${PRUNE_APPLY} - commands: - - | - set -eu - if [ "$$PRUNE_APPLY" != "yes" ]; then - echo "Dry run: nothing changed at the origin, so no purge is needed." - exit 0 - fi - apk add --no-cache -q bash curl jq - bash scripts/purge_cdn_zone.sh "$BUNNYNET_API_KEY" $BUNNY_PULLZONES - # Run it even when a per-minor re-index above failed: the generic index - # and the objects were still replaced, and a stale edge keeps them hidden. - when: - - status: [success, failure] diff --git a/.crow/rebuild-abi-gap.yaml b/.crow/rebuild-abi-gap.yaml deleted file mode 100644 index afab781..0000000 --- a/.crow/rebuild-abi-gap.yaml +++ /dev/null @@ -1,215 +0,0 @@ -# Rebuild specific packages into a per-R-minor slot. -# -# The per-minor scheme only ever covered packages that passed through the build -# pipeline after it existed. A package built into the flat slot before that, and -# never updated on CRAN since, is never reclassified and never gets a per-minor -# copy - so the union index serves its flat binary to every minor. When that -# binary references a symbol the client's R no longer exports, the install fails -# at dyn.load(): -# -# base64enc.so: undefined symbol: SETLENGTH -# -# base64enc calls SETLENGTH, its flat binary was built under R 4.4.3, and R 4.6 -# does not export SETLENGTH. There was no way to rebuild one package into one -# minor from CI, only `just rebuild` from a workstation with the S3 and Postgres -# credentials to hand. This adds that path. -# -# `--sensitive-only` is deliberately NOT passed. That flag gates on the source -# classifier, which misses Rcpp: the repair therefore skipped Rcpp entirely, -# leaving its 4.5-built flat binary as the only copy and breaking every R 4.4 -# client on the slot. -# -# Since bincraft v5.3.0 the destination is decided by the built binary's symbols -# in `upload_single_binary()`, so building unconditionally is safe: a package -# that needs a per-minor slot lands there, and one that does not lands in the -# flat slot. Skipping before the build is what removed that decision. -# -# Trigger with the slot and an explicit package list: -# -# crow pipeline create devxy/build-cran-binaries \ -# --var rebuild_abi_gap=ubuntu-2604-amd64 \ -# --var ABI_PACKAGES="base64enc@0.1-6 lobstr@1.2.1" \ -# --var ABI_R_MINOR=4.6 - -variables: - # A manual pipeline creation instantiates every file in .crow/, so the - # default must match no matrix row. - rebuild_abi_gap: - description: "Rebuild target: a specific -, 'all' for every slot, or 'none'." - options: - - none - - all - - alpine-323-amd64 - - alpine-323-arm64 - - alpine-324-amd64 - - alpine-324-arm64 - - redhat-8-amd64 - - redhat-8-arm64 - - redhat-9-amd64 - - redhat-9-arm64 - - redhat-10-amd64 - - redhat-10-arm64 - - ubuntu-2204-amd64 - - ubuntu-2204-arm64 - - ubuntu-2404-amd64 - - ubuntu-2404-arm64 - - ubuntu-2604-amd64 - - ubuntu-2604-arm64 - default: none - ABI_PACKAGES: - description: 'Space-separated package@version list, e.g. "base64enc@0.1-6 lobstr@1.2.1".' - default: '' - ABI_R_MINOR: - description: 'The R minor to build into.' - options: - - '4.4' - - '4.5' - - '4.6' - default: '4.6' - -when: - - event: manual - evaluate: 'rebuild_abi_gap == "all" || rebuild_abi_gap == "${OS}-${ARCH}"' - -skip_clone: true - -labels: - group: rpkgs-${ARCH} - -matrix: - include: - - OS: alpine-323 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - - OS: alpine-323 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - - OS: alpine-324 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - - OS: alpine-324 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - - OS: redhat-8 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:8 - - OS: redhat-8 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:8 - - OS: redhat-9 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:9 - - OS: redhat-9 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:9 - - OS: redhat-10 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: redhat:10 - - OS: redhat-10 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: redhat:10 - - OS: ubuntu-2204 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - - OS: ubuntu-2204 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - - OS: ubuntu-2404 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - - OS: ubuntu-2404 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - - OS: ubuntu-2604 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - - OS: ubuntu-2604 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - -steps: - - name: 'Rebuild packages into the per-minor slot' - image: reg.devxy.io/rpkgs/build-env-${IMG} - pull: true - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - 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 - GIT_USER: pat-s - # Pipeline variables are substituted into the YAML, not exported, so they - # have to be bound here to be readable as env vars in the script below. - ABI_PACKAGES: ${ABI_PACKAGES} - ABI_R_MINOR: ${ABI_R_MINOR} - UVR_CACHE_DIR: /tmp/uvr/cache - UVR_PACKAGES_DIR: /tmp/uvr/packages - CCACHE_DIR: /tmp/ccache - NCPUS: 2 - commands: - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - mkdir -p $UVR_CACHE_DIR $UVR_PACKAGES_DIR $CCACHE_DIR - - | - set -eu - if [ -z "$$ABI_PACKAGES" ]; then - echo "ABI_PACKAGES is empty; nothing to rebuild." >&2 - exit 1 - fi - RBIN=$(ls -d /opt/R/$${ABI_R_MINOR}*/bin 2>/dev/null | head -1) - if [ -z "$$RBIN" ]; then - echo "R $$ABI_R_MINOR is not installed in this image." >&2 - exit 1 - fi - # Container-local library: this workflow mounts no shared cache volume, - # so it cannot disturb the build pipeline's per-agent caches. - LIB="/tmp/R-pkgs-$$ABI_R_MINOR" - mkdir -p "$$LIB" - export R_LIBS_USER="$$LIB" - rm -rf "$$LIB"/00LOCK-* - "$$RBIN/Rscript" local/install-bincraft.R - UVR_R_BIN="$$RBIN/R" local/uvr-install.sh RPostgres - rc=0 - for spec in $$ABI_PACKAGES; do - pkg=$${spec%@*} - ver=$${spec#*@} - if [ "$$pkg" = "$$ver" ]; then - echo "malformed spec '$$spec'; expected package@version" >&2 - rc=1 - continue - fi - echo "=== rebuilding $$pkg $$ver into $$ABI_R_MINOR ===" - "$$RBIN/Rscript" local/build-one.R "$$pkg" "$$ver" || rc=1 - done - exit $$rc - backend_options: - docker: - resources: - requests: - memory: 5Gi - cpu: 1000m diff --git a/.crow/reindex.yaml b/.crow/reindex.yaml deleted file mode 100644 index bb8508f..0000000 --- a/.crow/reindex.yaml +++ /dev/null @@ -1,203 +0,0 @@ -# Re-index every slot without rebuilding anything. -# -# `weekly-rebuild-reindex` exists to run after `weekly-rebuild-missing`, so it -# depends on that workflow and shares its gate: triggering it manually also -# starts hours of package rebuilds. That is the wrong tool when only the index -# needs regenerating - after a bincraft release that changes how the index is -# written, for instance, where the objects in the bucket are already correct -# and only `PACKAGES*` is stale. -# -# This workflow does the index half on its own. It installs the latest bincraft -# release, republishes the generic and per-R-minor indexes for each slot, and -# purges the edge. No package is built. -# -# Trigger with the `reindex` variable set to `all` or to a single -# `-`, e.g. -# -# crow pipeline create devxy/build-cran-binaries --var reindex=all - -variables: - # A manual pipeline creation instantiates every file in .crow/, so the - # default must match no matrix row. - reindex: - description: "Re-index target: a specific -, 'all' for every slot, or 'none'." - options: - - none - - all - - alpine-323-amd64 - - alpine-323-arm64 - - alpine-324-amd64 - - alpine-324-arm64 - - redhat-8-amd64 - - redhat-8-arm64 - - redhat-9-amd64 - - redhat-9-arm64 - - redhat-10-amd64 - - redhat-10-arm64 - - ubuntu-2204-amd64 - - ubuntu-2204-arm64 - - ubuntu-2404-amd64 - - ubuntu-2404-arm64 - - ubuntu-2604-amd64 - - ubuntu-2604-arm64 - default: none - -when: - - event: manual - evaluate: 'reindex == "all" || reindex == "${OS}-${ARCH}"' - -skip_clone: true - -labels: - group: rpkgs-${ARCH} - -matrix: - include: - - OS: alpine-323 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - - OS: alpine-323 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - - OS: alpine-324 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - - OS: alpine-324 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - - OS: redhat-8 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:8 - - OS: redhat-8 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:8 - - OS: redhat-9 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:9 - - OS: redhat-9 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:9 - - OS: redhat-10 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: redhat:10 - - OS: redhat-10 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: redhat:10 - - OS: ubuntu-2204 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - - OS: ubuntu-2204 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - - OS: ubuntu-2404 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - - OS: ubuntu-2404 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - - OS: ubuntu-2604 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - - OS: ubuntu-2604 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - -steps: - - name: 'Re-index the slot' - image: reg.devxy.io/rpkgs/build-env-${IMG} - pull: true - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - 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 - # The index build reads the ABI classifier cache to decide which packages - # may be carried from the flat slot into a per-minor one. Without the - # password that query fails, and it fails soft, so the run still succeeds - # while quietly using an empty risky set: exactly the state the cache was - # added to fix. It logs one connection error per slot. - PGPASS: - from_secret: PGPASS - REPO_RO_TOKEN: - from_secret: REPO_RO_TOKEN - # bincraft reads the DESCRIPTION of every new or replaced tarball from - # the CRAN mirror on raw.githubusercontent.com, and authenticates with - # this token when it is set. A slot whose published index cannot be read - # is re-read in full, ~25k requests, which the anonymous rate limit would - # cut short. - GITHUB_PAT: - from_secret: GITHUB_PAT - GIT_USER: pat-s - R_LIBS_USER: /mnt/cache/R-pkgs - R_VERSION: ${R_VERSION} - PLATFORM: ${OS} - ARCH: ${ARCH} - commands: - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - mkdir -p /mnt/cache/R-pkgs - - rm -rf /mnt/cache/R-pkgs/00LOCK-* - - /opt/R/$R_VERSION/bin/Rscript local/install-bincraft.R - - UVR_R_BIN=/opt/R/$R_VERSION/bin/R local/uvr-install.sh RPostgres - # The codename is detected from the image's /etc/os-release. - - /opt/R/$R_VERSION/bin/R -q -e 'library(bincraft); upload_package_index(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"))' - - | - FAILED_MINORS="" - 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 "library(bincraft); upload_package_index(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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_port = 15432L, metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'verify-full')" || FAILED_MINORS="$FAILED_MINORS $RMINOR" - done - if [ -n "$FAILED_MINORS" ]; then - echo "Could not republish the per-minor index for:$FAILED_MINORS" >&2 - exit 1 - fi - - - name: Purge CDN cache - image: reg.devxy.io/docker.io/library/alpine:3.24 - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - BUNNYNET_API_KEY: - from_secret: BUNNYNET_API_KEY - # cran.rpkgs.com and cran.allianceswisspass.devxy.io are on separate - # Bunny pull zones, so both must be purged after the shared origin changes. - # The staging zone is listed too. It shares the B2 origin, so an index - # it still holds is a stale copy of the same object, and its - # cache_expiration_time is the same ~370 days: without a purge here it - # serves pre-reindex indexes indefinitely and any verification run - # against it measures the past. - BUNNY_PULLZONES: '3857050 cran.allianceswisspass.devxy.io cran-rpkgs-test.b-cdn.net' - commands: - - apk add --no-cache -q bash curl jq - # Crow carries the checkout from the re-index step into this step. - - bash scripts/purge_cdn_zone.sh "$BUNNYNET_API_KEY" $BUNNY_PULLZONES - # Runs on every row rather than on one designated slot: a cron fires only - # its own slot's row, so gating on a named slot would leave every other - # slot unpurged. A manual "all" run therefore purges the zone 18 times, - # which is a cheap API call and rare. - # - # Run it even when the re-index above failed: the objects were still - # replaced, and a stale edge is exactly what keeps them hidden. - when: - - status: [success, failure] diff --git a/.crow/repair-built-stamp.yaml b/.crow/repair-built-stamp.yaml deleted file mode 100644 index fe499df..0000000 --- a/.crow/repair-built-stamp.yaml +++ /dev/null @@ -1,109 +0,0 @@ -### Manual repair of a slot whose PACKAGES index advertises a broken `Built` -### stamp (e.g. `Built: R 4.5.0; NA; ...`). -# -# uvr matches the stamp's platform triple plus R minor to decide binary vs -# source, so an unusable triple turns a whole slot source-only. See -# local/repair-built-stamp.R for why this patches the published PACKAGES.rds in -# place instead of forcing a full reparse. -# -# Run with `dry_run: true` first: it reports how many entries are broken per -# slot and changes nothing. Pick the R version the slot should advertise, which -# is the R_VERSION its entry in .crow/process-updates.yaml uses. -# -# The gate variable is `repair_built_stamp`, not `target_arch`: `target_arch` is -# what build-all-versions and build-all-versions-install-deps gate on, so a -# manual run passing it would start a full rebuild alongside this repair. Every -# pipeline here gates on a variable named after itself for exactly that reason. -# -# crow pipeline create --branch main \ -# --var repair_built_stamp=arm64 --var OS=alpine --var OS_VERSION=3.23 \ -# --var R_VERSION=4.5.3 --var dry_run=true devxy/build-cran-binaries -variables: - # Gates this pipeline. A manual pipeline creation instantiates every file in - # .crow/, and a declared default is applied even when the run never passed - # this variable, so the default must be a value that matches no matrix row. - repair_built_stamp: - description: 'Architecture of the slot to repair, or "none" to run nothing.' - options: - - none - - amd64 - - arm64 - default: none - OS: - description: 'Base OS image name.' - options: - - alpine - - redhat - - ubuntu - default: alpine - OS_VERSION: - description: 'OS image tag. Must match OS (alpine: 3.23/3.24; redhat: 8/9/10; ubuntu: jammy/noble/resolute).' - options: - - '3.23' - - '3.24' - - '8' - - '9' - - '10' - - 'jammy' - - 'noble' - - 'resolute' - default: '3.23' - R_VERSION: - description: 'R version whose stamp the slot should advertise.' - options: - - 4.5.3 - - 4.4.3 - default: 4.5.3 - dry_run: - description: 'Report what would change without writing anything.' - options: - - 'true' - - 'false' - default: 'true' - -when: - - event: manual - evaluate: 'repair_built_stamp == "${ARCH}"' - -skip_clone: true - -labels: - platform: linux/${ARCH} - group: rpkgs-${ARCH} - -matrix: - include: - - ARCH: amd64 - - ARCH: arm64 - -steps: - - name: 'Repair Built stamp' - 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 - REPO_RO_TOKEN: - from_secret: REPO_RO_TOKEN - GIT_USER: pat-s - commands: - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - /opt/R/$R_VERSION/bin/Rscript local/install-bincraft.R - - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' - - | - if [ "$dry_run" = "false" ]; then - /opt/R/$R_VERSION/bin/Rscript local/repair-built-stamp.R "$ARCH" --apply - else - /opt/R/$R_VERSION/bin/Rscript local/repair-built-stamp.R "$ARCH" - fi - backend_options: - docker: - resources: - requests: - memory: 2Gi - cpu: 1000m - limits: - memory: 8Gi - cpu: 2000m diff --git a/.crow/repair-unsafe-flat-objects.yaml b/.crow/repair-unsafe-flat-objects.yaml deleted file mode 100644 index d11084a..0000000 --- a/.crow/repair-unsafe-flat-objects.yaml +++ /dev/null @@ -1,175 +0,0 @@ -# Rebuild every flat object recorded as unable to load under some R minor. -# -# The list comes from `abi_flat_safety`, written by the flat-safety backfill -# from the binaries themselves, so it names exactly the objects that fail at -# dyn.load() somewhere rather than everything a source heuristic suspects. The -# heuristic calls 93% of compiled packages risky; the binaries say 4.3%. -# -# Each object is rebuilt under every R minor installed in the image, with no -# `--sensitive-only` gate. Since bincraft v5.3.0 the destination is decided by -# the built binary's symbols in `upload_single_binary()`, so a package needing a -# per-minor slot lands there and a portable one lands in the flat slot. Gating -# on the source classifier is what let Rcpp slip through and break every R 4.4 -# client on the slot. -# -# crow pipeline create devxy/build-cran-binaries --var repair_unsafe=all - -variables: - # A manual pipeline creation instantiates every file in .crow/, so the default - # must match no matrix row. - repair_unsafe: - description: "Repair target: a specific -, 'all' for every slot, or 'none'." - options: - - none - - all - - alpine-323-amd64 - - alpine-323-arm64 - - alpine-324-amd64 - - alpine-324-arm64 - - redhat-8-amd64 - - redhat-8-arm64 - - redhat-9-amd64 - - redhat-9-arm64 - - redhat-10-amd64 - - redhat-10-arm64 - - ubuntu-2204-amd64 - - ubuntu-2204-arm64 - - ubuntu-2404-amd64 - - ubuntu-2404-arm64 - - ubuntu-2604-amd64 - - ubuntu-2604-arm64 - default: none - -when: - - event: manual - evaluate: 'repair_unsafe == "all" || repair_unsafe == "${OS}-${ARCH}"' - -skip_clone: true - -labels: - group: rpkgs-${ARCH} - -matrix: - include: - - OS: alpine-323 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - - OS: alpine-323 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - - OS: alpine-324 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - - OS: alpine-324 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - - OS: redhat-8 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:8 - - OS: redhat-8 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:8 - - OS: redhat-9 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:9 - - OS: redhat-9 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:9 - - OS: redhat-10 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: redhat:10 - - OS: redhat-10 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: redhat:10 - - OS: ubuntu-2204 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - - OS: ubuntu-2204 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - - OS: ubuntu-2404 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - - OS: ubuntu-2404 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - - OS: ubuntu-2604 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - - OS: ubuntu-2604 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - -steps: - - name: 'Rebuild objects recorded unsafe' - image: reg.devxy.io/rpkgs/build-env-${IMG} - pull: true - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - 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 - GIT_USER: pat-s - R_LIBS_USER: /tmp/R-pkgs - NCPUS: 2 - REPAIR_ARCH: ${ARCH} - commands: - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - mkdir -p /tmp/R-pkgs - - /opt/R/$R_VERSION/bin/Rscript local/install-bincraft.R - - UVR_R_BIN=/opt/R/$R_VERSION/bin/R local/uvr-install.sh RPostgres - - | - set -eu - CODENAME=$(/opt/R/$R_VERSION/bin/Rscript -e 'cat(bincraft::set_codename(NULL))') - /opt/R/$R_VERSION/bin/Rscript local/list-unsafe-flat-objects.R \ - "$$REPAIR_ARCH" "$$CODENAME" > /tmp/unsafe.txt - echo "objects to rebuild: $(wc -l < /tmp/unsafe.txt)" - rc=0 - for RBIN in /opt/R/[0-9]*/bin/R; do - RV=$(basename "$(dirname "$(dirname "$$RBIN")")") - RMINOR=$(echo "$$RV" | cut -d. -f1-2) - echo "=== rebuilding under R $$RV ===" - LIB="/tmp/R-pkgs-$$RMINOR" - mkdir -p "$$LIB" - R_LIBS_USER="$$LIB" "$(dirname "$$RBIN")/Rscript" local/install-bincraft.R || true - R_LIBS_USER="$$LIB" UVR_R_BIN="$$RBIN" local/uvr-install.sh RPostgres || true - while read -r pkg ver; do - [ -z "$$pkg" ] && continue - R_LIBS_USER="$$LIB" "$(dirname "$$RBIN")/Rscript" \ - local/build-one.R "$$pkg" "$$ver" || rc=1 - done < /tmp/unsafe.txt - done - exit $$rc - backend_options: - docker: - resources: - requests: - memory: 5Gi - cpu: 1000m diff --git a/.crow/retire-slot.yaml b/.crow/retire-slot.yaml deleted file mode 100644 index 1b62ba7..0000000 --- a/.crow/retire-slot.yaml +++ /dev/null @@ -1,72 +0,0 @@ -# Delete a retired slot's objects from the bucket. -# -# The config half is a commit, so it runs on a workstation: -# just retire-slot --apply -# -# This half needs the B2 credentials, which only exist in CI. -# `local/retire-slot.R` refuses any slot still listed in `local.rpkgs_slots`, -# so this cannot delete a live slot. Both architectures go together. -# -# Dry run unless RETIRE_APPLY is 'yes': -# -# crow pipeline create devxy/build-cran-binaries --branch main \ -# --var retire_slot=alpine322 --var RETIRE_APPLY=yes - -variables: - # A manual pipeline creation instantiates every file in .crow/, so the - # default must be a value the script never accepts. - retire_slot: - description: "Codename of the slot to retire (e.g. alpine322), or 'none'." - default: none - RETIRE_APPLY: - description: "Set to 'yes' to delete. Anything else reports and changes nothing." - options: - - 'no' - - 'yes' - default: 'no' - -when: - - event: manual - evaluate: 'retire_slot != "none"' - -skip_clone: true - -labels: - group: rpkgs-amd64 - -steps: - - name: 'Delete the retired slot from the bucket' - image: reg.devxy.io/rpkgs/build-env-alpine:3.24 - pull: true - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - B2_S3_ACCESS_KEY: - from_secret: B2_S3_ACCESS_KEY - B2_S3_SECRET_KEY: - from_secret: B2_S3_SECRET_KEY - REPO_RO_TOKEN: - from_secret: REPO_RO_TOKEN - R_LIBS_USER: /tmp/R-pkgs - # Pipeline variables are substituted into the YAML, not exported, so they - # have to be bound here to be readable as env vars in the script below. - RETIRE_SLOT: ${retire_slot} - RETIRE_APPLY: ${RETIRE_APPLY} - commands: - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - mkdir -p /tmp/R-pkgs - - /opt/R/4.5.3/bin/Rscript local/install-bincraft.R - - | - set -eu - APPLY="" - if [ "$$RETIRE_APPLY" = "yes" ]; then - APPLY="--apply" - fi - /opt/R/4.5.3/bin/Rscript local/retire-slot.R "$$RETIRE_SLOT" --assets-only $$APPLY - backend_options: - docker: - resources: - requests: - memory: 2Gi - cpu: 1000m diff --git a/.crow/trial-build-registry.yaml b/.crow/trial-build-registry.yaml deleted file mode 100644 index 7826d3e..0000000 --- a/.crow/trial-build-registry.yaml +++ /dev/null @@ -1,152 +0,0 @@ -# Merge gate for the auto-patch PR (issue #115, step 3). -# For each platform, trial-builds every registry entry the auto-patch branch -# ADDS (vs main) in that platform's own `reg.devxy.io/rpkgs/build-env-*` image, -# with the registry applied. A row with no new entries for its platform is a -# fast no-op. The pipeline is green only if every new entry builds, so it gates -# the PR before merge. Nothing is uploaded/archived/recorded. -# -# The repo uses no `pull_request` triggers, so this runs manually against the -# branch (or on a cron); point it at the auto-patch branch via `patch_branch`: -# crow pipeline create --branch main --var trial_build_registry=true \ -# --var patch_branch=auto/registry-patch-proposals devxy/build-cran-binaries -# -# The gate variable is `trial_build_registry`, named after the pipeline: a -# manual run instantiates every pipeline in `.crow/`, so one without its own -# gate runs on *any* manual trigger in this repo. This one starts a build per -# matrix row on both arches, which is far too expensive to fire by accident. -variables: - trial_build_registry: - description: 'Trial-build the branch new registry entries. Also gates this pipeline.' - options: - - 'true' - - 'false' - default: 'false' - patch_branch: - description: 'Branch whose new registry entries to trial-build.' - default: auto/registry-patch-proposals - -when: - - event: manual - evaluate: 'trial_build_registry == "true"' - - event: cron - cron: trial-build-registry - -skip_clone: true - -labels: - group: rpkgs-${ARCH} - -matrix: - include: - - OS: alpine-323 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - - OS: alpine-323 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - - OS: alpine-324 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - - OS: alpine-324 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - - OS: redhat-8 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:8 - - OS: redhat-8 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:8 - - OS: redhat-9 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:9 - - OS: redhat-9 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:9 - - OS: redhat-10 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: redhat:10 - - OS: redhat-10 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: redhat:10 - - OS: ubuntu-2204 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - - OS: ubuntu-2204 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - - OS: ubuntu-2404 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - - OS: ubuntu-2404 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - - OS: ubuntu-2604 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: ubuntu:resolute - - OS: ubuntu-2604 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: ubuntu:resolute - -steps: - - name: 'Trial-build new registry entries' - image: reg.devxy.io/rpkgs/build-env-${IMG} - pull: true - environment: - B2_S3_ACCESS_KEY: - from_secret: B2_S3_ACCESS_KEY - B2_S3_SECRET_KEY: - from_secret: B2_S3_SECRET_KEY - REPO_RO_TOKEN: - from_secret: REPO_RO_TOKEN - GITHUB_PAT: - from_secret: GITHUB_PAT - PLATFORM: ${OS} - ARCH: ${ARCH} - R_VERSION: ${R_VERSION} - R_LIBS_USER: /mnt/cache/R-pkgs - # Surface the real compiler error when an isolated patched build fails, - # instead of bincraft's opaque "System command 'R' failed" (needs bincraft - # with BINCRAFT_VERBOSE_PATCH_BUILD support; harmless on older versions). - BINCRAFT_VERBOSE_PATCH_BUILD: 'TRUE' - commands: - # Clone main, then check out the auto-patch branch if it exists. When the - # proposer had no candidates it never (re)creates that branch, so a missing - # branch means "nothing to verify" -- no-op cleanly instead of failing the - # clone. - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - git fetch -q origin main - - 'if git ls-remote --exit-code --heads origin ${patch_branch} >/dev/null 2>&1; then git fetch -q origin ${patch_branch} && git checkout -q FETCH_HEAD; else echo "No ${patch_branch} branch; no pending auto-patch proposals to verify."; exit 0; fi' - - mkdir -p /mnt/cache/R-pkgs - - rm -rf /mnt/cache/R-pkgs/00LOCK-* - - /opt/R/$R_VERSION/bin/Rscript local/install-bincraft.R - - /opt/R/$R_VERSION/bin/Rscript local/trial-build-registry.R origin/main - backend_options: - kubernetes: - resources: - requests: - memory: 2Gi - cpu: 2000m - limits: - memory: 4Gi - cpu: 2000m - tolerations: - - key: 'CI' - operator: 'Equal' - value: 'true' - effect: 'NoSchedule' diff --git a/.crow/verify-repo-routing.yaml b/.crow/verify-repo-routing.yaml deleted file mode 100644 index b20c993..0000000 --- a/.crow/verify-repo-routing.yaml +++ /dev/null @@ -1,146 +0,0 @@ -# Install a fixed set of packages from a published slot under every R minor the -# image carries, through each URL form the website tells people to configure, -# and check that each one loads. -# -# This is the end-to-end counterpart to the ABI bookkeeping: `abi_flat_safety` -# records what the binaries say about themselves, this proves what a client -# actually receives once the CDN, the per-minor indexes and the `Path:` field -# have had their say. It runs on the build agents rather than a workstation so -# arm64 is covered on real hardware. -# -# crow pipeline create devxy/build-cran-binaries --var verify_routing=all - -variables: - # A manual pipeline creation instantiates every file in .crow/, so the default - # must match no matrix row. - verify_routing: - description: "Verify target: a specific -, 'all' for every slot, or 'none'." - options: - - none - - all - - alpine-323-amd64 - - alpine-323-arm64 - - alpine-324-amd64 - - alpine-324-arm64 - - redhat-8-amd64 - - redhat-8-arm64 - - redhat-9-amd64 - - redhat-9-arm64 - - redhat-10-amd64 - - redhat-10-arm64 - - ubuntu-2204-amd64 - - ubuntu-2204-arm64 - - ubuntu-2404-amd64 - - ubuntu-2404-arm64 - - ubuntu-2604-amd64 - - ubuntu-2604-arm64 - default: none - -when: - - event: manual - evaluate: 'verify_routing == "all" || verify_routing == "${OS}-${ARCH}"' - -skip_clone: true - -labels: - group: rpkgs-${ARCH} - -matrix: - include: - - OS: alpine-323 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - - OS: alpine-323 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - - OS: alpine-324 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - - OS: alpine-324 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - - OS: redhat-8 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:8 - - OS: redhat-8 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:8 - - OS: redhat-9 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:9 - - OS: redhat-9 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:9 - - OS: redhat-10 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: redhat:10 - - OS: redhat-10 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: redhat:10 - - OS: ubuntu-2204 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - - OS: ubuntu-2204 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - - OS: ubuntu-2404 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - - OS: ubuntu-2404 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - - OS: ubuntu-2604 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - - OS: ubuntu-2604 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - -steps: - - name: 'Verify routing serves loadable binaries' - image: reg.devxy.io/rpkgs/build-env-${IMG} - pull: true - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - REPO_RO_TOKEN: - from_secret: REPO_RO_TOKEN - VERIFY_ARCH: ${ARCH} - commands: - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - | - set -eu - CODENAME=$(/opt/R/$R_VERSION/bin/Rscript -e 'cat(bincraft::set_codename(NULL))') - rc=0 - for RBIN in /opt/R/[0-9]*/bin/R; do - RV=$(basename "$(dirname "$(dirname "$$RBIN")")") - for FORM in arch generic flat; do - echo "=== R $$RV via $$FORM ===" - "$(dirname "$$RBIN")/Rscript" local/verify-repo-routing.R \ - "$$VERIFY_ARCH" "$$CODENAME" "$$FORM" || rc=1 - done - done - exit $$rc - backend_options: - docker: - resources: - requests: - memory: 4Gi - cpu: 1000m diff --git a/.crow/weekly-audit-missing-alpine-321-amd64.yaml b/.crow/weekly-audit-missing-alpine-321-amd64.yaml new file mode 100644 index 0000000..ef5a200 --- /dev/null +++ b/.crow/weekly-audit-missing-alpine-321-amd64.yaml @@ -0,0 +1,52 @@ +when: + - event: cron + cron: weekly-audit-missing-alpine-321-amd64 + - event: manual + evaluate: 'task == "weekly-audit-missing-alpine-321-amd64"' + +skip_clone: true + +steps: + - name: 'Audit missing binaries' + image: reg.devxy.io/rpkgs/build-env-alpine:3.23 + pull: true + environment: + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + PLATFORM: alpine-321 + ARCH: amd64 + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.5.3 + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - mkdir -p /mnt/cache/packages /mnt/cache/R-pkgs + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak(c("git::https://codefloe.com/rpkgs/bincraft.git", "httr2", "jsonlite"))' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/weekly-missing-binaries-audit.R")' + backend_options: + kubernetes: + resources: + requests: + memory: 2Gi + cpu: 2000m + limits: + memory: 4Gi + cpu: 2000m + nodeSelector: + kubernetes.io/arch: amd64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-audit-missing-alpine-321-arm64.yaml b/.crow/weekly-audit-missing-alpine-321-arm64.yaml new file mode 100644 index 0000000..8099c57 --- /dev/null +++ b/.crow/weekly-audit-missing-alpine-321-arm64.yaml @@ -0,0 +1,52 @@ +when: + - event: cron + cron: weekly-audit-missing-alpine-321-arm64 + - event: manual + evaluate: 'task == "weekly-audit-missing-alpine-321-arm64"' + +skip_clone: true + +steps: + - name: 'Audit missing binaries' + image: reg.devxy.io/rpkgs/build-env-alpine:3.23 + pull: true + environment: + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + PLATFORM: alpine-321 + ARCH: arm64 + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.5.3 + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - mkdir -p /mnt/cache/packages /mnt/cache/R-pkgs + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak(c("git::https://codefloe.com/rpkgs/bincraft.git", "httr2", "jsonlite"))' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/weekly-missing-binaries-audit.R")' + backend_options: + kubernetes: + resources: + requests: + memory: 2Gi + cpu: 2000m + limits: + memory: 4Gi + cpu: 2000m + nodeSelector: + kubernetes.io/arch: arm64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-audit-missing-alpine-322-amd64.yaml b/.crow/weekly-audit-missing-alpine-322-amd64.yaml new file mode 100644 index 0000000..75cd8c3 --- /dev/null +++ b/.crow/weekly-audit-missing-alpine-322-amd64.yaml @@ -0,0 +1,51 @@ +when: + - event: cron + cron: weekly-audit-missing-alpine-322-amd64 + - event: manual + +skip_clone: true + +steps: + - name: 'Audit missing binaries' + image: reg.devxy.io/rpkgs/build-env-alpine:3.22 + pull: true + environment: + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + PLATFORM: alpine-322 + ARCH: amd64 + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.5.3 + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - mkdir -p /mnt/cache/packages /mnt/cache/R-pkgs + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak(c("git::https://codefloe.com/rpkgs/bincraft.git", "httr2", "jsonlite"))' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/weekly-missing-binaries-audit.R")' + backend_options: + kubernetes: + resources: + requests: + memory: 2Gi + cpu: 2000m + limits: + memory: 4Gi + cpu: 2000m + nodeSelector: + kubernetes.io/arch: amd64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-audit-missing-alpine-322-arm64.yaml b/.crow/weekly-audit-missing-alpine-322-arm64.yaml new file mode 100644 index 0000000..290c7aa --- /dev/null +++ b/.crow/weekly-audit-missing-alpine-322-arm64.yaml @@ -0,0 +1,50 @@ +when: + - event: cron + cron: weekly-audit-missing-alpine-322-arm64 + - event: manual + +skip_clone: true + +steps: + - name: 'Audit missing binaries' + image: reg.devxy.io/rpkgs/build-env-alpine:3.22 + pull: true + environment: + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + PLATFORM: alpine-322 + ARCH: arm64 + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.5.3 + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - mkdir -p /mnt/cache/packages /mnt/cache/R-pkgs + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak(c("git::https://codefloe.com/rpkgs/bincraft.git", "httr2", "jsonlite"))' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/weekly-missing-binaries-audit.R")' + backend_options: + kubernetes: + resources: + requests: + memory: 2Gi + cpu: 2000m + limits: + memory: 4Gi + cpu: 2000m + nodeSelector: + kubernetes.io/arch: arm64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-audit-missing-alpine-323-amd64.yaml b/.crow/weekly-audit-missing-alpine-323-amd64.yaml new file mode 100644 index 0000000..15c761d --- /dev/null +++ b/.crow/weekly-audit-missing-alpine-323-amd64.yaml @@ -0,0 +1,51 @@ +when: + - event: cron + cron: weekly-audit-missing-alpine-323-amd64 + - event: manual + +skip_clone: true + +steps: + - name: 'Audit missing binaries' + image: reg.devxy.io/rpkgs/build-env-alpine:3.23 + pull: true + environment: + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + PLATFORM: alpine-323 + ARCH: amd64 + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.5.3 + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - mkdir -p /mnt/cache/packages /mnt/cache/R-pkgs + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak(c("git::https://codefloe.com/rpkgs/bincraft.git", "httr2", "jsonlite"))' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/weekly-missing-binaries-audit.R")' + backend_options: + kubernetes: + resources: + requests: + memory: 2Gi + cpu: 2000m + limits: + memory: 4Gi + cpu: 2000m + nodeSelector: + kubernetes.io/arch: amd64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-audit-missing-alpine-323-arm64.yaml b/.crow/weekly-audit-missing-alpine-323-arm64.yaml new file mode 100644 index 0000000..efa41be --- /dev/null +++ b/.crow/weekly-audit-missing-alpine-323-arm64.yaml @@ -0,0 +1,51 @@ +when: + - event: cron + cron: weekly-audit-missing-alpine-323-arm64 + - event: manual + +skip_clone: true + +steps: + - name: 'Audit missing binaries' + image: reg.devxy.io/rpkgs/build-env-alpine:3.23 + pull: true + environment: + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + PLATFORM: alpine-323 + ARCH: arm64 + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.5.3 + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - mkdir -p /mnt/cache/packages /mnt/cache/R-pkgs + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak(c("git::https://codefloe.com/rpkgs/bincraft.git", "httr2", "jsonlite"))' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/weekly-missing-binaries-audit.R")' + backend_options: + kubernetes: + resources: + requests: + memory: 2Gi + cpu: 2000m + limits: + memory: 4Gi + cpu: 2000m + nodeSelector: + kubernetes.io/arch: arm64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-audit-missing-redhat-10-amd64.yaml b/.crow/weekly-audit-missing-redhat-10-amd64.yaml new file mode 100644 index 0000000..d1c53cb --- /dev/null +++ b/.crow/weekly-audit-missing-redhat-10-amd64.yaml @@ -0,0 +1,51 @@ +when: + - event: cron + cron: weekly-audit-missing-redhat-10-amd64 + - event: manual + evaluate: 'task == "weekly-audit-missing-redhat-10-amd64"' + +skip_clone: true + +steps: + - name: 'Audit missing binaries' + image: reg.devxy.io/rpkgs/build-env-redhat:10 + pull: true + environment: + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + PLATFORM: redhat-10 + ARCH: amd64 + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.5.3 + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - mkdir -p /mnt/cache/packages /mnt/cache/R-pkgs + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak(c("git::https://codefloe.com/rpkgs/bincraft.git", "httr2", "jsonlite"))' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/weekly-missing-binaries-audit.R")' + backend_options: + kubernetes: + resources: + requests: + memory: 2Gi + cpu: 2000m + limits: + memory: 4Gi + cpu: 2000m + nodeSelector: + kubernetes.io/arch: amd64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-audit-missing-redhat-10-arm64.yaml b/.crow/weekly-audit-missing-redhat-10-arm64.yaml new file mode 100644 index 0000000..b040da0 --- /dev/null +++ b/.crow/weekly-audit-missing-redhat-10-arm64.yaml @@ -0,0 +1,51 @@ +when: + - event: cron + cron: weekly-audit-missing-redhat-10-arm64 + - event: manual + evaluate: 'task == "weekly-audit-missing-redhat-10-arm64"' + +skip_clone: true + +steps: + - name: 'Audit missing binaries' + image: reg.devxy.io/rpkgs/build-env-redhat:10 + pull: true + environment: + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + PLATFORM: redhat-10 + ARCH: arm64 + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.5.3 + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - mkdir -p /mnt/cache/packages /mnt/cache/R-pkgs + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak(c("git::https://codefloe.com/rpkgs/bincraft.git", "httr2", "jsonlite"))' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/weekly-missing-binaries-audit.R")' + backend_options: + kubernetes: + resources: + requests: + memory: 2Gi + cpu: 2000m + limits: + memory: 4Gi + cpu: 2000m + nodeSelector: + kubernetes.io/arch: arm64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-audit-missing-redhat-8-amd64.yaml b/.crow/weekly-audit-missing-redhat-8-amd64.yaml new file mode 100644 index 0000000..81fb7d0 --- /dev/null +++ b/.crow/weekly-audit-missing-redhat-8-amd64.yaml @@ -0,0 +1,52 @@ +when: + - event: cron + cron: weekly-audit-missing-redhat-8-amd64 + - event: manual + evaluate: 'task == "weekly-audit-missing-redhat-8-amd64"' + +skip_clone: true + +steps: + - name: 'Audit missing binaries' + image: reg.devxy.io/rpkgs/build-env-redhat:8 + pull: true + environment: + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + PLATFORM: redhat-8 + ARCH: amd64 + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.4.3 + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - mkdir -p /mnt/cache/packages /mnt/cache/R-pkgs + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak(c("git::https://codefloe.com/rpkgs/bincraft.git", "httr2", "jsonlite"))' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/weekly-missing-binaries-audit.R")' + backend_options: + kubernetes: + resources: + requests: + memory: 2Gi + cpu: 2000m + limits: + memory: 4Gi + cpu: 2000m + nodeSelector: + kubernetes.io/arch: amd64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-audit-missing-redhat-8-arm64.yaml b/.crow/weekly-audit-missing-redhat-8-arm64.yaml new file mode 100644 index 0000000..0a624f8 --- /dev/null +++ b/.crow/weekly-audit-missing-redhat-8-arm64.yaml @@ -0,0 +1,52 @@ +when: + - event: cron + cron: weekly-audit-missing-redhat-8-arm64 + - event: manual + evaluate: 'task == "weekly-audit-missing-redhat-8-arm64"' + +skip_clone: true + +steps: + - name: 'Audit missing binaries' + image: reg.devxy.io/rpkgs/build-env-redhat:8 + pull: true + environment: + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + PLATFORM: redhat-8 + ARCH: arm64 + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.4.3 + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - mkdir -p /mnt/cache/packages /mnt/cache/R-pkgs + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak(c("git::https://codefloe.com/rpkgs/bincraft.git", "httr2", "jsonlite"))' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/weekly-missing-binaries-audit.R")' + backend_options: + kubernetes: + resources: + requests: + memory: 2Gi + cpu: 2000m + limits: + memory: 4Gi + cpu: 2000m + nodeSelector: + kubernetes.io/arch: arm64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-audit-missing-redhat-9-amd64.yaml b/.crow/weekly-audit-missing-redhat-9-amd64.yaml new file mode 100644 index 0000000..0d4b043 --- /dev/null +++ b/.crow/weekly-audit-missing-redhat-9-amd64.yaml @@ -0,0 +1,52 @@ +when: + - event: cron + cron: weekly-audit-missing-redhat-9-amd64 + - event: manual + evaluate: 'task == "weekly-audit-missing-redhat-9-amd64"' + +skip_clone: true + +steps: + - name: 'Audit missing binaries' + image: reg.devxy.io/rpkgs/build-env-redhat:9 + pull: true + environment: + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + PLATFORM: redhat-9 + ARCH: amd64 + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.4.3 + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - mkdir -p /mnt/cache/packages /mnt/cache/R-pkgs + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak(c("git::https://codefloe.com/rpkgs/bincraft.git", "httr2", "jsonlite"))' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/weekly-missing-binaries-audit.R")' + backend_options: + kubernetes: + resources: + requests: + memory: 2Gi + cpu: 2000m + limits: + memory: 4Gi + cpu: 2000m + nodeSelector: + kubernetes.io/arch: amd64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-audit-missing-redhat-9-arm64.yaml b/.crow/weekly-audit-missing-redhat-9-arm64.yaml new file mode 100644 index 0000000..adda69f --- /dev/null +++ b/.crow/weekly-audit-missing-redhat-9-arm64.yaml @@ -0,0 +1,52 @@ +when: + - event: cron + cron: weekly-audit-missing-redhat-9-arm64 + - event: manual + evaluate: 'task == "weekly-audit-missing-redhat-9-arm64"' + +skip_clone: true + +steps: + - name: 'Audit missing binaries' + image: reg.devxy.io/rpkgs/build-env-redhat:9 + pull: true + environment: + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + PLATFORM: redhat-9 + ARCH: arm64 + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.4.3 + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - mkdir -p /mnt/cache/packages /mnt/cache/R-pkgs + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak(c("git::https://codefloe.com/rpkgs/bincraft.git", "httr2", "jsonlite"))' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/weekly-missing-binaries-audit.R")' + backend_options: + kubernetes: + resources: + requests: + memory: 2Gi + cpu: 2000m + limits: + memory: 4Gi + cpu: 2000m + nodeSelector: + kubernetes.io/arch: arm64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-audit-missing-ubuntu-2204-amd64.yaml b/.crow/weekly-audit-missing-ubuntu-2204-amd64.yaml new file mode 100644 index 0000000..17b759d --- /dev/null +++ b/.crow/weekly-audit-missing-ubuntu-2204-amd64.yaml @@ -0,0 +1,52 @@ +when: + - event: cron + cron: weekly-audit-missing-ubuntu-2204-amd64 + - event: manual + evaluate: 'task == "weekly-audit-missing-ubuntu-2204-amd64"' + +skip_clone: true + +steps: + - name: 'Audit missing binaries' + image: reg.devxy.io/rpkgs/build-env-ubuntu:jammy + pull: true + environment: + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + PLATFORM: ubuntu-2204 + ARCH: amd64 + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.4.3 + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - mkdir -p /mnt/cache/packages /mnt/cache/R-pkgs + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak(c("git::https://codefloe.com/rpkgs/bincraft.git", "httr2", "jsonlite"))' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/weekly-missing-binaries-audit.R")' + backend_options: + kubernetes: + resources: + requests: + memory: 2Gi + cpu: 2000m + limits: + memory: 4Gi + cpu: 2000m + nodeSelector: + kubernetes.io/arch: amd64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-audit-missing-ubuntu-2204-arm64.yaml b/.crow/weekly-audit-missing-ubuntu-2204-arm64.yaml new file mode 100644 index 0000000..4a8591b --- /dev/null +++ b/.crow/weekly-audit-missing-ubuntu-2204-arm64.yaml @@ -0,0 +1,52 @@ +when: + - event: cron + cron: weekly-audit-missing-ubuntu-2204-arm64 + - event: manual + evaluate: 'task == "weekly-audit-missing-ubuntu-2204-arm64"' + +skip_clone: true + +steps: + - name: 'Audit missing binaries' + image: reg.devxy.io/rpkgs/build-env-ubuntu:jammy + pull: true + environment: + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + PLATFORM: ubuntu-2204 + ARCH: arm64 + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.4.3 + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - mkdir -p /mnt/cache/packages /mnt/cache/R-pkgs + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak(c("git::https://codefloe.com/rpkgs/bincraft.git", "httr2", "jsonlite"))' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/weekly-missing-binaries-audit.R")' + backend_options: + kubernetes: + resources: + requests: + memory: 2Gi + cpu: 2000m + limits: + memory: 4Gi + cpu: 2000m + nodeSelector: + kubernetes.io/arch: arm64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-audit-missing-ubuntu-2404-amd64.yaml b/.crow/weekly-audit-missing-ubuntu-2404-amd64.yaml new file mode 100644 index 0000000..2b94959 --- /dev/null +++ b/.crow/weekly-audit-missing-ubuntu-2404-amd64.yaml @@ -0,0 +1,52 @@ +when: + - event: cron + cron: weekly-audit-missing-ubuntu-2404-amd64 + - event: manual + evaluate: 'task == "weekly-audit-missing-ubuntu-2404-amd64"' + +skip_clone: true + +steps: + - name: 'Audit missing binaries' + image: reg.devxy.io/rpkgs/build-env-ubuntu:noble + pull: true + environment: + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + PLATFORM: ubuntu-2404 + ARCH: amd64 + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.4.3 + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - mkdir -p /mnt/cache/packages /mnt/cache/R-pkgs + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak(c("git::https://codefloe.com/rpkgs/bincraft.git", "httr2", "jsonlite"))' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/weekly-missing-binaries-audit.R")' + backend_options: + kubernetes: + resources: + requests: + memory: 2Gi + cpu: 2000m + limits: + memory: 4Gi + cpu: 2000m + nodeSelector: + kubernetes.io/arch: amd64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-audit-missing-ubuntu-2404-arm64.yaml b/.crow/weekly-audit-missing-ubuntu-2404-arm64.yaml new file mode 100644 index 0000000..b9a16dc --- /dev/null +++ b/.crow/weekly-audit-missing-ubuntu-2404-arm64.yaml @@ -0,0 +1,52 @@ +when: + - event: cron + cron: weekly-audit-missing-ubuntu-2404-arm64 + - event: manual + evaluate: 'task == "weekly-audit-missing-ubuntu-2404-arm64"' + +skip_clone: true + +steps: + - name: 'Audit missing binaries' + image: reg.devxy.io/rpkgs/build-env-ubuntu:noble + pull: true + environment: + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + PLATFORM: ubuntu-2404 + ARCH: arm64 + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.4.3 + commands: + - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . + - mkdir -p /mnt/cache/packages /mnt/cache/R-pkgs + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak(c("git::https://codefloe.com/rpkgs/bincraft.git", "httr2", "jsonlite"))' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/weekly-missing-binaries-audit.R")' + backend_options: + kubernetes: + resources: + requests: + memory: 2Gi + cpu: 2000m + limits: + memory: 4Gi + cpu: 2000m + nodeSelector: + kubernetes.io/arch: arm64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-audit-missing.yaml b/.crow/weekly-audit-missing.yaml deleted file mode 100644 index 7072c65..0000000 --- a/.crow/weekly-audit-missing.yaml +++ /dev/null @@ -1,150 +0,0 @@ -# Consolidated weekly-audit-missing pipeline (all platforms, both arches). -# One matrix row per OS/arch replaces the former per-platform files. -# Routing is preserved 1:1: -# - cron: each existing `weekly-audit-missing--` cron fires only -# its matching matrix row (via the per-row `cron:` name filter). -# - manual: pick a target from the `weekly_audit_missing` dropdown; -# "all" fans out every os/arch as parallel matrix workflows. -# Arch placement is via the group label (rpkgs-amd64, rpkgs-arm64). -variables: - # Gates this pipeline. A manual pipeline creation instantiates every file in - # .crow/, and a declared default is applied even when the run never passed - # this variable, so the default must be a value that matches no matrix row. - weekly_audit_missing: - description: "Manual run target: a specific -, 'all' to run every os/arch in parallel, or 'none' to run nothing." - options: - - none - - all - - alpine-323-amd64 - - alpine-323-arm64 - - alpine-324-amd64 - - alpine-324-arm64 - - redhat-8-amd64 - - redhat-8-arm64 - - redhat-9-amd64 - - redhat-9-arm64 - - redhat-10-amd64 - - redhat-10-arm64 - - ubuntu-2204-amd64 - - ubuntu-2204-arm64 - - ubuntu-2404-amd64 - - ubuntu-2404-arm64 - - ubuntu-2604-amd64 - - ubuntu-2604-arm64 - default: none - -when: - - event: cron - cron: weekly-audit-missing-${OS}-${ARCH} - - event: manual - evaluate: 'weekly_audit_missing == "all" || weekly_audit_missing == "${OS}-${ARCH}"' - -skip_clone: true - -labels: - group: rpkgs-${ARCH} - -matrix: - include: - - OS: alpine-323 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - - OS: alpine-323 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - - OS: alpine-324 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - - OS: alpine-324 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - - OS: redhat-8 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:8 - - OS: redhat-8 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:8 - - OS: redhat-9 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:9 - - OS: redhat-9 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:9 - - OS: redhat-10 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: redhat:10 - - OS: redhat-10 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: redhat:10 - - OS: ubuntu-2204 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - - OS: ubuntu-2204 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - - OS: ubuntu-2404 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - - OS: ubuntu-2404 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - - OS: ubuntu-2604 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: ubuntu:resolute - - OS: ubuntu-2604 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: ubuntu:resolute - -steps: - - name: 'Audit missing binaries' - image: reg.devxy.io/rpkgs/build-env-${IMG} - pull: true - environment: - 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 - FORGEJO_TOKEN: - from_secret: FORGEJO_TOKEN - PLATFORM: ${OS} - ARCH: ${ARCH} - R_LIBS_USER: /mnt/cache/R-pkgs - R_VERSION: ${R_VERSION} - commands: - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - mkdir -p /mnt/cache/packages /mnt/cache/R-pkgs - - rm -rf /mnt/cache/R-pkgs/00LOCK-* - - /opt/R/$R_VERSION/bin/Rscript local/install-bincraft.R - - UVR_R_BIN=/opt/R/$R_VERSION/bin/R local/uvr-install.sh RPostgres httr2 jsonlite data.table - - /opt/R/$R_VERSION/bin/R -q -e 'source("local/weekly-missing-binaries-audit.R")' - backend_options: - docker: - resources: - requests: - memory: 2Gi - cpu: 2000m - limits: - memory: 4Gi - cpu: 2000m diff --git a/.crow/weekly-patch-proposals.yaml b/.crow/weekly-patch-proposals.yaml deleted file mode 100644 index 7ea6c97..0000000 --- a/.crow/weekly-patch-proposals.yaml +++ /dev/null @@ -1,72 +0,0 @@ -# Weekly failure-triage proposals (issue #115, steps 3 + 4). -# Classifies the recorded `single_builds` failures and: -# 1. posts/updates a Forgejo issue with the auto-proposable registry entries -# (human reviews, trial-builds, and opens the PR -- nothing merges), -# 2. posts/updates a second Forgejo issue with the classifier's blind spots -# (unclassified failures = candidates for new signatures, and groups -# blocked on a dependency), and prints the feedback-loop metrics to the log. -# Global across platforms (the classifier groups over all of single_builds), so -# a single job -- no matrix. Clones read-only; the only writes are the two -# Forgejo issues via FORGEJO_TOKEN. -# -# Run manually with: -# crow pipeline create --branch main \ -# --var weekly_patch_proposals=true devxy/build-cran-binaries -# -# The gate variable is `weekly_patch_proposals`, named after the pipeline: a -# manual run instantiates every pipeline in `.crow/`, so one without its own -# gate runs on *any* manual trigger in this repo. This one posts and edits -# Forgejo issues, so an unrelated manual run must not fire it. -variables: - weekly_patch_proposals: - description: 'Run the weekly failure triage. Also gates this pipeline.' - options: - - 'true' - - 'false' - default: 'false' - -when: - - event: manual - evaluate: 'weekly_patch_proposals == "true"' - - event: cron - cron: weekly-patch-proposals - -skip_clone: true - -labels: - group: rpkgs-amd64 - -steps: - - name: 'Propose registry patches + track feedback loop' - image: reg.devxy.io/rpkgs/build-env-alpine:3.24 - pull: true - environment: - PGPASS: - from_secret: PGPASS - REPO_RO_TOKEN: - from_secret: REPO_RO_TOKEN - FORGEJO_TOKEN: - from_secret: FORGEJO_TOKEN - R_VERSION: 4.5.3 - R_LIBS_USER: /mnt/cache/R-pkgs - commands: - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - mkdir -p /mnt/cache/R-pkgs - - rm -rf /mnt/cache/R-pkgs/00LOCK-* - - UVR_R_BIN=/opt/R/$R_VERSION/bin/R local/uvr-install.sh RPostgres httr2 jsonlite - - /opt/R/$R_VERSION/bin/Rscript local/propose-patches.R --open-issue - - /opt/R/$R_VERSION/bin/Rscript local/proposal-tracking.R --open-issue - backend_options: - kubernetes: - resources: - requests: - memory: 1Gi - cpu: 2000m - limits: - memory: 2Gi - cpu: 2000m - tolerations: - - key: 'CI' - operator: 'Equal' - value: 'true' - effect: 'NoSchedule' diff --git a/.crow/weekly-rebuild-missing-alpine-322-amd64.yaml b/.crow/weekly-rebuild-missing-alpine-322-amd64.yaml new file mode 100644 index 0000000..2df97fb --- /dev/null +++ b/.crow/weekly-rebuild-missing-alpine-322-amd64.yaml @@ -0,0 +1,64 @@ +when: + - event: cron + cron: weekly-rebuild-missing-alpine-322-amd64 + - event: manual + +skip_clone: true + +labels: + agent: artemis + +steps: + - name: 'Rebuild missing binaries' + image: reg.devxy.io/rpkgs/build-env-alpine:3.22 + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + GIT_USER: pat-s + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.5.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: alpine-322 + ARCH: amd64 + NCPUS: 2 + 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 + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - 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 + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak("httr2")' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/fetch-rebuild-packages-from-issue.R")' + - $XVFB $XVFB_ARGS -- /opt/R/$R_VERSION/bin/R -q -e "sink(stdout(), type = 'message'); options(crayon.enabled = TRUE, Ncpus = $NCPUS, future.globals.onReference = NULL); pkgs <- readLines('/tmp/rebuild_pkgs.txt'); if (length(pkgs) == 0) { cat('Nothing to rebuild\n'); q('no') }; excluded <- jsonlite::fromJSON('local/excluded-packages.json')[['package']]; pkgs <- setdiff(pkgs, excluded); cat(sprintf('Rebuilding %d packages\n', length(pkgs))); n <- length(pkgs); for (i in seq_along(pkgs)) { x <- pkgs[i]; cat(sprintf('[%d/%d] %s\n', i, n, x)); tryCatch(bincraft::build_binary_package(x, tag_limit = 1L, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE), error = function(e) cat(sprintf('ERROR building %s - %s\n', x, conditionMessage(e)))) }" 2>&1 + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: amd64 + node.kubernetes.io/instance-type: AX42 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-rebuild-missing-alpine-322-arm64.yaml b/.crow/weekly-rebuild-missing-alpine-322-arm64.yaml new file mode 100644 index 0000000..11eeca5 --- /dev/null +++ b/.crow/weekly-rebuild-missing-alpine-322-arm64.yaml @@ -0,0 +1,63 @@ +when: + - event: cron + cron: weekly-rebuild-missing-alpine-322-arm64 + - event: manual + +skip_clone: true + +labels: + agent: gaia + +steps: + - name: 'Rebuild missing binaries' + image: reg.devxy.io/rpkgs/build-env-alpine:3.22 + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + GIT_USER: pat-s + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.5.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: alpine-322 + ARCH: arm64 + NCPUS: 2 + 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 + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - 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 + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak("httr2")' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/fetch-rebuild-packages-from-issue.R")' + - $XVFB $XVFB_ARGS -- /opt/R/$R_VERSION/bin/R -q -e "sink(stdout(), type = 'message'); options(crayon.enabled = TRUE, Ncpus = $NCPUS, future.globals.onReference = NULL); pkgs <- readLines('/tmp/rebuild_pkgs.txt'); if (length(pkgs) == 0) { cat('Nothing to rebuild\n'); q('no') }; excluded <- jsonlite::fromJSON('local/excluded-packages.json')[['package']]; pkgs <- setdiff(pkgs, excluded); cat(sprintf('Rebuilding %d packages\n', length(pkgs))); n <- length(pkgs); for (i in seq_along(pkgs)) { x <- pkgs[i]; cat(sprintf('[%d/%d] %s\n', i, n, x)); tryCatch(bincraft::build_binary_package(x, tag_limit = 1L, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE), error = function(e) cat(sprintf('ERROR building %s - %s\n', x, conditionMessage(e)))) }" 2>&1 + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: arm64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-rebuild-missing-alpine-323-amd64.yaml b/.crow/weekly-rebuild-missing-alpine-323-amd64.yaml new file mode 100644 index 0000000..a111e34 --- /dev/null +++ b/.crow/weekly-rebuild-missing-alpine-323-amd64.yaml @@ -0,0 +1,64 @@ +when: + - event: cron + cron: weekly-rebuild-missing-alpine-323-amd64 + - event: manual + +skip_clone: true + +labels: + agent: artemis + +steps: + - name: 'Rebuild missing binaries' + image: reg.devxy.io/rpkgs/build-env-alpine:3.23 + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + GIT_USER: pat-s + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.5.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: alpine-323 + ARCH: amd64 + NCPUS: 2 + 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 + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - 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 + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak("httr2")' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/fetch-rebuild-packages-from-issue.R")' + - $XVFB $XVFB_ARGS -- /opt/R/$R_VERSION/bin/R -q -e "sink(stdout(), type = 'message'); options(crayon.enabled = TRUE, Ncpus = $NCPUS, future.globals.onReference = NULL); pkgs <- readLines('/tmp/rebuild_pkgs.txt'); if (length(pkgs) == 0) { cat('Nothing to rebuild\n'); q('no') }; excluded <- jsonlite::fromJSON('local/excluded-packages.json')[['package']]; pkgs <- setdiff(pkgs, excluded); cat(sprintf('Rebuilding %d packages\n', length(pkgs))); n <- length(pkgs); for (i in seq_along(pkgs)) { x <- pkgs[i]; cat(sprintf('[%d/%d] %s\n', i, n, x)); tryCatch(bincraft::build_binary_package(x, tag_limit = 1L, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE), error = function(e) cat(sprintf('ERROR building %s - %s\n', x, conditionMessage(e)))) }" 2>&1 + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: amd64 + node.kubernetes.io/instance-type: AX42 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-rebuild-missing-alpine-323-arm64.yaml b/.crow/weekly-rebuild-missing-alpine-323-arm64.yaml new file mode 100644 index 0000000..a30cf76 --- /dev/null +++ b/.crow/weekly-rebuild-missing-alpine-323-arm64.yaml @@ -0,0 +1,63 @@ +when: + - event: cron + cron: weekly-rebuild-missing-alpine-323-arm64 + - event: manual + +skip_clone: true + +labels: + agent: gaia + +steps: + - name: 'Rebuild missing binaries' + image: reg.devxy.io/rpkgs/build-env-alpine:3.23 + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + GIT_USER: pat-s + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.5.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: alpine-323 + ARCH: arm64 + NCPUS: 2 + 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 + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - 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 + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak("httr2")' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/fetch-rebuild-packages-from-issue.R")' + - $XVFB $XVFB_ARGS -- /opt/R/$R_VERSION/bin/R -q -e "sink(stdout(), type = 'message'); options(crayon.enabled = TRUE, Ncpus = $NCPUS, future.globals.onReference = NULL); pkgs <- readLines('/tmp/rebuild_pkgs.txt'); if (length(pkgs) == 0) { cat('Nothing to rebuild\n'); q('no') }; excluded <- jsonlite::fromJSON('local/excluded-packages.json')[['package']]; pkgs <- setdiff(pkgs, excluded); cat(sprintf('Rebuilding %d packages\n', length(pkgs))); n <- length(pkgs); for (i in seq_along(pkgs)) { x <- pkgs[i]; cat(sprintf('[%d/%d] %s\n', i, n, x)); tryCatch(bincraft::build_binary_package(x, tag_limit = 1L, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE), error = function(e) cat(sprintf('ERROR building %s - %s\n', x, conditionMessage(e)))) }" 2>&1 + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: arm64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-rebuild-missing-redhat-10-amd64.yaml b/.crow/weekly-rebuild-missing-redhat-10-amd64.yaml new file mode 100644 index 0000000..93054bd --- /dev/null +++ b/.crow/weekly-rebuild-missing-redhat-10-amd64.yaml @@ -0,0 +1,64 @@ +when: + - event: cron + cron: weekly-rebuild-missing-redhat-10-amd64 + - event: manual + +skip_clone: true + +labels: + agent: artemis + +steps: + - name: 'Rebuild missing binaries' + image: reg.devxy.io/rpkgs/build-env-redhat:10 + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + GIT_USER: pat-s + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.5.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: redhat-10 + ARCH: amd64 + NCPUS: 2 + 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 + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - 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 + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak("httr2")' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/fetch-rebuild-packages-from-issue.R")' + - $XVFB $XVFB_ARGS -- /opt/R/$R_VERSION/bin/R -q -e "sink(stdout(), type = 'message'); options(crayon.enabled = TRUE, Ncpus = $NCPUS, future.globals.onReference = NULL); pkgs <- readLines('/tmp/rebuild_pkgs.txt'); if (length(pkgs) == 0) { cat('Nothing to rebuild\n'); q('no') }; excluded <- jsonlite::fromJSON('local/excluded-packages.json')[['package']]; pkgs <- setdiff(pkgs, excluded); cat(sprintf('Rebuilding %d packages\n', length(pkgs))); n <- length(pkgs); for (i in seq_along(pkgs)) { x <- pkgs[i]; cat(sprintf('[%d/%d] %s\n', i, n, x)); tryCatch(bincraft::build_binary_package(x, tag_limit = 1L, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE), error = function(e) cat(sprintf('ERROR building %s - %s\n', x, conditionMessage(e)))) }" 2>&1 + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: amd64 + node.kubernetes.io/instance-type: AX42 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-rebuild-missing-redhat-10-arm64.yaml b/.crow/weekly-rebuild-missing-redhat-10-arm64.yaml new file mode 100644 index 0000000..79a3a11 --- /dev/null +++ b/.crow/weekly-rebuild-missing-redhat-10-arm64.yaml @@ -0,0 +1,63 @@ +when: + - event: cron + cron: weekly-rebuild-missing-redhat-10-arm64 + - event: manual + +skip_clone: true + +labels: + agent: gaia + +steps: + - name: 'Rebuild missing binaries' + image: reg.devxy.io/rpkgs/build-env-redhat:10 + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + GIT_USER: pat-s + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.5.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: redhat-10 + ARCH: arm64 + NCPUS: 2 + 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 + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - 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 + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak("httr2")' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/fetch-rebuild-packages-from-issue.R")' + - $XVFB $XVFB_ARGS -- /opt/R/$R_VERSION/bin/R -q -e "sink(stdout(), type = 'message'); options(crayon.enabled = TRUE, Ncpus = $NCPUS, future.globals.onReference = NULL); pkgs <- readLines('/tmp/rebuild_pkgs.txt'); if (length(pkgs) == 0) { cat('Nothing to rebuild\n'); q('no') }; excluded <- jsonlite::fromJSON('local/excluded-packages.json')[['package']]; pkgs <- setdiff(pkgs, excluded); cat(sprintf('Rebuilding %d packages\n', length(pkgs))); n <- length(pkgs); for (i in seq_along(pkgs)) { x <- pkgs[i]; cat(sprintf('[%d/%d] %s\n', i, n, x)); tryCatch(bincraft::build_binary_package(x, tag_limit = 1L, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE), error = function(e) cat(sprintf('ERROR building %s - %s\n', x, conditionMessage(e)))) }" 2>&1 + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: arm64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-rebuild-missing-redhat-8-amd64.yaml b/.crow/weekly-rebuild-missing-redhat-8-amd64.yaml new file mode 100644 index 0000000..26bf277 --- /dev/null +++ b/.crow/weekly-rebuild-missing-redhat-8-amd64.yaml @@ -0,0 +1,64 @@ +when: + - event: cron + cron: weekly-rebuild-missing-redhat-8-amd64 + - event: manual + +skip_clone: true + +labels: + agent: artemis + +steps: + - name: 'Rebuild missing binaries' + image: reg.devxy.io/rpkgs/build-env-redhat:8 + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + GIT_USER: pat-s + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.4.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: redhat-8 + ARCH: amd64 + NCPUS: 2 + 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 + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - 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 + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak("httr2")' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/fetch-rebuild-packages-from-issue.R")' + - $XVFB $XVFB_ARGS -- /opt/R/$R_VERSION/bin/R -q -e "sink(stdout(), type = 'message'); options(crayon.enabled = TRUE, Ncpus = $NCPUS, future.globals.onReference = NULL); pkgs <- readLines('/tmp/rebuild_pkgs.txt'); if (length(pkgs) == 0) { cat('Nothing to rebuild\n'); q('no') }; excluded <- jsonlite::fromJSON('local/excluded-packages.json')[['package']]; pkgs <- setdiff(pkgs, excluded); cat(sprintf('Rebuilding %d packages\n', length(pkgs))); n <- length(pkgs); for (i in seq_along(pkgs)) { x <- pkgs[i]; cat(sprintf('[%d/%d] %s\n', i, n, x)); tryCatch(bincraft::build_binary_package(x, tag_limit = 1L, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE), error = function(e) cat(sprintf('ERROR building %s - %s\n', x, conditionMessage(e)))) }" 2>&1 + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: amd64 + node.kubernetes.io/instance-type: AX42 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-rebuild-missing-redhat-8-arm64.yaml b/.crow/weekly-rebuild-missing-redhat-8-arm64.yaml new file mode 100644 index 0000000..6b7582f --- /dev/null +++ b/.crow/weekly-rebuild-missing-redhat-8-arm64.yaml @@ -0,0 +1,63 @@ +when: + - event: cron + cron: weekly-rebuild-missing-redhat-8-arm64 + - event: manual + +skip_clone: true + +labels: + agent: gaia + +steps: + - name: 'Rebuild missing binaries' + image: reg.devxy.io/rpkgs/build-env-redhat:8 + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + GIT_USER: pat-s + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.4.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: redhat-8 + ARCH: arm64 + NCPUS: 2 + 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 + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - 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 + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak("httr2")' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/fetch-rebuild-packages-from-issue.R")' + - $XVFB $XVFB_ARGS -- /opt/R/$R_VERSION/bin/R -q -e "sink(stdout(), type = 'message'); options(crayon.enabled = TRUE, Ncpus = $NCPUS, future.globals.onReference = NULL); pkgs <- readLines('/tmp/rebuild_pkgs.txt'); if (length(pkgs) == 0) { cat('Nothing to rebuild\n'); q('no') }; excluded <- jsonlite::fromJSON('local/excluded-packages.json')[['package']]; pkgs <- setdiff(pkgs, excluded); cat(sprintf('Rebuilding %d packages\n', length(pkgs))); n <- length(pkgs); for (i in seq_along(pkgs)) { x <- pkgs[i]; cat(sprintf('[%d/%d] %s\n', i, n, x)); tryCatch(bincraft::build_binary_package(x, tag_limit = 1L, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE), error = function(e) cat(sprintf('ERROR building %s - %s\n', x, conditionMessage(e)))) }" 2>&1 + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: arm64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-rebuild-missing-redhat-9-amd64.yaml b/.crow/weekly-rebuild-missing-redhat-9-amd64.yaml new file mode 100644 index 0000000..c10ac34 --- /dev/null +++ b/.crow/weekly-rebuild-missing-redhat-9-amd64.yaml @@ -0,0 +1,64 @@ +when: + - event: cron + cron: weekly-rebuild-missing-redhat-9-amd64 + - event: manual + +skip_clone: true + +labels: + agent: artemis + +steps: + - name: 'Rebuild missing binaries' + image: reg.devxy.io/rpkgs/build-env-redhat:9 + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + GIT_USER: pat-s + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.4.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: redhat-9 + ARCH: amd64 + NCPUS: 2 + 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 + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - 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 + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak("httr2")' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/fetch-rebuild-packages-from-issue.R")' + - $XVFB $XVFB_ARGS -- /opt/R/$R_VERSION/bin/R -q -e "sink(stdout(), type = 'message'); options(crayon.enabled = TRUE, Ncpus = $NCPUS, future.globals.onReference = NULL); pkgs <- readLines('/tmp/rebuild_pkgs.txt'); if (length(pkgs) == 0) { cat('Nothing to rebuild\n'); q('no') }; excluded <- jsonlite::fromJSON('local/excluded-packages.json')[['package']]; pkgs <- setdiff(pkgs, excluded); cat(sprintf('Rebuilding %d packages\n', length(pkgs))); n <- length(pkgs); for (i in seq_along(pkgs)) { x <- pkgs[i]; cat(sprintf('[%d/%d] %s\n', i, n, x)); tryCatch(bincraft::build_binary_package(x, tag_limit = 1L, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE), error = function(e) cat(sprintf('ERROR building %s - %s\n', x, conditionMessage(e)))) }" 2>&1 + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: amd64 + node.kubernetes.io/instance-type: AX42 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-rebuild-missing-redhat-9-arm64.yaml b/.crow/weekly-rebuild-missing-redhat-9-arm64.yaml new file mode 100644 index 0000000..b693252 --- /dev/null +++ b/.crow/weekly-rebuild-missing-redhat-9-arm64.yaml @@ -0,0 +1,63 @@ +when: + - event: cron + cron: weekly-rebuild-missing-redhat-9-arm64 + - event: manual + +skip_clone: true + +labels: + agent: gaia + +steps: + - name: 'Rebuild missing binaries' + image: reg.devxy.io/rpkgs/build-env-redhat:9 + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + GIT_USER: pat-s + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.4.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: redhat-9 + ARCH: arm64 + NCPUS: 2 + 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 + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - 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 + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak("httr2")' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/fetch-rebuild-packages-from-issue.R")' + - $XVFB $XVFB_ARGS -- /opt/R/$R_VERSION/bin/R -q -e "sink(stdout(), type = 'message'); options(crayon.enabled = TRUE, Ncpus = $NCPUS, future.globals.onReference = NULL); pkgs <- readLines('/tmp/rebuild_pkgs.txt'); if (length(pkgs) == 0) { cat('Nothing to rebuild\n'); q('no') }; excluded <- jsonlite::fromJSON('local/excluded-packages.json')[['package']]; pkgs <- setdiff(pkgs, excluded); cat(sprintf('Rebuilding %d packages\n', length(pkgs))); n <- length(pkgs); for (i in seq_along(pkgs)) { x <- pkgs[i]; cat(sprintf('[%d/%d] %s\n', i, n, x)); tryCatch(bincraft::build_binary_package(x, tag_limit = 1L, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE), error = function(e) cat(sprintf('ERROR building %s - %s\n', x, conditionMessage(e)))) }" 2>&1 + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: arm64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-rebuild-missing-ubuntu-2204-amd64.yaml b/.crow/weekly-rebuild-missing-ubuntu-2204-amd64.yaml new file mode 100644 index 0000000..839d1ed --- /dev/null +++ b/.crow/weekly-rebuild-missing-ubuntu-2204-amd64.yaml @@ -0,0 +1,64 @@ +when: + - event: cron + cron: weekly-rebuild-missing-ubuntu-2204-amd64 + - event: manual + +skip_clone: true + +labels: + agent: artemis + +steps: + - name: 'Rebuild missing binaries' + image: reg.devxy.io/rpkgs/build-env-ubuntu:jammy + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + GIT_USER: pat-s + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.4.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: ubuntu-2204 + ARCH: amd64 + NCPUS: 2 + 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 + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - 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 + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak("httr2")' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/fetch-rebuild-packages-from-issue.R")' + - $XVFB $XVFB_ARGS -- /opt/R/$R_VERSION/bin/R -q -e "sink(stdout(), type = 'message'); options(crayon.enabled = TRUE, Ncpus = $NCPUS, future.globals.onReference = NULL); pkgs <- readLines('/tmp/rebuild_pkgs.txt'); if (length(pkgs) == 0) { cat('Nothing to rebuild\n'); q('no') }; excluded <- jsonlite::fromJSON('local/excluded-packages.json')[['package']]; pkgs <- setdiff(pkgs, excluded); cat(sprintf('Rebuilding %d packages\n', length(pkgs))); n <- length(pkgs); for (i in seq_along(pkgs)) { x <- pkgs[i]; cat(sprintf('[%d/%d] %s\n', i, n, x)); tryCatch(bincraft::build_binary_package(x, tag_limit = 1L, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE), error = function(e) cat(sprintf('ERROR building %s - %s\n', x, conditionMessage(e)))) }" 2>&1 + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: amd64 + node.kubernetes.io/instance-type: AX42 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-rebuild-missing-ubuntu-2204-arm64.yaml b/.crow/weekly-rebuild-missing-ubuntu-2204-arm64.yaml new file mode 100644 index 0000000..d4fadf0 --- /dev/null +++ b/.crow/weekly-rebuild-missing-ubuntu-2204-arm64.yaml @@ -0,0 +1,63 @@ +when: + - event: cron + cron: weekly-rebuild-missing-ubuntu-2204-arm64 + - event: manual + +skip_clone: true + +labels: + agent: gaia + +steps: + - name: 'Rebuild missing binaries' + image: reg.devxy.io/rpkgs/build-env-ubuntu:jammy + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + GIT_USER: pat-s + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.4.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: ubuntu-2204 + ARCH: arm64 + NCPUS: 2 + 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 + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - 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 + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak("httr2")' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/fetch-rebuild-packages-from-issue.R")' + - $XVFB $XVFB_ARGS -- /opt/R/$R_VERSION/bin/R -q -e "sink(stdout(), type = 'message'); options(crayon.enabled = TRUE, Ncpus = $NCPUS, future.globals.onReference = NULL); pkgs <- readLines('/tmp/rebuild_pkgs.txt'); if (length(pkgs) == 0) { cat('Nothing to rebuild\n'); q('no') }; excluded <- jsonlite::fromJSON('local/excluded-packages.json')[['package']]; pkgs <- setdiff(pkgs, excluded); cat(sprintf('Rebuilding %d packages\n', length(pkgs))); n <- length(pkgs); for (i in seq_along(pkgs)) { x <- pkgs[i]; cat(sprintf('[%d/%d] %s\n', i, n, x)); tryCatch(bincraft::build_binary_package(x, tag_limit = 1L, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE), error = function(e) cat(sprintf('ERROR building %s - %s\n', x, conditionMessage(e)))) }" 2>&1 + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: arm64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-rebuild-missing-ubuntu-2404-amd64.yaml b/.crow/weekly-rebuild-missing-ubuntu-2404-amd64.yaml new file mode 100644 index 0000000..8b3edc9 --- /dev/null +++ b/.crow/weekly-rebuild-missing-ubuntu-2404-amd64.yaml @@ -0,0 +1,64 @@ +when: + - event: cron + cron: weekly-rebuild-missing-ubuntu-2404-amd64 + - event: manual + +skip_clone: true + +labels: + agent: artemis + +steps: + - name: 'Rebuild missing binaries' + image: reg.devxy.io/rpkgs/build-env-ubuntu:noble + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + GIT_USER: pat-s + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.4.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: ubuntu-2404 + ARCH: amd64 + NCPUS: 2 + 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 + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - 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 + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak("httr2")' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/fetch-rebuild-packages-from-issue.R")' + - $XVFB $XVFB_ARGS -- /opt/R/$R_VERSION/bin/R -q -e "sink(stdout(), type = 'message'); options(crayon.enabled = TRUE, Ncpus = $NCPUS, future.globals.onReference = NULL); pkgs <- readLines('/tmp/rebuild_pkgs.txt'); if (length(pkgs) == 0) { cat('Nothing to rebuild\n'); q('no') }; excluded <- jsonlite::fromJSON('local/excluded-packages.json')[['package']]; pkgs <- setdiff(pkgs, excluded); cat(sprintf('Rebuilding %d packages\n', length(pkgs))); n <- length(pkgs); for (i in seq_along(pkgs)) { x <- pkgs[i]; cat(sprintf('[%d/%d] %s\n', i, n, x)); tryCatch(bincraft::build_binary_package(x, tag_limit = 1L, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE), error = function(e) cat(sprintf('ERROR building %s - %s\n', x, conditionMessage(e)))) }" 2>&1 + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: amd64 + node.kubernetes.io/instance-type: AX42 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-rebuild-missing-ubuntu-2404-arm64.yaml b/.crow/weekly-rebuild-missing-ubuntu-2404-arm64.yaml new file mode 100644 index 0000000..df4f3f0 --- /dev/null +++ b/.crow/weekly-rebuild-missing-ubuntu-2404-arm64.yaml @@ -0,0 +1,63 @@ +when: + - event: cron + cron: weekly-rebuild-missing-ubuntu-2404-arm64 + - event: manual + +skip_clone: true + +labels: + agent: gaia + +steps: + - name: 'Rebuild missing binaries' + image: reg.devxy.io/rpkgs/build-env-ubuntu:noble + 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 + FORGEJO_TOKEN: + from_secret: FORGEJO_TOKEN + GIT_USER: pat-s + R_PKG_CACHE_DIR: /mnt/cache/pkgcache + R_LIBS_USER: /mnt/cache/R-pkgs + R_VERSION: 4.4.3 + CCACHE_DIR: /mnt/cache/ccache + PLATFORM: ubuntu-2404 + ARCH: arm64 + NCPUS: 2 + 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 + - rm -rf /mnt/cache/R-pkgs/00LOCK-* + - /opt/R/$R_VERSION/bin/R -q -e 'if (!requireNamespace("bincraft", quietly = TRUE) || packageVersion("bincraft") != "4.1.0") pak::pak("git::https://codefloe.com/rpkgs/bincraft.git@v4.1.0")' + - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' + - 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 + - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak("httr2")' + - /opt/R/$R_VERSION/bin/R -q -e 'source("local/fetch-rebuild-packages-from-issue.R")' + - $XVFB $XVFB_ARGS -- /opt/R/$R_VERSION/bin/R -q -e "sink(stdout(), type = 'message'); options(crayon.enabled = TRUE, Ncpus = $NCPUS, future.globals.onReference = NULL); pkgs <- readLines('/tmp/rebuild_pkgs.txt'); if (length(pkgs) == 0) { cat('Nothing to rebuild\n'); q('no') }; excluded <- jsonlite::fromJSON('local/excluded-packages.json')[['package']]; pkgs <- setdiff(pkgs, excluded); cat(sprintf('Rebuilding %d packages\n', length(pkgs))); n <- length(pkgs); for (i in seq_along(pkgs)) { x <- pkgs[i]; cat(sprintf('[%d/%d] %s\n', i, n, x)); tryCatch(bincraft::build_binary_package(x, tag_limit = 1L, 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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_table = 'single_builds', metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'require', metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE), error = function(e) cat(sprintf('ERROR building %s - %s\n', x, conditionMessage(e)))) }" 2>&1 + backend_options: + kubernetes: + resources: + requests: + memory: 5Gi + cpu: 3000m + limits: + memory: 18Gi + cpu: 3000m + nodeSelector: + kubernetes.io/arch: arm64 + tolerations: + - key: 'CI' + operator: 'Equal' + value: 'true' + effect: 'NoSchedule' diff --git a/.crow/weekly-rebuild-missing.yaml b/.crow/weekly-rebuild-missing.yaml deleted file mode 100644 index e54d107..0000000 --- a/.crow/weekly-rebuild-missing.yaml +++ /dev/null @@ -1,406 +0,0 @@ -# Consolidated weekly-rebuild-missing pipeline (all platforms, both arches). -# Three matrix rows per OS/arch, one per shard of that slot's rebuild list. -# Routing is preserved 1:1: -# - cron: each existing `weekly-rebuild-missing--` cron fires only -# its matching matrix rows (via the per-row `cron:` name filter), -# which is now all three shards of that slot. -# - manual: pick a target from the `weekly_rebuild_missing` dropdown; -# "all" fans out every os/arch and shard as parallel matrix -# workflows, while a single - runs its three shards. -# Arch placement is handled by the group label (rpkgs-amd64, rpkgs-arm64). -# -# The shard picks up its own slice and re-derives what is still outstanding -# from the bucket, so a restart resumes rather than replaying; see -# local/rebuild-missing.R. -# -# Re-indexing and the CDN purge deliberately do NOT live here. Three shards -# writing one slot's PACKAGES concurrently would race, so they moved to -# .crow/weekly-rebuild-reindex.yaml, which depends on this pipeline. -variables: - # Gates this pipeline. A manual pipeline creation instantiates every file in - # .crow/, and a declared default is applied even when the run never passed - # this variable, so the default must be a value that matches no matrix row. - weekly_rebuild_missing: - description: "Manual run target: a specific -, 'all' to run every os/arch in parallel, or 'none' to run nothing." - options: - - none - - all - - alpine-323-amd64 - - alpine-323-arm64 - - alpine-324-amd64 - - alpine-324-arm64 - - redhat-8-amd64 - - redhat-8-arm64 - - redhat-9-amd64 - - redhat-9-arm64 - - redhat-10-amd64 - - redhat-10-arm64 - - ubuntu-2204-amd64 - - ubuntu-2204-arm64 - - ubuntu-2404-amd64 - - ubuntu-2404-arm64 - - ubuntu-2604-amd64 - - ubuntu-2604-arm64 - default: none - -when: - - event: cron - cron: weekly-rebuild-missing-${OS}-${ARCH} - - event: manual - evaluate: 'weekly_rebuild_missing == "all" || weekly_rebuild_missing == "${OS}-${ARCH}"' - -skip_clone: true - -labels: - group: rpkgs-${ARCH} - -matrix: - include: - - OS: alpine-323 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - SPLIT_INTO: 3 - SPLIT_INDEX: 1 - - OS: alpine-323 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - SPLIT_INTO: 3 - SPLIT_INDEX: 2 - - OS: alpine-323 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - SPLIT_INTO: 3 - SPLIT_INDEX: 3 - - OS: alpine-323 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - SPLIT_INTO: 3 - SPLIT_INDEX: 1 - - OS: alpine-323 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - SPLIT_INTO: 3 - SPLIT_INDEX: 2 - - OS: alpine-323 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - SPLIT_INTO: 3 - SPLIT_INDEX: 3 - - OS: alpine-324 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - SPLIT_INTO: 3 - SPLIT_INDEX: 1 - - OS: alpine-324 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - SPLIT_INTO: 3 - SPLIT_INDEX: 2 - - OS: alpine-324 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - SPLIT_INTO: 3 - SPLIT_INDEX: 3 - - OS: alpine-324 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - SPLIT_INTO: 3 - SPLIT_INDEX: 1 - - OS: alpine-324 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - SPLIT_INTO: 3 - SPLIT_INDEX: 2 - - OS: alpine-324 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - SPLIT_INTO: 3 - SPLIT_INDEX: 3 - - OS: redhat-8 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:8 - SPLIT_INTO: 3 - SPLIT_INDEX: 1 - - OS: redhat-8 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:8 - SPLIT_INTO: 3 - SPLIT_INDEX: 2 - - OS: redhat-8 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:8 - SPLIT_INTO: 3 - SPLIT_INDEX: 3 - - OS: redhat-8 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:8 - SPLIT_INTO: 3 - SPLIT_INDEX: 1 - - OS: redhat-8 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:8 - SPLIT_INTO: 3 - SPLIT_INDEX: 2 - - OS: redhat-8 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:8 - SPLIT_INTO: 3 - SPLIT_INDEX: 3 - - OS: redhat-9 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:9 - SPLIT_INTO: 3 - SPLIT_INDEX: 1 - - OS: redhat-9 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:9 - SPLIT_INTO: 3 - SPLIT_INDEX: 2 - - OS: redhat-9 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:9 - SPLIT_INTO: 3 - SPLIT_INDEX: 3 - - OS: redhat-9 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:9 - SPLIT_INTO: 3 - SPLIT_INDEX: 1 - - OS: redhat-9 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:9 - SPLIT_INTO: 3 - SPLIT_INDEX: 2 - - OS: redhat-9 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:9 - SPLIT_INTO: 3 - SPLIT_INDEX: 3 - - OS: redhat-10 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: redhat:10 - SPLIT_INTO: 3 - SPLIT_INDEX: 1 - - OS: redhat-10 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: redhat:10 - SPLIT_INTO: 3 - SPLIT_INDEX: 2 - - OS: redhat-10 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: redhat:10 - SPLIT_INTO: 3 - SPLIT_INDEX: 3 - - OS: redhat-10 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: redhat:10 - SPLIT_INTO: 3 - SPLIT_INDEX: 1 - - OS: redhat-10 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: redhat:10 - SPLIT_INTO: 3 - SPLIT_INDEX: 2 - - OS: redhat-10 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: redhat:10 - SPLIT_INTO: 3 - SPLIT_INDEX: 3 - - OS: ubuntu-2204 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - SPLIT_INTO: 3 - SPLIT_INDEX: 1 - - OS: ubuntu-2204 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - SPLIT_INTO: 3 - SPLIT_INDEX: 2 - - OS: ubuntu-2204 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - SPLIT_INTO: 3 - SPLIT_INDEX: 3 - - OS: ubuntu-2204 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - SPLIT_INTO: 3 - SPLIT_INDEX: 1 - - OS: ubuntu-2204 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - SPLIT_INTO: 3 - SPLIT_INDEX: 2 - - OS: ubuntu-2204 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - SPLIT_INTO: 3 - SPLIT_INDEX: 3 - - OS: ubuntu-2404 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - SPLIT_INTO: 3 - SPLIT_INDEX: 1 - - OS: ubuntu-2404 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - SPLIT_INTO: 3 - SPLIT_INDEX: 2 - - OS: ubuntu-2404 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - SPLIT_INTO: 3 - SPLIT_INDEX: 3 - - OS: ubuntu-2404 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - SPLIT_INTO: 3 - SPLIT_INDEX: 1 - - OS: ubuntu-2404 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - SPLIT_INTO: 3 - SPLIT_INDEX: 2 - - OS: ubuntu-2404 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - SPLIT_INTO: 3 - SPLIT_INDEX: 3 - - OS: ubuntu-2604 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - SPLIT_INTO: 3 - SPLIT_INDEX: 1 - - OS: ubuntu-2604 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - SPLIT_INTO: 3 - SPLIT_INDEX: 2 - - OS: ubuntu-2604 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - SPLIT_INTO: 3 - SPLIT_INDEX: 3 - - OS: ubuntu-2604 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - SPLIT_INTO: 3 - SPLIT_INDEX: 1 - - OS: ubuntu-2604 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - SPLIT_INTO: 3 - SPLIT_INDEX: 2 - - OS: ubuntu-2604 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - SPLIT_INTO: 3 - SPLIT_INDEX: 3 - -steps: - - name: 'Rebuild missing binaries' - image: reg.devxy.io/rpkgs/build-env-${IMG} - pull: true - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - 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 - FORGEJO_TOKEN: - from_secret: FORGEJO_TOKEN - GIT_USER: pat-s - UVR_CACHE_DIR: /mnt/cache/uvr/cache - UVR_PACKAGES_DIR: /mnt/cache/uvr/packages - R_LIBS_USER: /mnt/cache/R-pkgs - R_VERSION: ${R_VERSION} - CCACHE_DIR: /mnt/cache/ccache - # parallel make within one package build, matched to the step's CPU limit - MAKE_JOBS: 3 - PLATFORM: ${OS} - ARCH: ${ARCH} - NCPUS: 2 - SPLIT_INTO: ${SPLIT_INTO} - SPLIT_INDEX: ${SPLIT_INDEX} - # Wall clock after which the shard stops cleanly instead of having to be - # killed. A kill matches neither `success` nor `failure`, so it would skip - # the dependent re-index and leave rebuilt binaries behind a stale edge. - REBUILD_BUDGET_HOURS: 20 - commands: - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - . local/compiler-cache.sh - - mkdir -p /mnt/cache/uvr/cache /mnt/cache/uvr/packages /mnt/cache/R-pkgs /mnt/cache/ccache /mnt/cache/packages - - rm -rf /mnt/cache/R-pkgs/00LOCK-* - - /opt/R/$R_VERSION/bin/Rscript local/install-bincraft.R - - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' - - XVFB=$(command -v xwfb-run 2>/dev/null || command -v xvfb-run); XVFB_ARGS="-a"; if command -v xwfb-run >/dev/null 2>&1; then dnf install -y -q weston 2>/dev/null; XVFB_ARGS="-c weston"; fi - - UVR_R_BIN=/opt/R/$R_VERSION/bin/R local/uvr-install.sh RPostgres httr2 - - /opt/R/$R_VERSION/bin/R -q -e 'source("local/fetch-rebuild-packages-from-issue.R")' - - $XVFB $XVFB_ARGS -n $SPLIT_INDEX -- /opt/R/$R_VERSION/bin/Rscript local/rebuild-missing.R $SPLIT_INTO $SPLIT_INDEX $REBUILD_BUDGET_HOURS 2>&1 - backend_options: - docker: - resources: - requests: - memory: 5Gi - cpu: 3000m - limits: - memory: 18Gi - cpu: 3000m diff --git a/.crow/weekly-rebuild-reindex.yaml b/.crow/weekly-rebuild-reindex.yaml deleted file mode 100644 index 1800deb..0000000 --- a/.crow/weekly-rebuild-reindex.yaml +++ /dev/null @@ -1,206 +0,0 @@ -# Re-index and purge after weekly-rebuild-missing. -# -# weekly-rebuild-missing runs three shards per slot. Each of them replaces -# objects in place, so the slot's index still advertises the old MD5 and, for -# anything that had been served from source, no Built stamp. Re-indexing from -# inside a shard would mean three concurrent `upload_package_index()` calls on -# one prefix: each lists the live bucket, so an early lister that uploads last -# publishes an index missing its siblings' work. -# -# So it happens exactly once per slot, here, after every shard has finished. -# `runs_on: [success, failure]` keeps that true when a shard fails; only an -# explicit cancel skips it, and this pipeline can then be triggered on its own. - -variables: - # Mirrors the gate on weekly-rebuild-missing so a manual run re-indexes - # exactly the slots it rebuilt. A manual pipeline creation instantiates every - # file in .crow/, so the default must match no matrix row. - weekly_rebuild_missing: - description: "Manual run target: a specific -, 'all' to run every os/arch in parallel, or 'none' to run nothing." - options: - - none - - all - - alpine-323-amd64 - - alpine-323-arm64 - - alpine-324-amd64 - - alpine-324-arm64 - - redhat-8-amd64 - - redhat-8-arm64 - - redhat-9-amd64 - - redhat-9-arm64 - - redhat-10-amd64 - - redhat-10-arm64 - - ubuntu-2204-amd64 - - ubuntu-2204-arm64 - - ubuntu-2404-amd64 - - ubuntu-2404-arm64 - - ubuntu-2604-amd64 - - ubuntu-2604-arm64 - default: none - -when: - - event: cron - cron: weekly-rebuild-missing-${OS}-${ARCH} - - event: manual - evaluate: 'weekly_rebuild_missing == "all" || weekly_rebuild_missing == "${OS}-${ARCH}"' - -depends_on: - - weekly-rebuild-missing - -runs_on: [success, failure] - -skip_clone: true - -labels: - group: rpkgs-${ARCH} - -matrix: - include: - - OS: alpine-323 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - - OS: alpine-323 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.23 - - OS: alpine-324 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - - OS: alpine-324 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: alpine:3.24 - - OS: redhat-8 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:8 - - OS: redhat-8 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:8 - - OS: redhat-9 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: redhat:9 - - OS: redhat-9 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: redhat:9 - - OS: redhat-10 - ARCH: amd64 - R_VERSION: 4.5.3 - IMG: redhat:10 - - OS: redhat-10 - ARCH: arm64 - R_VERSION: 4.5.3 - IMG: redhat:10 - - OS: ubuntu-2204 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - - OS: ubuntu-2204 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:jammy - - OS: ubuntu-2404 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - - OS: ubuntu-2404 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:noble - - OS: ubuntu-2604 - ARCH: amd64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - - OS: ubuntu-2604 - ARCH: arm64 - R_VERSION: 4.4.3 - IMG: ubuntu:resolute - -steps: - - name: 'Re-index the slot' - image: reg.devxy.io/rpkgs/build-env-${IMG} - pull: true - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - 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 - # The index build reads the ABI classifier cache to decide which packages - # may be carried from the flat slot into a per-minor one. Without the - # password that query fails, and it fails soft, so the run still succeeds - # while quietly using an empty risky set: exactly the state the cache was - # added to fix. It logs one connection error per slot. - PGPASS: - from_secret: PGPASS - REPO_RO_TOKEN: - from_secret: REPO_RO_TOKEN - # bincraft reads the DESCRIPTION of every new or replaced tarball from - # the CRAN mirror on raw.githubusercontent.com, and authenticates with - # this token when it is set. A slot whose published index cannot be read - # is re-read in full, ~25k requests, which the anonymous rate limit would - # cut short. - GITHUB_PAT: - from_secret: GITHUB_PAT - GIT_USER: pat-s - R_LIBS_USER: /mnt/cache/R-pkgs - R_VERSION: ${R_VERSION} - PLATFORM: ${OS} - ARCH: ${ARCH} - commands: - - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . - - mkdir -p /mnt/cache/R-pkgs - - rm -rf /mnt/cache/R-pkgs/00LOCK-* - - /opt/R/$R_VERSION/bin/Rscript local/install-bincraft.R - - UVR_R_BIN=/opt/R/$R_VERSION/bin/R local/uvr-install.sh RPostgres - # The codename is detected from the image's /etc/os-release. - - /opt/R/$R_VERSION/bin/R -q -e 'library(bincraft); upload_package_index(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"))' - - | - FAILED_MINORS="" - 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 "library(bincraft); upload_package_index(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'), metadata_db_host = 'r-binaries.devxy.io', metadata_db_name = 'build_metadata', metadata_db_port = 15432L, metadata_db_user = 'rpkgs', metadata_db_password = Sys.getenv('PGPASS'), metadata_db_sslmode = 'verify-full')" || FAILED_MINORS="$FAILED_MINORS $RMINOR" - done - if [ -n "$FAILED_MINORS" ]; then - echo "Could not republish the per-minor index for:$FAILED_MINORS" >&2 - exit 1 - fi - - - name: Purge CDN cache - image: reg.devxy.io/docker.io/library/alpine:3.24 - environment: - OTEL_R_TRACES_EXPORTER: none - OTEL_R_LOGS_EXPORTER: none - OTEL_R_METRICS_EXPORTER: none - BUNNYNET_API_KEY: - from_secret: BUNNYNET_API_KEY - # cran.rpkgs.com and cran.allianceswisspass.devxy.io are on separate - # Bunny pull zones, so both must be purged after the shared origin changes. - # The staging zone is listed too. It shares the B2 origin, so an index - # it still holds is a stale copy of the same object, and its - # cache_expiration_time is the same ~370 days: without a purge here it - # serves pre-reindex indexes indefinitely and any verification run - # against it measures the past. - BUNNY_PULLZONES: '3857050 cran.allianceswisspass.devxy.io cran-rpkgs-test.b-cdn.net' - commands: - - apk add --no-cache -q bash curl jq - # Crow carries the checkout from the re-index step into this step. - - bash scripts/purge_cdn_zone.sh "$BUNNYNET_API_KEY" $BUNNY_PULLZONES - # Runs on every row rather than on one designated slot: a cron fires only - # its own slot's row, so gating on a named slot would leave every other - # slot unpurged. A manual "all" run therefore purges the zone 18 times, - # which is a cheap API call and rare. - # - # Run it even when the re-index above failed: the objects were still - # replaced, and a stale edge is exactly what keeps them hidden. - when: - - status: [success, failure] diff --git a/.editorconfig b/.editorconfig index 82fac74..734c5ee 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,10 +11,6 @@ insert_final_newline = true [*.md] trim_trailing_whitespace = false -# Markdown code fences hold verbatim content (logs, snippets) whose -# indentation must not be forced to the source indent rules. -indent_style = unset -indent_size = unset # Ignore paths [/collections/ansible_collections/community/**] diff --git a/.editorconfig-checker.json b/.editorconfig-checker.json deleted file mode 100644 index f7abef3..0000000 --- a/.editorconfig-checker.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Exclude": ["^LICENSE\\.md$", "^benchmark/", "^docker/reprex/"] -} diff --git a/.gitignore b/.gitignore index c072661..94e2c2f 100644 --- a/.gitignore +++ b/.gitignore @@ -99,10 +99,3 @@ docs/ local/test.R .DS_Store docs/ - -# Superpowers SDD scratch (briefs, reports, ledger) -.superpowers/ - -# Internal design docs (plans and specs) are kept out of the repo. -plans/ -specs/ diff --git a/.markdownlint-cli2.yaml b/.markdownlint-cli2.yaml deleted file mode 100644 index 66e7cc8..0000000 --- a/.markdownlint-cli2.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Rules live in .markdownlint.yaml; this file only sets cli2 options. -ignores: - - LICENSE.md - - docs/superpowers/** diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 960f7aa..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,59 +0,0 @@ -# cSpell:ignore autofix autoupdate -# Excluded: verbatim GPL license and auxiliary shell scripts with intentional -# in-string formatting (reformatting would corrupt their output). -exclude: | - (?x)^( - LICENSE\.md| - benchmark/| - docker/reprex/ - ) -# The `^local/patches/.*\.patch$` excludes below keep unified diffs byte-exact: -# a context line for a blank line is a single space, and stripping it (or -# appending a newline) makes `git apply` reject the patch, which surfaces as -# "patch did not apply cleanly" at build time rather than as a lint failure -# here. The exclusions are per-hook, not global, so `validate patch registry` -# still runs when a patch changes. -repos: - - repo: builtin - hooks: - - id: end-of-file-fixer - exclude: ^local/patches/.*\.patch$ - - id: trailing-whitespace - exclude: ^local/patches/.*\.patch$ - args: - - --markdown-linebreak-ext=md - - repo: https://github.com/DavidAnson/markdownlint-cli2 - rev: v0.24.2 - hooks: - - id: markdownlint-cli2 - - repo: https://github.com/rbubley/mirrors-prettier - rev: v3.10.1 - hooks: - - id: prettier - - repo: https://github.com/posit-dev/air-pre-commit - rev: 0.13.0 - hooks: - - id: air-format - - repo: https://github.com/editorconfig-checker/editorconfig-checker - rev: v4.0.2 - hooks: - - id: editorconfig-checker - exclude: ^local/patches/.*\.patch$ - - repo: https://github.com/adrienverge/yamllint.git - rev: v1.38.0 - hooks: - - id: yamllint - args: [--strict, -c=.yamllint.yaml] - - repo: local - hooks: - - id: yaml-file-extension - name: Check if YAML files has *.yaml extension. - entry: YAML filenames must have .yaml extension. - language: fail - files: .yml$ - - id: validate-patches - name: validate patch registry - entry: Rscript local/validate-patches.R - language: system - files: ^local/(patches/|validate-patches\.R$) - pass_filenames: false diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 0e4b780..0000000 --- a/.prettierignore +++ /dev/null @@ -1 +0,0 @@ -LICENSE.md diff --git a/.terraform.lock.hcl b/.terraform.lock.hcl index 7095056..1f15eb6 100644 --- a/.terraform.lock.hcl +++ b/.terraform.lock.hcl @@ -2,79 +2,79 @@ # Manual edits may be lost in future updates. provider "registry.opentofu.org/hashicorp/http" { - version = "3.6.3" + version = "3.6.0" hashes = [ - "h1:4Qcn3THnwpzEH7EJvhnDYw82YM/+Fs4x5rjtaOdHIGg=", - "h1:DWXJhjYQ66frFZ2edx766sUWDPoPTsWcO8VeL1TQmj0=", - "h1:ISETodakZAv3gUBLFHm1+JpKB0vUXzOSmJGlyTvap0A=", - "h1:IWCGxH32+DkaMeH7xd1SCggVeuhKnKOlkKxlRfQnSlc=", - "h1:JrmuoX6FTlDFJDqveHpyO0xCOyWd40BVTAEFGmwbsPI=", - "h1:OqnVFnmMgeKLZ0l32P80o6DdAhd2ug0nJmEcngf6u/U=", - "h1:Se19S4Etttxlm6u/fT0JbvqfsTJjNusWK5pe2Hb1Aso=", - "h1:Sj+741LS543TKq6nf2MXCKzhzEygGgE8ptZKZhWh1N0=", - "h1:T8pVs0L1oME182/NXYte0G65aOxNod8fhKd6Gi7l+04=", - "h1:VYtHHeZQ+jzrqFppK/eAzdj3dMXn4wPYvfWn9STSaKg=", - "h1:Xkog5MBnip5VSOe8gkMAg/s+fBSpuc2yOPtoMY78mVQ=", - "h1:Xoun8WNhPBF/Acv6vvBJcOtPS30rWL8bDbPBXAZkWXA=", - "h1:b8JSDcp7TH6fQYII+ZZSrMlyAyyP8oSA6FPLs+2Hm3g=", - "h1:bK4m/bKTU8PjLG4G3wEdoRjqmFSB222h1ue0Jxdsp1U=", - "h1:sIiP0wiUT/sXTzwxUoAcEnTgxDkWQZUspChLs/SbXI8=", - "zh:0551a71cf3c063c8c4925fb3bc95e9145da6440887e8513040ea49ea1ecf61ed", - "zh:19f379bb524434d05f5c917371c8d993491058cf577a6c66ebbf1b26a9924003", - "zh:2da5794d9f33f5ba8bdc74de7422b3289f1862be7583fcd86328d28a35a533d9", - "zh:3e3d463e11d3a0d1eb54d4a4936d5de42395271e00a0aa884b27f00ca98d246d", - "zh:476a140b360acb9ca589b7de6a5a8a379aabab4e034fd2dbf4be033c21749907", - "zh:47f46c2a71075a414049f9c3382dad1b6a0fa3b02a67ed8b7db1e7e24dac1960", - "zh:5845ccfc22524f8b2b76a8b790569183e70962b05f8767738edcd4a1b86c0c23", - "zh:80b341609f5f962f709bae424860334e69e1fe6d12b9027f9c0355a1da63eb02", - "zh:94cd85fd04a0b36a8e622efc63e08c34a6ba135713dd9c7a60059af55aea6876", - "zh:abee98f71480a9485f85dee138d9c120d0a0bccb77c700e03fe9585ad0538673", - "zh:ba330dc3fd22cb646d225b0e5e1263a1aa5493c7e880f97b22788e3702a93acd", - "zh:c3534ef0998dba2a3b79d4c993197ed86f1482dd451479ae8244d92cf7b3b3a9", - "zh:d2a2d76caa8256430cae2238f91ca4d5cdb8aa50cccd0c057c97c229ae8508d5", - "zh:ec3f1132210103816061bcff2043e852d9dc2add1857af4620f49059771e1646", - "zh:f3294fc74d18ada739f968b4e0b5ec65c0acb6a821c777909c6c54e3c54cf771", + "h1:0n4RBz9zNw6TTddh5+x7E8L2+qzPXNwKhK4uoZ/DUwE=", + "h1:22Ob7lpzMBSqdrCvoFN5EgmhGPHPBovV/9qo0c/Cd+A=", + "h1:2IRBvmWOYrq/ooaYYn2i86jZb7iIUvlg0KlmOMfDHoQ=", + "h1:5mucXikk4OcW3un3u94QnMx4AB4Wfih+sXeMd5QxSNk=", + "h1:5oU7Zm+2gAVGmxqtJ9E8uTudUkYy/DEn/y3IWphdv4k=", + "h1:5w0R4b1/VSzpqQF1tXXPr/qmaQLPVRXamOmPKWFcTk4=", + "h1:AEVeJr8xGmwad+JUUQ833C3x5d4W+W2szF5DfwxYppw=", + "h1:CPHJ+0zQbS/cX1m55Y90jIOgf1jV3ocUUnqsXAh+9Eg=", + "h1:JPewnGDOJudNer5+ghqwXoaJkfot3QRq9uiEYvo+JHU=", + "h1:QzbluV2vQLxsJYxjpziQCmPndIoJ/UGS4/UHH/GpwUM=", + "h1:TjUNbUdqweRBq/ycQ4ixpNkx5qaYwpXEOn9QCpqNZP8=", + "h1:XNbcODP60ajj21N/OO7af8bBg1ltIsYkq9egn7BYbiY=", + "h1:tgrbgmX7WYQz9G9ncgu7TkpVB+RlLjJA/Rvp9KPlZH8=", + "h1:vLxthX/ZWsOZ+aHKbAMqmNKqD0K5f4nJ8ppy0Ioyup0=", + "h1:wZOdGBAZkY8OKEPjKz82j1HloAKOmmvtjWyTxM+I110=", + "zh:0f719fa5426bc883e9fa6abf7f6498e48025edafbc29015e2f5c028f1cca3b9d", + "zh:1b4d7dafefd6c61764b2f9ed6943ceb9a200dee3590d18747e3a5f6b20ce85e0", + "zh:1d23a712984866d29f7b07028a4e99c783c71f1a5dddf08bc3d4e7da9d91a1fa", + "zh:257d23d58c3bb024b6bc8eb88736eaf912e934ad47c639d0c3c742bddda849a1", + "zh:479860e1a5468f5e04013b9364c9496d7ed0804bf9a1acd8e07558d57609993d", + "zh:4cb5e681bf599b411b27c4a2c4066a5fb2ed79aaa3a1a3cb5a30002fec062ce9", + "zh:4fb35c3f643dae9f3670d719397a415f815a0b95f8ed7bd8a72f27a94ba78092", + "zh:59ba40825ab38db5b4a0989a2db0df35cc15d8984f898176011ba352f27d77b7", + "zh:61fc1252eb88088638f4c69ea4e2171cde2e5089fa632ac1e943b13787348f73", + "zh:7c5d6dd5f7cbc460e95d368be35c29b4e0402069b8912dbd5d1cd7fa9acef216", + "zh:7f76d756240d4284642f359ad470226e5378670239aadc366ef54d9d914d4d2e", + "zh:8133ad0814098177e0d067c816ccf1bf48bbadacd18f6f2c808c90447505723b", + "zh:c93be06269bb728f1968f8c50506de56c887017ac1d6e4be1f925651d8437eb6", + "zh:ef47b78a10a82e6cf53344a6a85a94041c28286c10a70541c564d762f1cfede0", + "zh:f5796a53a74999135bd9087aff50fddda59129d09b2f9b1902ff8c0c1e047e48", ] } provider "registry.terraform.io/bunnyway/bunnynet" { - version = "0.20.3" - constraints = "~> 0.20" + version = "0.14.2" + constraints = "~> 0.14" hashes = [ - "h1:09RqUsHrSx1IZ7GZsjn5J7vxqG5jv9aTJe9qR7amJJs=", - "h1:0HE3kahGf8gl1wWze3+wA8+oMkRnIQwdVeDmwm6LtZc=", - "h1:1QQgmqEu46pDn0KR27VSQ0Bi2E87CjcNseP4JgQn8C8=", - "h1:3oouE6cghziTZJ+l+udbXi03wNjH/aYKZETkQ3z9+hU=", - "h1:4ABuqzs2BlJu1bNHkHvd0b4NY1PmWYeqtd+32fR3Wmk=", - "h1:5u3+Nk4DpAIuW0mDbItelbiZL5KWKcLLdh/szuXJfEM=", - "h1:DC9++/g5hv8W9M3YvWn27PC/NBXbfKjtI7XbfNy4Y+Q=", - "h1:DH3JLDv9oGtUxQi3eCLzUm9OILS4oBO+/T2iSu7fFAg=", - "h1:FnFnDiIyzoroOSf6zHyejpN1bvyo9PqwfSfWm0FcThs=", - "h1:Lb95sYGHhBThec7qXeUPFyVdkM1ViDytYkA3vYtUfYo=", - "h1:RFA0Pm6G8ZbaIrDnDrSHGXGqcfPIJJCXiWQcO83R5CE=", - "h1:dqebzlaxgTHfPfotskbJ72Nl6ft/exl04CwR9f8Zqz8=", - "h1:iHUmCyzRcantigqlJYtTjFUhjt8udTpShton09isK2c=", - "h1:lltTH48SIjhUY1v5TBIxp96xqC8aaiik0HoAJYUHqQM=", - "h1:o09J6fw7vV/M7J/DYfVHsNUZnk8c3aYMU3p+nnpMWj8=", - "h1:ofBGqkMXdAtVMpmGCXoKQj6hlwsYYk1L7mvuESSxLHk=", - "h1:t/YBNaqpoJuMz7b+TjRdzNuwWbnGZvByAz7wUklX22M=", - "zh:256f3fbfbebb6383ce720001d024bf267c299a48c559d96c20f8f95262030267", - "zh:28dfae8191b836bad53fab92305298d6ce111c825ab6d857794e95c447c09d83", - "zh:315a6a933184bf7aed0e45bec3e820b7196bdc643bed9194a760b74ffb12fd62", - "zh:427c563c207efc9b8805b90fcd79b200510ab8d2e5216a3ece6c44806027dfd5", - "zh:4a71a7f161416d4c3270724c62d04f75c24d0c009b06b1d3521a0df755395d60", - "zh:4edb43070df5112a58baa85bac209465f479713bd722800723bdbf7686f518d6", - "zh:533cdd87680b68c56025a9c60ca0cfc582c285136292be2dd79046126e76bc0d", - "zh:59c1a09dcd148f053ce26ed34788ca05b7307c2e8e8e1f78e6d621b93533f1bf", - "zh:60e1bbe4f679bf5c7565ebea38c4cbca84b578e1458d3ba92e75b31433647516", - "zh:7621c7380f91d44727d53c238bc78c66a04cd2f8e302ae173e2f48d7558fdec6", - "zh:876a61ff9b46f5092531b6808903002285952683e05625d6180acbc8f5d642b0", - "zh:8840722da44ebbf4286b1f2da6263d1f550cad2f7445d4136c98758f7adcfe79", + "h1:/83HKJVEe5PlXxETNi3QYL0Tp9CkKZ6WS7IUhGG/OYU=", + "h1:3DUcGLigdB+8Bu8hh82yoLV+5m2zjrr5HC/QwG56aAY=", + "h1:7q5hf9ODMChDRsDKGJwv8EIlr5vzh3YlZjr3eEzkqN4=", + "h1:APYf6Y7TVdn8lU9C0aR2f1aUnLe652B4HRS9NOMMous=", + "h1:DmE7sOE8wrkYUsGDhUwhonG1LHJZS73IfkzNyACCJJM=", + "h1:K1OeDvRN2GuLjtwCIYuJXpXQYNaaPPknI165CTFyy9c=", + "h1:WPM2ucudI9tm75UoGc0rH9ZM0eKlhTGz5sgO3k4iN7E=", + "h1:WSOCqiEhlK450HYNKwMlUeI5O9inuCaNX5teWZUV/vw=", + "h1:XqaxnjsTBPtiqvHdTjEa0IVgMO+FZhcBxcqE1ALFNzI=", + "h1:YYoBZijn79PiwrIBwv/kb3PP0HzLm3SUxBIzwiuOots=", + "h1:enK6/t/ETDf4iNMrHygg2w9W//K/L0E4lML/bK+kLVc=", + "h1:gOEm/6/hbrg9BWOrsdHSB/GgZcma5zfytEbEDchDj/k=", + "h1:pQ9zZXoKrZRFcUj0OLRFnJK0P/PgY5S+4TpiqbRR5hA=", + "h1:qXl1v7FweyP8/DuzrQIh7LxDbWsWUo+u/wzqB0A93EU=", + "h1:vTuPTvNy3Y/SpmQqnNE1xSEjEoaJYc0b33+tl7q19Gg=", + "h1:wlS2vpTqH0PG85MPk/N1Q9CmtH+jL4pRjXLAkubSOK4=", + "h1:yuwpqTkuqKNwhwEDIOeJdzISZZxECxMiboDUqNHby6Y=", + "zh:019a5c9d068133d0414ab5cf043814a592b1b80f1dcc4afac5ee35d2c43e2409", + "zh:07ba98c56711b584f28dfe7eaea4bbb803ce0e0d7b793b06bb9c6e8ac8358a25", + "zh:0c0e2c343d047221dd0c3f99df6e24ff23e5c982507b634c8e5ed0bf654be2a0", + "zh:0efbabcec9d2bd802bc2cb043e4e7ca7be35716fcec890893b6847fdd7afd05b", + "zh:26a17d31655d45cefab9e1fa76cfb9189eb88d65ce8b3d9922a81f5d2345117e", + "zh:29b3c2447bf202ca33866f724dbe4da28be1e0c988531cd79428cba3ef42b838", + "zh:2bfb3f49610874cb44b2e4122e56a5048b634ef9461c1d02baff81e3c3f9dd91", + "zh:4a6f1db14163c0005eb04eafe1c395d662030a04856e1d08de68623f67c61d59", + "zh:5030883e81c4a2b4a1091cb40d18457dd4de72ce95907c2508184c8df289337f", + "zh:561c6104fd529ccc1da106ed4a8c54ab953f00f5cd0bfec737561c0756639734", + "zh:75eb1fc005852002dd42d3369672db93b423306ccf7b271c4d4c5c372b4924d0", + "zh:7775c4c1663af6f07efe9c0bbabeb66117bb734c1d21fb7e1358f29a18482baa", "zh:890df766e9b839623b1f0437355032a3c006226a6c200cd911e15ee1a9014e9f", - "zh:b2fd5fb60183750d6403a2411eb7a36f3a9a3fad39e9ad4c65c8536f58d54614", - "zh:b69bdd246040e3792a87acbf963d5c3f6bb5b5513dd49b5df3d7ba629450cd79", - "zh:cbbd0b28082eae5585860a4cac1d19b42c9fe692caa167bec4ec0571bcf4634c", - "zh:e08440881ef438969bab652af115e471e5645ed25b4c7e983ec6ba9cf6933505", - "zh:ff7540cebcb08f8a211890dad58777d54a74649a9231b25d10751208371f2826", + "zh:c22bf8a5bb54c67531f944a15383ef6821ef3073e3036e05a2a8253c3e030443", + "zh:d1be91e623365a81203dbafedaf908d2cffd70ddedda3e2da6258fd227176086", + "zh:f7c9920523f9e82c1fee0c3d6ec2872eb322ddadf8af4ffff41d8fca397922e7", + "zh:f95f455cfdda5ad7f972606a6eaaa2a2a4efb1c3e4c0f7fc55631928266311c4", + "zh:fbfab962729139dcd6ac9529f395be296febcb2aba9017733f58cd1e9c186802", ] } diff --git a/.yamllint.yaml b/.yamllint.yaml deleted file mode 100644 index d0370a3..0000000 --- a/.yamllint.yaml +++ /dev/null @@ -1,19 +0,0 @@ -rules: - comments: - require-starting-space: false - ignore-shebangs: true - min-spaces-from-content: 1 - braces: - min-spaces-inside-empty: 0 - max-spaces-inside-empty: 0 - min-spaces-inside: 0 - max-spaces-inside: 1 - document-start: - present: false - indentation: - spaces: 2 - indent-sequences: true - # .crow/* workflows embed long single-line R commands (>1k chars) - line-length: disable - new-lines: - type: unix diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index faae5f1..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,14 +0,0 @@ -# CLAUDE.md - -Crow CI pipelines (`.crow/`) and local tooling (`local/`) that build CRAN binary packages (incl. Alpine/musl) and upload them to Backblaze B2. - -## Conventions - -- **PRs:** the remote is Forgejo on `codefloe.com`; use `fj -H codefloe.com` (not `gh`). -- **Storage:** Backblaze B2 bucket `devxy-r-builds` (endpoints configured in the `.crow/` pipelines). - -## Gotchas - -- **B2 requires authentication for the list-bucket API.** Anonymous GET only works for individual public-read objects — an empty listing means missing credentials, not an empty bucket. -- Weekly-rebuild pipelines run for hours; watch them as background tasks and fetch Crow logs yourself instead of having the user paste progress. -- musl builds of packages with bundled native deps (e.g. RcppParallel/TBB) recur as failures; check for an existing patch before re-deriving a fix. diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..0c960d9 --- /dev/null +++ b/Justfile @@ -0,0 +1,13 @@ +# just build-all alpine 3.22 arm64 4.5.3 odbc 1 +build-all OS OS_VERSION ARCH R_VERSION PACKAGE NCPUS: + docker run --rm -it --platform linux/{{ARCH}} -v ./:/package -e AWS_ACCESS_KEY_ID="$HETZNER_S3_ACCESS_KEY_K3S" -e AWS_SECRET_ACCESS_KEY="$HETZNER_S3_SECRET_KEY_K3S" -e PGPASS="$PGPASS" -e NCPUS={{NCPUS}} --pull=always reg.devxy.io/rpkgs/build-env-{{OS}}:{{OS_VERSION}} bash -c '/opt/R/{{R_VERSION}}/bin/R -q -e "install.packages(\"pak\", repos = sprintf(\"https://r-lib.github.io/p/pak/stable/%s/%s/%s\", .Platform\$pkgType, R.Version()\$os, R.Version()\$arch))" && /opt/R/{{R_VERSION}}/bin/R -q -e "pak::pak(\"git::https://codefloe.com/rpkgs/bincraft.git\")" && /opt/R/{{R_VERSION}}/bin/R -q -e "bincraft::build_binary_package(\"{{PACKAGE}}\", platform = \"{{OS}}\", force=TRUE, s3_endpoint = \"https://hel1.your-objectstorage.com\", s3_region = \"hel1\", s3_bucket = \"devxy-r-package-binaries-hel1\", s3_access_key_id = Sys.getenv(\"HETZNER_S3_ACCESS_KEY_K3S\"), s3_secret_access_key = Sys.getenv(\"HETZNER_S3_SECRET_KEY_K3S\"), metadata_db_host = \"r-binaries.devxy.io\", metadata_db_name = \"build_metadata\", metadata_db_table = \"single_builds\", metadata_db_user = \"rpkgs\", metadata_db_password = Sys.getenv(\"PGPASS\"), metadata_db_sslmode = \"require\", metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)"' + +# just build-single alpine 3.22 arm64 4.5.3 odbc 1.5.0 1 +# just build-single alpine 3.22 arm64 4.5.3 sf latest 1 +# just build-single ubuntu noble arm64 4.4.3 rlang 1.1.6 1 +build-single OS OS_VERSION ARCH R_VERSION PACKAGE TAG NCPUS: + docker run --rm -it --platform linux/{{ARCH}} -v ./:/package -e AWS_ACCESS_KEY_ID="$HETZNER_S3_ACCESS_KEY_K3S" -e AWS_SECRET_ACCESS_KEY="$HETZNER_S3_SECRET_KEY_K3S" -e PGPASS="$PGPASS" -e NCPUS={{NCPUS}} --pull=always reg.devxy.io/rpkgs/build-env-{{OS}}:{{OS_VERSION}} bash -c '/opt/R/{{R_VERSION}}/bin/R -q -e "install.packages(\"pak\", repos = sprintf(\"https://r-lib.github.io/p/pak/stable/%s/%s/%s\", .Platform\$pkgType, R.Version()\$os, R.Version()\$arch))" && /opt/R/{{R_VERSION}}/bin/R -q -e "pak::pak(\"git::https://codefloe.com/rpkgs/bincraft.git\")" && /opt/R/{{R_VERSION}}/bin/R -q -e "bincraft::build_binary_package(\"{{PACKAGE}}\", tag = \"{{TAG}}\", platform = \"{{OS}}\", force=TRUE, s3_endpoint = \"https://hel1.your-objectstorage.com\", s3_region = \"hel1\", s3_bucket = \"devxy-r-package-binaries-hel1\", s3_access_key_id = Sys.getenv(\"HETZNER_S3_ACCESS_KEY_K3S\"), s3_secret_access_key = Sys.getenv(\"HETZNER_S3_SECRET_KEY_K3S\"), metadata_db_host = \"r-binaries.devxy.io\", metadata_db_name = \"build_metadata\", metadata_db_table = \"single_builds\", metadata_db_user = \"rpkgs\", metadata_db_password = Sys.getenv(\"PGPASS\"), metadata_db_sslmode = \"require\", metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)"' + +# just process-updates redhat 9 arm64 4.4.3 'lubridate::interval(lubridate::today() - 4, lubridate::today() - 4)' +process-updates OS OS_VERSION ARCH R_VERSION interval: + docker run --rm -it --platform linux/{{ARCH}} -e AWS_ACCESS_KEY_ID="$HETZNER_S3_ACCESS_KEY_K3S" -e AWS_SECRET_ACCESS_KEY="$HETZNER_S3_SECRET_KEY_K3S" -e PGPASS="$PGPASS" --pull=always reg.devxy.io/rpkgs/build-env-{{OS}}:{{OS_VERSION}} /opt/R/{{R_VERSION}}/bin/R -q -e "bincraft::process_cran_updates(interval = {{interval}}, platform = \"{{OS}}\", s3_endpoint = \"https://hel1.your-objectstorage.com\", s3_region = \"hel1\", s3_bucket = \"devxy-r-package-binaries-hel1\", s3_access_key_id = Sys.getenv(\"HETZNER_S3_ACCESS_KEY_K3S\"), s3_secret_access_key = Sys.getenv(\"HETZNER_S3_SECRET_KEY_K3S\"), metadata_db_host = \"r-binaries.devxy.io\", metadata_db_name = \"build_metadata\", metadata_db_table = \"single_builds\", metadata_db_user = \"rpkgs\", metadata_db_password = Sys.getenv(\"PGPASS\"), metadata_db_sslmode = \"require\", metadata_db_port = 15432, archive = TRUE, upload = TRUE, store_build_metadata = TRUE)" diff --git a/README.md b/README.md index df69048..fd03609 100644 --- a/README.md +++ b/README.md @@ -53,26 +53,6 @@ For every package+tag combination: 1. Archive old package versions and keep the latest one in the root 1. Delete local binaries after successful upload -## Patching packages - -Some CRAN packages fail to compile on specific platforms due to compiler- or OS-specific issues unrelated to the package itself. -The canonical example is `RcppParallel`, whose bundled TBB is linked in a way that lets a system TBB on the build host shadow it, so the published binary depends on a library the consumer does not have. -Because such packages are often transitive dependencies of many others, a single failure cascades: all dependents fail even though nothing is wrong with the dependent itself. - -To address this, frequently-failing packages can be "patched" before they are installed — whether as a direct build target or a transitive dependency pulled in by `pak`. - -The patch registry lives in `local/patches/registry.json`. -Each entry specifies a package and the platforms/versions it applies to, along with either lightweight build-time overrides (environment variables, configure arguments, Makevars) or a source diff (for deeper fixes). -See `local/patches/README.md` for the complete schema. - -Patching uses a two-tier approach: - -1. **Lightweight overrides:** environment variables, configure arguments, or Makevars settings applied during build — typically version-independent and fast. -2. **Source diffs:** unified diff patches applied to the unpacked source before building — more powerful but version-pinned. - -The system is implemented in `bincraft`: when a package needs patching, `bincraft` pre-builds it with the patch and serves the patched binary to `pak`, ensuring transitive dependents receive the fixed package. -This way, the fix cascades to all packages that depend on it. - ## Build Environment Binaries are built on a mixed-architecture Kubernetes cluster using CI. @@ -82,32 +62,13 @@ This elastic server architecture offers a robust and performant backend while mi ## Technical Details -### Packages requiring a newer R - -The daily update and weekly full-build pipelines run `local/build-newer-r.R` under each non-primary installed R, alongside the ABI-sensitive pass. -It selects current CRAN versions whose `Depends: R` constraints cannot be met by the slot's primary R but can be met by the running R, including incompatibility inherited through `Depends`, `Imports`, and `LinkingTo`. -These builds retain bincraft's ABI classification and storage routing: sensitive binaries use the running minor, while safe binaries can be shared. -No shared S3 existence cache is passed, so bincraft checks the actual objects and distinguishes a source fallback from a binary. -The pass reads unfiltered CRAN metadata independently of the weekly snapshot and its primary-R failure exclusions; existing binaries and failures for the running minor retain bincraft's usual skip behavior. -Weekly workers split this extra work across their existing shards. -This does not select older archive versions for unsupported R minors or change index filtering. - -Preview the selection without building or accessing storage or build metadata: - -```sh -# Run with the target R and supply the slot's full primary R version. -/opt/R/4.6.0/bin/Rscript local/build-newer-r.R 4.4.3 --dry-run -``` - ### Creating/Updating the PACKAGES Index Files -Tools such as `tools::write_PACKAGES()` and {cranlike} only index files on a local file system. +Currently, the {cranlike} and {desc} packages only work with files on a local file system. This is infeasible if the goal is to store binaries in S3. Storing binaries permanently on a disk-based file system would incur significantly higher costs, especially when operating in the cloud. -Hence, `bincraft::upload_package_index()` builds the index from a listing of the slot in S3 (through {s3fs}). -Each record is read from the package's CRAN `DESCRIPTION` on the GitHub mirror of CRAN, falling back to the `DESCRIPTION` inside the tarball for a package the mirror does not have. -The previously published `PACKAGES.rds` serves as a cache, so only new or replaced tarballs are read. +Hence, [{cranlike}](https://devxy.gitlab.io/r-package-binaries/bincraft/) and [{desc}](https://github.com/pat-s/desc/tree/description-from-remote) were forked to handle files in S3 (through {s3fs}). ### Resources @@ -129,9 +90,9 @@ Processing updates with an existing database file takes around 5 minutes. ### Inferring System Dependencies -R package dependencies and their system dependencies are installed through [uvr](https://github.com/nbafrank/uvr). -`uvr` allows for parallel downloads and installation, significantly speeding up package installation compared to `install.packages()`. -Additionally, it automatically infers package dependencies using JSON rules vendored from [rstudio/r-system-requirements](https://github.com/rstudio/r-system-requirements). +R package dependencies and their system dependencies are installed through {pak}. +{pak} allows for parallel downloads and installation, significantly speeding up package installation compared to `install.packages()`. +Additionally, it automatically infers package dependencies using JSON rules from [rstudio/r-system-requirements](https://github.com/rstudio/r-system-requirements). Not all R packages specify required system dependencies in their DESCRIPTION file, and not all listed dependencies have existing rules in `rstudio/r-system-requirements`. For Alpine, no rules existed until recently, establishing a foundation for semi-automated package installation on Alpine Linux. @@ -139,7 +100,6 @@ For Alpine, no rules existed until recently, establishing a foundation for semi- The build metadata is stored in a PostgreSQL database. The database has a public endpoint at `r-binaries.devxy.io` and port `15432`. -It serves a Let's Encrypt certificate for that name, so connect with `sslmode=verify-full`; from R, pass `sslrootcert = bincraft::postgres_sslrootcert("verify-full")` as well, since libpq does not read the system trust store by default. It contains one table named `single_builds`, which holds the build metadata for each package: | package_name | tag | platform | error_occurred | build_timestamp | build_duration | error | size | removed | @@ -170,13 +130,12 @@ A Shiny dashboard providing a search functionality of the database and grouped s Is supported by writing `Meta/archive.rds` during each package index update, listing all available archived packages. -### `uvr add package@version` +### `pak::pak(package@version)` -Clients that resolve archived versions search for `Archive/` and can install all versions they find. -This holds for `uvr` as well as for older `pak`-based clients. +`pak` searches for `Archive/` and can install all versions it finds. Ensure to use a clean cache if other repositories have been used previously. -If in doubt or when testing, call `uvr cache clean`. +If in doubt or when testing, call `pak::meta_clean(force = TRUE)`. ## Lessons Learned @@ -199,7 +158,7 @@ If in doubt or when testing, call `uvr cache clean`. ## URL Composition and Platform Identifiers -Platform identifiers have been aligned with those used in , which `uvr` vendors and uses for its automatic syslib dependency installer (`uvr sync --install-system-deps`): +Platform identifiers have been aligned with those used in to ensure proper recognition by the automatic syslib dependency installer of `pak`, specifically via the environment variable `PKG_SYSREQS_PLATFORM`: - redhat-9 - redhat-8 @@ -216,28 +175,6 @@ Example: Technically, no date-based snapshots are planned, so this component from the Posit PM structure is not included. -## Retiring a slot - -A slot is only reachable if it is listed in `local.rpkgs_slots` in `cdn.tf`, which feeds `UNION_SLOTS` in `edge/rpkgs-router.ts`. -An unrouted slot serves the flat index to every client, so its binaries fail at `dyn.load()` under every R minor but one. - -In order: - -1. Remove it from `local.rpkgs_slots` in `cdn.tf` and from `DistroId` in the website's `src/src/data/repos.ts`, then `tofu apply`. -2. `just retire-slot --apply`, then commit. -3. Delete its cron jobs on the Crow server; `local/retire-slot.R` prints them with the API call. -4. Delete its objects: - - ```sh - crow pipeline create devxy/build-cran-binaries --branch main \ - --var retire_slot= --var RETIRE_APPLY=yes - ``` - -Steps 2 and 4 refuse any slot still listed in `cdn.tf`. -Running step 4 before step 2 means the next nightly rebuilds everything just deleted. - -`just check-slots` fails when a pipeline still targets an unrouted slot. - ## Helpers Helper scripts are located in `local/`. @@ -249,20 +186,20 @@ Below is a collection of raw errors observed during the build process:
-```text +``` * installing to library '/tmp/Rtmp7WPw19/temp_libpath114b846b58'\n* installing *source* package 'ade4' ...\n** using staged installation\nERROR: a 'NAMESPACE' file is required\n* removing '/tmp/Rtmp7WPw19/temp_libpath114b846b58/ade4'\n" ``` Tag does not have a NAMESPACE file and hence cannot be built. -```text +``` "* installing to library '/tmp/RtmpLcCitS/temp_libpath1146aabbe92'\nERROR: dependency 'tripack' is not available for package 'alphahull'\n* removing '/tmp/RtmpLcCitS/temp_libpath1146aabbe92/alphahull'\n" ``` Dependency not available: Either because the dependency was not declared or errored itself during installation. -```text - In function '\033[01m\033[KRcpp::List solveRRBLUP(const mat&, const mat&, const mat&)\033[m\033[K':\n\033[01m\033[KMME.cpp:162:61:\033[m\033[K \033[01;31m\033[Kerror: \033[m\033[K'\033[01m\033[KPI\033[m\033[K' was not declared in this scope\n 162 | double ll = -0.5*(double(optRes[\"objective\"])+df+df*log(2*\033[01;31m\033[KPI\033[m\033[K/df));\n | \033[01;31m\033[K^~\033[m\033[K\n\033[01m\033[KMME.cpp:\033[m\033[K In function '\033[01m\033[KRcpp::List solveRRBLUPMV(const mat&, const mat&, const mat&, int, double)\033[m\033[K':\n\033[01m\033[KMME.cpp:277:31:\033[m\033[K \033[01;31m\033[Kerror: \033[m\033[K'\033[01m\033[KPI\033[m\033[K' was not declared in this scope; did you mean '\033[01m\033[KHI\033[m\033[K'?\n 277 | ll -= double(n*m)/2.0*log(2*\033[01;31m\033[KPI\033[m\033[K);\n | \033[01;31m\033[K^~\033[m\033[K\n | \033[32m\033[KHI\033[m\033[K\nmake: *** [/opt/R/4.4.2/lib/R/etc/Makeconf:204: MME.o] Error 1\nERROR: compilation failed for package 'AlphaSimR'\n* removing '/tmp/RtmpclI5CE/temp_libpath11135d215d5/AlphaSimR'\n +``` + In function '\033[01m\033[KRcpp::List solveRRBLUP(const mat&, const mat&, const mat&)\033[m\033[K':\n\033[01m\033[KMME.cpp:162:61:\033[m\033[K \033[01;31m\033[Kerror: \033[m\033[K'\033[01m\033[KPI\033[m\033[K' was not declared in this scope\n 162 | double ll = -0.5*(double(optRes[\"objective\"])+df+df*log(2*\033[01;31m\033[KPI\033[m\033[K/df));\n | \033[01;31m\033[K^~\033[m\033[K\n\033[01m\033[KMME.cpp:\033[m\033[K In function '\033[01m\033[KRcpp::List solveRRBLUPMV(const mat&, const mat&, const mat&, int, double)\033[m\033[K':\n\033[01m\033[KMME.cpp:277:31:\033[m\033[K \033[01;31m\033[Kerror: \033[m\033[K'\033[01m\033[KPI\033[m\033[K' was not declared in this scope; did you mean '\033[01m\033[KHI\033[m\033[K'?\n 277 | ll -= double(n*m)/2.0*log(2*\033[01;31m\033[KPI\033[m\033[K);\n | \033[01;31m\033[K^~\033[m\033[K\n | \033[32m\033[KHI\033[m\033[K\nmake: *** [/opt/R/4.4.1/lib/R/etc/Makeconf:204: MME.o] Error 1\nERROR: compilation failed for package 'AlphaSimR'\n* removing '/tmp/RtmpclI5CE/temp_libpath11135d215d5/AlphaSimR'\n ``` Compiler error: Possible reasons: too old CXX code which cannot be compiled anymore with CXX14 or CXX17. @@ -278,8 +215,8 @@ internal error 1 in memDecompress Solution: ```sh -uvr cache clean -rm -rf /mnt/cache/uvr /root/.cache/R/ +rm -rf /mnt/cache/R-pkgs/pak /mnt/cache/pkgcache/ /root/.cache/R/ +R -q -e 'install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/stable/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch))' ```
@@ -293,26 +230,26 @@ For others it might be due to exotic external dependencies which require manual Help in resolving these issues are highly welcome! -| Name | Platform | Arch | Reason | Date Created | Date Solved | -| ------------- | -------------- | ------- | -------------------------------- | ------------ | ----------- | -| Apollonius | redhat-8 | | gmp missing | 2024-11-15 | | -| doBy | alpine-320 | amd | hangs | 2024-11-23 | | -| later | ubuntu 22 & 24 | amd | hangs for early versions - xfvb? | 2024-11-23 | | -| CoTiMA | ubuntu 22 & 24 | amd | OOM? | 2024-11-23 | | -| FrF2 | alpine | arm | hangs | 2024-11-23 | | -| FrF2.catlg128 | alpine | arm | hangs | 2024-11-23 | | -| DoE.base | alpine | arm/amd | hangs | 2024-11-23 | | -| eha | alpine | amd | hangs | 2024-11-23 | | -| gRain | alpine | amd | hangs | 2024-11-23 | | -| gRbase | alpine | amd | hangs | 2024-11-24 | | -| IDPmisc | alpine | amd | hangs | 2024-11-24 | | -| RVAideMemoire | alpine | amd | hangs | 2024-11-25 | | -| pbkrtest | alpine | arm | hangs | 2024-11-25 | | -| seewave | alpine | arm | hangs | 2024-11-25 | | -| spdep | alpine | arm | hangs | 2024-12-03 | | -| compareGroups | alpine | arm | hangs | 2024-12-11 | | -| SNPassoc | alpine | arm | hangs | 2024-12-11 | | -| surveillance | alpine | arm | hangs | 2024-12-13 | | +| Name | Platform | Arch | Reason | Solved via | Date Created | Date Solved | +| ------------- | -------------- | ------- | -------------------------------- | ---------- | ------------ | ----------- | +| Apollonius | redhat-8 | | gmp missing | 2024-11-15 | | +| doBy | alpine-320 | amd | hangs | 2024-11-23 | | +| later | ubuntu 22 & 24 | amd | hangs for early versions - xfvb? | 2024-11-23 | | +| CoTiMA | ubuntu 22 & 24 | amd | OOM? | 2024-11-23 | | +| FrF2 | alpine | arm | hangs | 2024-11-23 | | +| FrF2.catlg128 | alpine | arm | hangs | 2024-11-23 | | +| DoE.base | alpine | arm/amd | hangs | 2024-11-23 | | +| eha | alpine | amd | hangs | 2024-11-23 | | +| gRain | alpine | amd | hangs | 2024-11-23 | | +| gRbase | alpine | amd | hangs | 2024-11-24 | | +| IDPmisc | alpine | amd | hangs | 2024-11-24 | | +| RVAideMemoire | alpine | amd | hangs | 2024-11-25 | | +| pbkrtest | alpine | arm | hangs | 2024-11-25 | | +| seewave | alpine | arm | hangs | 2024-11-25 | | +| spdep | alpine | arm | hangs | 2024-12-03 | | +| compareGroups | alpine | arm | hangs | 2024-12-11 | | +| SNPassoc | alpine | arm | hangs | 2024-12-11 | | +| surveillance | alpine | arm | hangs | 2024-12-13 | | ## CDN Settings diff --git a/build-all-versions-install-deps.yaml b/build-all-versions-install-deps.yaml index dd02e8a..926d550 100644 --- a/build-all-versions-install-deps.yaml +++ b/build-all-versions-install-deps.yaml @@ -30,9 +30,8 @@ # from_secret: HETZNER_S3_SECRET_KEY_K3S # # normal env vars # GIT_USER: pat-s -# # set the location of uvr's caches, which persist the R package dependencies needed to install the packages themselves -# # UVR_CACHE_DIR: /mnt/cache/uvr/cache -# # UVR_PACKAGES_DIR: /mnt/cache/uvr/packages +# # 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 # volumes: @@ -40,8 +39,9 @@ # commands: # - git clone -q https://pat-s:$$REPO_RO_TOKEN@git.devxy.io/devxy/build-cran-binaries.git . # - mkdir -p /mnt/cache/R-pkgs -# - rm -rf /mnt/cache/R-pkgs/00LOCK-* /mnt/cache/R-pkgs/bincraft /mnt/cache/uvr -# - UVR_R_BIN=/opt/R/$R_VERSION/bin/R local/uvr-install.sh forgejo::codefloe.com/rpkgs/bincraft +# - rm -rf /mnt/cache/R-pkgs/00LOCK-* /mnt/cache/R-pkgs/bincraft /mnt/cache/pkgcache +# - /opt/R/$R_VERSION/bin/R -q -e 'install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/stable/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch))' +# - /opt/R/$R_VERSION/bin/R -q -e 'pak::pak("git::https://codefloe.com/rpkgs/bincraft.git", dependencies = TRUE)' # - /opt/R/$R_VERSION/bin/R -q -e 'packageVersion("bincraft")' # # - /opt/R/$R_VERSION/bin/R -q -e "future::plan('multisession', workers = 6L); pkgs = bincraft::query_packages_without_historic_versions('alpine322', 'amd64'); saveRDS(pkgs, '/mnt/cache/pkgs_amd64.rds')" # - /opt/R/$R_VERSION/bin/R -q -e "future::plan('multisession', workers = 6L); pkgs = bincraft::query_packages_without_historic_versions('alpine323', 'arm64'); saveRDS(pkgs, '/mnt/cache/pkgs_arm64.rds')" diff --git a/cdn.tf b/cdn.tf index 46b3e70..30ee1e2 100644 --- a/cdn.tf +++ b/cdn.tf @@ -1,136 +1,28 @@ # https://registry.terraform.io/providers/BunnyWay/bunnynet/latest/docs/resources/pullzone -# terraform import bunnynet_pullzone.devxy-r-binaries cran -# resource "bunnynet_pullzone" "devxy-r-binaries" { -# name = "cran" - -# origin { -# type = "OriginUrl" -# url = "https://devxy-rpkgs-binaries.s3.eu-central-003.backblazeb2.com" -# } - -# routing { -# tier = "Standard" -# } - -# s3_auth_enabled = true -# s3_auth_key = var.B2_S3_ACCESS_KEY -# s3_auth_secret = var.B2_S3_SECRET_KEY -# s3_auth_region = "eu-central-003" - -# cache_enabled = true -# cache_errors = true -# request_coalescing_enabled = true -# block_post_requests = true - -# limit_requests = 500 -# limit_connections = 50 - -# safehop_enabled = true - -# add_canonical_header = true - -# cache_stale = ["offline", "updating"] -# use_background_update = true - -# block_ips = var.cdn_block_ips - -# # 50 TB -# limit_bandwidth = 50000000000000 - -# permacache_storagezone = bunnynet_storage_zone.devxy-r-binaries.id - -# # rec from docs: https://www.backblaze.com/docs/cloud-storage-integrate-bunnynet-with-backblaze-b2 -# block_root_path = true -# } - -# resource "bunnynet_pullzone_hostname" "devxy-r-binaries" { -# pullzone = bunnynet_pullzone.devxy-r-binaries.id -# name = "cran.devxy.io" -# force_ssl = true -# tls_enabled = true -# } - -### cran.rpkgs.com locals { - rpkgs_slots = [ - for pair in setproduct( - ["amd64", "arm64"], - ["resolute", "noble", "jammy", "rhel8", "rhel9", "rhel10", "alpine323", "alpine324"] - ) : "${pair[0]}/${pair[1]}" - ] - - # The supported R minors: the current one plus the two previous, which is - # exactly what build-env-images installs as R_VERSION_LATEST / PREV1 / PREV2. - # These must stay in step. A minor listed here without a published index - # sends those clients to a 404; a published minor missing from this list - # sends them to CRAN for sources instead of serving the binaries we built. - rpkgs_supported_minors = ["4.4", "4.5", "4.6"] - - # bunny.net serves every pull zone on .b-cdn.net, so staging needs no - # DNS record and is never advertised. - rpkgs_test_hostname = "cran-rpkgs-test.b-cdn.net" + pullzones = { + "cran" = { + hostname = "cran.devxy.io" + } + "cran-rpkgs" = { + hostname = "cran.rpkgs.com" + } + } } -# The edge middleware that resolves the bare cran.rpkgs.com form to an -# / slot and routes PACKAGES* to the per-R-minor slot. The source of -# truth is edge/rpkgs-router.ts; `tofu apply` publishes a new release. -# -# The script pre-dates this configuration, so it is adopted rather than created: -# tofu import bunnynet_compute_script.rpkgs_router 29277 -resource "bunnynet_compute_script" "rpkgs_router" { - type = "middleware" - name = "rpkgs-router" - content = file("${path.module}/edge/rpkgs-router.ts") -} +resource "bunnynet_pullzone" "this" { + for_each = local.pullzones -# Slots ("/", comma separated) whose per-minor index bincraft has -# already republished as a union of the per-minor and flat slots. Routing to a -# slot that is not listed here would hide every package the per-minor index does -# not carry, so this stays empty until a slot has been backfilled. -resource "bunnynet_compute_script_variable" "rpkgs_router_union_slots" { - script = bunnynet_compute_script.rpkgs_router.id - name = "UNION_SLOTS" - # Enabled. Until this was set, every client resolved against the generic - # index and never reached a per-minor binary: an R 4.6.1 client on resolute - # downloaded the 4.5-built rlang (2079570 bytes) while the correct 4.6 build - # (2075106 bytes) sat unused one directory away, and died at load with - # `undefined symbol: SETLENGTH`. - # - # Verified before enabling, against the staging zone with the same script and - # the same origin: all 16 slots report zero regressions against the generic - # slot, an excluded R minor is sent to CRAN, a client without an R minor - # still gets the generic index, and tarball requests are never rewritten. - default_value = join(",", local.rpkgs_slots) - required = false -} - -resource "bunnynet_compute_script_variable" "rpkgs_router_known_minors" { - script = bunnynet_compute_script.rpkgs_router.id - name = "KNOWN_MINORS" - default_value = join(",", local.rpkgs_supported_minors) - required = false -} - -resource "bunnynet_pullzone" "cran_rpkgs_com" { - name = "cran-rpkgs" - - cache_errors = false - - cache_expiration_time = 31919000 - websockets_enabled = false - errorpage_whitelabel = true + name = each.key origin { - type = "OriginUrl" - url = "https://devxy-rpkgs-binaries.s3.eu-central-003.backblazeb2.com" - middleware_script = bunnynet_compute_script.rpkgs_router.id + type = "OriginUrl" + url = "https://devxy-rpkgs-binaries.s3.eu-central-003.backblazeb2.com" } routing { - filters = [ - "scripting", - ] + tier = "Standard" } s3_auth_enabled = true @@ -139,217 +31,69 @@ resource "bunnynet_pullzone" "cran_rpkgs_com" { s3_auth_region = "eu-central-003" cache_enabled = true + cache_errors = true request_coalescing_enabled = true block_post_requests = true - # Set on the zone since before this configuration existed; declared here so - # `tofu apply` stops silently removing it. - # - # The router makes it redundant on paper: the only UA-dependent responses it - # produces are redirects, and those carry `Cache-Control: no-store`, while - # their targets are concrete per-slot, per-minor URLs whose content depends - # only on the path. Dropping it would also be a real win, because otherwise - # every distinct R version string keys its own copy of every tarball. - # - # It stays for now anyway: it is the second line of defence against the one - # failure that would be quiet and confusing (an R 4.6 client served the 4.5 - # index), and removing it is worth doing on its own once per-minor routing is - # confirmed live, not as a side effect of enabling that routing. - cache_vary_headers = ["User-Agent"] - - limit_requests = 5000 - limit_connections = 1000 + limit_requests = 60 + limit_connections = 10 safehop_enabled = true add_canonical_header = true - # Access logs feed the public download statistics (`stats/`, published to - # `/stats/downloads.json`). Both settings were already on; declaring them - # keeps an apply from quietly switching off the only source of that data. - # Bunny keeps the logs for three days, which is why `download-stats` runs on - # a schedule. IPs stay anonymized to /24 (/64 for IPv6) at the edge. - log_enabled = true - log_anonymized = true - log_anonymized_style = "OneDigit" + cache_stale = ["offline", "updating"] + use_background_update = true - # The rpkgs.com website reads `/stats/downloads.json` from the browser, so - # JSON needs the CORS header too. The rest is the zone's existing list. - cors_enabled = true - cors_extensions = [ - "css", "eot", "gif", "jpeg", "jpg", "js", "json", "mp3", "mp4", "mpeg", "png", "svg", "ttf", "webm", "webp", - "woff", "woff2", + block_ips = [ + "185.172.53.0" ] - cache_stale = ["offline", "updating"] - - block_ips = var.cdn_block_ips - # 50 TB limit_bandwidth = 50000000000000 - # permacache_storagezone = bunnynet_storage_zone.devxy-r-binaries.id + permacache_storagezone = bunnynet_storage_zone.devxy-r-binaries.id # rec from docs: https://www.backblaze.com/docs/cloud-storage-integrate-bunnynet-with-backblaze-b2 block_root_path = true } -resource "bunnynet_pullzone_hostname" "cran_rpkgs_com" { - pullzone = bunnynet_pullzone.cran_rpkgs_com.id - name = "cran.rpkgs.com" +resource "bunnynet_pullzone_hostname" "this" { + for_each = local.pullzones + + pullzone = bunnynet_pullzone.this[each.key].id + name = each.value.hostname force_ssl = true tls_enabled = true } -### Staging zone for edge-router changes - -# Every published / slot. The staging zone enables per-minor routing -# for all of them at once; production adopts the same list only after -# `scripts/verify-r-minor-routing.sh --live` passes against staging. - -# A second copy of the same router, bound to the same B2 origin, so UNION_SLOTS -# can be exercised end to end before production is touched. -resource "bunnynet_compute_script" "rpkgs_router_test" { - type = "middleware" - name = "rpkgs-router-test" - content = file("${path.module}/edge/rpkgs-router.ts") +resource "bunnynet_storage_zone" "devxy-r-binaries" { + name = "devxy-r-binaries-storage" + region = "DE" + zone_tier = "Standard" + # Los Angeles and Singapore + replication_regions = ["LA", "SG"] } -resource "bunnynet_compute_script_variable" "rpkgs_router_test_union_slots" { - script = bunnynet_compute_script.rpkgs_router_test.id - name = "UNION_SLOTS" - default_value = join(",", local.rpkgs_slots) - required = false +# State-migration markers so the previously-singleton resources slide into +# the for_each map addresses without a destroy/create. Safe to delete after +# a successful apply on every workspace. +moved { + from = bunnynet_pullzone.devxy-r-binaries + to = bunnynet_pullzone.this["cran"] } -# Without this the staging zone rewrites to PUBLIC_CDN_ORIGIN, so its redirects -# land on production and the test silently measures the wrong system. -resource "bunnynet_compute_script_variable" "rpkgs_router_test_extra_hosts" { - script = bunnynet_compute_script.rpkgs_router_test.id - name = "EXTRA_PUBLIC_HOSTS" - default_value = local.rpkgs_test_hostname - required = false +moved { + from = bunnynet_pullzone.cran_rpkgs_com + to = bunnynet_pullzone.this["cran-rpkgs"] } -resource "bunnynet_compute_script_variable" "rpkgs_router_test_known_minors" { - script = bunnynet_compute_script.rpkgs_router_test.id - name = "KNOWN_MINORS" - default_value = join(",", local.rpkgs_supported_minors) - required = false +moved { + from = bunnynet_pullzone_hostname.devxy-r-binaries + to = bunnynet_pullzone_hostname.this["cran"] } -resource "bunnynet_pullzone" "cran_rpkgs_test" { - name = "cran-rpkgs-test" - - cache_errors = false - - cache_expiration_time = 31919000 - websockets_enabled = false - errorpage_whitelabel = true - - origin { - type = "OriginUrl" - url = "https://devxy-rpkgs-binaries.s3.eu-central-003.backblazeb2.com" - middleware_script = bunnynet_compute_script.rpkgs_router_test.id - } - - routing { - filters = [ - "scripting", - ] - } - - s3_auth_enabled = true - s3_auth_key = var.B2_S3_ACCESS_KEY - s3_auth_secret = var.B2_S3_SECRET_KEY - s3_auth_region = "eu-central-003" - - cache_enabled = true - request_coalescing_enabled = true - block_post_requests = true - - cache_vary_headers = ["User-Agent"] - - # Staging carries only synthetic verification traffic, so the production - # ceilings would be pure headroom. - limit_requests = 500 - limit_connections = 100 - - safehop_enabled = true - add_canonical_header = true - cache_stale = ["offline", "updating"] - block_ips = var.cdn_block_ips - - # 1 TB - limit_bandwidth = 1000000000000 - - block_root_path = true +moved { + from = bunnynet_pullzone_hostname.cran_rpkgs_com + to = bunnynet_pullzone_hostname.this["cran-rpkgs"] } - - -# Alliance SwissPass historically used a separate, manually configured pull -# zone. Adopt it so both public repositories use the same B2 origin, middleware -# release and cache behavior. -import { - to = bunnynet_pullzone.cran_allianceswisspass - id = "3265648" -} - -resource "bunnynet_pullzone" "cran_allianceswisspass" { - name = "cran-allianceswisspass" - - cache_errors = false - cache_expiration_time = 31919000 - websockets_enabled = false - errorpage_whitelabel = true - - origin { - type = "OriginUrl" - url = "https://devxy-rpkgs-binaries.s3.eu-central-003.backblazeb2.com" - middleware_script = bunnynet_compute_script.rpkgs_router.id - } - - routing { - filters = [ - "scripting", - ] - } - - s3_auth_enabled = true - s3_auth_key = var.B2_S3_ACCESS_KEY - s3_auth_secret = var.B2_S3_SECRET_KEY - s3_auth_region = "eu-central-003" - - cache_enabled = true - request_coalescing_enabled = true - block_post_requests = true - cache_vary_headers = ["User-Agent"] - - limit_requests = 5000 - limit_connections = 1000 - - safehop_enabled = true - add_canonical_header = true - cache_stale = ["offline", "updating"] - block_ips = var.cdn_block_ips - - # 50 TB - limit_bandwidth = 50000000000000 - - block_root_path = true -} - -resource "bunnynet_pullzone_hostname" "cran_allianceswisspass" { - pullzone = bunnynet_pullzone.cran_allianceswisspass.id - name = "cran.allianceswisspass.devxy.io" - force_ssl = true - tls_enabled = true -} - -# resource "bunnynet_storage_zone" "devxy-r-binaries" { -# name = "devxy-r-binaries-storage" -# region = "DE" -# zone_tier = "Standard" -# # Los Angeles and Singapore -# replication_regions = ["LA", "SG"] -# } diff --git a/docker/Containerfile-shiny-app b/docker/Containerfile-shiny-app index 4b0bd6c..7c7994f 100644 --- a/docker/Containerfile-shiny-app +++ b/docker/Containerfile-shiny-app @@ -1,15 +1,7 @@ FROM devxygmbh/r-alpine:4.4-3.20 AS build # ARG GITHUB_PAT -RUN apk add --no-cache curl ca-certificates \ - && curl -fsSL https://raw.githubusercontent.com/nbafrank/uvr/main/install.sh \ - | UVR_INSTALL_DIR=/usr/local/bin sh - -# One uvr project drives both dependency installs below. UVR_LIBRARY points the -# syncs at the image's R library instead of the project-local .uvr/library/, so -# `Rscript app.R` finds the packages without a uvr-aware .Rprofile. -ENV UVR_LIBRARY=/usr/lib/R/library -RUN mkdir -p /uvr && cd /uvr && uvr init --here +RUN R -q -e 'install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/stable/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch))' COPY --link ./DESCRIPTION . COPY --link ./R ./R @@ -19,19 +11,13 @@ COPY --link ./shiny/app.R /app/app.R RUN ls -la -# install R package deps. uvr has no equivalent of bare `pak::pak()`, which -# reads the DESCRIPTION in the working directory, so extract the dependency -# names and hand them to `uvr add`. -RUN R -q --no-echo -e "d <- read.dcf('DESCRIPTION'); f <- intersect(colnames(d), c('Depends', 'Imports', 'LinkingTo')); p <- trimws(sub('[(].*', '', unlist(strsplit(paste(d[, f], collapse = ','), ',')))); writeLines(setdiff(p[nzchar(p)], c('R', rownames(installed.packages()))), '/tmp/deps.txt')" \ - && cd /uvr && xargs -r uvr add --no-install < /tmp/deps.txt \ - && uvr sync --install-system-deps +# install R package deps +RUN R -q -e 'pak::pak()' RUN R CMD INSTALL --no-docs --without-keep.source . # install shiny app deps -RUN R -q -e "install.packages('renv'); pkgs <- renv::dependencies('/app/app.R')[['Package']]; pkgs = setdiff(pkgs, 'bincraft'); writeLines(pkgs, '/tmp/app-deps.txt')" \ - && cd /uvr && xargs -r uvr add --no-install < /tmp/app-deps.txt \ - && uvr sync --install-system-deps +RUN R -q -e "install.packages('renv'); pkgs <- renv::dependencies('/app/app.R')[['Package']]; pkgs = setdiff(pkgs, 'bincraft'); pak::pak(pkgs)" ENV PGPASS="" diff --git a/docker/build-one.Dockerfile b/docker/build-one.Dockerfile deleted file mode 100644 index 8e61ebd..0000000 --- a/docker/build-one.Dockerfile +++ /dev/null @@ -1,76 +0,0 @@ -# syntax=docker/dockerfile:1 -# Targeted (re)build of specific package versions, executed on a remote buildx -# builder. The build's effect is the S3 upload performed by build-one.R; no -# image is kept (the justfile uses --output type=cacheonly). CACHEBUST forces -# the RUN to re-execute on every invocation. -# -# Build context is `local/` (see the `rebuild` recipe in the justfile). -ARG OS -ARG OS_VERSION -FROM reg.devxy.io/rpkgs/build-env-${OS}:${OS_VERSION} - -ARG R_VERSION=4.5.3 -ARG PACKAGE -ARG VERSIONS -ARG CACHEBUST - -WORKDIR /work -COPY build-one.R /work/build-one.R -# Resolve and install the latest bincraft release dynamically (no hardcoded pin). -# uvr-install.sh lands under /work/local/ because install-bincraft.R looks for it -# there when the working directory is not a repo checkout. -COPY install-bincraft.R /work/install-bincraft.R -COPY uvr-install.sh /work/local/uvr-install.sh -# Ship the patch registry so build-one.R's `patches = "local/patches"` resolves -# (build context is `local/`, CWD is /work). -COPY patches /work/local/patches - -RUN --mount=type=secret,id=b2_access,required=true \ - --mount=type=secret,id=b2_secret,required=true \ - --mount=type=secret,id=pgpass,required=true \ - --mount=type=secret,id=github_pat,required=false \ - export B2_S3_ACCESS_KEY="$(cat /run/secrets/b2_access)" && \ - export B2_S3_SECRET_KEY="$(cat /run/secrets/b2_secret)" && \ - export PGPASS="$(cat /run/secrets/pgpass)" && \ - export GITHUB_PAT="$(cat /run/secrets/github_pat 2>/dev/null || true)" && \ - export GIT_TERMINAL_PROMPT=0 && \ - export OTEL_SDK_DISABLED=true && \ - export OTEL_R_TRACES_EXPORTER=none && \ - export OTEL_R_LOGS_EXPORTER=none && \ - export OTEL_R_METRICS_EXPORTER=none && \ - XVFB=$(command -v xwfb-run 2>/dev/null || command -v xvfb-run || true); \ - 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; \ - USE_XVFB=0; \ - if [ -n "$XVFB" ] && $XVFB -a $XVFB_ARGS -- true >/dev/null 2>&1; then \ - USE_XVFB=1; echo "Using virtual display via $XVFB"; \ - else \ - echo "No working virtual display; building without xvfb" >&2; \ - fi; \ - run_build() { if [ "$USE_XVFB" = 1 ]; then $XVFB -a $XVFB_ARGS -- "$@"; else "$@"; fi; }; \ - ensure_bincraft() { "$1" -q -e 'source("/work/install-bincraft.R")'; }; \ - PRIMARY_MINOR=$(echo "$R_VERSION" | cut -d. -f1-2); \ - seen=" $PRIMARY_MINOR "; \ - prc=0; failed=""; \ - rm -f .r_minor_sensitive; \ - echo "=== primary pass under R $R_VERSION ==="; \ - ensure_bincraft /opt/R/${R_VERSION}/bin/R; \ - run_build /opt/R/${R_VERSION}/bin/Rscript /work/build-one.R "${PACKAGE}" ${VERSIONS} || prc=$?; \ - if [ -f .r_minor_sensitive ]; then \ - for RBIN in /opt/R/*/bin/Rscript; do \ - [ -x "$RBIN" ] || continue; \ - RV=$(basename "$(dirname "$(dirname "$RBIN")")"); \ - case "$RV" in [0-9]*) ;; *) continue ;; esac; \ - RMINOR=$(echo "$RV" | cut -d. -f1-2); \ - case "$seen" in *" $RMINOR "*) continue ;; esac; \ - seen="$seen$RMINOR "; \ - echo "=== sensitive-only pass under R $RV ==="; \ - ensure_bincraft "$(dirname "$RBIN")/R"; \ - run_build "$RBIN" /work/build-one.R --sensitive-only "${PACKAGE}" ${VERSIONS} || failed="$failed $RV"; \ - done; \ - else \ - echo "Package not r-minor-sensitive; skipping per-minor passes."; \ - fi; \ - if [ -n "$failed" ]; then echo "WARNING: extra-minor build(s) failed (non-fatal; e.g. a version too old to compile on a newer R):$failed" >&2; fi; \ - if [ "$prc" != 0 ]; then echo "primary pass under R $R_VERSION failed (exit $prc)" >&2; fi; \ - exit "$prc" diff --git a/docker/buildkitd.toml b/docker/buildkitd.toml deleted file mode 100644 index ebbeb38..0000000 --- a/docker/buildkitd.toml +++ /dev/null @@ -1,41 +0,0 @@ -# BuildKit GC config for the remote buildx builders (artemis/amd64, gaia/arm64). -# -# Apply when creating the docker-container builders: -# docker buildx create --name artemis --driver docker-container \ -# --config docker/buildkitd.toml ssh:// -# docker buildx create --name gaia --driver docker-container \ -# --config docker/buildkitd.toml ssh:// -# -# Why: BuildKit's default GC caps the ephemeral cache tier — RUN -# --mount=type=cache mounts, local build context, git checkouts — at a -# hardcoded 512 MB (shown as "488.3 MiB" in `buildx inspect`). Across our -# 7-distro build matrix that fills instantly and forces re-downloads of -# system + R packages every rebuild. The first rule below raises that tier. -# -# Limits are absolute (not %) on purpose: artemis and gaia have very -# different free space (Hetzner ~42 GiB free vs Mac mini ~279 GiB), so a -# percentage would mean wildly different real budgets. minFreeSpace = 20 GB -# keeps the tight Hetzner host safe while staying modest on the Mac mini. - -[worker.oci] - gc = true - - # Tier 1 — ephemeral caches (cache mounts, local context, git checkouts). - # Raised from the 512 MB default to 8 GB, retained for 7 days so weekly - # rebuilds reuse downloaded packages instead of re-fetching them. - [[worker.oci.gcpolicy]] - filters = [ - "type==source.local", - "type==exec.cachemount", - "type==source.git.checkout", - ] - keepDuration = "168h" - maxUsedSpace = "8GB" - - # Tier 2 — everything else (image layers, RUN exec results). Bounds the - # whole buildkit cache and always leaves 20 GB free on the host disk. - [[worker.oci.gcpolicy]] - all = true - reservedSpace = "2GB" - maxUsedSpace = "40GB" - minFreeSpace = "20GB" diff --git a/docker/reprex/alpine.sh b/docker/reprex/alpine.sh index 851a9cc..94806e5 100644 --- a/docker/reprex/alpine.sh +++ b/docker/reprex/alpine.sh @@ -1,14 +1,10 @@ docker run --rm -it --platform linux/arm64 alpine sh -apk add --no-cache R R-dev g++ curl ca-certificates +apk add --no-cache R R-dev g++ -curl -fsSL https://raw.githubusercontent.com/nbafrank/uvr/main/install.sh | UVR_INSTALL_DIR=/usr/local/bin sh +R -q -e 'install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/devel/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch))' -# `uvr add` always writes to .uvr/library/; only `uvr sync` honours UVR_LIBRARY, -# so add without installing and let the sync place the packages. -export UVR_LIBRARY=/usr/lib/R/library -mkdir -p /uvr && cd /uvr && uvr init --here -uvr add --no-install gert purrr && uvr sync --install-system-deps +R -q -e 'pak::pak(c("gert", "purrr"))' R @@ -26,20 +22,14 @@ unlink(sprintf("%s/%s", tempdir(), "tmp1"), force = TRUE, recursive = TRUE) tag <- all_tags$name package_name <- rep(package_name, length(tag)) -# uvr has no `pak::local_install_deps()`; read the DESCRIPTION of the checkout -# and `uvr add` the dependency names instead. purrr::walk2(package_name[1], tag, \(x, y) { print(y) system("git config --global advice.detachedHead false") - src <- sprintf("/tmp/%s_%s", x[1], y) system2("git", args = c( "clone", "-q", sprintf("--branch=%s", tail(y, 1)), - sprintf("https://github.com/cran/%s", x[1]), src + sprintf("https://github.com/cran/%s", x[1]), sprintf("/tmp/%s_%s", x[1], y) )) - d <- read.dcf(file.path(src, "DESCRIPTION")) - f <- intersect(colnames(d), c("Depends", "Imports", "LinkingTo")) - deps <- trimws(sub("[(].*", "", unlist(strsplit(paste(d[, f], collapse = ","), ",")))) - deps <- setdiff(deps[nzchar(deps)], "R") - system2("uvr", c("add", "--no-install", deps)) - system2("uvr", c("sync", "--install-system-deps")) + pak::local_install_deps(sprintf("/tmp/%s_%s", x[1], y)) }) + + diff --git a/edge/rpkgs-router.test.ts b/edge/rpkgs-router.test.ts deleted file mode 100644 index 3e2fe8b..0000000 --- a/edge/rpkgs-router.test.ts +++ /dev/null @@ -1,209 +0,0 @@ -/** - * Routing matrix for `edge/rpkgs-router.ts`. - * - * The script is exercised through the SDK's local server rather than by - * importing its internals, so what is tested is the artifact that gets - * deployed. Requests that the script passes through are proxied to the real - * origin, which keeps the "no redirect" cases honest: they assert that the - * client reached the flat slot, not merely that no `Location` was set. - * - * Run with `just edge-test`. - */ -import { assertEquals } from 'jsr:@std/assert@1'; - -const SCRIPT = new URL('./rpkgs-router.ts', import.meta.url).pathname; -const BASE = 'http://127.0.0.1:8080'; -const UNION_SLOTS = 'amd64/alpine324'; - -const UA_R45_MUSL = 'R (4.5.3 x86_64-pc-linux-musl x86_64 linux-musl)'; -const UA_R46_MUSL = 'R (4.6.0 x86_64-pc-linux-musl x86_64 linux-musl)'; -const UA_R43_MUSL = 'R (4.3.3 x86_64-pc-linux-musl x86_64 linux-musl)'; -const UA_R47_MUSL = 'R (4.7.0 x86_64-pc-linux-musl x86_64 linux-musl)'; -const UA_R45_ALPINE = 'R/4.5.3 R (4.5.3 x86_64-pc-linux-musl x86_64 linux-musl) Alpine Linux 3.24'; -const UA_R45_RESOLUTE = 'R/4.5.3 (Ubuntu 26.04) (aarch64-unknown-linux-gnu aarch64 linux-gnu)'; -const UA_R45_FUTURE_UBUNTU = - 'R/4.5.3 (Ubuntu 28.04; codename=dynamic-dugong) (aarch64-unknown-linux-gnu aarch64 linux-gnu)'; -const UA_R45_DARWIN = 'R (4.5.1 aarch64-apple-darwin20 aarch64 darwin20)'; -const UA_CURL = 'curl/8.0.1'; - -const SLOT = '/amd64/alpine324/latest/src/contrib'; -const OTHER_SLOT = '/amd64/noble/latest/src/contrib'; - -interface Probe { - status: number; - location: string | null; - cacheControl: string | null; -} - -async function probe(path: string, userAgent: string): Promise { - const res = await fetch(BASE + path, { - headers: { 'User-Agent': userAgent }, - redirect: 'manual', - }); - await res.body?.cancel(); - return { - status: res.status, - location: res.headers.get('location'), - cacheControl: res.headers.get('cache-control'), - }; -} - -/** Kill tolerantly: the child has already exited if the script failed to load. */ -async function stopServer(child: Deno.ChildProcess): Promise { - try { - child.kill(); - } catch { - // already gone - } - await child.status; -} - -async function startServer(): Promise { - const child = new Deno.Command(Deno.execPath(), { - args: ['run', '-A', SCRIPT], - env: { UNION_SLOTS }, - stdout: 'null', - stderr: 'inherit', - }).spawn(); - - for (let attempt = 0; attempt < 150; attempt++) { - try { - const res = await fetch(`${BASE}/`, { - headers: { 'User-Agent': UA_CURL }, - redirect: 'manual', - }); - await res.body?.cancel(); - return child; - } catch { - await new Promise((resolve) => setTimeout(resolve, 200)); - } - } - - await stopServer(child); - throw new Error('edge script did not start listening on ' + BASE); -} - -Deno.test('rpkgs-router', async (t) => { - const server = await startServer(); - - try { - await t.step("routes an index request to the client's R minor", async () => { - const res = await probe(`${SLOT}/PACKAGES.gz`, UA_R45_MUSL); - assertEquals(res.status, 302); - assertEquals(res.location, `https://cran.rpkgs.com${SLOT}/4.5/PACKAGES.gz`); - }); - - await t.step('routes R 4.6 to its own slot', async () => { - const res = await probe(`${SLOT}/PACKAGES.gz`, UA_R46_MUSL); - assertEquals(res.location, `https://cran.rpkgs.com${SLOT}/4.6/PACKAGES.gz`); - }); - - // We publish binaries only for the supported window. An excluded minor has - // no slot we can serve safely, so it goes to CRAN for sources rather than - // to a 404 or to binaries built under another minor. - await t.step('sends an excluded R minor to CRAN for the index', async () => { - const res = await probe(`${SLOT}/PACKAGES.gz`, UA_R43_MUSL); - assertEquals(res.location, 'https://cran.r-project.org/src/contrib/PACKAGES.gz'); - }); - - await t.step('sends a future R minor to CRAN too', async () => { - const res = await probe(`${SLOT}/PACKAGES.gz`, UA_R47_MUSL); - assertEquals(res.location, 'https://cran.r-project.org/src/contrib/PACKAGES.gz'); - }); - - // The index and the tarballs R resolves against it have to come from the - // same place. Serving one from CRAN and the other from here would hand R a - // binary where it expects a source tarball. - await t.step('sends an excluded minor to CRAN for tarballs as well', async () => { - const res = await probe(`${SLOT}/foo_1.0.tar.gz`, UA_R43_MUSL); - assertEquals(res.location, 'https://cran.r-project.org/src/contrib/foo_1.0.tar.gz'); - }); - - await t.step('leaves an excluded minor alone on a slot outside UNION_SLOTS', async () => { - const res = await probe(`${OTHER_SLOT}/PACKAGES.gz`, UA_R43_MUSL); - assertEquals(res.location, null); - assertEquals(res.status, 200); - }); - - await t.step('routes PACKAGES and PACKAGES.rds too', async () => { - for (const file of ['PACKAGES', 'PACKAGES.rds']) { - const res = await probe(`${SLOT}/${file}`, UA_R45_MUSL); - assertEquals(res.location, `https://cran.rpkgs.com${SLOT}/4.5/${file}`, `expected ${file} to be routed`); - } - }); - - await t.step('marks the redirect uncacheable', async () => { - const res = await probe(`${SLOT}/PACKAGES.gz`, UA_R45_MUSL); - assertEquals(res.cacheControl, 'no-store'); - }); - - await t.step('leaves a slot outside UNION_SLOTS alone', async () => { - const res = await probe(`${OTHER_SLOT}/PACKAGES.gz`, UA_R45_MUSL); - assertEquals(res.location, null); - assertEquals(res.status, 200); - }); - - await t.step('never routes a tarball', async () => { - const res = await probe(`${SLOT}/jsonlite_2.0.0.tar.gz`, UA_R45_MUSL); - assertEquals(res.location, null); - assertEquals(res.status, 200); - }); - - await t.step('serves an archived binary when it exists', async () => { - const path = `${SLOT}/Archive/xml2/xml2_1.5.2.tar.gz`; - const res = await probe(path, UA_R45_MUSL); - assertEquals(res.status, 200); - assertEquals(res.location, null); - }); - - await t.step('does not redirect a path already under a minor', async () => { - const res = await probe(`${SLOT}/4.5/PACKAGES.gz`, UA_R45_MUSL); - assertEquals(res.location, null); - assertEquals(res.status, 200); - }); - - await t.step('leaves a client without an R version alone', async () => { - const res = await probe(`${SLOT}/PACKAGES.gz`, UA_CURL); - assertEquals(res.location, null); - assertEquals(res.status, 200); - }); - - await t.step('resolves the bare root to slot and minor', async () => { - const res = await probe('/src/contrib/PACKAGES.gz', UA_R45_ALPINE); - assertEquals(res.location, `https://cran.rpkgs.com${SLOT}/4.5/PACKAGES.gz`); - }); - - await t.step('resolves Ubuntu 26.04 to the resolute slot', async () => { - const res = await probe('/src/contrib/PACKAGES.gz', UA_R45_RESOLUTE); - assertEquals(res.location, 'https://cran.rpkgs.com/arm64/resolute/latest/src/contrib/PACKAGES.gz'); - }); - - await t.step('resolves a future Ubuntu release from its codename', async () => { - const res = await probe('/src/contrib/PACKAGES.gz', UA_R45_FUTURE_UBUNTU); - assertEquals(res.location, 'https://cran.rpkgs.com/arm64/dynamic-dugong/latest/src/contrib/PACKAGES.gz'); - }); - - await t.step('sends an unidentifiable distro to CRAN', async () => { - const res = await probe('/src/contrib/PACKAGES.gz', UA_R45_MUSL); - assertEquals(res.location, 'https://cran.r-project.org/src/contrib/PACKAGES.gz'); - }); - - await t.step('keeps the macOS rewrite', async () => { - const res = await probe('/src/contrib/foo_1.0.tar.gz', UA_R45_DARWIN); - assertEquals(res.location, 'https://cran.rpkgs.com/bin/macosx/big-sur-arm64/contrib/4.5/foo_1.0.tar.gz'); - }); - - await t.step('keeps the macOS binary passthrough to CRAN', async () => { - const path = '/bin/macosx/big-sur-arm64/contrib/4.5/foo_1.0.tar.gz'; - const res = await probe(path, UA_R45_DARWIN); - assertEquals(res.location, `https://cran.r-project.org${path}`); - }); - - await t.step('collapses duplicate slashes before matching', async () => { - const res = await probe(`/amd64/alpine324//latest/src/contrib//PACKAGES.gz`, UA_R45_MUSL); - assertEquals(res.location, `https://cran.rpkgs.com${SLOT}/4.5/PACKAGES.gz`); - }); - } finally { - await stopServer(server); - } -}); diff --git a/edge/rpkgs-router.ts b/edge/rpkgs-router.ts deleted file mode 100644 index 05b6e18..0000000 --- a/edge/rpkgs-router.ts +++ /dev/null @@ -1,316 +0,0 @@ -/** - * Edge middleware for cran.rpkgs.com. - * - * Two jobs: - * - * 1. Resolve the bare `https://cran.rpkgs.com` form to a concrete - * `/` slot from the User-Agent, or send the client to CRAN when - * the distro cannot be identified. - * 2. Route `PACKAGES*` requests to the per-R-minor slot - * (`…/latest/src/contrib//`), so a stock `install.packages()` sees the - * packages that only exist there. - * - * Only index files are routed. Tarballs are deliberately left alone: R keeps - * the contrib URL it asked for, not the one it was redirected to, so every - * tarball URL is resolved against the flat directory and the union index steers - * the per-minor ones with a `Path: ` field. Rewriting a tarball request - * here would send flat-slot packages into a directory that does not hold them. - * - * Routing is gated on UNION_SLOTS. The raw per-minor index holds only the - * ABI-sensitive subset of a slot; it is safe to route to it only once bincraft - * has republished it as a union of the per-minor and flat slots. - * - * Deployed by OpenTofu from this file (`bunnynet_compute_script.rpkgs_router`). - * Test with `just edge-test`. - */ -import * as BunnySDK from 'https://esm.sh/@bunny.net/edgescript-sdk@0.12'; - -const PUBLIC_CDN_ORIGIN = 'https://cran.rpkgs.com'; -const CRAN_ORIGIN = 'https://cran.r-project.org'; -const PUBLIC_CDN_HOSTS = new Set([ - 'cran.rpkgs.com', - 'cran.allianceswisspass.devxy.io', - // Staging hostnames, so the identical script can run on a test pull zone and - // redirect within itself. Without this a test zone rewrites to - // PUBLIC_CDN_ORIGIN, quietly exercising production instead of itself. - ...(Deno.env.get('EXTRA_PUBLIC_HOSTS') ?? '') - .split(',') - .map((host) => host.trim()) - .filter((host) => host.length > 0), -]); - -/** Slots ("/", comma separated) whose per-minor index is a union. */ -const UNION_SLOTS = new Set( - (Deno.env.get('UNION_SLOTS') ?? '') - .split(',') - .map((slot) => slot.trim()) - .filter((slot) => slot.length > 0), -); - -/** - * R minors for which a per-minor index is actually published. - * - * contribPath() has no way to probe the origin, so a minor that is not - * published here must fall back to the flat index. Routing an unlisted minor - * would send that client to a 404 and it would see no packages at all - a - * silent, total failure rather than a degraded one. - */ -const KNOWN_MINORS = new Set( - (Deno.env.get('KNOWN_MINORS') ?? '4.4,4.5,4.6') - .split(',') - .map((minor) => minor.trim()) - .filter((minor) => minor.length > 0), -); - -/** `///latest/src/contrib[/]` */ -const SLOT_PATH_REGEX = /^\/(amd64|arm64)\/([a-z0-9._-]+)\/latest\/src\/contrib\/?(.*)$/; - -/** A path that already sits in a per-minor slot, e.g. `4.5/PACKAGES.gz`. */ -const MINOR_DIR_REGEX = /^\d+\.\d+\//; - -/** The only files this script routes. */ -const INDEX_FILE_REGEX = /^PACKAGES(\.gz|\.rds)?$/; - -const SRC_CONTRIB_REGEX = /^\/src\/contrib\/(.+)$/; - -/** A binary archive URL whose upstream source counterpart CRAN can serve. */ -const ARCHIVE_TARBALL_REGEX = - /^\/(?:amd64|arm64)\/[a-z0-9._-]+\/latest\/src\/contrib\/Archive\/([^/]+)\/([^/]+\.tar\.gz)$/; - -const MACOS_BIN_REGEX = - /^\/bin\/macosx\/(big-sur-arm64|big-sur-x86_64|monterey-arm64|monterey-x86_64)\/contrib\/([0-9.]+)\/(.+)$/; - -const RHEL_REGEX = /(almalinux|rocky)[^\d]*(\d+)/i; - -const UBUNTU_REGEX = /Ubuntu ([\d.]+)/i; -const UBUNTU_CODENAME_REGEX = /Ubuntu [\d.]+;\s*codename=([a-z][a-z0-9-]*)/i; -const UBUNTU_CODENAMES: Record = { - '26.04': 'resolute', - '24.04': 'noble', - '22.04': 'jammy', -}; - -const ALPINE_REGEX = /(?:Alpine Linux(?:\s+VERSION_ID=)?|alpine-)\s*(\d+)\.(\d+)/i; - -/** - * R's own User-Agent is `R (4.5.3 x86_64-pc-linux-musl …)`; the Posit-style one - * some sites configure is `R/4.5.3 R (…)`. Both carry the minor, which is why - * per-minor routing works without the distro being identifiable. - */ -const R_MINOR_REGEXES = [/\bR\/(\d+)\.(\d+)/, /\bR \((\d+)\.(\d+)/]; - -function normalizePathname(pathname: string): string { - return pathname.replace(/\/{2,}/g, '/'); -} - -function redirectTo(location: string, status = 302): Response { - return new Response(null, { - status, - headers: { - Location: location, - // The target depends on the User-Agent, so the redirect itself must - // never be cached; only its target is a cacheable, UA-independent URL. - 'Cache-Control': 'no-store', - 'X-Via': 'MyMiddleware', - 'X-Rewritten-By': 'rpkgs-edge-middleware', - }, - }); -} - -function publicCdnOrigin(url: URL): string { - return PUBLIC_CDN_HOSTS.has(url.hostname) ? url.origin : PUBLIC_CDN_ORIGIN; -} - -/** - * True when the client reports an R minor that we deliberately do not serve. - * - * A client that reports no minor at all is not "unsupported": non-R fetchers - * (mirror scripts, image builds) must keep getting the flat slot. Only a - * known-and-excluded minor falls through to CRAN. - */ -function isExcludedMinor(userAgent: string): boolean { - const rMinor = extractRMinor(userAgent); - return rMinor !== null && !KNOWN_MINORS.has(rMinor); -} - -function extractRMinor(userAgent: string): string | null { - for (const regex of R_MINOR_REGEXES) { - const match = userAgent.match(regex); - if (match) { - return `${match[1]}.${match[2]}`; - } - } - return null; -} - -function mapArch(arch: string): string { - if (arch === 'aarch64') return 'arm64'; - if (arch === 'x86_64') return 'amd64'; - return arch; -} - -function extractArch(userAgent: string): string { - const match = userAgent.match(/(x86_64|aarch64|arm64|i386|i686)/); - return match ? mapArch(match[1]) : ''; -} - -/** - * Identify the `/` slot from the User-Agent, or null. - * - * A stock R User-Agent carries only `linux-gnu` / `linux-musl`, which are not - * slot names: returning them produced redirects into slots that do not exist - * (`/amd64/linux-musl/latest/…`, a guaranteed 404). An unidentifiable distro - * is reported as such so the caller can fall back to CRAN. - */ -function parseSlot(userAgent: string): string | null { - const arch = extractArch(userAgent); - if (!arch) { - return null; - } - - const rhel = userAgent.match(RHEL_REGEX); - if (rhel) { - return `${arch}/rhel${rhel[2]}`; - } - - const ubuntu = userAgent.match(UBUNTU_REGEX); - if (ubuntu) { - const codenameMatch = userAgent.match(UBUNTU_CODENAME_REGEX); - if (codenameMatch) { - return `${arch}/${codenameMatch[1].toLowerCase()}`; - } - - const codename = UBUNTU_CODENAMES[ubuntu[1]]; - if (codename) { - return `${arch}/${codename}`; - } - } - - const alpine = userAgent.match(ALPINE_REGEX); - if (alpine) { - return `${arch}/alpine${alpine[1]}${alpine[2]}`; - } - - return null; -} - -function parseMacUserAgent(userAgent: string): { os: string; arch: string; rver: string } | null { - const rverMatch = userAgent.match(/R \((\d+)\.(\d+)/); - const archMatch = userAgent.match(/(aarch64|arm64|x86_64)/); - const osMatch = userAgent.match(/darwin(\d+)/); - - if (!rverMatch || !archMatch || !osMatch) { - return null; - } - - const arch = archMatch[1] === 'aarch64' ? 'arm64' : archMatch[1]; - const darwinVer = parseInt(osMatch[1], 10); - const os = darwinVer >= 21 && darwinVer < 22 ? `monterey-${arch}` : `big-sur-${arch}`; - - return { os, arch, rver: `${rverMatch[1]}.${rverMatch[2]}` }; -} - -/** - * The contrib path a request should be served from, relative to the slot. - * - * Returns the per-minor path for an index file when the slot is known to carry - * a union index and the client's R minor is one we publish; otherwise the flat - * path, which is what every client sees today. - */ -function contribPath(slot: string, rest: string, userAgent: string): string { - const flat = rest ? `/${slot}/latest/src/contrib/${rest}` : `/${slot}/latest/src/contrib`; - - if (!INDEX_FILE_REGEX.test(rest) || !UNION_SLOTS.has(slot)) { - return flat; - } - - const rMinor = extractRMinor(userAgent); - return rMinor && KNOWN_MINORS.has(rMinor) ? `/${slot}/latest/src/contrib/${rMinor}/${rest}` : flat; -} - -BunnySDK.net.http - .servePullZone({ url: 'https://cran.rpkgs.com/' }) - .onOriginRequest((ctx) => { - const url = new URL(ctx.request.url); - const path = normalizePathname(url.pathname); - const userAgent = ctx.request.headers.get('User-Agent') || ''; - const publicOrigin = publicCdnOrigin(url); - - // macOS clients are served from CRAN's own binary tree. - const srcContrib = path.match(SRC_CONTRIB_REGEX); - if (srcContrib && /darwin/.test(userAgent)) { - const mac = parseMacUserAgent(userAgent); - if (mac) { - return Promise.resolve(redirectTo(`${publicOrigin}/bin/macosx/${mac.os}/contrib/${mac.rver}/${srcContrib[1]}`)); - } - } - - if (MACOS_BIN_REGEX.test(path)) { - return Promise.resolve(redirectTo(`${CRAN_ORIGIN}${path}`)); - } - - // Already-qualified slot URLs: what the runtime images have baked in. - const slotPath = path.match(SLOT_PATH_REGEX); - if (slotPath) { - const slot = `${slotPath[1]}/${slotPath[2]}`; - const rest = slotPath[3]; - - // Never rewrite a request that is already in a per-minor slot, or the - // redirect would chase its own tail. - if (MINOR_DIR_REGEX.test(rest)) { - return Promise.resolve(ctx.request); - } - - // An R minor outside the supported window has no binaries we can safely - // serve, so the whole interaction goes to CRAN: the index and the - // tarballs R will resolve against it. Serving the index from CRAN but - // tarballs from here would hand R a binary where it expects a source - // tarball, which fails in a far more confusing way than not being - // served at all. - if (UNION_SLOTS.has(slot) && isExcludedMinor(userAgent)) { - return Promise.resolve(redirectTo(`${CRAN_ORIGIN}/src/contrib/${rest}`)); - } - - const target = contribPath(slot, rest, userAgent); - if (target === path) { - return Promise.resolve(ctx.request); - } - return Promise.resolve(redirectTo(`${publicOrigin}${target}`)); - } - - // The bare `https://cran.rpkgs.com` form, resolved from the User-Agent. - if (path === '/' || path === '/src/contrib' || path.startsWith('/src/contrib/')) { - const slot = parseSlot(userAgent); - if (!slot) { - return Promise.resolve(redirectTo(`${CRAN_ORIGIN}${path}`)); - } - - if (UNION_SLOTS.has(slot) && isExcludedMinor(userAgent)) { - return Promise.resolve(redirectTo(`${CRAN_ORIGIN}${path}`)); - } - - const rest = srcContrib ? srcContrib[1] : ''; - return Promise.resolve(redirectTo(`${publicOrigin}${contribPath(slot, rest, userAgent)}`)); - } - - return Promise.resolve(ctx.request); - }) - .onOriginResponse(async (ctx) => { - const path = normalizePathname(new URL(ctx.request.url).pathname); - const archive = path.match(ARCHIVE_TARBALL_REGEX); - - // Binary archives can be incomplete when an older build never succeeded. - // Preserve renv/remotes version restores by falling back to CRAN's source - // package only for an absent archived tarball. A requested version can be - // either archived upstream or still current, so probe the archive first. - // Other 404s remain visible. - if (ctx.response.status === 404 && archive) { - const archiveUrl = `${CRAN_ORIGIN}/src/contrib/Archive/${archive[1]}/${archive[2]}`; - const archiveResponse = await fetch(archiveUrl, { method: 'HEAD' }); - const sourceUrl = archiveResponse.ok ? archiveUrl : `${CRAN_ORIGIN}/src/contrib/${archive[2]}`; - return redirectTo(sourceUrl); - } - - ctx.response.headers.append('X-Via', 'MyMiddleware'); - return Promise.resolve(ctx.response); - }); diff --git a/justfile b/justfile deleted file mode 100644 index 524ac9a..0000000 --- a/justfile +++ /dev/null @@ -1,104 +0,0 @@ -# Local helpers for build-cran-binaries. -# -# `rebuild` (re)builds specific versions of a single package on a given OS/arch -# by dispatching to a remote buildx builder (the build runs there, not locally). -# Sensitivity is auto-detected: risky packages land in the per-minor slot -# (contrib//), everything else in the generic slot; the touched index is -# refreshed so the result is immediately servable. -# -# Prerequisites: -# - buildx builders named `artemis` (amd64) and `gaia` (arm64), created with the -# docker-container driver (runs BuildKit on the remote host's docker daemon over -# SSH). The default `remote` driver does NOT work with an ssh:// docker host. -# Pass --config docker/buildkitd.toml so BuildKit's GC keeps a usable cache -# (the default caps the cache-mount tier at 512 MB, forcing re-downloads). -# docker buildx create --name artemis --driver docker-container --config docker/buildkitd.toml ssh:// -# docker buildx create --name gaia --driver docker-container --config docker/buildkitd.toml ssh:// -# - exported secrets: B2_S3_ACCESS_KEY, B2_S3_SECRET_KEY, PGPASS (GITHUB_PAT optional) -# -# Overridable (env or `just VAR=… rebuild …`): -# R_VERSION (default 4.5.3) — selects the R minor → the per-minor slot -# AMD64_BUILDER / ARM64_BUILDER — buildx builder names -# -# Examples: -# just rebuild alpine 3.23 amd64 rlang 1.1.4 1.1.3 -# just rebuild redhat 10 arm64 data.table 1.15.4 -# R_VERSION=4.4.3 just rebuild ubuntu noble amd64 Rcpp 1.0.12 - -r_version := env_var_or_default("R_VERSION", "4.5.3") -amd64_builder := env_var_or_default("AMD64_BUILDER", "artemis") -arm64_builder := env_var_or_default("ARM64_BUILDER", "gaia") - -# (re)build PACKAGE at one or more VERSIONS on OS/TAG/ARCH via a remote builder -rebuild os tag arch package *versions: - #!/usr/bin/env bash - set -euo pipefail - if [ -z "{{ versions }}" ]; then - echo "error: provide at least one version, e.g. just rebuild alpine 3.23 amd64 rlang 1.1.4" >&2 - exit 1 - fi - case "{{ arch }}" in - amd64) builder="{{ amd64_builder }}" ;; - arm64) builder="{{ arm64_builder }}" ;; - *) echo "error: arch must be 'amd64' or 'arm64'" >&2; exit 1 ;; - esac - # Accept TF_VAR_-prefixed names (direnv) or plain names. - export B2_S3_ACCESS_KEY="${B2_S3_ACCESS_KEY:-${TF_VAR_B2_S3_ACCESS_KEY:-}}" - export B2_S3_SECRET_KEY="${B2_S3_SECRET_KEY:-${TF_VAR_B2_S3_SECRET_KEY:-}}" - : "${B2_S3_ACCESS_KEY:?set B2_S3_ACCESS_KEY or TF_VAR_B2_S3_ACCESS_KEY}" - : "${B2_S3_SECRET_KEY:?set B2_S3_SECRET_KEY or TF_VAR_B2_S3_SECRET_KEY}" - : "${PGPASS:?set PGPASS}" - secret_args=( - --secret id=b2_access,env=B2_S3_ACCESS_KEY - --secret id=b2_secret,env=B2_S3_SECRET_KEY - --secret id=pgpass,env=PGPASS - ) - # GITHUB_PAT is optional (raises the GitHub API rate limit); pass only if set. - if [ -n "${GITHUB_PAT:-}" ]; then - secret_args+=(--secret id=github_pat,env=GITHUB_PAT) - fi - echo "Dispatching build of {{ package }} ({{ versions }}) on {{ os }}:{{ tag }}/{{ arch }} (R {{ r_version }}) to builder '$builder'" - docker buildx build \ - --builder "$builder" \ - --platform "linux/{{ arch }}" \ - --no-cache \ - --progress=plain \ - --output type=cacheonly \ - "${secret_args[@]}" \ - --build-arg OS="{{ os }}" \ - --build-arg OS_VERSION="{{ tag }}" \ - --build-arg R_VERSION="{{ r_version }}" \ - --build-arg PACKAGE="{{ package }}" \ - --build-arg VERSIONS="{{ versions }}" \ - --build-arg CACHEBUST="$(date +%s)" \ - -f docker/build-one.Dockerfile \ - local - -# run the edge middleware routing matrix (uses a local deno, else the deno image) -edge-test: - #!/usr/bin/env bash - set -euo pipefail - if command -v deno >/dev/null 2>&1; then - deno test -A edge/rpkgs-router.test.ts - else - docker run --rm \ - -v "$PWD:/w" -w /w \ - -v deno-cache:/deno-dir \ - denoland/deno:latest \ - deno test -A edge/rpkgs-router.test.ts - fi - -# fail if any pipeline still targets a slot the edge does not route -check-slots: - Rscript local/check-slots.R - -# strip a retired slot from .crow/*.yaml (dry run; pass --apply to write) -retire-slot codename *flags: - Rscript local/retire-slot.R {{ codename }} --config-only {{ flags }} - -# Format or lint selected R files, defaulting to local tooling. -format *files="local": - air format {{ files }} - -fix *files="local": - jarl check --fix {{ files }} diff --git a/local/archive-missed-pkgs.R b/local/archive-missed-pkgs.R index f817c3e..57e92d7 100644 --- a/local/archive-missed-pkgs.R +++ b/local/archive-missed-pkgs.R @@ -11,34 +11,16 @@ s3fs::s3_file_system( arch = "arm64" os = "alpine321" -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/%s/%s/latest/src/contrib", - arch, - os -)) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/%s/%s/latest/src/contrib", arch, os)) length(unique(sapply(strsplit(basename(files), "_"), function(x) x[1]))) -non_archived = unique(sapply(strsplit(basename(files), "_"), function(x) { - x[1] -})[duplicated(sapply(strsplit(basename(files), "_"), function(x) x[1]))]) +non_archived = unique(sapply(strsplit(basename(files), "_"), function(x) x[1])[duplicated(sapply(strsplit(basename(files), "_"), function(x) x[1]))]) # RInno is not built because it only exists for Windows non_archived = setdiff(non_archived, "RInno") # future::plan("sequential", workers = 8) future::plan("sequential", workers = 1) # future.apply::future_lapply(non_archived, function(x) archive_package(x, codename = os, arch = arch)) -lapply(non_archived, function(x) { - archive_package( - x, - codename = os, - arch = arch, - s3_region = "hel1", - s3_endpoint = "https://hel1.your-objectstorage.com", - s3_bucket = "devxy-r-package-binaries-hel1", - s3_access_key_id = Sys.getenv( - "HETZNER_S3_ACCESS_KEY_K3S", - s3_secret_access_key = Sys.getenv("HETZNER_S3_SECRET_KEY_K3S") - ) - ) -}) +lapply(non_archived, function(x) archive_package(x, codename = os, arch = arch, s3_region = "hel1", s3_endpoint = "https://hel1.your-objectstorage.com", s3_bucket = "devxy-r-package-binaries-hel1", s3_access_key_id = Sys.getenv("HETZNER_S3_ACCESS_KEY_K3S", s3_secret_access_key = Sys.getenv("HETZNER_S3_SECRET_KEY_K3S")))) # archive_package() + # grep("duckdb_", files, value = T) diff --git a/local/backfill-abi-classification.R b/local/backfill-abi-classification.R deleted file mode 100644 index c964a86..0000000 --- a/local/backfill-abi-classification.R +++ /dev/null @@ -1,129 +0,0 @@ -### Classify every compiled package in a slot's flat index, into the ABI cache. -# -# Usage: Rscript local/backfill-abi-classification.R [limit] -# -# The per-minor scheme only ever classified packages that passed through the -# build pipeline after it existed. Everything built before that, and not updated -# on CRAN since, has no verdict at all -- and bincraft's risky set is what -# decides whether a flat binary may be carried into a per-minor index. With no -# verdict the answer defaults to "carry it", which is how a base64enc built -# under R 4.4.3 reached R 4.6 clients and died at dyn.load() on SETLENGTH. -# -# The verdict is a property of the source, so it is independent of OS, arch and -# R minor: one slot's backfill populates the cache for every slot. The slot -# argument only selects which flat index to enumerate. -# -# Only packages with NeedsCompilation=yes are classified. A package with no -# compiled code has no symbols to bind and cannot fail this way, so downloading -# its source to prove that would be wasted work. -# -# Resumable: `classify_r_minor_sensitive()` returns cached verdicts without -# touching the network, so a re-run costs one query per package and only the -# unclassified remainder is downloaded. - -options(error = function() { - cat("ERROR:", geterrmessage(), "\n", file = stdout()) - traceback(2) - q(status = 1) -}) - -library(bincraft, quietly = TRUE) - -args <- commandArgs(trailingOnly = TRUE) -if (length(args) < 2L) { - stop( - "usage: backfill-abi-classification.R [limit]", - call. = FALSE - ) -} -arch <- args[[1L]] -codename <- args[[2L]] -limit <- if (length(args) >= 3L) as.integer(args[[3L]]) else NA_integer_ - -db <- list( - metadata_db_type = "postgres", - metadata_db_host = "r-binaries.devxy.io", - metadata_db_name = "build_metadata", - metadata_db_port = 15432L, - metadata_db_user = "rpkgs", - metadata_db_password = Sys.getenv("PGPASS"), - metadata_db_sslmode = "verify-full" -) - -read_index <- function(index_url) { - con <- gzcon(url(index_url, open = "rb")) - on.exit(close(con), add = TRUE) - read.dcf(con, fields = c("Package", "Version", "Built")) -} - -flat <- read_index(sprintf( - "https://cran.rpkgs.com/%s/%s/latest/src/contrib/PACKAGES.gz", - arch, - codename -)) -# Source fallbacks have no binary to be unsafe, so skip them. -flat <- flat[!is.na(flat[, "Built"]), , drop = FALSE] - -cran <- read.dcf( - gzcon(url( - "https://cloud.r-project.org/src/contrib/PACKAGES.gz", - open = "rb" - )), - fields = c("Package", "NeedsCompilation") -) -compiled <- cran[ - !is.na(cran[, "NeedsCompilation"]) & cran[, "NeedsCompilation"] == "yes", - "Package" -] - -todo <- flat[flat[, "Package"] %in% compiled, , drop = FALSE] -cat(sprintf( - "%s/%s: %d binaries in the flat index, %d compiled and due classification\n", - arch, - codename, - nrow(flat), - nrow(todo) -)) -if (!is.na(limit) && limit > 0L && limit < nrow(todo)) { - todo <- todo[seq_len(limit), , drop = FALSE] - cat(sprintf("Limited to the first %d\n", limit)) -} - -sensitive <- 0L -failed <- 0L -for (i in seq_len(nrow(todo))) { - pkg <- todo[i, "Package"] - ver <- todo[i, "Version"] - verdict <- tryCatch( - do.call( - bincraft::classify_r_minor_sensitive, - c(list(package_name = pkg, tag = ver), db) - ), - error = function(e) { - cat(sprintf(" %s %s: %s\n", pkg, ver, conditionMessage(e))) - NA - } - ) - if (is.na(verdict)) { - failed <- failed + 1L - } else if (isTRUE(verdict)) { - sensitive <- sensitive + 1L - } - if (i %% 250L == 0L) { - cat(sprintf( - " classified %d/%d (%d r-minor-sensitive, %d failed)\n", - i, - nrow(todo), - sensitive, - failed - )) - utils::flush.console() - } -} - -cat(sprintf( - "Done: %d classified, %d r-minor-sensitive, %d failed\n", - nrow(todo), - sensitive, - failed -)) diff --git a/local/backfill-flat-safety.R b/local/backfill-flat-safety.R deleted file mode 100644 index 59faa3c..0000000 --- a/local/backfill-flat-safety.R +++ /dev/null @@ -1,199 +0,0 @@ -### Record, per flat-slot object, whether it loads under every supported R minor. -# -# Usage: Rscript local/backfill-flat-safety.R [limit] -# -# `union_index_records()` keeps a carried flat record when that object is -# recorded safe, and drops it otherwise. Objects uploaded before that record -# existed have no verdict, so they are dropped: a full re-index removed ~2000 -# records per per-minor index, all resolving to CRAN source for clients the -# routing serves correctly. -# -# This inspects the objects already in the bucket and writes the verdict, which -# is what restores that coverage. The question is decided by symbols, not -# heuristics: a binary fails at dyn.load() under minor M exactly when it -# references a symbol M does not export, and the volatile set is derived by -# diffing the R builds installed in this image. -# -# Only compiled packages are inspected. A package with no shared object cannot -# fail this way and is never dropped, so proving it would be wasted downloads. -# -# Resumable: objects already recorded are skipped, so a re-run costs one query. - -options(error = function() { - cat("ERROR:", geterrmessage(), "\n", file = stdout()) - traceback(2) - q(status = 1) -}) - -library(bincraft, quietly = TRUE) - -args <- commandArgs(trailingOnly = TRUE) -if (length(args) < 2L) { - stop("usage: backfill-flat-safety.R [limit]", call. = FALSE) -} -arch <- args[[1L]] -codename <- args[[2L]] -limit <- if (length(args) >= 3L) as.integer(args[[3L]]) else NA_integer_ - -sets <- bincraft:::installed_r_symbol_sets() -if (is.null(sets)) { - stop( - "Fewer than two R minors are installed here, so nothing can be compared. Refusing to record verdicts that would all read 'safe'.", # nolint - call. = FALSE - ) -} -cat(sprintf( - "Comparing R minors: %s (%d symbols vary across them)\n", - paste(names(sets), collapse = ", "), - length(bincraft:::cross_minor_volatile_symbols(sets)) -)) - -# The flat slot is listed from S3, not from PACKAGES.gz over HTTPS. Reading the -# index from inside R sends an R User-Agent, which the edge routes to a -# per-minor index; that enumerates union records carrying `Path: `, whose -# objects do not exist at the flat path. Every download then 404s: a first run -# skipped 292 of 300 that way. The bucket cannot be routed and is authoritative. -s3fs::s3_file_system( - aws_access_key_id = Sys.getenv("B2_S3_ACCESS_KEY"), - aws_secret_access_key = Sys.getenv("B2_S3_SECRET_KEY"), - endpoint = "https://s3.eu-central-003.backblazeb2.com", - region_name = "eu-central-003", - refresh = TRUE -) -contrib <- sprintf( - "devxy-rpkgs-binaries/%s/%s/latest/src/contrib", - arch, - codename -) -objects <- s3fs::s3_dir_ls(contrib, recurse = TRUE) -relative <- sub(sprintf("^(s3://)?%s/", contrib), "", objects) -# Flat objects only: no `/` prefix and nothing under Archive/. -flat_files <- relative[ - grepl("\\.tar\\.gz$", relative) & !grepl("/", relative, fixed = TRUE) -] -flat_pkg <- sub("_.*$", "", flat_files) -flat_ver <- sub("\\.tar\\.gz$", "", sub("^[^_]*_", "", flat_files)) - -# Only compiled packages can fail at dyn.load(), so the rest are not worth -# downloading. Ask the slot's own index rather than CRAN's: CRAN lists only the -# versions it currently ships, so a package it has archived is absent, is never -# recognised as compiled, and is never inspected. No verdict is ever recorded -# for it, while `union_index_records()` reads the slot's own `NeedsCompilation` -# and happily drops it -- with nothing able to clear the flag, because the -# repair works from recorded verdicts too. `mixedMem` and `vcpen`, both removed -# from CRAN, were stuck out of every rhel8 per-minor index that way. -# -# Read it from the bucket, not over HTTPS: this runs inside R, so the edge would -# route the request to a per-minor index and the flat objects would not all be -# there. Same reason the object listing above comes from S3. -index_file <- file.path(tempdir(), "flat-PACKAGES.gz") -s3fs::s3_file_download( - sprintf("%s/PACKAGES.gz", contrib), - index_file, - overwrite = TRUE -) -index <- read.dcf( - gzfile(index_file), - fields = c("Package", "Version", "NeedsCompilation") -) -if (nrow(index) == 0L) { - stop( - sprintf( - "Read no records from %s/PACKAGES.gz; refusing to guess what is compiled.", - contrib - ), - call. = FALSE - ) -} -# Key on the object, not the package: a slot can carry several versions and -# only some of them compile. -compiled_objects <- paste( - index[, "Package"], - index[, "Version"], - sep = "_" -)[ - !is.na(index[, "NeedsCompilation"]) & - tolower(index[, "NeedsCompilation"]) == "yes" -] -keep <- paste(flat_pkg, flat_ver, sep = "_") %in% compiled_objects -compiled <- data.frame( - Package = flat_pkg[keep], - Version = flat_ver[keep], - stringsAsFactors = FALSE -) -cat(sprintf( - "%s/%s: %d flat objects, %d compiled and worth inspecting\n", - arch, - codename, - length(flat_files), - nrow(compiled) -)) -if (!is.na(limit) && limit > 0L && limit < nrow(compiled)) { - compiled <- compiled[seq_len(limit), , drop = FALSE] - cat(sprintf("Limited to the first %d\n", limit)) -} - -# Fetch from the bucket as well: the edge does not rewrite tarball requests, -# but it does cache them, and the object is what the verdict is about. -safe <- 0L -unsafe <- 0L -skipped <- 0L -for (i in seq_len(nrow(compiled))) { - pkg <- compiled[i, "Package"] - ver <- compiled[i, "Version"] - tarball <- file.path(tempdir(), sprintf("%s_%s.tar.gz", pkg, ver)) - ok <- tryCatch( - { - s3fs::s3_file_download( - sprintf("%s/%s_%s.tar.gz", contrib, pkg, ver), - tarball, - overwrite = TRUE - ) - file.exists(tarball) - }, - error = function(e) FALSE, - warning = function(w) FALSE - ) - if (!ok) { - skipped <- skipped + 1L - next - } - verdict <- bincraft:::tarball_abi_verdict(tarball, sets) - unlink(tarball) - if (!isTRUE(verdict$inspected)) { - skipped <- skipped + 1L - next - } - bincraft:::flat_safety_store( - pkg, - ver, - codename, - arch, - safe = !isTRUE(verdict$sensitive), - unsupported = verdict$unsupported - ) - if (isTRUE(verdict$sensitive)) { - unsafe <- unsafe + 1L - } else { - safe <- safe + 1L - } - if (i %% 250L == 0L) { - cat(sprintf( - " inspected %d/%d (%d safe, %d unsafe, %d skipped)\n", - i, - nrow(compiled), - safe, - unsafe, - skipped - )) - utils::flush.console() - } -} - -cat(sprintf( - "Done: %d inspected, %d safe for every minor, %d unsafe, %d skipped\n", - nrow(compiled), - safe, - unsafe, - skipped -)) diff --git a/local/build-all.R b/local/build-all.R index 04d382f..651a0c7 100644 --- a/local/build-all.R +++ b/local/build-all.R @@ -1,14 +1,10 @@ sink(stdout(), type = "message") options(crayon.enabled = TRUE, future.globals.onReference = NULL) -source(file.path("local", "r-minor-helpers.R")) -source(file.path("local", "rebuild-missing-helpers.R")) args <- commandArgs(trailingOnly = TRUE) -parsed <- parse_build_args(args) -split_into <- parsed$split_into -split_index <- parsed$split_index -ncpus <- parsed$ncpus -sensitive_only <- parsed$sensitive_only +split_into <- as.integer(args[1]) +split_index <- as.integer(args[2]) +ncpus <- as.integer(args[3]) options(Ncpus = ncpus) # Load bincraft eagerly to avoid lazy-load memory spike during first build call @@ -16,227 +12,46 @@ library(bincraft, quietly = TRUE) library(future) plan("sequential") -# The install-deps step precomputes the package snapshot into /mnt/cache, but -# that volume is per-agent: a job landing on a fresh agent (or racing -# install-deps) finds it empty. Recompute the snapshot here when any part is -# missing, so the first job on an agent repopulates the cache for the jobs that -# follow; concurrent jobs that also miss simply redo the work. Write via a -# temp file + atomic rename so a concurrent reader never sees a half-written rds. -package_cache_files <- c( - "/mnt/cache/packages/pkgs_to_build.rds", - "/mnt/cache/packages/r_minor_sensitive_pkgs.rds", - "/mnt/cache/packages/s3_cache.rds" -) -# Existence is not freshness. The snapshot describes S3 and CRAN state at the -# moment it was written, and the volume is per-agent, so an agent that ran an -# earlier pipeline keeps serving that pipeline's answer forever. arm64/alpine324 -# reported "0 remaining" for both 4.4 and 4.6 from a stale snapshot listing 43 -# sensitive packages, while the install-deps step in the very same pipeline had -# just computed 6871 on another agent. -# -# Keyed on the pipeline when the CI exposes one, so a new pipeline recomputes -# once per agent and its shards then share the result. Off CI, or when no such -# variable is set, fall back to an age check. -snapshot_id_path <- "/mnt/cache/packages/snapshot.id" -snapshot_ttl_hours <- as.numeric( - Sys.getenv("PACKAGE_SNAPSHOT_TTL_HOURS", unset = "2") -) -current_snapshot_id <- "" -for (v in c("CI_PIPELINE_NUMBER", "CI_BUILD_NUMBER", "CI_PIPELINE_ID")) { - val <- Sys.getenv(v, unset = "") - if (nzchar(val)) { - current_snapshot_id <- paste(v, val, sep = "=") - break - } -} +# Read precomputed package+version pairs +pkgs <- readRDS("/mnt/cache/packages/pkgs_to_build.rds") +sprintf("Total# of remaining package versions: %s", nrow(pkgs)) -snapshot_is_stale <- function() { - if (!all(file.exists(package_cache_files))) { - return(TRUE) - } - if (nzchar(current_snapshot_id)) { - cached <- tryCatch( - readLines(snapshot_id_path, warn = FALSE)[1L], - error = function(e) NA_character_, - warning = function(w) NA_character_ - ) - return(!identical(cached, current_snapshot_id)) - } - age_hours <- as.numeric( - difftime(Sys.time(), file.mtime(package_cache_files[1L]), units = "hours") - ) - isTRUE(age_hours > snapshot_ttl_hours) -} - -if (snapshot_is_stale()) { - message( - "Package snapshot missing or stale; recomputing via packages-to-build.R" - ) - dir.create("/mnt/cache/packages", showWarnings = FALSE, recursive = TRUE) - save_rds_atomic <- function(obj, path) { - tmp <- paste0(path, ".tmp.", Sys.getpid()) - saveRDS(obj, tmp) - file.rename(tmp, path) - } - source(file.path("local", "packages-to-build.R")) - save_rds_atomic(pkgs, "/mnt/cache/packages/pkgs_to_build.rds") - save_rds_atomic( - pkgs[r_minor_sensitive == TRUE], - "/mnt/cache/packages/r_minor_sensitive_pkgs.rds" - ) - if (nzchar(current_snapshot_id)) { - writeLines(current_snapshot_id, snapshot_id_path) - } - message("Package snapshot recomputed.") -} - -pkgs <- if (sensitive_only) { - readRDS("/mnt/cache/packages/r_minor_sensitive_pkgs.rds") -} else { - readRDS("/mnt/cache/packages/pkgs_to_build.rds") -} -# Back-compat: tolerate an older RDS without the column (treat all as non-sensitive) -if (is.null(pkgs$r_minor_sensitive)) { - pkgs$r_minor_sensitive <- FALSE -} -sprintf( - "Total# of remaining package versions: %s (sensitive_only=%s)", - nrow(pkgs), - sensitive_only -) - -# Interleave rather than cut the alphabetical list into contiguous blocks: build -# cost clusters by name (Rcpp*, rstan*), and contiguous quarters of the last -# full rebuild ran anywhere from 0.1h to 28h. -chunk <- pkgs[shard_slice(seq_len(nrow(pkgs)), split_into, split_index), ] +# Split into chunks for this worker +chunks <- split(pkgs, cut(seq_len(nrow(pkgs)), split_into, labels = FALSE)) +chunk <- chunks[[split_index]] sprintf("# of package versions for this job: %s", nrow(chunk)) -# Exclude known problematic packages (single source of truth) -exclude <- jsonlite::fromJSON("local/excluded-packages.json")[["package"]] +# Exclude known problematic packages +exclude <- c( + "RInno", "KeyboardSimulator", "R2PPT", "RWinEdt", "blatr", "excel.link", + "spectrino", "taskscheduleR", "MDSGUI", "BiplotGUI", "R2wd", "rFUSION", + "MediaNews", "doBy", "IDPmisc", "frailtypack", "afex", "FrF2", "DoE.base", + "agricolae", "doFuture", "fscaret", "PHYLOGR", "seewave", "pls", "relaimpo", + "geepack", "gggenes", "NPCirc", "repmis", "PNDSIBGE", "lidR", "poismf", + "neonstore", "MachineShop", "mvst", "MacBehaviour", "mcmcderive", "RGIFT", + "KnowBR", "netmeta", "spdep", "Rfast", "compareGroups", "ff", "GsymPoint", + "RcppDynProg", "comtradr", "FD", "PearsonDS", "DCluster", "gRc", "mixlm", + "geospt", "fdth", "ffmanova", "fiery", "ffscrapr", "cold", + "RcmdrPlugin.DoE", "RcmdrPlugin.NMBU", "RcmdrPlugin.RiskDemo", + "RcmdrPlugin.ROC", "RcmdrPlugin.TeachStat", "RcmdrPlugin.TeachingDemos", + "RcmdrPlugin.UCA", "RcmdrPlugin.WorldFlora", "RcmdrPlugin.aRnova", + "RcmdrPlugin.depthTools", "RcmdrPlugin.orloca", "RcmdrPlugin.sos", + "RcmdrPlugin.survival", "RcmdrPlugin.temis", "GWlasso", "GWmodelVis" +) chunk <- chunk[!chunk$Package %in% exclude, ] -# Skip package versions already attempted in a previous run (built or errored). -# pkgs_to_build.rds is a static snapshot from the install-deps step, so on a -# restart it still lists everything an interrupted run already produced. The -# metadata DB reflects that progress, so we re-derive the remaining set here. -# We exclude *all* attempted versions, not just successful ones: a previously -# errored version is skipped by build_binary_package() anyway, so leaving it in -# the chunk only makes the job cycle through it one-by-one for no benefit. -# Derive platform + arch from the running container, mirroring the codename -> -# platform mapping bincraft uses internally. The OS/OS_VERSION selectors are -# workflow-level CI variables that are not injected into the container -# environment, so Sys.getenv() would return "" and this pre-filter would query -# platform "-" and skip nothing. -codename <- bincraft::set_codename(NULL) -platform <- codename_platform(codename) -local_machine <- Sys.info()[["machine"]] -arch <- if (grepl("arm64|aarch64", local_machine)) "arm64" else "amd64" -con <- DBI::dbConnect( - RPostgres::Postgres(), - dbname = "build_metadata", - host = "r-binaries.devxy.io", - port = 15432, - user = "rpkgs", - password = Sys.getenv("PGPASS"), - sslmode = "verify-full", - sslrootcert = bincraft::postgres_sslrootcert("verify-full") -) -# Scope the skip to the R minor this pass is running under. `single_builds` -# records `r_version` per attempt, but querying without it made a non-primary -# pass skip everything the primary pass had already attempted under a different -# minor - so `--sensitive-only` under 4.6 skipped packages that had only ever -# been built for 4.5, and the per-minor slots never filled. That is why -# amd64/resolute served 4000 fewer packages to a 4.6 client than to a 4.5 one. -r_minor <- paste( - R.version$major, - strsplit(R.version$minor, ".", fixed = TRUE)[[1L]][1L], - sep = "." -) -built <- DBI::dbGetQuery( - con, - paste( - "SELECT name, tag FROM single_builds", - "WHERE platform = $1 AND arch = $2", - "AND substring(r_version from '^[0-9]+[.][0-9]+') = $3" - ), - params = list(platform, arch, r_minor) -) -DBI::dbDisconnect(con) -before <- nrow(chunk) -chunk <- chunk[ - !paste(chunk$Package, chunk$Version) %in% paste(built$name, built$tag), -] -sprintf( - "Skipped %d package versions already attempted under R %s; %d remaining for this job", - before - nrow(chunk), - r_minor, - nrow(chunk) -) - # Read pre-computed S3 listing from install-deps step # This avoids loading s3fs/reticulate/Python in the build container, -# saving significant memory for the dependency-installer subprocesses -s3_cache_paths <- readRDS("/mnt/cache/packages/s3_cache.rds") +# saving significant memory for pak subprocess forks +s3_cache <- readRDS("/mnt/cache/packages/s3_cache.rds") +sprintf("S3 cache: %s files", length(s3_cache)) -# The cache is stored as paths relative to the slot, so a pass can select the -# objects that belong to it. `build_binary_package()` compares basenames, which -# cannot distinguish `4.4/curl_1.0.tar.gz` from `curl_1.0.tar.gz`, so the choice -# has to be made here where the running R minor is known. -# -# Getting this wrong is expensive in both directions: hand it everything and a -# per-minor pass believes the flat slot's binaries are its own and builds -# nothing; hand it nothing and it rebuilds what it already has. amd64/resolute -# recompiled 8683 packages that way. -select_cache_for_pass <- function(paths, sensitive_only, r_minor) { - # A cache written before #191 holds bare basenames. Filtering those by path - # would select nothing and trigger a full rebuild, so use them as they are; - # #190's staleness check replaces it on the next pipeline anyway. - # - # The format is read from the marker `packages-to-build.R` sets, not guessed - # from the content: a slot-relative cache with no per-minor or Archive object - # holds bare names too, and treating that as legacy would hand a per-minor - # pass the flat slot's binaries and build nothing. - if (!isTRUE(attr(paths, "slot_relative"))) { - message("S3 cache is in the legacy basename format; using it unfiltered.") - return(paths) - } - in_minor <- grepl(sprintf("^%s/", r_minor), paths) - if (sensitive_only) { - basename(paths[in_minor]) - } else { - # The primary pass writes the flat slot. Archive/ counts as present there: - # those are versions built and later superseded. - basename(paths[!grepl("^[0-9]+\\.[0-9]+/", paths)]) - } -} - -s3_cache <- select_cache_for_pass(s3_cache_paths, sensitive_only, r_minor) -sprintf( - "S3 cache: %s files (%s of %s objects apply to this pass)", - length(s3_cache), - length(s3_cache), - length(s3_cache_paths) -) - -deadline <- build_deadline() n <- nrow(chunk) -for (i in seq_len(n)) { - if (deadline_reached(deadline)) { - cat(sprintf( - "Build deadline reached after %d/%d package versions; stopping cleanly. The next run resumes from the metadata DB.\n", - i - 1L, - n - )) - break - } - pkg <- chunk$Package[i] - ver <- chunk$Version[i] - sens <- chunk$r_minor_sensitive[i] - cat(sprintf("[%d/%d] %s_%s (r_minor_sensitive=%s)\n", i, n, pkg, ver, sens)) +mapply(function(pkg, ver, i) { + cat(sprintf("[%d/%d] %s_%s\n", i, n, pkg, ver)) bincraft::build_binary_package( pkg, tag = ver, - is_r_minor_sensitive = isTRUE(sens), s3_endpoint = "https://s3.eu-central-003.backblazeb2.com", s3_region = "eu-central-003", s3_bucket = "devxy-rpkgs-binaries", @@ -248,11 +63,10 @@ for (i in seq_len(n)) { metadata_db_table = "single_builds", metadata_db_user = "rpkgs", metadata_db_password = Sys.getenv("PGPASS"), - metadata_db_sslmode = "verify-full", + metadata_db_sslmode = "require", metadata_db_port = 15432, archive = TRUE, - patches = "local/patches", upload = TRUE, store_build_metadata = TRUE ) -} +}, chunk$Package, chunk$Version, seq_len(n)) diff --git a/local/build-newer-r.R b/local/build-newer-r.R deleted file mode 100644 index 05ffba0..0000000 --- a/local/build-newer-r.R +++ /dev/null @@ -1,171 +0,0 @@ -source(file.path("local", "newer-r-helpers.R")) -source(file.path("local", "rebuild-missing-helpers.R")) -source(file.path("local", "r-minor-helpers.R")) - -args <- commandArgs(trailingOnly = TRUE) -pos <- args[!startsWith(args, "--")] -if (!length(pos) %in% c(1L, 3L)) { - stop("Usage: build-newer-r.R PRIMARY_R [SPLIT_INTO SPLIT_INDEX] [--dry-run]") -} -primary_r <- pos[1L] -target_r <- as.character(getRversion()) -pkgs <- newer_r_candidates(tools::CRAN_package_db(), primary_r, target_r) -exclude <- jsonlite::fromJSON("local/excluded-packages.json")[["package"]] -pkgs <- pkgs[!pkgs$Package %in% exclude, , drop = FALSE] -if (length(pos) == 3L) { - pkgs <- pkgs[ - shard_slice(seq_len(nrow(pkgs)), pos[2L], pos[3L]), - , - drop = FALSE - ] -} -message(sprintf( - "R %s: %d package(s) unsupported by primary R %s", - target_r, - nrow(pkgs), - primary_r -)) -if ("--dry-run" %in% args) { - print(pkgs, row.names = FALSE) -} else { - # Most candidates were built on an earlier run. Asking bincraft about each one - # costs a DB connection plus several S3 requests, about 4s a package, so the - # loop spent well over an hour per run re-confirming existing binaries. - # Decide those in bulk first; bincraft still checks whatever is left. - local_machine <- Sys.info()[["machine"]] - arch <- if (grepl("arm64|aarch64", local_machine)) "arm64" else "amd64" - slot_dir <- sprintf( - "devxy-rpkgs-binaries/%s/%s/latest/src/contrib", - arch, - bincraft::set_codename(NULL) - ) - s3fs::s3_file_system( - aws_access_key_id = Sys.getenv("B2_S3_ACCESS_KEY"), - aws_secret_access_key = Sys.getenv("B2_S3_SECRET_KEY"), - endpoint = "https://s3.eu-central-003.backblazeb2.com", - region_name = "eu-central-003", - refresh = TRUE - ) - # NULL when the listing fails, so that route falls back to bincraft. - list_etags <- function(dir) { - info <- tryCatch(s3fs::s3_dir_info(dir), error = function(e) { - message(sprintf("Could not list %s: %s", dir, conditionMessage(e))) - NULL - }) - if (is.null(info)) { - return(NULL) - } - stats::setNames( - gsub('^"|"$', "", as.character(info$etag)), - basename(as.character(info$uri)) - ) - } - # The verdicts bincraft::classify_r_minor_sensitive() would read from its - # cache, fetched in one query rather than one connection per package. - read_verdicts <- function(packages) { - tryCatch( - { - con <- DBI::dbConnect( - RPostgres::Postgres(), - dbname = "build_metadata", - host = "r-binaries.devxy.io", - port = 15432, - user = "rpkgs", - password = Sys.getenv("PGPASS"), - sslmode = "verify-full", - sslrootcert = bincraft::postgres_sslrootcert("verify-full") - ) - on.exit(DBI::dbDisconnect(con), add = TRUE) - rows <- DBI::dbGetQuery( - con, - paste( - "SELECT package, version, r_minor_sensitive FROM abi_classification", - "WHERE classifier_sig = $1 AND package = ANY($2::text[])" - ), - params = list( - bincraft:::abi_classifier_signature(), - paste0("{", paste(packages, collapse = ","), "}") - ) - ) - stats::setNames( - as.logical(rows$r_minor_sensitive), - paste(rows$package, rows$version, sep = "_") - ) - }, - error = function(e) { - message(sprintf("Could not read ABI verdicts: %s", conditionMessage(e))) - logical() - } - ) - } - sensitive <- read_verdicts(pkgs$Package) - before <- nrow(pkgs) - pkgs <- newer_r_outstanding( - pkgs, - sensitive, - list_etags(slot_dir), - list_etags(file.path( - slot_dir, - sub("^(\\d+\\.\\d+).*", "\\1", target_r) - )), - bincraft:::cran_source_md5() - ) - message(sprintf( - "%d of %d already carry a binary at their routed path; %d left for bincraft", - before - nrow(pkgs), - before, - nrow(pkgs) - )) - - options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = NULL) - deadline <- build_deadline() - for (i in seq_len(nrow(pkgs))) { - if (deadline_reached(deadline)) { - message(sprintf( - "Build deadline reached after %d/%d package(s); stopping cleanly.", - i - 1L, - nrow(pkgs) - )) - break - } - message(sprintf( - "[%d/%d] %s %s", - i, - nrow(pkgs), - pkgs$Package[i], - pkgs$Version[i] - )) - bincraft::build_binary_package( - pkgs$Package[i], - tag = pkgs$Version[i], - # Keep bincraft's normal ABI routing: safe binaries can be shared; - # sensitive ones use this interpreter's minor for presence and output. - is_r_minor_sensitive = bincraft::classify_r_minor_sensitive( - pkgs$Package[i], - pkgs$Version[i], - metadata_db_host = "r-binaries.devxy.io", - metadata_db_name = "build_metadata", - metadata_db_user = "rpkgs", - metadata_db_password = Sys.getenv("PGPASS"), - metadata_db_sslmode = "verify-full", - metadata_db_port = 15432 - ), - 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"), - metadata_db_host = "r-binaries.devxy.io", - metadata_db_name = "build_metadata", - metadata_db_table = "single_builds", - metadata_db_user = "rpkgs", - metadata_db_password = Sys.getenv("PGPASS"), - metadata_db_sslmode = "verify-full", - metadata_db_port = 15432, - archive = TRUE, - patches = "local/patches", - upload = TRUE, - store_build_metadata = TRUE - ) - } -} diff --git a/local/build-one.R b/local/build-one.R deleted file mode 100644 index 25aae6e..0000000 --- a/local/build-one.R +++ /dev/null @@ -1,164 +0,0 @@ -# Targeted (re)build of specific versions of a single package. -# Invoked inside a build-env container (see docker/build-one.Dockerfile). -# Usage: build-one.R [--sensitive-only] [ ...] -# Sensitivity is auto-detected per version via bincraft's ABI classifier: -# risky packages go to the per-minor slot, everything else to the generic slot. -# With --sensitive-only, non-risky versions are skipped (used for the extra -# per-minor passes under non-primary R versions). - -options(crayon.enabled = TRUE, future.globals.onReference = NULL) - -args <- commandArgs(trailingOnly = TRUE) -sensitive_only <- "--sensitive-only" %in% args -args <- args[args != "--sensitive-only"] -if (length(args) < 2L) { - stop( - "usage: build-one.R [--sensitive-only] [ ...]", - call. = FALSE - ) -} -package <- args[1L] -versions <- args[-1L] - -library(bincraft, quietly = TRUE) - -s3 <- list( - 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") -) - -# Clone the CRAN source for a version and ask the ABI classifier whether it -# must be rebuilt per R minor. Fails safe to TRUE so a possibly-fragile binary -# is never served from the cross-minor generic slot by mistake. -classify <- function(pkg, ver) { - dest <- file.path(tempdir(), sprintf("classify_%s_%s", pkg, ver)) - on.exit(unlink(dest, recursive = TRUE, force = TRUE), add = TRUE) - tryCatch( - { - message(sprintf( - "[classify] cloning %s@%s from github.com/cran ...", - pkg, - ver - )) - system2( - "git", - c( - "clone", - "--depth", - "1", - "--branch", - ver, - sprintf("https://github.com/cran/%s", pkg), - dest - ) - ) - message(sprintf("[classify] running ABI classifier on %s ...", pkg)) - isTRUE(as.logical(bincraft::needs_per_minor_recompile(dest))) - }, - error = function(e) { - message(sprintf( - "classify failed for %s %s: %s; treating as r-minor-sensitive", - pkg, - ver, - conditionMessage(e) - )) - TRUE - } - ) -} - -minor <- paste( - R.version$major, - strsplit(R.version$minor, ".", fixed = TRUE)[[1L]][1L], - sep = "." -) -touched_generic <- FALSE -touched_minor <- FALSE - -for (ver in versions) { - sensitive <- classify(package, ver) - if (sensitive_only && !sensitive) { - message(sprintf( - "Skipping %s %s under R %s (not r-minor-sensitive)", - package, - ver, - minor - )) - next - } - cat(sprintf( - "Building %s %s (r_minor_sensitive=%s, R %s)\n", - package, - ver, - sensitive, - minor - )) - bincraft::build_binary_package( - package, - tag = ver, - is_r_minor_sensitive = sensitive, - force = TRUE, - upload = TRUE, - archive = TRUE, - patches = "local/patches", - store_build_metadata = TRUE, - s3_endpoint = s3$s3_endpoint, - s3_region = s3$s3_region, - s3_bucket = s3$s3_bucket, - s3_access_key_id = s3$s3_access_key_id, - s3_secret_access_key = s3$s3_secret_access_key, - metadata_db_host = "r-binaries.devxy.io", - metadata_db_name = "build_metadata", - metadata_db_table = "single_builds", - metadata_db_user = "rpkgs", - metadata_db_password = Sys.getenv("PGPASS"), - metadata_db_sslmode = "verify-full", - metadata_db_port = 15432 - ) - if (sensitive) touched_minor <- TRUE else touched_generic <- TRUE -} - -# Signal the container wrapper whether per-minor passes are warranted (a single -# package's sensitivity is the same across R minors, so a non-sensitive package -# need not touch any other minor's library). -if (touched_minor) { - file.create(".r_minor_sensitive") -} - -# Refresh the PACKAGES index for each slot we wrote to, so the (re)built binary -# is immediately resolvable by clients. -codename <- bincraft::set_codename(NULL) -# cranlike keeps a working PACKAGES.db in the CWD; clear any copy left by a -# previous pass so each per-slot index is built fresh. Otherwise the 2nd index -# update in the same container fails with "table packages already exists". -clean_index_workdir <- function() { - unlink(c("PACKAGES", "PACKAGES.gz", "PACKAGES.rds", "PACKAGES.db")) -} -if (touched_generic) { - cat("Refreshing generic index\n") - clean_index_workdir() - bincraft::upload_package_index( - codename = codename, - s3_endpoint = s3$s3_endpoint, - s3_region = s3$s3_region, - s3_bucket = s3$s3_bucket, - s3_access_key_id = s3$s3_access_key_id, - s3_secret_access_key = s3$s3_secret_access_key - ) -} -if (touched_minor) { - cat(sprintf("Refreshing per-minor index %s\n", minor)) - clean_index_workdir() - bincraft::upload_package_index( - codename = codename, - r_minor = minor, - s3_endpoint = s3$s3_endpoint, - s3_region = s3$s3_region, - s3_bucket = s3$s3_bucket, - s3_access_key_id = s3$s3_access_key_id, - s3_secret_access_key = s3$s3_secret_access_key - ) -} diff --git a/local/check-NA.R b/local/check-NA.R index 95c158e..7405db4 100644 --- a/local/check-NA.R +++ b/local/check-NA.R @@ -1,3 +1,4 @@ + ### Scope: Check whether there are any incomplete entries in PACKAGES.rds. These will result in NA when calling available.packages() foo = available.packages("https://cran.devxy.io/amd64/jammy/latest/src/contrib") sum((is.na(foo[, "Version"]))) @@ -16,9 +17,7 @@ foo = available.packages("https://cran.devxy.io/amd64/rhel9/latest/src/contrib") sum((is.na(foo[, "Version"]))) which((is.na(foo[, "Version"]))) -foo = available.packages( - "https://cran.devxy.io/amd64/alpine320/latest/src/contrib" -) +foo = available.packages("https://cran.devxy.io/amd64/alpine320/latest/src/contrib") sum((is.na(foo[, "Version"]))) which((is.na(foo[, "Version"]))) @@ -41,8 +40,6 @@ foo = available.packages("https://cran.devxy.io/arm64/rhel9/latest/src/contrib") sum((is.na(foo[, "Version"]))) which((is.na(foo[, "Version"]))) -foo = available.packages( - "https://cran.devxy.io/arm64/alpine320/latest/src/contrib" -) +foo = available.packages("https://cran.devxy.io/arm64/alpine320/latest/src/contrib") sum((is.na(foo[, "Version"]))) which((is.na(foo[, "Version"]))) diff --git a/local/check-slots.R b/local/check-slots.R deleted file mode 100644 index 5345da9..0000000 --- a/local/check-slots.R +++ /dev/null @@ -1,151 +0,0 @@ -### Fail when a pipeline targets a slot that is not in `local.rpkgs_slots`. -# -# Rscript local/check-slots.R -# -# That list feeds `UNION_SLOTS`, which `edge/rpkgs-router.ts` gates per-R-minor -# routing on. An unrouted slot serves the flat index to every client, so its -# binaries fail at dyn.load() under every R minor but one. -# -# One-directional: a published slot missing from some pipeline is only -# reported, since several pipelines cover a subset on purpose. - -options(error = function() { - cat("ERROR:", geterrmessage(), "\n", file = stdout()) - q(status = 1) -}) - -# Parses the distro list out of the setproduct's second array. -published_codenames <- function(path = "cdn.tf") { - if (!file.exists(path)) { - stop( - sprintf("%s not found; run this from the repository root.", path), - call. = FALSE - ) - } - lines <- readLines(path, warn = FALSE) - start <- grep("rpkgs_slots\\s*=", lines) - if (length(start) != 1L) { - stop( - "Could not find exactly one `rpkgs_slots` local in cdn.tf.", - call. = FALSE - ) - } - block <- paste(lines[start:min(start + 10L, length(lines))], collapse = "\n") - arrays <- regmatches(block, gregexpr("\\[[^]]*\\]", block))[[1L]] - if (length(arrays) < 2L) { - stop( - "`rpkgs_slots` no longer has the two-array setproduct shape this parses.", - call. = FALSE - ) - } - codenames <- gsub( - '"', - "", - regmatches(arrays[[2L]], gregexpr('"[^"]+"', arrays[[2L]]))[[1L]] - ) - if (length(codenames) == 0L) { - stop("Parsed an empty distro list from cdn.tf.", call. = FALSE) - } - codenames -} - -UBUNTU_CODENAMES <- c( - resolute = "ubuntu-2604", - noble = "ubuntu-2404", - jammy = "ubuntu-2204" -) - -as_pipeline_os <- function(codename) { - ifelse( - codename %in% names(UBUNTU_CODENAMES), - UBUNTU_CODENAMES[codename], - ifelse( - grepl("^rhel[0-9]+$", codename), - sub("^rhel", "redhat-", codename), - ifelse( - grepl("^alpine[0-9]+$", codename), - sub("^alpine([0-9])([0-9]+)$", "alpine-\\1\\2", codename), - NA_character_ - ) - ) - ) -} - -# Structural lines only, so a codename in a comment is not a finding. -slots_in_pipeline <- function(path) { - lines <- readLines(path, warn = FALSE) - row <- regmatches( - lines, - regexec("^\\s*-?\\s*(OS|CODENAME|OS_ID):\\s*(\\S+)\\s*$", lines) - ) - opt <- regmatches( - lines, - regexec("^\\s*-\\s*([a-z0-9]+-[a-z0-9]+)-(amd64|arm64)\\s*$", lines) - ) - hits <- c( - vapply( - row, - function(m) if (length(m) == 3L) m[[3L]] else NA_character_, - "" - ), - vapply(opt, function(m) if (length(m) == 4L) m[[2L]] else NA_character_, "") - ) - hits <- hits[!is.na(hits)] - # `OS: alpine` (build-all-versions' bare image name) is not a slot. - unique(hits[grepl("^(alpine|redhat|ubuntu)-?[0-9]", hits)]) -} - -codenames <- published_codenames() -published_os <- unname(as_pipeline_os(codenames)) -if (anyNA(published_os)) { - stop( - sprintf( - "Unrecognised codename(s) in cdn.tf: %s", - paste(codenames[is.na(published_os)], collapse = ", ") - ), - call. = FALSE - ) -} -# Files spell a slot either way, so accept both. -published <- unique(c(published_os, codenames)) - -cat(sprintf( - "Published slots (cdn.tf): %s\n\n", - paste(sort(published_os), collapse = ", ") -)) - -files <- sort(list.files(".crow", pattern = "\\.yaml$", full.names = TRUE)) -findings <- list() -for (f in files) { - stale <- setdiff(slots_in_pipeline(f), published) - if (length(stale) > 0L) { - findings[[f]] <- stale - cat(sprintf( - "%-45s targets unpublished: %s\n", - f, - paste(sort(stale), collapse = ", ") - )) - } -} - -uncovered <- setdiff( - published_os, - unique(unlist(lapply(files, slots_in_pipeline))) -) -if (length(uncovered) > 0L) { - cat(sprintf( - "\nNote: %s appear(s) in no pipeline at all.\n", - paste(sort(uncovered), collapse = ", ") - )) -} - -if (length(findings) == 0L) { - cat("All pipeline slots are published and routed.\n") - quit(status = 0) -} - -cat(sprintf( - "\n%d file(s) target an unrouted slot. Retire it with:\n just retire-slot \n", - length(findings) -)) -quit(status = 1) diff --git a/local/compiler-cache.sh b/local/compiler-cache.sh deleted file mode 100644 index 8e179b2..0000000 --- a/local/compiler-cache.sh +++ /dev/null @@ -1,32 +0,0 @@ -# Sourced (`. local/compiler-cache.sh`) by the build pipelines before any -# package is compiled. POSIX sh: the Alpine images run steps under busybox. -# -# Routes gcc/g++ through ccache. The images name their compilers by bare -# `gcc`/`g++` in both R's Makeconf and /root/.R/Makevars, so prepending ccache's -# masquerade dir catches every compile, CMake-driven vendored builds included. -# Wrapping CC in a Makevars instead would need R_MAKEVARS_USER, which replaces -# the images' /root/.R/Makevars (CXX_STD, the musl defines) rather than adding -# to it. The dir differs per distro: Alpine, RHEL, Debian/Ubuntu. -for dir in /usr/lib/ccache/bin /usr/lib64/ccache /usr/lib/ccache; do - if [ -x "$dir/gcc" ]; then - PATH="$dir:$PATH" - break - fi -done -export PATH - -# R compiles every package in a fresh /tmp/RtmpXXXXXX/ dir. R's default -# flags include -g, which makes ccache hash the working directory, and the line -# markers carry the absolute source path, so without these two settings no -# compile ever hits the cache across runs. -export CCACHE_BASEDIR="${CCACHE_BASEDIR:-/tmp}" -export CCACHE_NOHASHDIR=1 -# The images are rebuilt regularly, which changes the compiler's mtime but not -# its content. ccache's default mtime check would discard the cache each time. -export CCACHE_COMPILERCHECK=content - -# Parallel make inside a single package build. Match it to the step's CPU limit -# via MAKE_JOBS; an explicit MAKEFLAGS wins. -export MAKEFLAGS="${MAKEFLAGS:--j${MAKE_JOBS:-2}}" - -echo "compiler-cache: $(command -v gcc), CCACHE_DIR=${CCACHE_DIR:-unset}, MAKEFLAGS=$MAKEFLAGS" diff --git a/local/debug-packages-writing.R b/local/debug-packages-writing.R index 533ae2b..5a0fd24 100644 --- a/local/debug-packages-writing.R +++ b/local/debug-packages-writing.R @@ -2,58 +2,42 @@ library(future) future::plan(multisession) future::plan(sequential) time = Sys.time() -files <- s3fs::s3_dir_ls( - sprintf( - "devxy-r-package-binaries-hel1/arm64/rhel9/latest/src/contrib/Archive" - ), - recurse = T -) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/arm64/rhel9/latest/src/contrib/Archive"), recurse = T) Sys.time() - time + archive <- llply(dirs, function(dir) { - files <- list.files( - dir, - recursive = FALSE, - full.names = TRUE, - pattern = "*.tar.gz" - ) + files <- list.files(dir, recursive = FALSE, full.names = TRUE, pattern = "*.tar.gz") if (length(files) == 0) { print(paste0("Error: Empty directory: ", dir)) return(NULL) } info <- file.info(files) - tryCatch( - { - rownames(info) <- paste0(basename(dirname(files)), "/", basename(files)) - }, - error = function(e) { - print(paste0("Error: Exception catched for Archived directory: ", dir)) - print(e) - return(NULL) - } - ) + tryCatch({ + rownames(info) <- paste0(basename(dirname(files)), "/", basename(files)) + }, error = function(e) { + print(paste0("Error: Exception catched for Archived directory: ", dir)) + print(e) + return(NULL) + }) info }) -tryCatch( - { - rownames(info) <- paste0(basename(dirname(files)), "/", basename(files)) - }, - error = function(e) { - print(paste0("Error: Exception catched for Archived directory: ", dir)) - print(e) - return(NULL) - } -) +tryCatch({ + rownames(info) <- paste0(basename(dirname(files)), "/", basename(files)) +}, error = function(e) { + print(paste0("Error: Exception catched for Archived directory: ", dir)) + print(e) + return(NULL) +}) -curl::curl_download( - "https://cran.devxy.io/amd64/rhel9/latest/src/contrib/PACKAGES.db", - "PACKAGES.db" -) + + +curl::curl_download("https://cran.devxy.io/amd64/rhel9/latest/src/contrib/PACKAGES.db", "PACKAGES.db") con = DBI::dbConnect(RSQLite::SQLite(), "PACKAGES.db") df = DBI::dbReadTable(con, "packages") @@ -66,14 +50,6 @@ which(grepl("digest", df$Package)) system("cat /tmp/PACKAGES | grep '^Package: digest' | wc -l") -curl::curl_fetch_memory( - "https://cloud.r-project.org/src/contrib/Meta/archive.rds" -) -remotes = readRDS(url( - "https://cloud.r-project.org/src/contrib/Meta/archive.rds", - "rb" -)) -packages = readRDS(url( - "https://cran.devxy.io/arm64/noble/latest/src/contrib/PACKAGES.rds", - "rb" -)) +curl::curl_fetch_memory("https://cloud.r-project.org/src/contrib/Meta/archive.rds") +remotes = readRDS(url("https://cloud.r-project.org/src/contrib/Meta/archive.rds", "rb")) +packages = readRDS(url("https://cran.devxy.io/arm64/noble/latest/src/contrib/PACKAGES.rds", "rb")) diff --git a/local/dedupe-audit-issue.R b/local/dedupe-audit-issue.R deleted file mode 100644 index c78015a..0000000 --- a/local/dedupe-audit-issue.R +++ /dev/null @@ -1,150 +0,0 @@ -# One-off maintenance: collapse the duplicate arch subsections that accumulated -# in the "Missing package binaries for latest version ()" issues. -# -# A bug in weekly-missing-binaries-audit.R matched the existing "### " -# subsection by its bare header while writing headers with a -# " (N missing, M to rebuild)" suffix, so every audit run appended a fresh block -# instead of replacing it. This script rewrites each "## " section to -# keep only the *last* (freshest) block per arch. The audit fix prevents further -# accumulation; this cleans up what is already there. -# -# Env: FORGEJO_TOKEN (required). DRY_RUN=1 to preview counts without patching. - -library(httr2, quietly = TRUE) - -forgejo_base <- "https://git.devxy.io/api/v1" -repo <- "devxy/build-cran-binaries" -token <- Sys.getenv("FORGEJO_TOKEN") -dry_run <- nchar(Sys.getenv("DRY_RUN")) > 0 - -if (nchar(token) == 0) { - stop("FORGEJO_TOKEN env var is not set") -} - -issue_titles <- c( - "Missing package binaries for latest version (Alpine)", - "Missing package binaries for latest version (Ubuntu)", - "Missing package binaries for latest version (Red Hat)" -) - -# Collapse one "## " block: keep only the last block per arch, -# emitted in order of first appearance. `pl[1]` is the "## " header. -dedupe_platform <- function(pl) { - sub_hdr <- which(grepl("^### ", pl)) - if (length(sub_hdr) == 0) { - return(pl) - } - preamble <- pl[seq_len(sub_hdr[1] - 1)] - sub_end <- c(sub_hdr[-1] - 1, length(pl)) - blocks <- lapply(seq_along(sub_hdr), function(k) { - pl[seq(sub_hdr[k], sub_end[k])] - }) - arches <- vapply( - blocks, - function(b) sub("^### (\\S+).*", "\\1", b[1]), - character(1) - ) - # Index of the last block for each arch, kept in first-appearance order. - last_idx <- vapply( - unique(arches), - function(a) max(which(arches == a)), - integer(1) - ) - keep <- sort(last_idx) - out <- preamble - for (i in keep) { - out <- c(out, blocks[[i]]) - } - out -} - -process_issue <- function(title) { - search_url <- sprintf( - "%s/repos/%s/issues?type=issues&state=open&q=%s&limit=50", - forgejo_base, - repo, - utils::URLencode(title, reserved = TRUE) - ) - resp <- request(search_url) |> - req_headers(Authorization = paste("token", token)) |> - req_perform() - issues <- resp_body_json(resp, simplifyVector = FALSE) - match_idx <- which(vapply(issues, function(x) x$title, character(1)) == title) - if (length(match_idx) == 0) { - cat(sprintf("[skip] No issue found: %s\n", title)) - return(invisible()) - } - - issue_number <- issues[[match_idx[1]]]$number - body <- issues[[match_idx[1]]]$body - if (is.null(body) || nchar(body) == 0) { - cat(sprintf("[skip] Empty body: #%d %s\n", issue_number, title)) - return(invisible()) - } - - lines <- strsplit(body, "\n", fixed = TRUE)[[1]] - before <- sum(grepl("^### ", lines)) - - # Split off the "## Excluded packages" footer so it is preserved verbatim. - excl_idx <- which(lines == "## Excluded packages") - footer <- character(0) - if (length(excl_idx) > 0) { - pre_dash <- which(lines == "---" & seq_along(lines) < excl_idx[1]) - cut <- if (length(pre_dash) > 0) pre_dash[length(pre_dash)] else excl_idx[1] - footer <- lines[seq(cut, length(lines))] - lines <- lines[seq_len(cut - 1)] - } - - # Platform headers ("## "); everything before the first is preamble. - plat_idx <- which(grepl("^## ", lines)) - if (length(plat_idx) == 0) { - cat(sprintf("[skip] No platform sections: #%d %s\n", issue_number, title)) - return(invisible()) - } - top <- lines[seq_len(plat_idx[1] - 1)] - plat_end <- c(plat_idx[-1] - 1, length(lines)) - - new_lines <- top - for (j in seq_along(plat_idx)) { - pl <- lines[seq(plat_idx[j], plat_end[j])] - new_lines <- c(new_lines, dedupe_platform(pl)) - } - if (length(footer) > 0) { - new_lines <- c(new_lines, footer) - } - - after <- sum(grepl("^### ", new_lines)) - cat(sprintf( - "#%d %s: %d -> %d arch subsections%s\n", - issue_number, - title, - before, - after, - if (dry_run) " (dry run, not patched)" else "" - )) - - if (dry_run) { - return(invisible()) - } - - patch_url <- sprintf( - "%s/repos/%s/issues/%d", - forgejo_base, - repo, - issue_number - ) - request(patch_url) |> - req_headers( - Authorization = paste("token", token), - `Content-Type` = "application/json" - ) |> - req_body_json(list(body = paste(new_lines, collapse = "\n"))) |> - req_method("PATCH") |> - req_perform() - cat(sprintf(" patched #%d\n", issue_number)) -} - -for (t in issue_titles) { - process_issue(t) -} -cat("Done.\n") diff --git a/local/detect-duplicates.R b/local/detect-duplicates.R index f7e2c18..076499d 100644 --- a/local/detect-duplicates.R +++ b/local/detect-duplicates.R @@ -37,13 +37,10 @@ future.apply::future_lapply( files <- s3fs::s3_dir_ls( sprintf( "devxy-r-package-binaries-hel1/%s/%s/latest/src/contrib", - arch, - codename + arch, codename ) ) - if (length(files) == 0) { - return(NULL) - } + if (length(files) == 0) return(NULL) files_b <- basename(files) pkg_names <- sapply(strsplit(files_b, "_"), `[`, 1) dupes <- unique(pkg_names[duplicated(pkg_names)]) diff --git a/local/excluded-packages.json b/local/excluded-packages.json index 6489998..4bfa2de 100644 --- a/local/excluded-packages.json +++ b/local/excluded-packages.json @@ -1,77 +1,76 @@ [ - { "package": "RInno", "reason": "windows-only" }, - { "package": "KeyboardSimulator", "reason": "windows-only" }, - { "package": "R2PPT", "reason": "windows-only" }, - { "package": "RWinEdt", "reason": "windows-only" }, - { "package": "blatr", "reason": "windows-only" }, - { "package": "excel.link", "reason": "windows-only" }, - { "package": "spectrino", "reason": "windows-only" }, - { "package": "taskscheduleR", "reason": "windows-only" }, - { "package": "MDSGUI", "reason": "windows-only" }, - { "package": "BiplotGUI", "reason": "windows-only" }, - { "package": "R2wd", "reason": "windows-only" }, - { "package": "rFUSION", "reason": "windows-only" }, - { "package": "MediaNews", "reason": "windows-only" }, - { "package": "doBy", "reason": "hang" }, - { "package": "IDPmisc", "reason": "hang" }, - { "package": "frailtypack", "reason": "hang" }, - { "package": "afex", "reason": "hang" }, - { "package": "FrF2", "reason": "hang" }, - { "package": "DoE.base", "reason": "hang" }, - { "package": "agricolae", "reason": "hang" }, - { "package": "doFuture", "reason": "hang" }, - { "package": "fscaret", "reason": "hang" }, - { "package": "PHYLOGR", "reason": "hang" }, - { "package": "seewave", "reason": "hang" }, - { "package": "pls", "reason": "hang" }, - { "package": "relaimpo", "reason": "hang" }, - { "package": "geepack", "reason": "hang" }, - { "package": "gggenes", "reason": "hang" }, - { "package": "NPCirc", "reason": "hang" }, - { "package": "repmis", "reason": "hang" }, - { "package": "PNDSIBGE", "reason": "hang" }, - { "package": "lidR", "reason": "hang" }, - { "package": "poismf", "reason": "hang" }, - { "package": "neonstore", "reason": "hang" }, - { "package": "MachineShop", "reason": "hang" }, - { "package": "mvst", "reason": "hang" }, - { "package": "MacBehaviour", "reason": "hang" }, - { "package": "mcmcderive", "reason": "hang" }, - { "package": "RGIFT", "reason": "hang" }, - { "package": "KnowBR", "reason": "hang" }, - { "package": "netmeta", "reason": "hang" }, - { "package": "spdep", "reason": "hang" }, - { "package": "Rfast", "reason": "hang" }, - { "package": "compareGroups", "reason": "hang" }, - { "package": "ff", "reason": "hang" }, - { "package": "GsymPoint", "reason": "hang" }, - { "package": "RcppDynProg", "reason": "hang" }, - { "package": "comtradr", "reason": "hang" }, - { "package": "FD", "reason": "hang" }, - { "package": "PearsonDS", "reason": "hang" }, - { "package": "DCluster", "reason": "hang" }, - { "package": "gRc", "reason": "hang" }, - { "package": "mixlm", "reason": "hang" }, - { "package": "geospt", "reason": "hang" }, - { "package": "fdth", "reason": "hang" }, - { "package": "ffmanova", "reason": "hang" }, - { "package": "fiery", "reason": "hang" }, - { "package": "ffscrapr", "reason": "hang" }, - { "package": "cold", "reason": "hang" }, - { "package": "RcmdrPlugin.DoE", "reason": "hang" }, - { "package": "RcmdrPlugin.NMBU", "reason": "hang" }, - { "package": "RcmdrPlugin.RiskDemo", "reason": "hang" }, - { "package": "RcmdrPlugin.ROC", "reason": "hang" }, - { "package": "RcmdrPlugin.TeachStat", "reason": "hang" }, - { "package": "RcmdrPlugin.TeachingDemos", "reason": "hang" }, - { "package": "RcmdrPlugin.UCA", "reason": "hang" }, - { "package": "RcmdrPlugin.WorldFlora", "reason": "hang" }, - { "package": "RcmdrPlugin.aRnova", "reason": "hang" }, - { "package": "RcmdrPlugin.depthTools", "reason": "hang" }, - { "package": "RcmdrPlugin.orloca", "reason": "hang" }, - { "package": "RcmdrPlugin.sos", "reason": "hang" }, - { "package": "RcmdrPlugin.survival", "reason": "hang" }, - { "package": "RcmdrPlugin.temis", "reason": "hang" }, - { "package": "GWlasso", "reason": "hang" }, - { "package": "GWmodelVis", "reason": "hang" } + {"package": "RInno", "reason": "windows-only"}, + {"package": "KeyboardSimulator", "reason": "windows-only"}, + {"package": "R2PPT", "reason": "windows-only"}, + {"package": "RWinEdt", "reason": "windows-only"}, + {"package": "blatr", "reason": "windows-only"}, + {"package": "excel.link", "reason": "windows-only"}, + {"package": "spectrino", "reason": "windows-only"}, + {"package": "taskscheduleR", "reason": "windows-only"}, + {"package": "MDSGUI", "reason": "windows-only"}, + {"package": "BiplotGUI", "reason": "windows-only"}, + {"package": "R2wd", "reason": "windows-only"}, + {"package": "rFUSION", "reason": "windows-only"}, + {"package": "MediaNews", "reason": "windows-only"}, + {"package": "doBy", "reason": "hang"}, + {"package": "IDPmisc", "reason": "hang"}, + {"package": "frailtypack", "reason": "hang"}, + {"package": "afex", "reason": "hang"}, + {"package": "FrF2", "reason": "hang"}, + {"package": "DoE.base", "reason": "hang"}, + {"package": "agricolae", "reason": "hang"}, + {"package": "doFuture", "reason": "hang"}, + {"package": "fscaret", "reason": "hang"}, + {"package": "PHYLOGR", "reason": "hang"}, + {"package": "seewave", "reason": "hang"}, + {"package": "pls", "reason": "hang"}, + {"package": "relaimpo", "reason": "hang"}, + {"package": "geepack", "reason": "hang"}, + {"package": "gggenes", "reason": "hang"}, + {"package": "NPCirc", "reason": "hang"}, + {"package": "repmis", "reason": "hang"}, + {"package": "PNDSIBGE", "reason": "hang"}, + {"package": "lidR", "reason": "hang"}, + {"package": "poismf", "reason": "hang"}, + {"package": "neonstore", "reason": "hang"}, + {"package": "MachineShop", "reason": "hang"}, + {"package": "mvst", "reason": "hang"}, + {"package": "MacBehaviour", "reason": "hang"}, + {"package": "mcmcderive", "reason": "hang"}, + {"package": "RGIFT", "reason": "hang"}, + {"package": "KnowBR", "reason": "hang"}, + {"package": "netmeta", "reason": "hang"}, + {"package": "spdep", "reason": "hang"}, + {"package": "Rfast", "reason": "hang"}, + {"package": "compareGroups", "reason": "hang"}, + {"package": "ff", "reason": "hang"}, + {"package": "GsymPoint", "reason": "hang"}, + {"package": "RcppDynProg", "reason": "hang"}, + {"package": "comtradr", "reason": "hang"}, + {"package": "FD", "reason": "hang"}, + {"package": "PearsonDS", "reason": "hang"}, + {"package": "DCluster", "reason": "hang"}, + {"package": "gRc", "reason": "hang"}, + {"package": "mixlm", "reason": "hang"}, + {"package": "geospt", "reason": "hang"}, + {"package": "fdth", "reason": "hang"}, + {"package": "ffmanova", "reason": "hang"}, + {"package": "fiery", "reason": "hang"}, + {"package": "ffscrapr", "reason": "hang"}, + {"package": "cold", "reason": "hang"}, + {"package": "RcmdrPlugin.DoE", "reason": "hang"}, + {"package": "RcmdrPlugin.NMBU", "reason": "hang"}, + {"package": "RcmdrPlugin.RiskDemo", "reason": "hang"}, + {"package": "RcmdrPlugin.TeachStat", "reason": "hang"}, + {"package": "RcmdrPlugin.TeachingDemos", "reason": "hang"}, + {"package": "RcmdrPlugin.UCA", "reason": "hang"}, + {"package": "RcmdrPlugin.WorldFlora", "reason": "hang"}, + {"package": "RcmdrPlugin.aRnova", "reason": "hang"}, + {"package": "RcmdrPlugin.depthTools", "reason": "hang"}, + {"package": "RcmdrPlugin.orloca", "reason": "hang"}, + {"package": "RcmdrPlugin.sos", "reason": "hang"}, + {"package": "RcmdrPlugin.survival", "reason": "hang"}, + {"package": "RcmdrPlugin.temis", "reason": "hang"}, + {"package": "GWlasso", "reason": "hang"}, + {"package": "GWmodelVis", "reason": "hang"} ] diff --git a/local/failing-builds-classify.R b/local/failing-builds-classify.R deleted file mode 100644 index 73922b3..0000000 --- a/local/failing-builds-classify.R +++ /dev/null @@ -1,399 +0,0 @@ -# Pure, side-effect-free helpers for triaging `single_builds` failures: -# normalise a raw `error_text` into a stable fingerprint, and classify it -# against a seed set of known failure signatures (issue #115, steps 1 + 2). -# -# Kept free of DB/IO so it can be sourced by both `failing-builds-report.R` -# and the unit tests in `local/tests/`. - -# --------------------------------------------------------------------------- -# Signature table -# --------------------------------------------------------------------------- -# Each rule maps a recurring compile/link/load error to a suggested fix tier. -# `pattern` is a case-insensitive regex matched against the raw `error_text`. -# `auto` marks whether the fix is a *known lever* safe to auto-propose as a PR -# (env / makevars / an already-curated package-specific patch). Rules that -# would require a brand-new source diff for a previously-unseen package stay -# `auto = FALSE` -> classified, but always routed to human triage, per the -# issue's guardrail against shipping autonomous novel source diffs. -# `applies_to` (optional) pins a package-specific fix to the package it targets: -# a signature whose registry patch belongs to one package (e.g. RcppParallel's -# disable-tbb patch) is only proposed for that package. Other packages matching -# the signature are downstream failures blocked on that dependency, not -# individually patchable, so they are reported but never proposed an entry. -# -# Seeded from the existing registry entries and known recurring failures; add -# a row here as new signatures are confirmed. Order matters: the first match -# wins, so keep more specific patterns above broader ones. -build_signatures <- function() { - list( - list( - id = "tbb-stddef-removed", - label = "removed TBB header tbb/tbb_stddef.h", - pattern = "tbb/tbb_stddef\\.h.*No such file", - tier = "makevars", - confidence = "high", - auto = TRUE, - fix = "add CPPFLAGS += -DTBB_INTERFACE_NEW so the source stops including the removed tbb/tbb_stddef.h header", - example = "StanHeaders / rstan (#114)", - registry = list( - env = NULL, - configure_args = NULL, - makevars = list(CPPFLAGS = "-DTBB_INTERFACE_NEW"), - patch = NULL, - reason = "package includes the removed tbb/tbb_stddef.h; -DTBB_INTERFACE_NEW selects the new oneTBB interface path" - ) - ), - list( - id = "rcppparallel-bundled-tbb", - label = "bundled Intel TBB build fails/hangs (musl / new g++)", - pattern = "USE_TBB[^\\n]*(not supported|unsupported)|RcppParallel[^\\n]*TBB|tbb[^\\n]*(Alpine|musl)", - tier = "patch", - confidence = "high", - auto = TRUE, - # The fix is a RcppParallel-specific source patch, so it is only ever - # proposed for RcppParallel itself. The hundreds of packages that fail - # merely because their RcppParallel *dependency* did not build carry - # RcppParallel's error text and match this signature too -- they are - # blocked on RcppParallel, not individually patchable (applying this diff - # to their source is meaningless). `applies_to` pins the proposal so those - # downstream failures are never proposed a bogus per-package entry. - applies_to = "RcppParallel", - fix = "apply the curated RcppParallel/disable-tbb.patch so the bundled TBB build is skipped and the TinyThread backend is used", - example = "RcppParallel", - registry = list( - env = NULL, - configure_args = NULL, - makevars = NULL, - patch = "RcppParallel/disable-tbb.patch", - reason = "bundled Intel TBB build hangs/fails on musl (Alpine) and newer toolchains; patch forces the TinyThread backend" - ) - ), - list( - id = "system-libuv-link-leak", - label = "binary links system libuv (NEEDED libuv.so.1)", - pattern = "libuv\\.so", - tier = "patch", - confidence = "medium", - # A novel per-package source diff is required to force the vendored lib; - # never auto-propose, only surface for a human (guardrail). - auto = FALSE, - fix = "force the vendored/static library instead of the system one via a human-authored source patch (see fs/force-vendored-libuv.patch as precedent)", - example = "fs", - registry = list( - env = NULL, - configure_args = NULL, - makevars = NULL, - patch = "/force-vendored-.patch", - reason = "binary links the system library and fails to dyn.load on consumer machines; force the vendored/static build" - ) - ) - ) -} - -# --------------------------------------------------------------------------- -# Normalisation -# --------------------------------------------------------------------------- -# Collapse build-specific noise (temp paths, version numbers, hex addresses, -# the package name) so the same root cause across packages/platforms/versions -# maps to one fingerprint bucket. -normalise_error <- function(error_text, package = NULL) { - if (length(error_text) == 0L || is.na(error_text) || !nzchar(error_text)) { - return("") - } - x <- as.character(error_text) - # Package-specific token first (before version/number stripping mangles it). - if (!is.null(package) && length(package) == 1L && nzchar(package)) { - # \Q..\E quotes the name literally so metachars (e.g. data.table's dot) - # are matched verbatim rather than as regex. - x <- gsub(paste0("\\b\\Q", package, "\\E\\b"), "", x, perl = TRUE) - } - # R temp dirs/files: /tmp/RtmpAbC123, RtmpXXXX, /tmp/Rtmp.../file123. - x <- gsub("/tmp/[^ \t\n]*", "", x, perl = TRUE) - x <- gsub("\\bRtmp[A-Za-z0-9]+", "Rtmp", x, perl = TRUE) - # Hex addresses and version-like number runs. - x <- gsub("0x[0-9a-fA-F]+", "0x", x, perl = TRUE) - x <- gsub("[0-9]+(\\.[0-9]+)+", "", x, perl = TRUE) - x <- gsub("\\b[0-9]{2,}\\b", "", x, perl = TRUE) - # Whitespace and case. - x <- tolower(x) - x <- gsub("[ \t\r\n]+", " ", x, perl = TRUE) - trimws(x) -} - -# Extract the single most informative line from a multi-line error, then -# normalise it. This is the grouping key; a short salient line groups far -# better than the whole (often huge) transcript. -fingerprint_error <- function(error_text, package = NULL, max_chars = 200L) { - if (length(error_text) == 0L || is.na(error_text) || !nzchar(error_text)) { - return("") - } - lines <- strsplit(as.character(error_text), "\n", fixed = TRUE)[[1L]] - lines <- trimws(lines) - lines <- lines[nzchar(lines)] - if (length(lines) == 0L) { - return("") - } - salient_re <- paste( - "error:", - "fatal error:", - "no such file", - "undefined reference", - "cannot find -l", - "cannot open shared object", - "configuration failed", - "non-zero exit", - "installation of package", - "compilation failed", - sep = "|" - ) - hit <- lines[grepl(salient_re, lines, ignore.case = TRUE)] - chosen <- if (length(hit) > 0L) hit[[1L]] else lines[[length(lines)]] - fp <- normalise_error(chosen, package) - if (nchar(fp) > max_chars) { - fp <- paste0(substr(fp, 1L, max_chars), "...") - } - fp -} - -# --------------------------------------------------------------------------- -# Dependency-cascade detection -# --------------------------------------------------------------------------- -# If a build's error_text shows the failure was actually in a DIFFERENT package -# (a dependency that would not compile), return that dependency's name; -# otherwise NA. Used to avoid proposing a per-package fix for a package that -# only fails because a shared dependency does not build (e.g. the ~73 Stan -# packages that fail while building `rstan`). Generalises the RcppParallel -# `applies_to` guard to any dependency named in the log. -failing_dependency <- function(error_text, package) { - if (length(error_text) == 0L || is.na(error_text) || !nzchar(error_text)) { - return(NA_character_) - } - x <- as.character(error_text) - # optional opening quote before the package name: apostrophe, double-quote, - # backtick, or curly quotes -- written as \u escapes so the pattern stays - # valid UTF-8 regardless of source encoding. - q <- "[\u0027\u0022\u0060\u2018\u2019]?" - name <- "([A-Za-z][A-Za-z0-9._]+)" - # Markers R/pak emit naming the package that actually failed to compile. - pats <- c( - paste0("compilation failed for package ", q, name), - paste0("Failed to build source package ", q, name), - paste0("Error in building package ", q, name), - paste0("dependenc(?:y|ies) ", q, name, q, "?[^\\n]*not available") - ) - deps <- character(0L) - for (p in pats) { - hits <- regmatches(x, gregexpr(p, x, perl = TRUE))[[1L]] - if (length(hits) > 0L) { - deps <- c(deps, sub(p, "\\1", hits, perl = TRUE)) - } - } - deps <- sub("[._]+$", "", deps) # drop a trailing sentence period (e.g. "rstan.") - deps <- setdiff(unique(deps), package) # a package failing on its OWN code is not a cascade - if (length(deps) == 0L) NA_character_ else deps[[1L]] -} - -# --------------------------------------------------------------------------- -# Classification -# --------------------------------------------------------------------------- -# Return the first matching signature (as a list) enriched with `matched`, or -# the unclassified fallback. Never guesses: an unmatched error is routed to a -# human, not assigned a fix. -classify_error <- function(error_text, signatures = build_signatures()) { - txt <- if (length(error_text) == 0L || is.na(error_text)) { - "" - } else { - as.character(error_text) - } - for (sig in signatures) { - if ( - nzchar(txt) && grepl(sig$pattern, txt, ignore.case = TRUE, perl = TRUE) - ) { - sig$matched <- TRUE - return(sig) - } - } - list( - id = "unclassified", - label = "unknown signature", - tier = NA_character_, - confidence = NA_character_, - auto = FALSE, - fix = "no known signature; flag for human triage", - example = NA_character_, - registry = NULL, - matched = FALSE - ) -} - -# Build a suggested registry.json entry (as an R list) for a classified group, -# filling package/versions/platforms from the observed failures. Only -# meaningful when the signature carries a `registry` template. -propose_registry_entry_list <- function( - signature, - package, - platforms, - versions = "*" -) { - if (is.null(signature$registry)) { - return(NULL) - } - tmpl <- signature$registry - entry <- list( - package = package, - versions = versions, - # I() keeps this a JSON array even when a single platform is affected. - platforms = I(sort(unique(as.character(platforms)))) - ) - for (k in c("env", "configure_args", "makevars", "patch")) { - if (!is.null(tmpl[[k]])) { - entry[[k]] <- tmpl[[k]] - } - } - entry$reason <- tmpl$reason - entry -} - -# Same, rendered as a pretty JSON string. -propose_registry_entry <- function( - signature, - package, - platforms, - versions = "*" -) { - entry <- propose_registry_entry_list(signature, package, platforms, versions) - if (is.null(entry)) { - return(NULL) - } - jsonlite::toJSON(entry, auto_unbox = TRUE, pretty = TRUE, null = "null") -} - -# Resolve the representative signature for a group by its id, re-attaching the -# `matched` flag the report/proposer rely on. Unknown ids -> unclassified. -resolve_signature <- function(sig_id, signatures = build_signatures()) { - hit <- Filter(function(s) s$id == sig_id, signatures) - if (length(hit) > 0L) { - s <- hit[[1L]] - s$matched <- TRUE - s - } else { - classify_error("", signatures) # unclassified fallback (matched = FALSE) - } -} - -# --------------------------------------------------------------------------- -# Triage report (shared by the report printer and the patch proposer) -# --------------------------------------------------------------------------- -# `failures` is a data.frame with at least: name, platform, arch, error_text. -# `registered_pkgs` is the set of packages that already carry a registry entry. -# Returns a list of group records (one per root-cause bucket), ordered by -# number of affected builds descending. Pure: no IO, no printing. -build_triage_report <- function( - failures, - registered_pkgs = character(0L), - signatures = build_signatures() -) { - if (nrow(failures) == 0L) { - return(list()) - } - idx <- seq_len(nrow(failures)) - failures$fingerprint <- vapply( - idx, - function(i) fingerprint_error(failures$error_text[[i]], failures$name[[i]]), - character(1L) - ) - failures$sig_id <- vapply( - idx, - function(i) classify_error(failures$error_text[[i]], signatures)$id, - character(1L) - ) - # Group by root cause: classified failures collapse by signature id (same fix - # candidate is one bucket regardless of log noise); unclassified failures fall - # back to the fingerprint so distinct unknowns stay separate for discovery. - failures$group_key <- ifelse( - failures$sig_id == "unclassified", - failures$fingerprint, - failures$sig_id - ) - groups <- split(failures, failures$group_key) - groups <- groups[order(-vapply(groups, nrow, integer(1L)))] - - lapply(unname(groups), function(g) { - sig_id <- names(sort(table(g$sig_id), decreasing = TRUE))[[1L]] - sig <- resolve_signature(sig_id, signatures) - - fp_tab <- sort(table(g$fingerprint), decreasing = TRUE) - pkgs <- sort(unique(g$name)) - plats <- sort(unique(g$platform)) - arches <- sort(unique(g$arch)) - unregistered <- setdiff(pkgs, registered_pkgs) - auto_proposable <- isTRUE(sig$auto) && sig$matched - - # Decide, per package, whether it is genuinely fixable or merely blocked on - # a dependency (so a per-package entry would be useless). Two blocking modes: - # 1. `applies_to`: a package-specific patch (e.g. RcppParallel's) is only - # valid for its own package; other matches are downstream of it. - # 2. data-driven cascade: the package's error_text shows a *different* - # package failed to compile (e.g. the ~73 Stan packages blocked on rstan). - # `blocked_map` maps a blocked package -> the dependency it waits on. - g$blocked_dep <- vapply( - seq_len(nrow(g)), - function(i) failing_dependency(g$error_text[[i]], g$name[[i]]), - character(1L) - ) - proposable <- unregistered - blocked_map <- list() - if (!is.null(sig$applies_to)) { - for (p in setdiff(pkgs, sig$applies_to)) { - blocked_map[[p]] <- sig$applies_to - } - proposable <- intersect(proposable, sig$applies_to) - } - for (p in proposable) { - deps <- g$blocked_dep[g$name == p] - if (!any(is.na(deps))) { - # every failing build of p is a cascade -> blocked, not fixable here - blocked_map[[p]] <- unique(deps) - } - } - proposable <- setdiff(proposable, names(blocked_map)) - blocked_packages <- names(blocked_map) - blocked_on <- unique(unlist(blocked_map, use.names = FALSE)) - if (length(blocked_on) == 0L) { - blocked_on <- NULL - } - - proposed <- list() - if (auto_proposable) { - for (p in proposable) { - proposed[[p]] <- propose_registry_entry_list( - sig, - p, - g$platform[g$name == p] - ) - } - } - - list( - signature = sig$id, - label = sig$label, - matched = sig$matched, - auto_proposable = auto_proposable, - tier = sig$tier, - confidence = sig$confidence, - suggested_fix = sig$fix, - applies_to = sig$applies_to, - blocked_on = blocked_on, - blocked_packages = blocked_packages, - blocked_map = if (length(blocked_map) > 0L) blocked_map else NULL, - fingerprint = names(fp_tab)[[1L]], - fingerprint_variants = length(fp_tab), - build_count = nrow(g), - packages = pkgs, - packages_without_entry = unregistered, - platforms = plats, - arches = arches, - proposed_entries = if (length(proposed) > 0L) proposed else NULL - ) - }) -} diff --git a/local/failing-builds-report.R b/local/failing-builds-report.R deleted file mode 100644 index b9df756..0000000 --- a/local/failing-builds-report.R +++ /dev/null @@ -1,235 +0,0 @@ -#!/usr/bin/env Rscript - -# Read-only failure triage over the `single_builds` metadata table (issue #115, -# steps 1 + 2): query every recorded build failure, group by a normalised error -# fingerprint, classify each bucket against the known signature set, and print a -# triaged report with a pre-filled `registry.json` suggestion where a *known, -# safe* fix lever applies. Novel source diffs and unknown signatures are routed -# to human triage; this script never writes to the DB or the registry. -# -# Usage: -# PGPASS=... Rscript local/failing-builds-report.R [--platform P] [--arch A] -# [--json out.json] [--min N] -# -# --platform / --arch restrict to one platform/arch (default: all) -# --min N only show fingerprint groups with >= N failing builds -# --json PATH also write the machine-readable report to PATH -# -# Env fallbacks: PLATFORM, ARCH (same effect as the flags). - -options(error = function() { - cat("ERROR:", geterrmessage(), "\n", file = stdout()) - q(status = 1) -}) - -suppressPackageStartupMessages({ - library(DBI, quietly = TRUE) - library(RPostgres, quietly = TRUE) - library(jsonlite, quietly = TRUE) -}) - -# Locate helpers relative to this script so it runs from any CWD. -script_path <- local({ - a <- commandArgs(trailingOnly = FALSE) - f <- sub("^--file=", "", a[grepl("^--file=", a)]) - if (length(f) == 1L && nzchar(f)) normalizePath(f) else NA_character_ -}) -script_dir <- if (is.na(script_path)) "local" else dirname(script_path) -source(file.path(script_dir, "failing-builds-classify.R")) - -# --------------------------------------------------------------------------- -# Arguments -# --------------------------------------------------------------------------- -args <- commandArgs(trailingOnly = TRUE) -opt_val <- function(flag, default = NA_character_) { - i <- match(flag, args) - if (!is.na(i) && i < length(args)) args[[i + 1L]] else default -} -platform <- opt_val("--platform", Sys.getenv("PLATFORM", "")) -arch <- opt_val("--arch", Sys.getenv("ARCH", "")) -json_out <- opt_val("--json") -min_count <- suppressWarnings(as.integer(opt_val("--min", "1"))) -if (is.na(min_count)) { - min_count <- 1L -} - -if (nchar(Sys.getenv("PGPASS")) == 0L) { - stop( - "PGPASS env var is not set; a DB password is required (no read-only role exists)." - ) -} - -# --------------------------------------------------------------------------- -# Query failing builds -# --------------------------------------------------------------------------- -con <- DBI::dbConnect( - RPostgres::Postgres(), - dbname = "build_metadata", - host = "r-binaries.devxy.io", - port = 15432, - user = "rpkgs", - password = Sys.getenv("PGPASS"), - sslmode = "verify-full", - sslrootcert = bincraft::postgres_sslrootcert("verify-full") -) -on.exit(DBI::dbDisconnect(con), add = TRUE) - -where <- "error_occurred = TRUE AND removed = FALSE" -params <- list() -if (nzchar(platform)) { - where <- paste0(where, " AND platform = $", length(params) + 1L) - params <- c(params, platform) -} -if (nzchar(arch)) { - where <- paste0(where, " AND arch = $", length(params) + 1L) - params <- c(params, arch) -} -failures <- DBI::dbGetQuery( - con, - paste0( - "SELECT name, tag, platform, arch, r_version, timestamp, error_text ", - "FROM single_builds WHERE ", - where - ), - params = if (length(params) > 0L) params else NULL -) - -cat(sprintf( - "Queried single_builds: %d failing builds%s\n", - nrow(failures), - if (nzchar(platform) || nzchar(arch)) { - sprintf( - " (filter: platform=%s arch=%s)", - if (nzchar(platform)) platform else "*", - if (nzchar(arch)) arch else "*" - ) - } else { - "" - } -)) -if (nrow(failures) == 0L) { - cat("No failing builds to triage.\n") - q(status = 0) -} - -# --------------------------------------------------------------------------- -# Packages that already carry a registry entry (so we don't re-propose) -# --------------------------------------------------------------------------- -`%||%` <- function(a, b) if (is.null(a)) b else a -registry_file <- file.path(script_dir, "patches", "registry.json") -registered_pkgs <- character(0L) -if (file.exists(registry_file)) { - reg <- jsonlite::fromJSON(registry_file, simplifyVector = FALSE) - registered_pkgs <- unique(vapply( - reg, - function(e) as.character(e$package %||% ""), - character(1L) - )) -} - -# --------------------------------------------------------------------------- -# Classify + group (shared logic), then render -# --------------------------------------------------------------------------- -report <- build_triage_report(failures, registered_pkgs) -report <- Filter(function(r) r$build_count >= min_count, report) - -cat(sprintf( - "\n%d distinct failure group(s); showing groups with >= %d build(s).\n", - length(report), - min_count -)) -cat(strrep("=", 78L), "\n", sep = "") - -for (r in report) { - status <- if (!r$matched) { - "HUMAN TRIAGE (unknown signature)" - } else if (!r$auto_proposable) { - sprintf("HUMAN TRIAGE (classified: %s; novel source diff)", r$signature) - } else { - sprintf("AUTO-PROPOSABLE (%s, %s confidence)", r$signature, r$confidence) - } - - cat(sprintf( - "\n[%d builds | %d pkgs | %s] %s\n", - r$build_count, - length(r$packages), - toString(r$platforms), - status - )) - cat(sprintf( - " fingerprint: %s%s\n", - r$fingerprint, - if (r$fingerprint_variants > 1L) { - sprintf(" (+%d fingerprint variant(s))", r$fingerprint_variants - 1L) - } else { - "" - } - )) - if (r$matched) { - cat(sprintf(" signature : %s\n", r$label)) - cat(sprintf(" suggested : [%s] %s\n", r$tier, r$suggested_fix)) - } - cat(sprintf(" arch : %s\n", toString(r$arches))) - cat(sprintf( - " packages : %s\n", - paste( - vapply( - r$packages, - function(p) { - if (p %in% registered_pkgs) paste0(p, " (has entry)") else p - }, - character(1L) - ), - collapse = ", " - ) - )) - - if (!is.null(r$proposed_entries)) { - cat(" proposed registry entries (validate + trial-build before merge):\n") - for (entry in r$proposed_entries) { - j <- jsonlite::toJSON( - entry, - auto_unbox = TRUE, - pretty = TRUE, - null = "null" - ) - cat(paste0(" ", gsub("\n", "\n ", j)), "\n", sep = "") - } - } else if (r$auto_proposable && length(r$blocked_packages) == 0L) { - cat(" (all affected packages already have a registry entry)\n") - } - # Blocked packages are shown even when the group also has proposals. - if (length(r$blocked_packages) > 0L) { - cat(sprintf( - " (blocked on %s -- %d package(s) fail because that dependency does not build; fix %s, do not patch each dependent)\n", - toString(r$blocked_on), - length(r$blocked_packages), - toString(r$blocked_on) - )) - } -} - -# --------------------------------------------------------------------------- -# Summary -# --------------------------------------------------------------------------- -matched <- Filter(function(r) r$matched, report) -auto <- Filter(function(r) r$auto_proposable, report) -cat("\n", strrep("=", 78L), "\n", sep = "") -cat(sprintf( - "Summary: %d groups | %d classified | %d auto-proposable | %d for human triage\n", - length(report), - length(matched), - length(auto), - length(report) - length(matched) -)) - -if (!is.na(json_out)) { - jsonlite::write_json( - report, - json_out, - auto_unbox = TRUE, - pretty = TRUE, - null = "null" - ) - cat(sprintf("Wrote machine-readable report to %s\n", json_out)) -} diff --git a/local/fetch-rebuild-packages-from-issue.R b/local/fetch-rebuild-packages-from-issue.R index 9d8043c..d944dd0 100644 --- a/local/fetch-rebuild-packages-from-issue.R +++ b/local/fetch-rebuild-packages-from-issue.R @@ -1,50 +1,15 @@ library(httr2, quietly = TRUE) forgejo_base <- "https://git.devxy.io/api/v1" -repo <- "devxy/build-cran-binaries" -platform <- Sys.getenv("PLATFORM") -arch <- Sys.getenv("ARCH") -output_file <- Sys.getenv("REBUILD_PKG_LIST", "/tmp/rebuild_pkgs.txt") +repo <- "devxy/build-cran-binaries" +platform <- Sys.getenv("PLATFORM") +arch <- Sys.getenv("ARCH") +token <- Sys.getenv("FORGEJO_TOKEN") +output_file <- Sys.getenv("REBUILD_PKG_LIST", "/tmp/rebuild_pkgs.txt") -if (nchar(platform) == 0) { - stop("PLATFORM env var is not set") -} -if (nchar(arch) == 0) { - stop("ARCH env var is not set") -} - -# Prefer the audit's freshly-written RDS. The audit overwrites it each run -# (saveRDS), so unlike the Forgejo issue body it is never subject to the -# duplicate-subsection accumulation bug. Fall back to parsing the issue when the -# RDS is absent (e.g. a fresh runner with no shared cache). -rds_file <- file.path( - Sys.getenv("REBUILD_PKG_RDS_DIR", "/mnt/cache/packages"), - sprintf("weekly_rebuild_%s_%s.rds", platform, arch) -) -if (file.exists(rds_file)) { - pkgs <- tryCatch(as.character(readRDS(rds_file)), error = function(e) NULL) - if (!is.null(pkgs) && length(pkgs) > 0) { - cat(sprintf( - "Using audit RDS %s: %d rebuildable packages for %s/%s\n", - rds_file, - length(pkgs), - platform, - arch - )) - writeLines(pkgs, output_file) - cat(sprintf("Wrote package list to %s\n", output_file)) - q("no") - } - cat(sprintf( - "RDS %s present but empty/unreadable -- falling back to issue\n", - rds_file - )) -} - -token <- Sys.getenv("FORGEJO_TOKEN") -if (nchar(token) == 0) { - stop("FORGEJO_TOKEN env var is not set") -} +if (nchar(platform) == 0) stop("PLATFORM env var is not set") +if (nchar(arch) == 0) stop("ARCH env var is not set") +if (nchar(token) == 0) stop("FORGEJO_TOKEN env var is not set") os_family <- if (grepl("^ubuntu", platform)) { "Ubuntu" @@ -56,16 +21,12 @@ os_family <- if (grepl("^ubuntu", platform)) { platform } -issue_title <- sprintf( - "Missing package binaries for latest version (%s)", - os_family -) +issue_title <- sprintf("Missing package binaries for latest version (%s)", os_family) cat(sprintf("Searching for issue: %s\n", issue_title)) search_url <- sprintf( "%s/repos/%s/issues?type=issues&state=open&q=%s&limit=50", - forgejo_base, - repo, + forgejo_base, repo, utils::URLencode(issue_title, reserved = TRUE) ) search_resp <- request(search_url) |> @@ -73,9 +34,7 @@ search_resp <- request(search_url) |> req_perform() issues <- resp_body_json(search_resp, simplifyVector = FALSE) -match_idx <- which( - vapply(issues, function(x) x$title, character(1)) == issue_title -) +match_idx <- which(vapply(issues, function(x) x$title, character(1)) == issue_title) if (length(match_idx) == 0) { cat("No matching issue found - nothing to rebuild\n") @@ -96,10 +55,7 @@ lines <- strsplit(body, "\n", fixed = TRUE)[[1]] plat_header <- sprintf("## %s", platform) plat_idx <- which(lines == plat_header) if (length(plat_idx) == 0) { - cat(sprintf( - "No section found for platform %s - nothing to rebuild\n", - platform - )) + cat(sprintf("No section found for platform %s - nothing to rebuild\n", platform)) writeLines(character(0), output_file) q("no") } @@ -108,11 +64,7 @@ if (length(plat_idx) == 0) { arch_pattern <- sprintf("^### %s ", arch) arch_idx <- which(grepl(arch_pattern, lines) & seq_along(lines) > plat_idx[1]) if (length(arch_idx) == 0) { - cat(sprintf( - "No section found for arch %s under %s - nothing to rebuild\n", - arch, - platform - )) + cat(sprintf("No section found for arch %s under %s - nothing to rebuild\n", arch, platform)) writeLines(character(0), output_file) q("no") } @@ -130,11 +82,6 @@ pkg_lines <- section_lines[grepl("^- ", section_lines)] pkgs <- sub("^- ([^ ]+) \\(.*\\)$", "\\1", pkg_lines) pkgs <- pkgs[nchar(pkgs) > 0 & pkgs != "_None_"] -cat(sprintf( - "Found %d rebuildable packages for %s/%s\n", - length(pkgs), - platform, - arch -)) +cat(sprintf("Found %d rebuildable packages for %s/%s\n", length(pkgs), platform, arch)) writeLines(pkgs, output_file) cat(sprintf("Wrote package list to %s\n", output_file)) diff --git a/local/find-R-api-packages.sh b/local/find-R-api-packages.sh deleted file mode 100644 index 1f36961..0000000 --- a/local/find-R-api-packages.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -# Directory to clone repos into -WORKDIR="cran_repos" -mkdir -p "$WORKDIR" -cd "$WORKDIR" - -# GitHub API paginates results, so we loop through pages -PAGE=1 -PER_PAGE=100 -MATCHES=() - -while :; do - # Fetch a page of repos - REPOS=$(curl -s "https://api.github.com/orgs/cran/repos?per_page=$PER_PAGE&page=$PAGE" | jq -r '.[].clone_url') - [ -z "$REPOS" ] && break - - for REPO_URL in $REPOS; do - REPO_NAME=$(basename "$REPO_URL" .git) - # Skip if already cloned - [ -d "$REPO_NAME" ] && continue - git clone --depth 1 "$REPO_URL" "$REPO_NAME" >/dev/null 2>&1 - if [ -d "$REPO_NAME/src" ]; then - # Search for Rinternals.h in src/ - if grep -r -q 'R_VERSION < R_Version(' "$REPO_NAME/src"; then - echo "$REPO_NAME" - fi - fi - # Clean up to save space - rm -rf "$REPO_NAME" - done - - PAGE=$((PAGE + 1)) -done diff --git a/local/install-bincraft.R b/local/install-bincraft.R deleted file mode 100644 index e39cb4f..0000000 --- a/local/install-bincraft.R +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env Rscript - -# Install the latest tagged bincraft release, resolved dynamically, so the CI -# workflows and the build-one image never pin a hardcoded version (no more -# editing `@vX.Y.Z` in many places on every release). -# -# Run with the R whose library should receive bincraft: -# Rscript local/install-bincraft.R -# or, to target a specific R from a shell loop: -# "$RBIN" -q -e 'source("local/install-bincraft.R")' -# -# How it works: list the remote tags with `git ls-remote` (no token needed for -# the public repo), keep the `vX.Y.Z` release tags, pick the highest version, -# and install it with uvr via `local/uvr-install.sh`. uvr is idempotent on the -# git ref, so re-running keeps the package when it is already current and only -# updates when a newer tag ships. Filtering/sorting is done in R (not via git's -# `--sort`/refspec) so behaviour is identical across git versions and -# `system2()` argument handling. - -repo_url <- Sys.getenv( - "BINCRAFT_GIT_URL", - unset = "https://codefloe.com/rpkgs/bincraft.git" -) - -# GIT_TERMINAL_PROMPT=0 keeps a non-interactive run from hanging on auth. -refs <- system2( - "git", - c("ls-remote", "--tags", repo_url), - stdout = TRUE, - stderr = FALSE, - env = "GIT_TERMINAL_PROMPT=0" -) -tags <- sub(".*refs/tags/", "", refs) -tags <- tags[!grepl("\\^\\{\\}$", tags)] # drop dereferenced "...^{}" lines -tags <- grep("^v[0-9]", tags, value = TRUE) # only vX.Y.Z release tags -if (length(tags) == 0L) { - stop( - "Could not resolve any bincraft release tag from ", - repo_url, - call. = FALSE - ) -} -latest <- tags[order(package_version(sub("^v", "", tags)), decreasing = TRUE)][ - 1L -] - -message(sprintf("Installing latest bincraft release: %s", latest)) - -# uvr addresses Forgejo repos as `forgejo::host/owner/repo@ref` rather than as a -# git URL, so drop the scheme and the trailing `.git` from `repo_url`. -spec <- sprintf( - "forgejo::%s@%s", - sub("\\.git$", "", sub("^[a-z]+://", "", repo_url)), - latest -) - -# `local/uvr-install.sh` when run from the repo root, `/work/local/` in the -# build-one image, which copies the two scripts into a flatter layout. -helper <- Sys.getenv("UVR_INSTALL_SH", unset = "") -if (!nzchar(helper)) { - candidates <- c("local/uvr-install.sh", "/work/local/uvr-install.sh") - found <- candidates[file.exists(candidates)] - if (length(found) == 0L) { - stop("Could not locate uvr-install.sh; set UVR_INSTALL_SH", call. = FALSE) - } - helper <- found[1L] -} - -# Point uvr at the R running this script and at the library it would install -# into, so the per-R-minor passes in the build pipelines (which call a different -# Rscript with R_LIBS_USER pointed elsewhere) target their own R and library. -Sys.setenv( - UVR_R_BIN = file.path(R.home("bin"), "R"), - UVR_TARGET_LIB = .libPaths()[1L] -) - -status <- system2(helper, shQuote(spec)) -if (!identical(status, 0L)) { - stop( - sprintf("uvr failed to install %s (exit %s)", spec, status), - call. = FALSE - ) -} - -message(sprintf( - "bincraft %s installed (%s)", - as.character(utils::packageVersion("bincraft")), - latest -)) diff --git a/local/label-removed-cran-packages.R b/local/label-removed-cran-packages.R index a6ba36a..92cd940 100644 --- a/local/label-removed-cran-packages.R +++ b/local/label-removed-cran-packages.R @@ -6,15 +6,10 @@ archived <- quickcode::archivedPkg() |> pull(name) # Query all distinct pkgs in the DB -con <- DBI::dbConnect( - RPostgres::Postgres(), - dbname = "build_metadata", - host = "r-binaries.devxy.io", - port = 15432, - user = "r_binaries", - password = Sys.getenv("PGPASS"), - sslmode = "verify-full", - sslrootcert = bincraft::postgres_sslrootcert("verify-full") +con <- DBI::dbConnect(RPostgres::Postgres(), + dbname = "build_metadata", host = "r-binaries.devxy.io", + port = 15432, user = "r_binaries", password = Sys.getenv("PGPASS"), + sslmode = "require" ) pkgs_db <- query_metadata_table() |> @@ -27,9 +22,7 @@ to_process <- pkgs_db[pkgs_db %in% archived] # for all matches, set 'removed = TRUE' sapply(to_process, function(.x) { - DBI::dbExecute( - con, - "UPDATE single_builds SET removed = 'TRUE' where name = $1", + DBI::dbExecute(con, "UPDATE single_builds SET removed = 'TRUE' where name = $1", params = list(.x) ) }) diff --git a/local/last-processed-by-platform.R b/local/last-processed-by-platform.R index 398b6c1..f913610 100644 --- a/local/last-processed-by-platform.R +++ b/local/last-processed-by-platform.R @@ -7,4 +7,4 @@ query_metadata_table() |> group_by(platform, arch) |> arrange(desc(timestamp)) |> select(name, timestamp) |> - filter(row_number() == 1) + filter(row_number()==1) diff --git a/local/list-unsafe-flat-objects.R b/local/list-unsafe-flat-objects.R deleted file mode 100644 index fca0a9d..0000000 --- a/local/list-unsafe-flat-objects.R +++ /dev/null @@ -1,162 +0,0 @@ -### Print the flat-slot objects recorded as unable to load under some R minor. -# -# Usage: Rscript local/list-unsafe-flat-objects.R -# -# Prints one ` ` per line, for a caller that rebuilds each -# under every installed R minor. -# -# The verdicts come from `abi_flat_safety`, written by the flat-safety backfill -# from the binaries themselves: an object is unsafe when it references a symbol -# some supported minor does not export. That is the authoritative list of what -# needs a per-minor build, and it replaces the ad-hoc symbol scans that produced -# earlier repair lists. - -options(error = function() { - cat("ERROR:", geterrmessage(), "\n", file = stdout()) - q(status = 1) -}) - -args <- commandArgs(trailingOnly = TRUE) -if (length(args) < 2L) { - stop("usage: list-unsafe-flat-objects.R ", call. = FALSE) -} -arch <- args[[1L]] -codename <- args[[2L]] - -con <- DBI::dbConnect( - RPostgres::Postgres(), - dbname = "build_metadata", - host = "r-binaries.devxy.io", - port = 15432L, - user = "rpkgs", - password = Sys.getenv("PGPASS"), - sslmode = "verify-full", - sslrootcert = bincraft::postgres_sslrootcert("verify-full") -) -on.exit(try(DBI::dbDisconnect(con), silent = TRUE), add = TRUE) - -rows <- DBI::dbGetQuery( - con, - paste0( - "SELECT package, version, unsupported FROM abi_flat_safety ", - "WHERE NOT safe AND codename = $1 AND arch = $2 ", - "ORDER BY package, version" - ), - params = list(codename, arch) -) - -# Drop what is already repaired. The verdict describes the *flat* object, and a -# per-minor build does not change it, so a resumed run would otherwise rebuild -# everything it did last time: ~2500 objects of duplicated compute after the -# first fleet run was interrupted. -# -# An object is repaired once a per-minor build exists for every minor that -# cannot load the flat one. The bucket is the source of truth for that, and it -# cannot be routed. -if (nrow(rows) > 0L) { - s3fs::s3_file_system( - aws_access_key_id = Sys.getenv("B2_S3_ACCESS_KEY"), - aws_secret_access_key = Sys.getenv("B2_S3_SECRET_KEY"), - endpoint = "https://s3.eu-central-003.backblazeb2.com", - region_name = "eu-central-003", - refresh = TRUE - ) - contrib <- sprintf( - "devxy-rpkgs-binaries/%s/%s/latest/src/contrib", - arch, - codename - ) - objects <- tryCatch( - s3fs::s3_dir_ls(contrib, recurse = TRUE), - error = function(e) character(0) - ) - if (length(objects) == 0L) { - stop( - sprintf( - "Could not list %s; refusing to guess what is already repaired.", - contrib - ), - call. = FALSE - ) - } - present <- sub(sprintf("^(s3://)?%s/", contrib), "", objects) - - # No recorded minors means unsafe without a reason, so require a build under - # every minor the image carries rather than assume one is enough. - installed <- sub( - "^([0-9]+[.][0-9]+).*$", - "\\1", - basename(list.dirs("/opt/R", recursive = FALSE)) - ) - installed <- unique(installed[grepl("^[0-9]+[.][0-9]+$", installed)]) - - repaired <- vapply( - seq_len(nrow(rows)), - function(i) { - u <- rows$unsupported[[i]] - minors <- if (is.na(u) || !nzchar(u)) { - installed - } else { - trimws(strsplit(u, ",", fixed = TRUE)[[1L]]) - } - if (length(minors) == 0L) { - return(FALSE) - } - wanted <- sprintf( - "%s/%s_%s.tar.gz", - minors, - rows$package[[i]], - rows$version[[i]] - ) - all(wanted %in% present) - }, - logical(1L) - ) - if (any(repaired)) { - message(sprintf( - "%s/%s: %d of %d already have per-minor builds for every minor that needs one; skipping those.", - arch, - codename, - sum(repaired), - nrow(rows) - )) - } - rows <- rows[!repaired, , drop = FALSE] -} - -# An empty result is ambiguous: either nothing is unsafe, or the backfill never -# ran for this slot. Say which, rather than let the caller read silence as done. -if (nrow(rows) == 0L) { - total <- DBI::dbGetQuery( - con, - "SELECT count(*) AS n FROM abi_flat_safety WHERE codename = $1 AND arch = $2", - params = list(codename, arch) - )$n[[1L]] - if (total == 0L) { - stop( - sprintf( - "No verdicts recorded for %s/%s at all. Run the flat-safety backfill first; an empty repair list here would look like success.", # nolint - arch, - codename - ), - call. = FALSE - ) - } - # `count(*)` arrives as a double (or integer64), and `%d` rejects both, so the - # nothing-to-do path used to die on its own success message. - message(sprintf( - "%s/%s: %s objects recorded, none unsafe. Nothing to repair.", - arch, - codename, - format(as.numeric(total), scientific = FALSE) - )) - quit(status = 0) -} - -message(sprintf( - "%s/%s: %d objects need a per-minor build", - arch, - codename, - nrow(rows) -)) -cat(sprintf("%s %s", rows$package, rows$version), sep = "\n") diff --git a/local/manual-package-index-update.R b/local/manual-package-index-update.R new file mode 100644 index 0000000..f100217 --- /dev/null +++ b/local/manual-package-index-update.R @@ -0,0 +1,39 @@ +# R -q -e 'pak::pak("git::https://codefloe.com/rpkgs/bincraft.git")' +# remotes::install_gitlab("devxy/r-package-binaries/bincraft") + +library(bincraft) +library(dplyr) +s3fs::s3_file_system( + aws_access_key_id = Sys.getenv("HETZNER_S3_ACCESS_KEY_K3S"), + aws_secret_access_key = Sys.getenv("HETZNER_S3_SECRET_KEY_K3S"), + endpoint = "https://hel1.your-objectstorage.com", + region_name = "hel1", + refresh = TRUE +) + +s3fs::s3_file_delete("devxy-r-package-binaries-hel1/arm64/noble/latest/src/contrib/PACKAGES.db") +s3fs::s3_file_delete("devxy-r-package-binaries-hel1/arm64/noble/latest/src/contrib/PACKAGES.gz") +s3fs::s3_file_delete("devxy-r-package-binaries-hel1/arm64/noble/latest/src/contrib/PACKAGES.rds") +s3fs::s3_file_delete("devxy-r-package-binaries-hel1/arm64/noble/latest/src/contrib/PACKAGES") + +s3fs::s3_file_info("devxy-r-package-binaries-hel1/amd64/rhel9/latest/src/contrib/duckdbfs_0.0.9.tar.gz")$etag +s3fs::s3_file_info("devxy-r-package-binaries-hel1/amd64/rhel9/latest/src/contrib/Archive/duckplyr/duckplyr_0.4.1.tar.gz")$etag +s3fs::s3_file_info("devxy-r-package-binaries-hel1/amd64/rhel9/latest/src/contrib/duckplyr_1.0.0.tar.gz")$etag +s3fs::s3_file_info("devxy-r-package-binaries-hel1/amd64/rhel9/latest/src/contrib/duckduckr_1.0.0.tar.gz")$etag +s3fs::s3_file_info("devxy-r-package-binaries-hel1/amd64/rhel9/latest/src/contrib/getDTeval_0.0.2.tar.gz")$etag +s3fs::s3_file_info("devxy-r-package-binaries-hel1/amd64/rhel9/latest/src/contrib/dualtrees_0.1.5.tar.gz")$etag +s3fs::s3_file_info("devxy-r-package-binaries-hel1/arm64/alpine321/latest/src/contrib/tidyselect_1.2.1.tar.gz") +s3fs::s3_file_info("devxy-r-package-binaries-hel1/arm64/alpine321/latest/src/contrib/tidysq_1.2.3.tar.gz") +# s3fs::s3_file_info("devxy-r-package-binaries-hel1/amd64/alpine320/latest/src/contrib/Archive/curl/curl_6.0.1.tar.gz") + +s3fs::s3_file_download("devxy-r-package-binaries-hel1/amd64/rhel9/latest/src/contrib/PACKAGES.db", "PACKAGES.db") + +upload_package_index(codename = "noble", arch = "arm64") + +fs::file_delete("PACKAGES.db") + + +con = DBI::dbConnect(RSQLite::SQLite(), "PACKAGES-debug.db") + +DBI::dbListTables(con) +df = DBI::dbReadTable(con, "packages") diff --git a/local/migrate-s3-hetzner-to-backblaze.sh b/local/migrate-s3-hetzner-to-backblaze.sh deleted file mode 100644 index 8cbd829..0000000 --- a/local/migrate-s3-hetzner-to-backblaze.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Migrate S3 buckets from Hetzner Object Storage to Backblaze B2 via rclone. -# -# Prerequisites: -# 1. Install rclone: https://rclone.org/install/ -# 2. Configure two rclone remotes: -# rclone config create hetzner s3 \ -# provider=Other \ -# env_auth=false \ -# access_key_id=YOUR_HETZNER_KEY \ -# secret_access_key=YOUR_HETZNER_SECRET \ -# endpoint=fsn1.your-objectstorage.com # adjust region -# -# rclone config create backblaze s3 \ -# provider=Other \ -# env_auth=false \ -# access_key_id=YOUR_B2_KEY \ -# secret_access_key=YOUR_B2_APP_KEY \ -# endpoint=s3.us-west-004.backblazeb2.com # adjust region -# -# Usage: -# ./migrate-s3-hetzner-to-backblaze.sh [src:dst] ... -# ./migrate-s3-hetzner-to-backblaze.sh hetzner-bucket:backblaze-bucket - -HETZNER_REMOTE="${HETZNER_REMOTE:-hetzner}" -BACKBLAZE_REMOTE="${BACKBLAZE_REMOTE:-backblaze}" -RCLONE_FLAGS="${RCLONE_FLAGS:---transfers=64 --checkers=64 --fast-list}" - -if [[ $# -eq 0 ]]; then - echo "Usage: $0 [src-bucket:dst-bucket...]" - echo "" - echo " Each argument is a source:destination bucket pair separated by a colon." - echo "" - echo "Environment variables:" - echo " HETZNER_REMOTE rclone remote name for Hetzner (default: hetzner)" - echo " BACKBLAZE_REMOTE rclone remote name for Backblaze (default: backblaze)" - echo " RCLONE_FLAGS extra rclone flags (default: --transfers=16 --checkers=16 --fast-list)" - echo " DRY_RUN=1 show what would be copied without copying" - exit 1 -fi - -for cmd in rclone; do - if ! command -v "$cmd" &>/dev/null; then - echo "Error: $cmd is not installed." >&2 - exit 1 - fi -done - -# Verify remotes exist -for remote in "$HETZNER_REMOTE" "$BACKBLAZE_REMOTE"; do - if ! rclone listremotes | grep -q "^${remote}:$"; then - echo "Error: rclone remote '${remote}' not found. Run 'rclone config' to set it up." >&2 - exit 1 - fi -done - -DRY_RUN_FLAG="" -if [[ "${DRY_RUN:-0}" == "1" ]]; then - DRY_RUN_FLAG="--dry-run" - echo "=== DRY RUN MODE ===" -fi - -for pair in "$@"; do - if [[ "$pair" != *:* ]]; then - echo "Error: '$pair' is not a valid src:dst pair. Use format 'hetzner-bucket:backblaze-bucket'." >&2 - exit 1 - fi - - src_bucket="${pair%%:*}" - dst_bucket="${pair#*:}" - src="${HETZNER_REMOTE}:${src_bucket}" - dst="${BACKBLAZE_REMOTE}:${dst_bucket}" - - echo "" - echo "--- Migrating: ${src} -> ${dst} ---" - - # shellcheck disable=SC2086 - rclone sync \ - ${RCLONE_FLAGS} \ - ${DRY_RUN_FLAG} \ - --progress \ - "$src" "$dst" - - echo "--- Done: ${src_bucket} -> ${dst_bucket} ---" -done - -echo "" -echo "Migration complete." diff --git a/local/missing-cran-packages-db.R b/local/missing-cran-packages-db.R index 0c73e99..56b3d94 100644 --- a/local/missing-cran-packages-db.R +++ b/local/missing-cran-packages-db.R @@ -3,35 +3,22 @@ library(bincraft) library(dplyr) library(DBI) -con <- DBI::dbConnect( - RPostgres::Postgres(), - dbname = "build_metadata", - host = "r-binaries.devxy.io", - port = 15432, - user = "r_binaries", - password = Sys.getenv("PGPASS"), - sslmode = "verify-full", - sslrootcert = bincraft::postgres_sslrootcert("verify-full") +con <- DBI::dbConnect(RPostgres::Postgres(), + dbname = "build_metadata", host = "r-binaries.devxy.io", + port = 15432, user = "r_binaries", password = Sys.getenv("PGPASS"), + sslmode = "require" ) `%nin%` <- Negate(`%in%`) -new_packages <- get_new_cran_packages(lubridate::interval( - lubridate::today(), - lubridate::today() - 2 -))$name -removed_pkgs <- get_removed_cran_packages(lubridate::interval( - lubridate::today(), - lubridate::today() - 2 -))$name +new_packages <- get_new_cran_packages(lubridate::interval(lubridate::today(), lubridate::today() - 2))$name +removed_pkgs <- get_removed_cran_packages(lubridate::interval(lubridate::today(), lubridate::today() - 2))$name # filter windows packages # filter new packages from the last X days -cran_pkgs <- unique( - tools::CRAN_package_db() |> - filter(`OS_type` != "windows" | is.na(`OS_type`)) |> - filter(`Package` %nin% new_packages) |> - pull(Package) -) +cran_pkgs <- unique(tools::CRAN_package_db() |> + filter(`OS_type` != "windows" | is.na(`OS_type`)) |> + filter(`Package` %nin% new_packages) |> + pull(Package)) arch <- "arm64" platform <- "redhat-8" @@ -41,24 +28,13 @@ platform <- "alpine-321" platform <- "ubuntu-2204" platform <- "ubuntu-2404" -data <- dbGetQuery( - con, - "SELECT name FROM single_builds WHERE platform = $1 AND arch = $2 and removed = FALSE;", - params = list(platform, arch) -) -removed_pkgs <- get_removed_cran_packages(lubridate::interval( - lubridate::today(), - lubridate::today() - 2 -))$name +data <- dbGetQuery(con, "SELECT name FROM single_builds WHERE platform = $1 AND arch = $2 and removed = FALSE;", params = list(platform, arch)) +removed_pkgs = get_removed_cran_packages(lubridate::interval(lubridate::today(), lubridate::today() - 2))$name pkgs_db <- unique(data$name) -pkgs_db <- setdiff(pkgs_db, removed_pkgs) +pkgs_db = setdiff(pkgs_db, removed_pkgs) pkgs <- setdiff(cran_pkgs, pkgs_db) -formatted_pkgs <- gsub( - '"', - "'", - capture.output(dput(as.character(na.omit(pkgs[1:length(pkgs)])))) -) +formatted_pkgs <- gsub('"', "'", capture.output(dput(as.character(na.omit(pkgs[1:length(pkgs)]))))) formatted_pkgs_one_line <- paste(formatted_pkgs, collapse = " ") cat(formatted_pkgs_one_line, "\n", sep = "") @@ -68,6 +44,7 @@ clipr::write_clip(formatted_pkgs_one_line) # sapply(pkgs, function(x) which(grepl(sprintf("^%s$", x), cran_pkgs))) + s3fs::s3_file_system( aws_access_key_id = Sys.getenv("HETZNER_S3_ACCESS_KEY_K3S"), aws_secret_access_key = Sys.getenv("HETZNER_S3_SECRET_KEY_K3S"), diff --git a/local/missing-cran-packages.R b/local/missing-cran-packages.R index ca5cad8..ab71b5b 100644 --- a/local/missing-cran-packages.R +++ b/local/missing-cran-packages.R @@ -10,39 +10,19 @@ s3fs::s3_file_system( ) s3fs::s3_dir_ls("s3://devxy-r-package-binaries") -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/amd64/jammy/latest/src/contrib" -)) # done -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/amd64/noble/latest/src/contrib" -)) # done -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/amd64/rhel8/latest/src/contrib" -)) # done -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/amd64/rhel9/latest/src/contrib" -)) # done -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/amd64/alpine320/latest/src/contrib" -)) # done +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/amd64/jammy/latest/src/contrib")) # done +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/amd64/noble/latest/src/contrib")) # done +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/amd64/rhel8/latest/src/contrib")) # done +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/amd64/rhel9/latest/src/contrib")) # done +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/amd64/alpine320/latest/src/contrib")) # done -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/arm64/jammy/latest/src/contrib" -)) # done -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/arm64/noble/latest/src/contrib" -)) # done -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/arm64/rhel8/latest/src/contrib" -)) # done -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/arm64/rhel9/latest/src/contrib" -)) # done -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/arm64/alpine320/latest/src/contrib" -)) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/arm64/jammy/latest/src/contrib")) # done +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/arm64/noble/latest/src/contrib")) # done +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/arm64/rhel8/latest/src/contrib")) # done +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/arm64/rhel9/latest/src/contrib")) # done +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/arm64/alpine320/latest/src/contrib")) -files_b = basename(files) +files_b=basename(files) files_b_split = sapply(strsplit(basename(files_b), "_"), function(x) x[1]) cran_pkgs <- tools::CRAN_package_db() |> @@ -50,11 +30,7 @@ cran_pkgs <- tools::CRAN_package_db() |> pull(Package) pkgs = setdiff(cran_pkgs, files_b_split) -formatted_pkgs <- gsub( - '"', - "'", - capture.output(dput(as.character(na.omit(pkgs[1:900])))) -) +formatted_pkgs <- gsub('"', "'", capture.output(dput(as.character(na.omit(pkgs[1:900]))))) formatted_pkgs_one_line <- paste(formatted_pkgs, collapse = " ") cat(formatted_pkgs_one_line, "\n", sep = "") diff --git a/local/missing-packages-in-index.R b/local/missing-packages-in-index.R index 6453888..810c89d 100644 --- a/local/missing-packages-in-index.R +++ b/local/missing-packages-in-index.R @@ -7,109 +7,42 @@ s3fs::s3_file_system( region_name = "hel1", ) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/amd64/jammy/latest/src/contrib" -)) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/amd64/noble/latest/src/contrib" -)) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/amd64/rhel8/latest/src/contrib" -)) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/amd64/rhel9/latest/src/contrib" -)) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/amd64/alpine320/latest/src/contrib" -)) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/amd64/jammy/latest/src/contrib")) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/amd64/noble/latest/src/contrib")) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/amd64/rhel8/latest/src/contrib")) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/amd64/rhel9/latest/src/contrib")) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/amd64/alpine320/latest/src/contrib")) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/arm64/jammy/latest/src/contrib" -)) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/arm64/noble/latest/src/contrib" -)) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/arm64/rhel8/latest/src/contrib" -)) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/arm64/rhel9/latest/src/contrib" -)) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/arm64/alpine320/latest/src/contrib" -)) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/arm64/jammy/latest/src/contrib")) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/arm64/noble/latest/src/contrib")) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/arm64/rhel8/latest/src/contrib")) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/arm64/rhel9/latest/src/contrib")) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/arm64/alpine320/latest/src/contrib")) -files_b = basename(files) +files_b=basename(files) files_b_split = sapply(strsplit(basename(files_b), "_"), function(x) x[1]) -files_b_split = setdiff( - files_b_split, - c("PACKAGES", "PACKAGES.gz", "PACKAGES.rds", "PACKAGES.db", "Archive") -) +files_b_split = setdiff(files_b_split, c("PACKAGES", "PACKAGES.gz", "PACKAGES.rds", "PACKAGES.db", "Archive")) # windows-only -files_b_split = setdiff( - files_b_split, - c( - "PACKAGES", - "PACKAGES.gz", - "PACKAGES.rds", - "PACKAGES.db", - "Archive", - "RInno", - "KeyboardSimulator", - "R2PPT", - "RWinEdt", - "blatr", - "excel.link", - "spectrino", - "taskscheduleR", - "MDSGUI", - "BiplotGUI", - "R2wd" - ) -) -pkgs_index = available.packages( - "https://cran.devxy.io/amd64/jammy/latest/src/contrib" -)[, "Package"] -pkgs_index_b = basename(pkgs_index) +files_b_split = setdiff(files_b_split, c("PACKAGES", "PACKAGES.gz", "PACKAGES.rds", "PACKAGES.db", "Archive", "RInno", "KeyboardSimulator", "R2PPT", "RWinEdt", "blatr", "excel.link", "spectrino", "taskscheduleR", "MDSGUI", "BiplotGUI", "R2wd")) +pkgs_index = available.packages("https://cran.devxy.io/amd64/jammy/latest/src/contrib")[, "Package"] +pkgs_index_b=basename(pkgs_index) if (length(files_b_split) != length(pkgs_index_b)) { pkgs_missing = setdiff(files_b_split, pkgs_index_b) message("Packages missing in index but present in S3:") pkgs_missing - formatted_pkgs <- gsub( - '"', - "'", - capture.output(dput(as.character(na.omit(pkgs_missing[1:900])))) - ) + formatted_pkgs <- gsub('"', "'", capture.output(dput(as.character(na.omit(pkgs_missing[1:900]))))) formatted_pkgs_one_line <- paste(formatted_pkgs, collapse = " ") cat(formatted_pkgs_one_line, "\n", sep = "") } -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/amd64/noble/latest/src/contrib" -)) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/amd64/rhel8/latest/src/contrib" -)) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/amd64/rhel9/latest/src/contrib" -)) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/amd64/alpine320/latest/src/contrib" -)) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/amd64/noble/latest/src/contrib")) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/amd64/rhel8/latest/src/contrib")) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/amd64/rhel9/latest/src/contrib")) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/amd64/alpine320/latest/src/contrib")) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/arm64/jammy/latest/src/contrib" -)) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/arm64/noble/latest/src/contrib" -)) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/arm64/rhel8/latest/src/contrib" -)) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/arm64/rhel9/latest/src/contrib" -)) -files <- s3fs::s3_dir_ls(sprintf( - "devxy-r-package-binaries-hel1/arm64/alpine320/latest/src/contrib" -)) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/arm64/jammy/latest/src/contrib")) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/arm64/noble/latest/src/contrib")) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/arm64/rhel8/latest/src/contrib")) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/arm64/rhel9/latest/src/contrib")) +files <- s3fs::s3_dir_ls(sprintf("devxy-r-package-binaries-hel1/arm64/alpine320/latest/src/contrib")) diff --git a/local/newer-r-helpers.R b/local/newer-r-helpers.R deleted file mode 100644 index b4ac689..0000000 --- a/local/newer-r-helpers.R +++ /dev/null @@ -1,114 +0,0 @@ -# Evaluate every R constraint, including patch-level and upper bounds. -r_requirement_satisfied <- function(depends, r_version) { - if (is.na(depends) || !nzchar(trimws(depends))) { - return(TRUE) - } - entries <- trimws(strsplit(depends, ",", fixed = TRUE)[[1L]]) - entries <- entries[grepl("^R(\\s|\\(|$)", entries)] - all(vapply( - entries, - function(entry) { - if (entry == "R") { - return(TRUE) - } - match <- regmatches( - entry, - regexec( - "^R\\s*\\(\\s*(>=|<=|==|>|<)\\s*([0-9]+(?:[.-][0-9]+)*)\\s*\\)$", - entry, - perl = TRUE - ) - )[[1L]] - if (length(match) != 3L) { - stop("Cannot parse R dependency: ", entry) - } - comparison <- utils::compareVersion(r_version, match[3L]) - switch( - match[2L], - ">=" = comparison >= 0L, - "<=" = comparison <= 0L, - "==" = comparison == 0L, - ">" = comparison > 0L, - "<" = comparison < 0L - ) - }, - logical(1L) - )) -} - -# Use unfiltered current CRAN metadata: available.packages() would hide exactly -# the packages that cannot run under the primary interpreter. -# Propagate R incompatibility through required dependencies, not Suggests. -newer_r_candidates <- function(db, primary_r, target_r) { - db <- as.data.frame(db, stringsAsFactors = FALSE) - # CRAN also lists R-specific Recommended copies (e.g. Matrix for R-devel). - # Prefer the ordinary contrib record, or a future-R copy can incorrectly - # block every package depending on Matrix on all released interpreters. - if ("Path" %in% names(db)) { - db <- db[order(!is.na(db$Path) & nzchar(db$Path)), , drop = FALSE] - } - db <- db[!duplicated(db$Package), , drop = FALSE] - deps <- tools::package_dependencies( - packages = db$Package, - db = as.matrix(db), - which = c("Depends", "Imports", "LinkingTo"), - recursive = FALSE - ) - supported <- function(version) { - ok <- vapply(db$Depends, r_requirement_satisfied, logical(1L), version) - repeat { - blocked <- db$Package[!ok] - next_ok <- ok & - !vapply(deps, function(x) any(x %in% blocked), logical(1L)) - if (identical(ok, next_ok)) { - return(ok) - } - ok <- next_ok - } - } - selected <- !supported(primary_r) & supported(target_r) - if ("OS_type" %in% names(db)) { - selected <- selected & (is.na(db$OS_type) | db$OS_type != "windows") - } - result <- db[selected, c("Package", "Version"), drop = FALSE] - result[order(result$Package), , drop = FALSE] -} - -# Candidates that still need a build, decided from one bucket listing per slot -# instead of a metadata-DB connection and several S3 requests per package. -# -# Mirrors bincraft's own skip decision: a package is done when a binary sits at -# the path its cached ABI verdict routes it to, `//` when -# r-minor-sensitive and the flat `/` otherwise. A CRAN source sitting at -# that key is a fallback, not a binary (see outstanding_packages()). Whatever -# this cannot decide, no cached verdict or a slot that could not be listed, -# stays in the list, so bincraft makes that call exactly as before. -# -# `sensitive` cached verdicts for the current classifier, named `_` -# `flat_etags` listing of the flat slot as for outstanding_packages(), or -# NULL when it could not be listed -# `minor_etags` the same for this interpreter's per-minor slot -newer_r_outstanding <- function( - pkgs, - sensitive, - flat_etags, - minor_etags, - cran_md5 -) { - verdict <- unname(sensitive[paste(pkgs$Package, pkgs$Version, sep = "_")]) - version <- stats::setNames(pkgs$Version, pkgs$Package) - keep <- rep(TRUE, nrow(pkgs)) - routes <- list( - list(sensitive = FALSE, etags = flat_etags), - list(sensitive = TRUE, etags = minor_etags) - ) - for (route in routes) { - idx <- which(verdict %in% route$sensitive) - if (length(idx) == 0L || is.null(route$etags)) { - next - } - keep[idx] <- pkgs$Package[idx] %in% - outstanding_packages(pkgs$Package[idx], route$etags, version, cran_md5) - } - pkgs[keep, , drop = FALSE] -} diff --git a/local/packages-to-build.R b/local/packages-to-build.R index 32f846e..91ee96e 100644 --- a/local/packages-to-build.R +++ b/local/packages-to-build.R @@ -5,23 +5,21 @@ options(error = function() { }) library(bincraft, quietly = TRUE) +suppressPackageStartupMessages(library(dplyr)) library(DBI, quietly = TRUE) library(purrr, quietly = TRUE) +library(progressr, quietly = TRUE) suppressPackageStartupMessages(library(data.table)) # Sys.setenv("OS" = "alpine") -# Sys.setenv("OS_VERSION" = "3.23") +# Sys.setenv("OS_VERSION" = "3.22") # Sys.setenv("ARCH" = "arm64") -arch <- Sys.getenv("ARCH") -# target: alpine-323, ubuntu-2404, redhat-9, etc. -platform <- paste( - Sys.getenv("OS"), - gsub("[.]", "", Sys.getenv("OS_VERSION")), - sep = "-" -) +arch = Sys.getenv("ARCH") +# target: alpine-322, ubuntu-2404, redhat-9, etc. +platform = paste(Sys.getenv("OS"), gsub("[.]", "", Sys.getenv("OS_VERSION")), sep = "-") # Use bincraft's codename detection for S3 paths (e.g. "rhel10" not "redhat10") -codename <- bincraft::set_codename(NULL) +codename = bincraft::set_codename(NULL) con <- DBI::dbConnect( RPostgres::Postgres(), @@ -30,16 +28,13 @@ con <- DBI::dbConnect( port = 15432, user = "rpkgs", password = Sys.getenv("PGPASS"), - sslmode = "verify-full", - sslrootcert = bincraft::postgres_sslrootcert("verify-full") + sslmode = "require" ) -cran_archive <- tools::CRAN_archive_db() -cran_release <- tools::CRAN_package_db() +cran_archive = tools::CRAN_archive_db() +cran_release = tools::CRAN_package_db() # Subset cran_archive to only those packages -cran_archive_in_release <- cran_archive[ - names(cran_archive) %in% cran_release$Package -] +cran_archive_in_release <- cran_archive[names(cran_archive) %in% cran_release$Package] archive_versions <- rbindlist( lapply(names(cran_archive), function(pkg) { @@ -67,36 +62,9 @@ archive_versions <- archive_versions[ ] # Now get release versions (assuming cran_release has Package and Version columns) -# -# Packages published in the last few days are held back. `check_for_binary()` -# reads the published version from the `cran` GitHub mirror -# (`GET /repos/cran//commits`), and that mirror lags CRAN: a package that -# has just appeared has no repository there yet. The call then 404s, which is -# permanent, but it is wrapped in `purrr::insistently` and retried ten times -# with a backoff capped at 60s - so one unmirrored package burns about five -# minutes and then aborts the whole shard. -# -# Holding them back costs nothing: the daily update pipeline builds new and -# updated packages anyway, and they arrive here on the next run once the mirror -# has caught up. -mirror_lag_days <- as.numeric( - Sys.getenv("CRAN_MIRROR_LAG_DAYS", unset = "3") -) -published <- as.POSIXct(cran_release$Published, tz = "UTC") -too_recent <- !is.na(published) & - published > (Sys.time() - mirror_lag_days * 86400) -if (any(too_recent)) { - message(sprintf( - "Holding back %d package(s) published in the last %g day(s); the cran GitHub mirror will not have them yet: %s", - sum(too_recent), - mirror_lag_days, - paste(utils::head(cran_release$Package[too_recent], 10L), collapse = ", ") - )) -} - release_versions <- data.table( - Package = cran_release$Package[!too_recent], - Version = as.character(cran_release$Version[!too_recent]) + Package = cran_release$Package, + Version = as.character(cran_release$Version) ) pkgs_to_build <- unique(rbind(archive_versions, release_versions, fill = TRUE)) @@ -110,205 +78,18 @@ s3fs::s3_file_system( region_name = "eu-central-003", refresh = TRUE ) -s3_pkgs <- s3fs::s3_dir_ls( +s3_pkgs = s3fs::s3_dir_ls( sprintf("devxy-rpkgs-binaries/%s/%s/latest/src/contrib", arch, codename), recurse = TRUE ) -# `recurse = TRUE` walks the per-minor slots as well, and `basename()` throws -# the directory away - so `4.5/curl_1.0.tar.gz` and `curl_1.0.tar.gz` collapse -# to one name and a package present under *any* R minor counts as built for -# *all* of them. The candidate list then prunes exactly the packages a -# per-minor pass exists to build: arm64/alpine324 reported "0 remaining" for -# both 4.4 and 4.6 while its indexes were dropping 2400+ packages as missing. -# -# Per-minor objects are therefore excluded here. Presence in a specific minor -# is decided downstream, where the running R version is known: build-all.R -# filters on it, and `build_binary_package()` checks the per-minor path per -# package and skips what is already there. -# -# Archive/ is kept. Those are versions that were built and then superseded; -# dropping them would make every archived version look unbuilt. -per_minor_object <- grepl("/[0-9]+\\.[0-9]+/[^/]+$", s3_pkgs) -if (any(per_minor_object)) { - cat(sprintf( - "Excluding %d per-minor object(s) from the presence check; those are decided per pass\n", - sum(per_minor_object) - )) -} -file_names <- basename(s3_pkgs[!per_minor_object]) +# Save the raw S3 file listing for the build step to use as s3_package_cache +# This avoids loading s3fs/reticulate in the build container, saving memory for pak forks +saveRDS(basename(s3_pkgs), "/mnt/cache/packages/s3_cache.rds") -# An object occupying a key is not proof a binary was built: a package whose -# build failed has its CRAN source published under exactly that name. Left in -# the cache, `build_binary_package()` reads it as "already built" and skips the -# package forever, which is how alpine324 accumulated ~13.5k source tarballs. -# -# bincraft stamps `Built` only on records it actually built, so the slot's own -# index distinguishes them. A slot last indexed by a bincraft that predates that -# fix stamps `Built` on everything, so the cache is then unchanged from before. -# Archived objects have no index record and are kept: unknown means binary, -# never "rebuild it". -index_url <- sprintf( - "https://cran.rpkgs.com/%s/%s/latest/src/contrib/PACKAGES.gz", - arch, - codename -) -read_source_served <- function(index) { - tryCatch( - { - con_idx <- gzcon(url(index, open = "rb")) - on.exit(close(con_idx), add = TRUE) - idx <- read.dcf(con_idx, fields = c("Package", "Version", "Built")) - sprintf( - "%s_%s.tar.gz", - idx[is.na(idx[, "Built"]), "Package"], - idx[is.na(idx[, "Built"]), "Version"] - ) - }, - error = function(e) { - cat(sprintf( - "WARNING: could not read %s (%s); keeping that index's cache in full\n", - index, - conditionMessage(e) - )) - character(0) - } - ) -} - -source_served <- read_source_served(index_url) - -binary_cache <- setdiff(file_names, source_served) - -# The existence cache and the candidate list need different views of the same -# listing, and conflating them is what made this wrong in both directions. -# -# The candidate list must ignore per-minor objects, or a package present under -# one minor prunes itself from every other minor's work (#189). The existence -# cache must NOT ignore them, or `build_binary_package()` is told nothing is -# present under any minor and recompiles the lot: amd64/resolute recompiled -# 8683 packages it had already built, reporting "already exists in S3" three -# times. -# -# So the cache keeps the path relative to the slot, and `build-all.R` selects -# the part that matches the pass it is running: the flat slot for the primary, -# `/` for a per-minor pass. -# -# `s3_dir_ls()` returns keys with the `s3://` scheme attached, so stripping the -# prefix as a fixed substring takes it out of the middle and leaves -# `s3://4.4/curl_1.0.tar.gz`. That leading scheme defeats the `^/` test -# downstream, so every per-minor object is read as a flat-slot object: the -# sensitive passes see an empty cache and recompile everything they already -# have. Anchor the pattern and swallow the scheme with it. -contrib_prefix <- sprintf( - "^(s3://)?devxy-rpkgs-binaries/%s/%s/latest/src/contrib/", - arch, - codename -) -relative_paths <- sub(contrib_prefix, "", s3_pkgs) - -# The strip is load-bearing and fails silently, so assert it. Both counts are -# derived from the same listing and use the same shape of pattern, so they must -# agree exactly; a mismatch means the prefix no longer describes the keys. -stripped_per_minor <- grepl("^[0-9]+\\.[0-9]+/[^/]+$", relative_paths) -if (sum(stripped_per_minor) != sum(per_minor_object)) { - stop(sprintf( - paste0( - "S3 prefix strip failed: %d per-minor objects in the listing, %d after ", - "stripping /%s/. Example key: %s" - ), - sum(per_minor_object), - sum(stripped_per_minor), - contrib_prefix, - if (any(per_minor_object)) { - s3_pkgs[which(per_minor_object)[1L]] - } else { - "" - } - )) -} -source_basenames <- source_served - -# A source-fallback list describes ONE index, so it may only be applied to that -# index's objects. Applied to every path it deletes real per-minor binaries from -# the cache: a package the flat slot serves as CRAN source still has a genuine -# `4.4/.tar.gz`, and dropping that name makes every per-minor pass rebuild -# it, every run, forever. -# -# The overlap is total rather than partial, which is why this pinned the skip -# rate near 0%: the sensitive candidate list is exactly "sensitive packages with -# no flat binary", which is the same set this was removing. amd64/resolute -# listed 21212 per-minor objects but cached only 13572, then recompiled osmdata, -# osqp and outbreaker2 while their 4.4 binaries sat in the bucket. -# -# So judge each minor by its own index, and the flat slot by the flat index. -is_per_minor_path <- grepl("^[0-9]+\\.[0-9]+/", relative_paths) -path_minor <- ifelse( - is_per_minor_path, - sub("^([0-9]+\\.[0-9]+)/.*$", "\\1", relative_paths), - "" -) -minors_present <- sort(unique(path_minor[is_per_minor_path])) -per_minor_source <- lapply(minors_present, function(m) { - read_source_served(sprintf( - "https://cran.rpkgs.com/%s/%s/latest/src/contrib/%s/PACKAGES.gz", - arch, - codename, - m - )) -}) -names(per_minor_source) <- minors_present -cat(sprintf( - "Source fallbacks per index: flat=%d%s\n", - length(source_basenames), - if (length(minors_present)) { - paste0( - ", ", - paste( - sprintf("%s=%d", minors_present, lengths(per_minor_source)), - collapse = ", " - ) - ) - } else { - "" - } -)) - -served_as_source <- vapply( - seq_along(relative_paths), - function(i) { - scope <- if (nzchar(path_minor[i])) { - per_minor_source[[path_minor[i]]] - } else { - source_basenames - } - basename(relative_paths[i]) %in% scope - }, - logical(1L) -) -existence_cache <- relative_paths[!served_as_source] -cat(sprintf( - "S3 cache: %d objects, %d served as CRAN source, %d usable binaries\n", - length(file_names), - length(file_names) - length(binary_cache), - length(binary_cache) -)) - -# Save the S3 file listing for the build step to use as s3_package_cache. -# This avoids loading s3fs/reticulate in the build container, saving memory for -# the dependency-installer subprocesses -# Mark the format explicitly. `build-all.R` has to tell a slot-relative cache -# from a pre-#191 basename one, and sniffing for a "/" cannot: a new-format -# cache for a slot with no per-minor or Archive objects holds bare names too, -# and would be read as legacy and used unfiltered, which makes a per-minor pass -# believe the flat slot's binaries are its own and build nothing. -attr(existence_cache, "slot_relative") <- TRUE -saveRDS(existence_cache, "/mnt/cache/packages/s3_cache.rds") -# Built from the filtered listing, not the raw one: `s3_dt` is subtracted from -# the build list below, so a source fallback left in here would exclude the very -# package that needs building. -matches <- regexec("^([A-Za-z0-9.]+)_([0-9][^/]*)\\.tar\\.gz$", binary_cache) -parts <- regmatches(binary_cache, matches) +file_names <- basename(s3_pkgs) +matches <- regexec("^([A-Za-z0-9.]+)_([0-9][^/]*)\\.tar\\.gz$", file_names) +parts <- regmatches(file_names, matches) parts <- parts[sapply(parts, length) == 3] s3_dt <- data.table( Package = sapply(parts, `[`, 2), @@ -317,22 +98,11 @@ s3_dt <- data.table( ### Get all packages with build errors -# Scoped to the R minor this snapshot is computed under. A failure is a fact -# about one interpreter: without the scope a package that failed under the -# primary minor is dropped from the candidate list for every other minor too, -# which is the same omission fixed in local/build-all.R and in bincraft's -# check_package_error(). -snapshot_r_minor <- paste( - R.version$major, - strsplit(R.version$minor, ".", fixed = TRUE)[[1L]][1L], - sep = "." -) sql_query <- paste0( # nolint "SELECT error_occurred FROM ", "single_builds", - " WHERE name = $1 AND tag = $2 AND platform = $3 AND arch = $4", - " AND substring(r_version from '^[0-9]+[.][0-9]+') = $5" + " WHERE name = $1 AND tag = $2 AND platform = $3 AND arch = $4" ) # Function to query for a single package-version query_error <- function(pkg, ver) { @@ -340,7 +110,7 @@ query_error <- function(pkg, ver) { ~ DBI::dbGetQuery( con, sql_query, - params = list(pkg, ver, platform, arch, snapshot_r_minor) + params = list(pkg, ver, platform, arch) ), rate = purrr::rate_backoff( pause_base = 1L, @@ -354,35 +124,13 @@ query_error <- function(pkg, ver) { } # Fetch all relevant columns from the database -# Scoped to the snapshot's own R minor, like `check_package_error()` in -# bincraft (#119) and the per-minor error query (#189). Unscoped, a single -# failure under any one minor removed the package from the candidate list for -# every minor, permanently: the row is keyed by (name, tag, platform, arch) -# only, so an error under 4.6 also cancelled its 4.4 and 4.5 builds. -# -# That is what the residual per-minor gaps were. On amd64/alpine324, 505 of the -# 508 ABI-risky packages missing from 4.4 were also missing from 4.6 -- a 99% -# overlap, which per-minor build failures would not produce. None of them were -# even attempted by the run that had just succeeded. -# -# Errors specific to another minor are still respected downstream: -# `filter_packages_with_errors()` runs per pass with that pass's r_version. errored_pkgs <- DBI::dbGetQuery( con, - sprintf( - paste0( - "SELECT name, tag FROM single_builds WHERE error_occurred = TRUE ", - "and platform='%s' and arch='%s' ", - "and substring(r_version from '^[0-9]+[.][0-9]+') = '%s'" - ), - platform, - arch, - snapshot_r_minor - ) + sprintf("SELECT name, tag FROM single_builds WHERE error_occurred = TRUE and platform='%s' and arch='%s'", platform, arch) ) errored_pkgs <- as.data.table(errored_pkgs) setkey(pkgs_to_build, Package, Version) -setnames(errored_pkgs, c("Package", "Version")) +setnames(errored_pkgs, c("Package","Version")) setkey(errored_pkgs, Package, Version) ### Final subsetting @@ -392,62 +140,3 @@ pkgs <- pkgs_no_error[!s3_dt] # Deduplicate pkgs <- unique(pkgs) setorder(pkgs, Package, Version) - -### R-minor sensitivity (classify once per package, applied to all versions) -source(file.path("local", "r-minor-helpers.R")) -risky_deps <- bincraft::abi_risky_linking_deps() - -release_meta <- data.table( - Package = cran_release$Package, - NeedsCompilation = cran_release$NeedsCompilation, - LinkingTo = cran_release$LinkingTo -) - -meta <- release_meta[Package %in% unique(pkgs$Package)] -meta[, - triage := mapply( - classify_from_metadata, - NeedsCompilation, - LinkingTo, - MoreArgs = list(risky_deps = risky_deps) - ) -] - -# Only the "ambiguous" compiled packages need a source grep. -ambiguous <- meta[triage == "ambiguous", Package] -sensitive_ambiguous <- character() -if (length(ambiguous) > 0L) { - tmp_src <- file.path(tempdir(), "abi_src") - dir.create(tmp_src, showWarnings = FALSE, recursive = TRUE) - sens <- vapply( - ambiguous, - function(pkg) { - out <- tryCatch( - { - dl <- utils::download.packages( - pkg, - destdir = tmp_src, - repos = "https://cloud.r-project.org", - quiet = TRUE - ) - isTRUE(as.logical(bincraft::needs_per_minor_recompile(dl[1L, 2L]))) - }, - error = function(e) TRUE - ) # fail safe: treat as sensitive - out - }, - logical(1L) - ) - sensitive_ambiguous <- ambiguous[sens] -} - -sensitive_pkgs <- unique(c( - meta[triage == "sensitive", Package], - sensitive_ambiguous -)) -pkgs[, r_minor_sensitive := Package %in% sensitive_pkgs] -sprintf( - "R-minor-sensitive packages: %s of %s", - length(sensitive_pkgs), - uniqueN(pkgs$Package) -) diff --git a/local/packages-without-any-binary.R b/local/packages-without-any-binary.R index 870dc6e..a6994ad 100644 --- a/local/packages-without-any-binary.R +++ b/local/packages-without-any-binary.R @@ -1,25 +1,17 @@ ### Lists packages without any successful binaries, i.e. pkgs for which all builds errored (per platform & arch) library(DBI) library(dplyr) -con <- DBI::dbConnect( - RPostgres::Postgres(), - dbname = "build_metadata", - host = "r-binaries.devxy.io", - port = 15432, - user = "r_binaries", - password = Sys.getenv("PGPASS"), - sslmode = "verify-full", - sslrootcert = bincraft::postgres_sslrootcert("verify-full") +con <- DBI::dbConnect(RPostgres::Postgres(), + dbname = "build_metadata", host = "r-binaries.devxy.io", + port = 15432, user = "r_binaries", password = Sys.getenv("PGPASS"), + sslmode = "require" ) -cran_pkgs <- tools::CRAN_package_db() |> - filter(`Date/Publication` <= "2024-12-02") |> +cran_pkgs <- tools::CRAN_package_db() |> + filter(`Date/Publication` <= "2024-12-02") |> pull(Package) -data <- dbGetQuery( - con, - "SELECT name,platform,arch,removed,error_occurred FROM single_builds;" -) +data <- dbGetQuery(con, "SELECT name,platform,arch,removed,error_occurred FROM single_builds;") pkgs <- data |> filter(platform == "alpine-320", arch == "arm64") |> @@ -28,13 +20,9 @@ pkgs <- data |> distinct(name) |> pull(name) -pkgs <- setdiff(cran_pkgs, pkgs) +pkgs = setdiff(cran_pkgs, pkgs) # Format, remove line breaks, and print as a single line -formatted_pkgs <- gsub( - '"', - "'", - capture.output(dput(as.character(na.omit(pkgs[1:900])))) -) +formatted_pkgs <- gsub('"', "'", capture.output(dput(as.character(na.omit(pkgs[1:900]))))) formatted_pkgs_one_line <- paste(formatted_pkgs, collapse = " ") diff --git a/local/patches/README.md b/local/patches/README.md deleted file mode 100644 index ce60c9a..0000000 --- a/local/patches/README.md +++ /dev/null @@ -1,120 +0,0 @@ -# Patch Registry - -This directory contains the curated registry of per-package build-time patches consumed by bincraft's `patches` argument. - -## Schema - -The registry is defined in `registry.json` as an array of patch entries. Each entry specifies lightweight build-time overrides (environment variables, configure arguments, Makevars) and optionally a source diff to apply before building. - -### Field semantics - -| Field | Type | Required | Description | -| ---------------- | ---------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `package` | string | yes | CRAN package name. | -| `versions` | string | yes | `"*"` for any, a constraint such as `">=5.1.0"`, or an exact version `"5.1.11-2"`. Env-tier fixes are typically `"*"`; source diffs are normally exact or lower-bounded because a diff is pinned to the source it was generated against. | -| `platforms` | array of strings | yes | Matched against the running build's platform tokens — distro family (`alpine`, `ubuntu`, `redhat`), codename (`ubuntu-2604`, `alpine-324`), and arch (`amd64`, `arm64`). An entry matches if any listed token matches any build token. `["*"]` matches all platforms. | -| `env` | object | no | Environment variables exported only for this package's isolated build. | -| `configure_args` | array | no | Arguments passed as `--configure-args` to the isolated build. | -| `makevars` | object | no | Key/value pairs written into a package-local Makevars for the isolated build. | -| `patch` | string or null | no | Path (relative to `local/patches/`) to a unified diff applied to the unpacked CRAN source before building. | -| `reason` | string | yes | Human explanation, surfaced in logs and metadata. | - -## Adding an entry - -To add a new patch entry: - -1. Add an object to the array in `registry.json` with the fields documented above. - Start with lightweight overrides (environment variables, configure arguments, Makevars) before resorting to source diffs. - -2. If a source diff is needed, place it in `local/patches//.patch` and reference its path in the `patch` field. - For example, a diff for `RcppParallel` would go in `local/patches/RcppParallel/fix.patch` and be referenced as `"patch": "RcppParallel/fix.patch"`. - -3. The `reason` field should clearly explain why the patch is needed and what problem it solves. - -## Validation - -The registry is validated and applied by bincraft during the build process. -For manual validation, run the validator from the repo root: - -```bash -Rscript local/validate-patches.R -``` - -This validates the schema, referenced patch-file existence, and checks for duplicate entries across platforms and versions. - -## Triaging failures into entries - -`local/failing-builds-report.R` turns recorded build failures into triaged patch suggestions instead of hand-scraping Crow logs (issue #115, steps 1 + 2). -It is read-only: it queries `single_builds WHERE error_occurred`, groups failures by a normalised error fingerprint, classifies each group against the known signature set in `local/failing-builds-classify.R`, and prints a report. - -```bash -# All platforms/arches; needs the DB password. -PGPASS=... Rscript local/failing-builds-report.R -# Restrict scope and also emit a machine-readable report. -PGPASS=... Rscript local/failing-builds-report.R --platform alpine-321 --arch amd64 --json report.json -``` - -Each group is tagged `AUTO-PROPOSABLE` (a known env/makevars lever, or an already-curated package patch, safe to pre-fill as a `registry.json` entry) or `HUMAN TRIAGE` (unknown signature, or a fix that needs a novel source diff). -For auto-proposable groups it prints a ready-to-review registry entry; still run `validate-patches.R` and an isolated trial build before merging. -Novel source diffs and unknown signatures stay human-reviewed by design. - -Add a new signature by appending a rule to `build_signatures()` in `local/failing-builds-classify.R`; the pure helpers are covered by `local/tests/test-failing-builds-classify.R`. - -### Proposing entries (step 3: propose, do not apply) - -`local/propose-patches.R` takes the auto-proposable candidates one step further: for each classified, safe fix affecting a package with no current entry, it emits a pre-filled `registry.json` entry and validates the candidate set against a temporary merged registry (the real registry is never touched unless you ask). -The human gate stays: it never merges. - -```bash -# Default: print candidates + validation, take no action. -PGPASS=... Rscript local/propose-patches.R -# Append the candidates to registry.json + the proposals ledger (you commit + open the PR). -PGPASS=... Rscript local/propose-patches.R --write -# Or post/update a Forgejo tracking issue instead (needs FORGEJO_TOKEN). -PGPASS=... FORGEJO_TOKEN=... Rscript local/propose-patches.R --open-issue -``` - -The acceptance criteria before merging a proposal are: `validate-patches.R` passes (checked automatically), and an isolated trial build succeeds. -Run the trial build inside the failing platform's build-env image; it uploads/archives nothing and writes no metadata: - -```bash -Rscript local/trial-build-patch.R -``` - -#### Autonomous PR + trial-build gate - -`--open-pr` closes the loop: it writes the top-N candidates (by failure volume) onto the reused `auto/registry-patch-proposals` branch and opens/updates a single PR. -`.crow/auto-apply-patches.yaml` runs this on a cron. -`FORGEJO_TOKEN` is used for both the branch push and the PR (no separate write-scoped secret). - -```bash -# Bounded batch; opens/updates one PR. -PGPASS=... FORGEJO_TOKEN=... Rscript local/propose-patches.R --open-pr --limit 10 -``` - -The merge gate is `.crow/trial-build-registry.yaml`: matrixed over the build-env images, each platform trial-builds only the entries the branch **adds** (`local/trial-build-registry.R`, which diffs the registry against `main`) and is green only if every new entry builds. -The repo uses no `pull_request` triggers, so this gate runs manually or on a cron against the auto-patch branch (`--var patch_branch=...`); wiring it to fire on the PR needs `event: pull_request` enabled on the forge. - -`--write` and `--open-issue` also append to `local/patches/proposals-log.json`, a ledger of what was proposed. - -### Feedback loop (step 4) - -`local/proposal-tracking.R` reports the signature hit rate, proposed-vs-merged status (a proposal counts as merged once its package appears in the registry), and retirement candidates (registry entries whose package no longer appears in any current failure, so the upstream cause was likely fixed). -It also surfaces the classifier's **blind spots**: the unclassified failures (candidates for a new signature) and the groups blocked on a dependency build, so the unknown buckets get the same visibility as the proposals. -It is read-only on the DB, with an optional Forgejo issue as the only write. - -```bash -# Print the metrics + blind spots. -PGPASS=... Rscript local/proposal-tracking.R --json metrics.json -# Post/update a "needs signatures" tracking issue with the unclassified failures. -PGPASS=... FORGEJO_TOKEN=... Rscript local/proposal-tracking.R --open-issue -``` - -The unclassified groups are the natural place to discover which new signatures are worth adding to `build_signatures()`. -The pure metric/ledger helpers live in `local/proposal-tracking-lib.R` and are covered by `local/tests/test-proposal-tracking-lib.R`. - -### Scheduled run - -`.crow/weekly-patch-proposals.yaml` runs both steps weekly (register the `weekly-patch-proposals` cron in the crow UI). -It posts/updates two Forgejo issues -- one with the auto-proposable entries, one with the unclassified/blocked failures -- and logs the feedback-loop metrics. -It clones read-only; the only writes are the two tracking issues. diff --git a/local/patches/RcppParallel/force-bundled-tbb-6.0.0.patch b/local/patches/RcppParallel/force-bundled-tbb-6.0.0.patch deleted file mode 100644 index a7f91dc..0000000 --- a/local/patches/RcppParallel/force-bundled-tbb-6.0.0.patch +++ /dev/null @@ -1,152 +0,0 @@ -diff --git a/R/aaa.R b/R/aaa.R -index 568a2aa..2744059 100644 ---- a/R/aaa.R -+++ b/R/aaa.R -@@ -5,4 +5,21 @@ TBB_LIB <- "" - TBB_INC <- "" - - TBB_NAME <- "tbb" --TBB_MALLOC_NAME <- "tbbmalloc" -\ No newline at end of file -+TBB_MALLOC_NAME <- "tbbmalloc" -+ -+# bincraft patch: build images (ours did until build-env-images c51ed09) and -+# plenty of user environments export TBB_ROOT / TBB_LIB / TBB_INC. A binary we -+# publish always carries its own oneTBB in RcppParallel/lib -- see the -+# companion changes in tools/config/configure.R and src/install.libs.R -- so -+# honouring those variables at run time is actively harmful: .onLoad() would -+# dyn.load() a second, unrelated TBB into the process next to the bundled one -+# (two copies of the same symbols in the global scope, which segfaults R on -+# load), and RcppParallelLibs() / CxxFlags() would hand that system TBB to -+# dependents such as rstan, putting NEEDED libtbb.so.12 back into their -+# binaries. Read the variables only when explicitly opted back in. -+bincraftGetenv <- function(name, unset = "") { -+ if (Sys.getenv("BINCRAFT_ALLOW_SYSTEM_TBB", unset = "FALSE") == "TRUE") -+ Sys.getenv(name, unset = unset) -+ else -+ unset -+} -\ No newline at end of file -diff --git a/R/tbb.R b/R/tbb.R -index 3d8fbb3..9560165 100644 ---- a/R/tbb.R -+++ b/R/tbb.R -@@ -17,7 +17,7 @@ tbbLibraryPath <- function(name = NULL) { - sysname <- Sys.info()[["sysname"]] - - # find root for TBB install -- tbbRoot <- Sys.getenv("TBB_LIB", unset = tbbRoot()) -+ tbbRoot <- bincraftGetenv("TBB_LIB", unset = tbbRoot()) - if (is.null(name)) - return(tbbRoot) - -@@ -60,7 +60,7 @@ tbbCxxFlags <- function() { - flags <- c("-DRCPP_PARALLEL_USE_TBB=1") - - # if TBB_INC is set, apply those library paths -- tbbInc <- Sys.getenv("TBB_INC", unset = TBB_INC) -+ tbbInc <- bincraftGetenv("TBB_INC", unset = TBB_INC) - if (!file.exists(tbbInc)) { - tbbInc <- system.file("include", package = "RcppParallel") - } -@@ -100,7 +100,7 @@ tbbLdFlags <- function() { - } - - # shortcut if TBB_LIB defined -- tbbLib <- Sys.getenv("TBB_LINK_LIB", Sys.getenv("TBB_LIB", unset = TBB_LIB)) -+ tbbLib <- bincraftGetenv("TBB_LINK_LIB", bincraftGetenv("TBB_LIB", unset = TBB_LIB)) - if (nzchar(tbbLib)) { - if (R.version$os == "emscripten") { - fmt <- "-L%1$s -l%2$s" -diff --git a/src/install.libs.R b/src/install.libs.R -index 4dcbac2..57dbc74 100644 ---- a/src/install.libs.R -+++ b/src/install.libs.R -@@ -258,6 +258,18 @@ prependFlags <- function(prependFlags, toFlags) { - tbbLib <- Sys.getenv("TBB_LIB") - tbbInc <- Sys.getenv("TBB_INC") - -+# bincraft patch: the companion change in tools/config/configure.R stops an -+# ambient TBB_LIB / TBB_INC from selecting a system TBB, but this script is -+# also run directly by `R CMD INSTALL` (not only through the `tbb` rule in -+# src/Makevars, which passes the configured values), so at install time it -+# still sees the image's environment and would symlink the system libraries -+# into RcppParallel/lib. Drop them here for the same reason, under the same -+# opt-out. -+if (Sys.getenv("BINCRAFT_ALLOW_SYSTEM_TBB", unset = "FALSE") != "TRUE") { -+ tbbLib <- "" -+ tbbInc <- "" -+} -+ - args <- commandArgs(trailingOnly = TRUE) - if (identical(args, "build")) { - if (nzchar(tbbLib) && nzchar(tbbInc)) { -diff --git a/tools/config/configure.R b/tools/config/configure.R -index a001e63..bfe8c8e 100644 ---- a/tools/config/configure.R -+++ b/tools/config/configure.R -@@ -144,6 +144,24 @@ tbbRoot <- Sys.getenv("TBB_ROOT", unset = NA) - tbbLib <- Sys.getenv("TBB_LIB", unset = NA) - tbbInc <- Sys.getenv("TBB_INC", unset = NA) - -+# bincraft patch: ignore an ambient TBB_ROOT / TBB_LIB / TBB_INC. Our build -+# images exported these until build-env-images c51ed09 (a leftover from -+# RcppParallel 5.x, whose bundled Intel TBB would not build on musl or with -+# modern g++), and any of them switches the branches below to a system TBB. -+# The published binary then records NEEDED libtbb.so.12 (or libtbb.so.2 for -+# the classic Intel TBB) and gets a RcppParallel/lib full of absolute symlinks -+# into the image's library dir, so it cannot dyn.load on a consumer machine -+# without that exact TBB. 6.x bundles oneTBB 2022 and builds it with cmake on -+# every platform we ship, so the bundled copy is always the right choice here; -+# forcing it in the package rather than relying on the image environment keeps -+# the binary correct whichever image version CI happens to pull. Set -+# BINCRAFT_ALLOW_SYSTEM_TBB=TRUE to restore the upstream behaviour. -+if (Sys.getenv("BINCRAFT_ALLOW_SYSTEM_TBB", unset = "FALSE") != "TRUE") { -+ tbbRoot <- NA -+ tbbLib <- NA -+ tbbInc <- NA -+} -+ - tbbName <- Sys.getenv("TBB_NAME", unset = "tbb") - tbbMallocName <- Sys.getenv("TBB_MALLOC_NAME", unset = "tbbmalloc") - -@@ -224,10 +242,21 @@ define( - ) - - # set PKG_LIBS -+# -+# bincraft patch: the library directories below are passed as plain '-L', not -+# '-Wl,-L'. gcc expands its own search dirs (/usr/lib64, /usr/lib/) -+# into explicit '-L' options ahead of anything forwarded verbatim with '-Wl,', -+# so with '-Wl,-L' a system libtbb.so wins over the one named here: on a build -+# host with a distro TBB installed, '-ltbb' resolves to that library and -+# RcppParallel.so records its SONAME (libtbb.so.12, or libtbb.so.2 for the -+# classic Intel TBB) instead of the bundled 'libtbb.so'. The binary then loads -+# the system TBB rather than the copy shipped in RcppParallel/lib, and fails -+# outright on a machine that has no system TBB. gcc places a plain '-L' before -+# its built-in dirs, so the intended library is found first. - pkgLibs <- if (!is.na(tbbLib)) { - - c( -- "-Wl,-L\"$(TBB_LIB)\"", -+ "-L\"$(TBB_LIB)\"", - sprintf("-Wl,-rpath,%s", shQuote(tbbLib)), - "-l$(TBB_NAME)", - "-l$(TBB_MALLOC_NAME)" -@@ -240,14 +269,14 @@ pkgLibs <- if (!is.na(tbbLib)) { - } else if (R.version$os == "emscripten") { - - c( -- "-Wl,-Ltbb/build/lib_release", -+ "-Ltbb/build/lib_release", - "-l$(TBB_NAME)" - ) - - } else { - - c( -- "-Wl,-Ltbb/build/lib_release", -+ "-Ltbb/build/lib_release", - "-l$(TBB_NAME)", - "-l$(TBB_MALLOC_NAME)" - ) diff --git a/local/patches/RcppParallel/force-bundled-tbb-6.1.x.patch b/local/patches/RcppParallel/force-bundled-tbb-6.1.x.patch deleted file mode 100644 index 948643c..0000000 --- a/local/patches/RcppParallel/force-bundled-tbb-6.1.x.patch +++ /dev/null @@ -1,157 +0,0 @@ -diff --git a/R/aaa.R b/R/aaa.R -index 568a2aa..2744059 100644 ---- a/R/aaa.R -+++ b/R/aaa.R -@@ -5,4 +5,21 @@ TBB_LIB <- "" - TBB_INC <- "" - - TBB_NAME <- "tbb" --TBB_MALLOC_NAME <- "tbbmalloc" -\ No newline at end of file -+TBB_MALLOC_NAME <- "tbbmalloc" -+ -+# bincraft patch: build images (ours did until build-env-images c51ed09) and -+# plenty of user environments export TBB_ROOT / TBB_LIB / TBB_INC. A binary we -+# publish always carries its own oneTBB in RcppParallel/lib -- see the -+# companion changes in tools/config/configure.R and src/install.libs.R -- so -+# honouring those variables at run time is actively harmful: .onLoad() would -+# dyn.load() a second, unrelated TBB into the process next to the bundled one -+# (two copies of the same symbols in the global scope, which segfaults R on -+# load), and RcppParallelLibs() / CxxFlags() would hand that system TBB to -+# dependents such as rstan, putting NEEDED libtbb.so.12 back into their -+# binaries. Read the variables only when explicitly opted back in. -+bincraftGetenv <- function(name, unset = "") { -+ if (Sys.getenv("BINCRAFT_ALLOW_SYSTEM_TBB", unset = "FALSE") == "TRUE") -+ Sys.getenv(name, unset = unset) -+ else -+ unset -+} -\ No newline at end of file -diff --git a/R/tbb.R b/R/tbb.R -index 152fd16..4b06aa5 100644 ---- a/R/tbb.R -+++ b/R/tbb.R -@@ -17,7 +17,7 @@ tbbLibraryPath <- function(name = NULL) { - sysname <- Sys.info()[["sysname"]] - - # find root for TBB install -- tbbRoot <- Sys.getenv("TBB_LIB", unset = tbbRoot()) -+ tbbRoot <- bincraftGetenv("TBB_LIB", unset = tbbRoot()) - if (is.null(name)) - return(tbbRoot) - -@@ -58,7 +58,7 @@ tbbCxxFlags <- function() { - flags <- c("-DRCPP_PARALLEL_USE_TBB=1") - - # if TBB_INC is set, apply those library paths -- tbbInc <- Sys.getenv("TBB_INC", unset = TBB_INC) -+ tbbInc <- bincraftGetenv("TBB_INC", unset = TBB_INC) - if (!file.exists(tbbInc)) { - tbbInc <- system.file("include", package = "RcppParallel") - } -@@ -96,7 +96,7 @@ tbbLdFlags <- function() { - } - - # shortcut if TBB_LIB defined -- tbbLib <- Sys.getenv("TBB_LINK_LIB", Sys.getenv("TBB_LIB", unset = TBB_LIB)) -+ tbbLib <- bincraftGetenv("TBB_LINK_LIB", bincraftGetenv("TBB_LIB", unset = TBB_LIB)) - if (nzchar(tbbLib)) { - if (R.version$os == "emscripten") { - fmt <- "-L%1$s -l%2$s" -diff --git a/src/install.libs.R b/src/install.libs.R -index e770838..1dd2fc7 100644 ---- a/src/install.libs.R -+++ b/src/install.libs.R -@@ -492,6 +492,18 @@ prependFlags <- function(prependFlags, toFlags) { - tbbLib <- Sys.getenv("TBB_LIB") - tbbInc <- Sys.getenv("TBB_INC") - -+# bincraft patch: the companion change in tools/config/configure.R stops an -+# ambient TBB_LIB / TBB_INC from selecting a system TBB, but this script is -+# also run directly by `R CMD INSTALL` (not only through the `tbb` rule in -+# src/Makevars, which passes the configured values), so at install time it -+# still sees the image's environment and would symlink the system libraries -+# into RcppParallel/lib. Drop them here for the same reason, under the same -+# opt-out. -+if (Sys.getenv("BINCRAFT_ALLOW_SYSTEM_TBB", unset = "FALSE") != "TRUE") { -+ tbbLib <- "" -+ tbbInc <- "" -+} -+ - args <- commandArgs(trailingOnly = TRUE) - if (identical(args, "build")) { - if (nzchar(tbbLib) && nzchar(tbbInc)) { -diff --git a/tools/config/configure.R b/tools/config/configure.R -index c3842f9..adf7876 100644 ---- a/tools/config/configure.R -+++ b/tools/config/configure.R -@@ -66,6 +66,24 @@ tbbRoot <- Sys.getenv("TBB_ROOT", unset = NA) - tbbLib <- Sys.getenv("TBB_LIB", unset = NA) - tbbInc <- Sys.getenv("TBB_INC", unset = NA) - -+# bincraft patch: ignore an ambient TBB_ROOT / TBB_LIB / TBB_INC. Our build -+# images exported these until build-env-images c51ed09 (a leftover from -+# RcppParallel 5.x, whose bundled Intel TBB would not build on musl or with -+# modern g++), and any of them switches the branches below to a system TBB. -+# The published binary then records NEEDED libtbb.so.12 (or libtbb.so.2 for -+# the classic Intel TBB) and gets a RcppParallel/lib full of absolute symlinks -+# into the image's library dir, so it cannot dyn.load on a consumer machine -+# without that exact TBB. 6.x bundles oneTBB 2022 and builds it with cmake on -+# every platform we ship, so the bundled copy is always the right choice here; -+# forcing it in the package rather than relying on the image environment keeps -+# the binary correct whichever image version CI happens to pull. Set -+# BINCRAFT_ALLOW_SYSTEM_TBB=TRUE to restore the upstream behaviour. -+if (Sys.getenv("BINCRAFT_ALLOW_SYSTEM_TBB", unset = "FALSE") != "TRUE") { -+ tbbRoot <- NA -+ tbbLib <- NA -+ tbbInc <- NA -+} -+ - tbbName <- Sys.getenv("TBB_NAME", unset = "tbb") - tbbMallocName <- Sys.getenv("TBB_MALLOC_NAME", unset = "tbbmalloc") - -@@ -146,6 +164,18 @@ define( - ) - - # set PKG_LIBS -+# -+# bincraft patch: the non-Windows library directories below are passed as -+# plain '-L', not '-Wl,-L'. gcc expands its own search dirs (/usr/lib64, -+# /usr/lib/) into explicit '-L' options ahead of anything forwarded -+# verbatim with '-Wl,', so with '-Wl,-L' a system libtbb.so wins over the one -+# named here: on a build host with a distro TBB installed, '-ltbb' resolves to -+# that library and RcppParallel.so records its SONAME (libtbb.so.12, or -+# libtbb.so.2 for the classic Intel TBB) instead of the bundled 'libtbb.so'. -+# The binary then loads the system TBB rather than the copy shipped in -+# RcppParallel/lib, and fails outright on a machine that has no system TBB. -+# gcc places a plain '-L' before its built-in dirs, so the intended library is -+# found first. - pkgLibs <- if (.Platform$OS.type == "windows") { - - if (!is.na(tbbLib) && file.exists(file.path(tbbInc, "oneapi"))) { -@@ -183,7 +213,7 @@ pkgLibs <- if (.Platform$OS.type == "windows") { - } else if (!is.na(tbbLib)) { - - c( -- "-Wl,-L\"$(TBB_LIB)\"", -+ "-L\"$(TBB_LIB)\"", - sprintf("-Wl,-rpath,%s", shQuote(tbbLib)), - "-l$(TBB_NAME)", - "-l$(TBB_MALLOC_NAME)" -@@ -192,14 +222,14 @@ pkgLibs <- if (.Platform$OS.type == "windows") { - } else if (R.version$os == "emscripten") { - - c( -- "-Wl,-Ltbb/build/lib_release", -+ "-Ltbb/build/lib_release", - "-l$(TBB_NAME)" - ) - - } else { - - c( -- "-Wl,-Ltbb/build/lib_release", -+ "-Ltbb/build/lib_release", - "-l$(TBB_NAME)", - "-l$(TBB_MALLOC_NAME)" - ) diff --git a/local/patches/RcppParallel/force-bundled-tbb-6.2.x.patch b/local/patches/RcppParallel/force-bundled-tbb-6.2.x.patch deleted file mode 100644 index d88cfc5..0000000 --- a/local/patches/RcppParallel/force-bundled-tbb-6.2.x.patch +++ /dev/null @@ -1,142 +0,0 @@ -diff --git a/R/aaa.R b/R/aaa.R -index 568a2aa..2744059 100644 ---- a/R/aaa.R -+++ b/R/aaa.R -@@ -5,4 +5,21 @@ TBB_LIB <- "" - TBB_INC <- "" - - TBB_NAME <- "tbb" --TBB_MALLOC_NAME <- "tbbmalloc" -\ No newline at end of file -+TBB_MALLOC_NAME <- "tbbmalloc" -+ -+# bincraft patch: build images (ours did until build-env-images c51ed09) and -+# plenty of user environments export TBB_ROOT / TBB_LIB / TBB_INC. A binary we -+# publish always carries its own oneTBB in RcppParallel/lib -- see the -+# companion changes in tools/config/configure.R and src/install.libs.R -- so -+# honouring those variables at run time is actively harmful: .onLoad() would -+# dyn.load() a second, unrelated TBB into the process next to the bundled one -+# (two copies of the same symbols in the global scope, which segfaults R on -+# load), and RcppParallelLibs() / CxxFlags() would hand that system TBB to -+# dependents such as rstan, putting NEEDED libtbb.so.12 back into their -+# binaries. Read the variables only when explicitly opted back in. -+bincraftGetenv <- function(name, unset = "") { -+ if (Sys.getenv("BINCRAFT_ALLOW_SYSTEM_TBB", unset = "FALSE") == "TRUE") -+ Sys.getenv(name, unset = unset) -+ else -+ unset -+} -\ No newline at end of file -diff --git a/R/tbb.R b/R/tbb.R -index b071833..e3bf7a5 100644 ---- a/R/tbb.R -+++ b/R/tbb.R -@@ -19,3 +19,3 @@ tbbLibraryPath <- function(name = NULL) { - # find root for TBB install -- tbbRoot <- Sys.getenv("TBB_LIB", unset = tbbRoot()) -+ tbbRoot <- bincraftGetenv("TBB_LIB", unset = tbbRoot()) - if (is.null(name)) -@@ -63,3 +63,3 @@ tbbCxxFlags <- function() { - # if TBB_INC is set, apply those library paths -- tbbInc <- Sys.getenv("TBB_INC", unset = TBB_INC) -+ tbbInc <- bincraftGetenv("TBB_INC", unset = TBB_INC) - if (!file.exists(tbbInc)) { -@@ -122,3 +122,3 @@ tbbLdFlags <- function() { - # shortcut if TBB_LIB defined -- tbbLib <- Sys.getenv("TBB_LINK_LIB", Sys.getenv("TBB_LIB", unset = TBB_LIB)) -+ tbbLib <- bincraftGetenv("TBB_LINK_LIB", bincraftGetenv("TBB_LIB", unset = TBB_LIB)) - if (nzchar(tbbLib)) { -diff --git a/src/install.libs.R b/src/install.libs.R -index 3b3cfda..c0e6f3e 100644 ---- a/src/install.libs.R -+++ b/src/install.libs.R -@@ -477,6 +477,18 @@ prependFlags <- function(prependFlags, toFlags) { - tbbLib <- Sys.getenv("TBB_LIB") - tbbInc <- Sys.getenv("TBB_INC") - -+# bincraft patch: the companion change in tools/config/configure.R stops an -+# ambient TBB_LIB / TBB_INC from selecting a system TBB, but this script is -+# also run directly by `R CMD INSTALL` (not only through the `tbb` rule in -+# src/Makevars, which passes the configured values), so at install time it -+# still sees the image's environment and would symlink the system libraries -+# into RcppParallel/lib. Drop them here for the same reason, under the same -+# opt-out. -+if (Sys.getenv("BINCRAFT_ALLOW_SYSTEM_TBB", unset = "FALSE") != "TRUE") { -+ tbbLib <- "" -+ tbbInc <- "" -+} -+ - args <- commandArgs(trailingOnly = TRUE) - if (identical(args, "build")) { - if (nzchar(tbbLib) && nzchar(tbbInc)) { -diff --git a/tools/config/configure.R b/tools/config/configure.R -index c203a1f..0050b5c 100644 ---- a/tools/config/configure.R -+++ b/tools/config/configure.R -@@ -79,6 +79,24 @@ tbbRoot <- Sys.getenv("TBB_ROOT", unset = NA) - tbbLib <- Sys.getenv("TBB_LIB", unset = NA) - tbbInc <- Sys.getenv("TBB_INC", unset = NA) - -+# bincraft patch: ignore an ambient TBB_ROOT / TBB_LIB / TBB_INC. Our build -+# images exported these until build-env-images c51ed09 (a leftover from -+# RcppParallel 5.x, whose bundled Intel TBB would not build on musl or with -+# modern g++), and any of them switches the branches below to a system TBB. -+# The published binary then records NEEDED libtbb.so.12 (or libtbb.so.2 for -+# the classic Intel TBB) and gets a RcppParallel/lib full of absolute symlinks -+# into the image's library dir, so it cannot dyn.load on a consumer machine -+# without that exact TBB. 6.x bundles oneTBB 2022 and builds it with cmake on -+# every platform we ship, so the bundled copy is always the right choice here; -+# forcing it in the package rather than relying on the image environment keeps -+# the binary correct whichever image version CI happens to pull. Set -+# BINCRAFT_ALLOW_SYSTEM_TBB=TRUE to restore the upstream behaviour. -+if (Sys.getenv("BINCRAFT_ALLOW_SYSTEM_TBB", unset = "FALSE") != "TRUE") { -+ tbbRoot <- NA -+ tbbLib <- NA -+ tbbInc <- NA -+} -+ - tbbName <- Sys.getenv("TBB_NAME", unset = "tbb") - tbbMallocName <- Sys.getenv("TBB_MALLOC_NAME", unset = "tbbmalloc") - -@@ -225,12 +243,23 @@ define( - ) - - # set PKG_LIBS -+# -+# bincraft patch: the library directories below are passed as plain '-L', not -+# '-Wl,-L'. gcc expands its own search dirs (/usr/lib64, /usr/lib/) -+# into explicit '-L' options ahead of anything forwarded verbatim with '-Wl,', -+# so with '-Wl,-L' a system libtbb.so wins over the one named here: on a build -+# host with a distro TBB installed, '-ltbb' resolves to that library and -+# RcppParallel.so records its SONAME (libtbb.so.12, or libtbb.so.2 for the -+# classic Intel TBB) instead of the bundled 'libtbb.so'. The binary then loads -+# the system TBB rather than the copy shipped in RcppParallel/lib, and fails -+# outright on a machine that has no system TBB. gcc places a plain '-L' before -+# its built-in dirs, so the intended library is found first. - pkgLibs <- if (!is.na(tbbLib)) { - - # a TBB supplied via TBB_LIB / TBB_ROOT. an rpath is meaningless on Windows, - # where the loader has no equivalent -- see R/zzz.R for how we resolve there - c( -- "-Wl,-L\"$(TBB_LIB)\"", -+ "-L\"$(TBB_LIB)\"", - if (.Platform$OS.type != "windows") - sprintf("-Wl,-rpath,%s", shQuote(tbbLib)), - "-l$(TBB_NAME)", -@@ -240,14 +269,14 @@ pkgLibs <- if (!is.na(tbbLib)) { - } else if (R.version$os == "emscripten") { - - c( -- "-Wl,-Ltbb/build/lib_release", -+ "-Ltbb/build/lib_release", - "-l$(TBB_NAME)" - ) - - } else { - - c( -- "-Wl,-Ltbb/build/lib_release", -+ "-Ltbb/build/lib_release", - "-l$(TBB_NAME)", - "-l$(TBB_MALLOC_NAME)" - ) diff --git a/local/patches/fs/force-vendored-libuv.patch b/local/patches/fs/force-vendored-libuv.patch deleted file mode 100644 index c69e8b9..0000000 --- a/local/patches/fs/force-vendored-libuv.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff --git a/configure b/configure ---- a/configure -+++ b/configure -@@ -11,6 +11,15 @@ - PKG_TEST_HEADER="" - PKG_LIBS="-luv" - -+# bincraft patch: force the vendored static libuv so the resulting binary -+# is self-contained. fs configure otherwise links system libuv whenever -+# pkg-config finds libuv-devel (installed as a build-time sysreq), yielding -+# an fs.so with NEEDED libuv.so.1 that fails to dyn.load on machines lacking -+# runtime libuv (install.packages/renv do not install SystemRequirements). -+echo "Building static libuv (bincraft: forced vendored)" 1>&2 -+cp -f src/Makevars.vendor src/Makevars -+exit 0 -+ - # Use pkg-config if available - if [ `command -v pkg-config` ]; then - PKGCONFIG_CFLAGS=`pkg-config --cflags --silence-errors ${PKG_CONFIG_NAME}` diff --git a/local/patches/registry.json b/local/patches/registry.json deleted file mode 100644 index 1f341b7..0000000 --- a/local/patches/registry.json +++ /dev/null @@ -1,62 +0,0 @@ -[ - { - "package": "RcppParallel", - "versions": "6.2.1", - "platforms": ["*"], - "env": {}, - "configure_args": [], - "makevars": {}, - "patch": "RcppParallel/force-bundled-tbb-6.2.x.patch", - "reason": "RcppParallel 6.x builds its bundled oneTBB 2022 with cmake, but tools/config/configure.R passes the library dir as '-Wl,-L...', and gcc places its own search dirs (/usr/lib64, /usr/lib/) ahead of anything forwarded with '-Wl,'. Every build image installs a distro libtbb, so '-ltbb' resolves to it: the binary records NEEDED libtbb.so.12 (libtbb.so.2 on el8/el9) instead of the bundled libtbb.so and cannot load on a machine without that exact system TBB. The patch passes a plain '-L' so the bundled build dir wins. As a safeguard it also makes configure.R, src/install.libs.R and R/tbb.R ignore an ambient TBB_ROOT/TBB_LIB/TBB_INC (opt out with BINCRAFT_ALLOW_SYSTEM_TBB=TRUE): the build images stopped exporting them in build-env-images c51ed09, but a stale image or ~/.Renviron would otherwise switch the build back to the system TBB, and R reads ~/.Renviron after the process environment, so no pipeline env can override it. The read sites move between releases, so each entry pins a patch generated against that version. Upstream still uses '-Wl,-L' in 6.2.1; drop these entries once a release passes a plain '-L'." - }, - { - "package": "RcppParallel", - "versions": "6.2.0", - "platforms": ["*"], - "env": {}, - "configure_args": [], - "makevars": {}, - "patch": "RcppParallel/force-bundled-tbb-6.2.x.patch", - "reason": "RcppParallel 6.x builds its bundled oneTBB 2022 with cmake, but tools/config/configure.R passes the library dir as '-Wl,-L...', and gcc places its own search dirs (/usr/lib64, /usr/lib/) ahead of anything forwarded with '-Wl,'. Every build image installs a distro libtbb, so '-ltbb' resolves to it: the binary records NEEDED libtbb.so.12 (libtbb.so.2 on el8/el9) instead of the bundled libtbb.so and cannot load on a machine without that exact system TBB. The patch passes a plain '-L' so the bundled build dir wins. As a safeguard it also makes configure.R, src/install.libs.R and R/tbb.R ignore an ambient TBB_ROOT/TBB_LIB/TBB_INC (opt out with BINCRAFT_ALLOW_SYSTEM_TBB=TRUE): the build images stopped exporting them in build-env-images c51ed09, but a stale image or ~/.Renviron would otherwise switch the build back to the system TBB, and R reads ~/.Renviron after the process environment, so no pipeline env can override it. The read sites move between releases, so each entry pins a patch generated against that version. Upstream still uses '-Wl,-L' in 6.2.1; drop these entries once a release passes a plain '-L'." - }, - { - "package": "RcppParallel", - "versions": "6.1.1", - "platforms": ["*"], - "env": {}, - "configure_args": [], - "makevars": {}, - "patch": "RcppParallel/force-bundled-tbb-6.1.x.patch", - "reason": "RcppParallel 6.x builds its bundled oneTBB 2022 with cmake, but tools/config/configure.R passes the library dir as '-Wl,-L...', and gcc places its own search dirs (/usr/lib64, /usr/lib/) ahead of anything forwarded with '-Wl,'. Every build image installs a distro libtbb, so '-ltbb' resolves to it: the binary records NEEDED libtbb.so.12 (libtbb.so.2 on el8/el9) instead of the bundled libtbb.so and cannot load on a machine without that exact system TBB. The patch passes a plain '-L' so the bundled build dir wins. As a safeguard it also makes configure.R, src/install.libs.R and R/tbb.R ignore an ambient TBB_ROOT/TBB_LIB/TBB_INC (opt out with BINCRAFT_ALLOW_SYSTEM_TBB=TRUE): the build images stopped exporting them in build-env-images c51ed09, but a stale image or ~/.Renviron would otherwise switch the build back to the system TBB, and R reads ~/.Renviron after the process environment, so no pipeline env can override it. The read sites move between releases, so each entry pins a patch generated against that version. Upstream still uses '-Wl,-L' in 6.2.1; drop these entries once a release passes a plain '-L'." - }, - { - "package": "RcppParallel", - "versions": "6.1.0", - "platforms": ["*"], - "env": {}, - "configure_args": [], - "makevars": {}, - "patch": "RcppParallel/force-bundled-tbb-6.1.x.patch", - "reason": "RcppParallel 6.x builds its bundled oneTBB 2022 with cmake, but tools/config/configure.R passes the library dir as '-Wl,-L...', and gcc places its own search dirs (/usr/lib64, /usr/lib/) ahead of anything forwarded with '-Wl,'. Every build image installs a distro libtbb, so '-ltbb' resolves to it: the binary records NEEDED libtbb.so.12 (libtbb.so.2 on el8/el9) instead of the bundled libtbb.so and cannot load on a machine without that exact system TBB. The patch passes a plain '-L' so the bundled build dir wins. As a safeguard it also makes configure.R, src/install.libs.R and R/tbb.R ignore an ambient TBB_ROOT/TBB_LIB/TBB_INC (opt out with BINCRAFT_ALLOW_SYSTEM_TBB=TRUE): the build images stopped exporting them in build-env-images c51ed09, but a stale image or ~/.Renviron would otherwise switch the build back to the system TBB, and R reads ~/.Renviron after the process environment, so no pipeline env can override it. The read sites move between releases, so each entry pins a patch generated against that version. Upstream still uses '-Wl,-L' in 6.2.1; drop these entries once a release passes a plain '-L'." - }, - { - "package": "RcppParallel", - "versions": "6.0.0", - "platforms": ["*"], - "env": {}, - "configure_args": [], - "makevars": {}, - "patch": "RcppParallel/force-bundled-tbb-6.0.0.patch", - "reason": "RcppParallel 6.x builds its bundled oneTBB 2022 with cmake, but tools/config/configure.R passes the library dir as '-Wl,-L...', and gcc places its own search dirs (/usr/lib64, /usr/lib/) ahead of anything forwarded with '-Wl,'. Every build image installs a distro libtbb, so '-ltbb' resolves to it: the binary records NEEDED libtbb.so.12 (libtbb.so.2 on el8/el9) instead of the bundled libtbb.so and cannot load on a machine without that exact system TBB. The patch passes a plain '-L' so the bundled build dir wins. As a safeguard it also makes configure.R, src/install.libs.R and R/tbb.R ignore an ambient TBB_ROOT/TBB_LIB/TBB_INC (opt out with BINCRAFT_ALLOW_SYSTEM_TBB=TRUE): the build images stopped exporting them in build-env-images c51ed09, but a stale image or ~/.Renviron would otherwise switch the build back to the system TBB, and R reads ~/.Renviron after the process environment, so no pipeline env can override it. The read sites move between releases, so each entry pins a patch generated against that version. Upstream still uses '-Wl,-L' in 6.2.1; drop these entries once a release passes a plain '-L'." - }, - { - "package": "fs", - "versions": "*", - "platforms": ["*"], - "env": {}, - "configure_args": [], - "makevars": {}, - "patch": "fs/force-vendored-libuv.patch", - "reason": "fs 2.x configure links system libuv whenever pkg-config finds libuv-devel (installed as a build-time sysreq), producing an fs.so with NEEDED libuv.so.1. That binary fails to dyn.load on consumer machines lacking runtime libuv, because install.packages/renv do not install SystemRequirements (only pak does, and only in the build container). The patch short-circuits configure to copy src/Makevars.vendor and build the bundled static libuv (needs cmake) so the binary is self-contained on every platform. An env/pkg-config override was tried first but the rebuilt binary still linked libuv.so.1, so a source patch is used instead." - } -] diff --git a/local/proposal-tracking-lib.R b/local/proposal-tracking-lib.R deleted file mode 100644 index 28f65db..0000000 --- a/local/proposal-tracking-lib.R +++ /dev/null @@ -1,230 +0,0 @@ -# Pure, IO-free helpers for the proposal feedback loop (issue #115, step 4): -# a small ledger of what the classifier proposed, plus metrics derived from the -# live triage report and the registry (signature hit rate, proposed-vs-merged, -# retirement candidates). -# -# Kept free of DB/HTTP/clock so it can be sourced by the proposer, the tracker -# entrypoint, and the unit tests. Timestamps are passed in by callers. - -# Split proposal candidates into the ones safe to emit and the ambiguous ones. -# A candidate is a list with at least `package` and `signature`. A package that -# maps to more than one distinct auto-proposable signature is genuinely -# ambiguous (two conflicting fix tiers, e.g. makevars vs source patch): emitting -# both would create colliding registry entries, so those are routed to human -# triage instead of guessed at. Returns list(keep = ..., ambiguous = ...), where -# `ambiguous` is a named list of package -> the distinct signatures seen. -dedupe_candidates <- function(candidates) { - if (length(candidates) == 0L) { - return(list(keep = list(), ambiguous = list())) - } - pkgs <- vapply(candidates, function(c) as.character(c$package), character(1L)) - by_pkg <- split(candidates, pkgs) - keep <- list() - ambiguous <- list() - for (pkg in names(by_pkg)) { - cs <- by_pkg[[pkg]] - sigs <- unique(vapply( - cs, - function(c) as.character(c$signature), - character(1L) - )) - if (length(sigs) == 1L) { - keep[[length(keep) + 1L]] <- cs[[1L]] # one signature -> take the first - } else { - ambiguous[[pkg]] <- sigs - } - } - list(keep = keep, ambiguous = ambiguous) -} - -# Stable identity of a ledger record: one proposal per (package, signature). -ledger_key <- function(record) { - paste0( - if (is.null(record$package)) "?" else record$package, - "|", - if (is.null(record$signature)) "?" else record$signature - ) -} - -# Merge freshly-generated proposals into an existing ledger without clobbering -# history: a record whose (package, signature) already exists is left as-is -# (its status/PR/issue are preserved); genuinely new proposals are appended. -# Returns the combined list. Pure: callers stamp `proposed_at` before passing. -merge_ledger <- function(existing, new_records) { - if (is.null(existing)) { - existing <- list() - } - seen <- vapply(existing, ledger_key, character(1L)) - out <- existing - for (rec in new_records) { - if (!(ledger_key(rec) %in% seen)) { - out[[length(out) + 1L]] <- rec - seen <- c(seen, ledger_key(rec)) - } - } - out -} - -# Per-signature hit rate from a triage report (list of group records from -# build_triage_report) crossed with the set of already-registered packages. -# For each *matched* signature: how many failing builds/packages it explains, -# and how many of those packages are already addressed by a registry entry. -signature_hit_rate <- function(report, registered_pkgs = character(0L)) { - matched <- Filter(function(g) isTRUE(g$matched), report) - by_sig <- split( - matched, - vapply(matched, function(g) g$signature, character(1L)) - ) - lapply(names(by_sig), function(sig) { - grps <- by_sig[[sig]] - pkgs <- unique(unlist(lapply(grps, function(g) g$packages))) - addressed <- intersect(pkgs, registered_pkgs) - list( - signature = sig, - builds = sum(vapply(grps, function(g) g$build_count, integer(1L))), - packages = length(pkgs), - addressed = length(addressed), - open = length(setdiff(pkgs, registered_pkgs)), - auto_proposable = any(vapply( - grps, - function(g) isTRUE(g$auto_proposable), - logical(1L) - )) - ) - }) -} - -# Proposed-vs-merged: a ledger record counts as "merged" once its package -# appears in the registry. Returns per-record status plus a rollup. -proposed_vs_merged <- function(ledger, registered_pkgs = character(0L)) { - if (is.null(ledger)) { - ledger <- list() - } - rows <- lapply(ledger, function(rec) { - merged <- !is.null(rec$package) && rec$package %in% registered_pkgs - list( - package = rec$package, - signature = rec$signature, - status = if (merged) "merged" else (rec$status %||% "proposed"), - merged = merged - ) - }) - list( - records = rows, - total = length(rows), - merged = sum(vapply(rows, function(r) isTRUE(r$merged), logical(1L))) - ) -} - -# Registry entries whose package no longer appears in any current failure are -# retirement candidates: the upstream cause was likely fixed, so the entry can -# be reviewed for removal. `failing_pkgs` is the set of currently-failing -# package names (from the live report). -retirement_candidates <- function(registry_entries, failing_pkgs) { - if (is.null(registry_entries)) { - registry_entries <- list() - } - keep <- Filter( - function(e) !is.null(e$package) && !(e$package %in% failing_pkgs), - registry_entries - ) - vapply(keep, function(e) as.character(e$package), character(1L)) -} - -# Discovery view: the failure groups the classifier could NOT auto-propose, so -# they get the same visibility as proposals. `report` is a build_triage_report -# result. Returns the unclassified groups (unknown signature -> candidates for a -# new signature) ranked by build count, capped to `max_groups`, each with up to -# `max_pkgs` example packages. `dropped_groups`/`packages_truncated` record any -# cap so nothing is silently hidden. -unclassified_summary <- function(report, max_groups = 30L, max_pkgs = 15L) { - un <- Filter(function(g) !isTRUE(g$matched), report) - un <- un[order(-vapply(un, function(g) g$build_count, integer(1L)))] - shown <- utils::head(un, max_groups) - groups <- lapply(shown, function(g) { - pkgs <- g$packages - list( - fingerprint = g$fingerprint, - build_count = g$build_count, - n_packages = length(pkgs), - packages = utils::head(pkgs, max_pkgs), - packages_truncated = length(pkgs) > max_pkgs, - platforms = g$platforms - ) - }) - list( - groups = groups, - total_groups = length(un), - dropped_groups = max(0L, length(un) - length(shown)), - total_builds = sum(vapply(un, function(g) g$build_count, integer(1L))) - ) -} - -# Aggregate blocked packages across ALL groups by the dependency they wait on, -# so one dependency (RcppParallel, rstan, sf, ...) is a single line -- deduped -# and ranked by how many distinct dependents it blocks -- instead of repeating -# once per fingerprint group. Reads each group's `blocked_map` (package -> the -# dependency it is blocked on). Returns records sorted by dependent count desc, -# each with up to `max_pkgs` example dependents. -blocked_by_dependency <- function(report, max_pkgs = 15L) { - acc <- list() # dependency -> character vector of dependent packages - for (g in report) { - bm <- g$blocked_map - if (is.null(bm) || length(bm) == 0L) { - next - } - for (pkg in names(bm)) { - for (dep in as.character(unlist(bm[[pkg]]))) { - acc[[dep]] <- unique(c(acc[[dep]], pkg)) - } - } - } - if (length(acc) == 0L) { - return(list()) - } - out <- lapply(names(acc), function(dep) { - pkgs <- acc[[dep]] - list( - dependency = dep, - n_packages = length(pkgs), - packages = utils::head(pkgs, max_pkgs), - packages_truncated = length(pkgs) > max_pkgs - ) - }) - out[order(-vapply(out, function(x) x$n_packages, integer(1L)))] -} - -# Does a registry entry's `platforms` apply to a build on `os` (e.g. -# "ubuntu-2604")? Mirrors bincraft's token match: an entry applies if any of its -# platform tokens is "*", the OS codename, or the distro family ("ubuntu"). -entry_applies_to_os <- function(entry_platforms, os) { - toks <- as.character(unlist(entry_platforms)) - family <- sub("-.*$", "", os) # ubuntu-2604 -> ubuntu - any(toks %in% c("*", os, family)) -} - -# Registry entries present in `current` but not in `base` (matched on -# package|platforms|versions), optionally restricted to those that apply to a -# given `os`. Used by the trial-build gate to build only the entries a PR adds. -new_registry_packages <- function(current, base, os = NULL) { - key <- function(e) { - sprintf( - "%s|%s|%s", - e$package %||% "?", - paste(sort(as.character(unlist(e$platforms))), collapse = ","), - e$versions %||% "?" - ) - } - base_keys <- vapply(base %||% list(), key, character(1L)) - added <- Filter(function(e) !(key(e) %in% base_keys), current %||% list()) - if (!is.null(os)) { - added <- Filter(function(e) entry_applies_to_os(e$platforms, os), added) - } - unique(vapply( - added, - function(e) as.character(e$package %||% ""), - character(1L) - )) -} - -`%||%` <- function(a, b) if (is.null(a)) b else a diff --git a/local/proposal-tracking.R b/local/proposal-tracking.R deleted file mode 100644 index 82d0beb..0000000 --- a/local/proposal-tracking.R +++ /dev/null @@ -1,305 +0,0 @@ -#!/usr/bin/env Rscript - -# Feedback loop for the failure classifier (issue #115, step 4): report the -# signature hit rate, proposed-vs-merged status, registry entries that look -# retirable, and -- so the classifier's blind spots get the same visibility as -# its proposals -- the failures it could NOT classify (candidates for new -# signatures) plus the groups blocked on a dependency build. -# Read-only on the DB/registry; the only optional write is the Forgejo issue. -# -# Usage: -# PGPASS=... Rscript local/proposal-tracking.R [--json PATH] [--open-issue] -# --open-issue post/update a Forgejo issue listing the unclassified and -# dependency-blocked failures (needs FORGEJO_TOKEN) - -options(error = function() { - cat("ERROR:", geterrmessage(), "\n", file = stdout()) - q(status = 1) -}) - -suppressPackageStartupMessages({ - library(DBI, quietly = TRUE) - library(RPostgres, quietly = TRUE) - library(jsonlite, quietly = TRUE) -}) - -script_path <- local({ - a <- commandArgs(trailingOnly = FALSE) - f <- sub("^--file=", "", a[grepl("^--file=", a)]) - if (length(f) == 1L && nzchar(f)) normalizePath(f) else NA_character_ -}) -script_dir <- if (is.na(script_path)) "local" else dirname(script_path) -source(file.path(script_dir, "failing-builds-classify.R")) -source(file.path(script_dir, "proposal-tracking-lib.R")) - -args <- commandArgs(trailingOnly = TRUE) -json_out <- local({ - i <- match("--json", args) - if (!is.na(i) && i < length(args)) args[[i + 1L]] else NA_character_ -}) -do_issue <- "--open-issue" %in% args - -if (nchar(Sys.getenv("PGPASS")) == 0L) { - stop("PGPASS env var is not set; a DB password is required.") -} - -registry_file <- file.path(script_dir, "patches", "registry.json") -ledger_file <- file.path(script_dir, "patches", "proposals-log.json") - -con <- DBI::dbConnect( - RPostgres::Postgres(), - dbname = "build_metadata", - host = "r-binaries.devxy.io", - port = 15432, - user = "rpkgs", - password = Sys.getenv("PGPASS"), - sslmode = "verify-full", - sslrootcert = bincraft::postgres_sslrootcert("verify-full") -) -on.exit(DBI::dbDisconnect(con), add = TRUE) - -failures <- DBI::dbGetQuery( - con, - paste0( - "SELECT name, tag, platform, arch, r_version, timestamp, error_text ", - "FROM single_builds WHERE error_occurred = TRUE AND removed = FALSE" - ) -) - -existing_entries <- if (file.exists(registry_file)) { - jsonlite::fromJSON(registry_file, simplifyVector = FALSE) -} else { - list() -} -registered_pkgs <- unique(vapply( - existing_entries, - function(e) as.character(e$package %||% ""), - character(1L) -)) -ledger <- if (file.exists(ledger_file)) { - jsonlite::fromJSON(ledger_file, simplifyVector = FALSE) -} else { - list() -} - -report <- build_triage_report(failures, registered_pkgs) -failing_pkgs <- unique(unlist(lapply(report, function(g) g$packages))) - -hit <- signature_hit_rate(report, registered_pkgs) -pvm <- proposed_vs_merged(ledger, registered_pkgs) -retire <- retirement_candidates(existing_entries, failing_pkgs) - -cat(sprintf( - "Feedback loop over %d failing builds, %d registry entries, %d ledger records.\n", - nrow(failures), - length(existing_entries), - length(ledger) -)) - -cat("\nSignature hit rate:\n") -cat(strrep("-", 60L), "\n", sep = "") -for (h in hit) { - cat(sprintf( - " %-26s %3d builds | %2d pkgs | %2d addressed | %2d open%s\n", - h$signature, - h$builds, - h$packages, - h$addressed, - h$open, - if (isTRUE(h$auto_proposable)) " [auto]" else "" - )) -} - -cat(sprintf("\nProposed vs merged: %d / %d merged.\n", pvm$merged, pvm$total)) -for (r in pvm$records) { - cat(sprintf(" %-24s %-26s %s\n", r$package, r$signature, r$status)) -} - -cat(sprintf( - "\nRetirement candidates (%d): registry entries with no current failure.\n", - length(retire) -)) -if (length(retire) > 0L) { - cat(paste0(" - ", retire, "\n"), sep = "") -} else { - cat(" (none)\n") -} - -# --------------------------------------------------------------------------- -# Blind spots: failures the classifier could not auto-propose. -# --------------------------------------------------------------------------- -blocked <- blocked_by_dependency(report) -unmatched <- unclassified_summary(report) - -cat("\nBlocked on a dependency (fix the dependency, not each dependent):\n") -if (length(blocked) > 0L) { - for (b in blocked) { - cat(sprintf(" %-20s %5d dependent(s)\n", b$dependency, b$n_packages)) - } -} else { - cat(" (none)\n") -} - -cat(sprintf( - "\nUnclassified failures (candidates for new signatures): %d group(s), %d builds.\n", - unmatched$total_groups, - unmatched$total_builds -)) -cat(strrep("-", 60L), "\n", sep = "") -for (g in unmatched$groups) { - cat(sprintf( - " [%d builds | %d pkgs] %s\n e.g. %s%s\n", - g$build_count, - g$n_packages, - g$fingerprint, - toString(g$packages), - if (isTRUE(g$packages_truncated)) ", ..." else "" - )) -} -if (unmatched$dropped_groups > 0L) { - cat(sprintf( - " (+%d more unclassified group(s) not shown)\n", - unmatched$dropped_groups - )) -} - -if (!is.na(json_out)) { - jsonlite::write_json( - list( - signature_hit_rate = hit, - proposed_vs_merged = pvm, - retirement_candidates = retire, - blocked = blocked, - unclassified = unmatched - ), - json_out, - auto_unbox = TRUE, - pretty = TRUE, - null = "null" - ) - cat(sprintf("\nWrote metrics to %s\n", json_out)) -} - -# --------------------------------------------------------------------------- -# Optionally publish the blind-spots to a Forgejo tracking issue. -# --------------------------------------------------------------------------- -if (do_issue) { - forgejo_token <- Sys.getenv("FORGEJO_TOKEN") - if (nchar(forgejo_token) == 0L) { - stop("--open-issue requires FORGEJO_TOKEN.") - } - suppressPackageStartupMessages(library(httr2, quietly = TRUE)) - forgejo_base <- "https://git.devxy.io/api/v1" - repo <- "devxy/build-cran-binaries" - issue_title <- "Unclassified build failures (needs signatures) (#115)" - now <- format(Sys.time(), "%Y-%m-%d %H:%M:%S") - - body_lines <- c( - sprintf("_Generated %s from `single_builds` failures._", now), - "", - "Failures the classifier could **not** auto-propose a fix for.", - "Each unclassified group is a candidate for a new signature in `local/failing-builds-classify.R`; the blocked groups clear once the named dependency builds.", - "" - ) - - body_lines <- c(body_lines, "## Blocked on a dependency", "") - if (length(blocked) > 0L) { - for (b in blocked) { - body_lines <- c( - body_lines, - sprintf( - "- **%s**: %d dependent(s) (e.g. %s%s)", - b$dependency, - b$n_packages, - toString(b$packages), - if (isTRUE(b$packages_truncated)) ", ..." else "" - ) - ) - } - } else { - body_lines <- c(body_lines, "_None._") - } - - body_lines <- c( - body_lines, - "", - sprintf( - "## Unclassified failures (%d groups, %d builds)", - unmatched$total_groups, - unmatched$total_builds - ), - "" - ) - if (length(unmatched$groups) > 0L) { - for (g in unmatched$groups) { - body_lines <- c( - body_lines, - sprintf( - "### %d builds / %d pkg(s)", - g$build_count, - g$n_packages - ), - "", - sprintf("Fingerprint: `%s`", g$fingerprint), - sprintf( - "Packages: %s%s", - toString(g$packages), - if (isTRUE(g$packages_truncated)) ", ..." else "" - ), - sprintf("Platforms: %s", toString(g$platforms)), - "" - ) - } - if (unmatched$dropped_groups > 0L) { - body_lines <- c( - body_lines, - sprintf("_(+%d more group(s) not shown.)_", unmatched$dropped_groups) - ) - } - } else { - body_lines <- c(body_lines, "_None -- every failure is classified._") - } - new_body <- paste(body_lines, collapse = "\n") - - search_url <- sprintf( - "%s/repos/%s/issues?type=issues&state=open&q=%s&limit=50", - forgejo_base, - repo, - utils::URLencode(issue_title, reserved = TRUE) - ) - existing <- httr2::request(search_url) |> - httr2::req_headers(Authorization = paste("token", forgejo_token)) |> - httr2::req_perform() |> - httr2::resp_body_json(simplifyVector = FALSE) - match_idx <- which(vapply( - existing, - function(x) identical(x$title, issue_title), - logical(1L) - )) - if (length(match_idx) > 0L) { - num <- existing[[match_idx[1]]]$number - httr2::request(sprintf("%s/repos/%s/issues/%d", forgejo_base, repo, num)) |> - httr2::req_headers( - Authorization = paste("token", forgejo_token), - `Content-Type` = "application/json" - ) |> - httr2::req_body_json(list(body = new_body)) |> - httr2::req_method("PATCH") |> - httr2::req_perform() - cat(sprintf("\nUpdated tracking issue #%d.\n", num)) - } else { - created <- httr2::request(sprintf( - "%s/repos/%s/issues", - forgejo_base, - repo - )) |> - httr2::req_headers( - Authorization = paste("token", forgejo_token), - `Content-Type` = "application/json" - ) |> - httr2::req_body_json(list(title = issue_title, body = new_body)) |> - httr2::req_perform() |> - httr2::resp_body_json() - cat(sprintf("\nOpened tracking issue #%d.\n", created$number)) - } -} diff --git a/local/propose-patches.R b/local/propose-patches.R deleted file mode 100644 index 52a62b8..0000000 --- a/local/propose-patches.R +++ /dev/null @@ -1,579 +0,0 @@ -#!/usr/bin/env Rscript - -# Propose registry patches for classified, auto-proposable build failures -# (issue #115, step 3: "propose, do not apply"). Queries `single_builds`, -# classifies failures, and for each *known, safe* fix lever affecting a package -# with no current registry entry, emits a pre-filled `registry.json` entry. -# -# The human gate stays: this never merges. Acceptance before merge is -# 1. `local/validate-patches.R` passes (checked here against a candidate -# registry), and -# 2. an isolated trial build succeeds -- run `local/trial-build-patch.R ` -# (this script prints the exact command per candidate). -# Novel source diffs and unknown signatures are never proposed (they carry -# `auto = FALSE` in the signature table). -# -# Usage: -# PGPASS=... Rscript local/propose-patches.R [--platform P] [--arch A] [--min N] -# [--limit N] -# (default) print candidates + validation, take no action -# --write append candidates to local/patches/registry.json and -# the proposals ledger (commit + open a PR yourself) -# --open-issue post/update a Forgejo tracking issue (needs FORGEJO_TOKEN) -# --open-pr write the entries, push the `auto/registry-patch-proposals` -# branch, and open/update a PR autonomously. Uses -# FORGEJO_TOKEN for both the push and the PR API. The -# `trial-build-registry` pipeline is the merge gate. -# --limit N only act on the top-N candidates by failure volume -# (bounded batch; the rest are picked up on the next run) -# --json PATH also write the machine-readable candidate list to PATH - -options(error = function() { - cat("ERROR:", geterrmessage(), "\n", file = stdout()) - q(status = 1) -}) - -suppressPackageStartupMessages({ - library(DBI, quietly = TRUE) - library(RPostgres, quietly = TRUE) - library(jsonlite, quietly = TRUE) -}) - -script_path <- local({ - a <- commandArgs(trailingOnly = FALSE) - f <- sub("^--file=", "", a[grepl("^--file=", a)]) - if (length(f) == 1L && nzchar(f)) normalizePath(f) else NA_character_ -}) -script_dir <- if (is.na(script_path)) "local" else dirname(script_path) -source(file.path(script_dir, "failing-builds-classify.R")) -source(file.path(script_dir, "proposal-tracking-lib.R")) - -# --------------------------------------------------------------------------- -# Arguments -# --------------------------------------------------------------------------- -args <- commandArgs(trailingOnly = TRUE) -opt_val <- function(flag, default = NA_character_) { - i <- match(flag, args) - if (!is.na(i) && i < length(args)) args[[i + 1L]] else default -} -platform <- opt_val("--platform", Sys.getenv("PLATFORM", "")) -arch <- opt_val("--arch", Sys.getenv("ARCH", "")) -json_out <- opt_val("--json") -min_count <- suppressWarnings(as.integer(opt_val("--min", "1"))) -if (is.na(min_count)) { - min_count <- 1L -} -do_write <- "--write" %in% args -do_issue <- "--open-issue" %in% args -do_pr <- "--open-pr" %in% args -limit <- suppressWarnings(as.integer(opt_val("--limit", NA_character_))) - -if (nchar(Sys.getenv("PGPASS")) == 0L) { - stop("PGPASS env var is not set; a DB password is required.") -} - -registry_file <- file.path(script_dir, "patches", "registry.json") -ledger_file <- file.path(script_dir, "patches", "proposals-log.json") -# Branch the autonomous PR reuses, so re-runs update one PR instead of piling up. -pr_branch <- "auto/registry-patch-proposals" - -# --------------------------------------------------------------------------- -# Query failing builds (same shape as failing-builds-report.R) -# --------------------------------------------------------------------------- -con <- DBI::dbConnect( - RPostgres::Postgres(), - dbname = "build_metadata", - host = "r-binaries.devxy.io", - port = 15432, - user = "rpkgs", - password = Sys.getenv("PGPASS"), - sslmode = "verify-full", - sslrootcert = bincraft::postgres_sslrootcert("verify-full") -) -on.exit(DBI::dbDisconnect(con), add = TRUE) - -where <- "error_occurred = TRUE AND removed = FALSE" -params <- list() -if (nzchar(platform)) { - where <- paste0(where, " AND platform = $", length(params) + 1L) - params <- c(params, platform) -} -if (nzchar(arch)) { - where <- paste0(where, " AND arch = $", length(params) + 1L) - params <- c(params, arch) -} -failures <- DBI::dbGetQuery( - con, - paste0( - "SELECT name, tag, platform, arch, r_version, timestamp, error_text ", - "FROM single_builds WHERE ", - where - ), - params = if (length(params) > 0L) params else NULL -) -cat(sprintf("Queried single_builds: %d failing builds\n", nrow(failures))) - -# --------------------------------------------------------------------------- -# Existing registry + classification -# --------------------------------------------------------------------------- -existing_entries <- if (file.exists(registry_file)) { - jsonlite::fromJSON(registry_file, simplifyVector = FALSE) -} else { - list() -} -registered_pkgs <- unique(vapply( - existing_entries, - function(e) as.character(e$package %||% ""), - character(1L) -)) - -report <- build_triage_report(failures, registered_pkgs) -report <- Filter(function(r) r$build_count >= min_count, report) - -# Flatten auto-proposable groups into candidate records, carrying the group's -# build volume so we can prioritise the highest-impact fixes. -candidates <- list() -for (r in report) { - if (is.null(r$proposed_entries)) { - next - } - for (pkg in names(r$proposed_entries)) { - candidates[[length(candidates) + 1L]] <- list( - package = pkg, - signature = r$signature, - confidence = r$confidence, - tier = r$tier, - build_count = r$build_count, - entry = r$proposed_entries[[pkg]] - ) - } -} - -# Packages blocked on a dependency are reported (aggregated by dependency, -# ranked by impact), not proposed: fixing the named dependency clears the batch. -blocked <- blocked_by_dependency(report) -if (length(blocked) > 0L) { - n_blocked_pkgs <- length(unique(unlist( - lapply(report, function(r) r$blocked_packages) - ))) - cat(sprintf( - "\nBlocked on a dependency (%d dependencies block %d dependents; fix the dependency, not each dependent):\n", - length(blocked), - n_blocked_pkgs - )) - for (b in blocked) { - cat(sprintf(" %-20s %5d dependent(s)\n", b$dependency, b$n_packages)) - } -} - -# A package that maps to more than one auto-proposable signature is ambiguous -# (conflicting fix tiers) and would collide on the same registry key; route it -# to human triage instead of emitting both. -split_candidates <- dedupe_candidates(candidates) -candidates <- split_candidates$keep -if (length(split_candidates$ambiguous) > 0L) { - cat("\nAmbiguous (multiple signatures) -> human triage, not proposed:\n") - for (pkg in names(split_candidates$ambiguous)) { - cat(sprintf( - " %s: %s\n", - pkg, - toString(split_candidates$ambiguous[[pkg]]) - )) - } -} - -if (length(candidates) == 0L) { - cat( - "\nNo auto-proposable candidates (nothing classified, safe, unregistered, and unambiguous).\n" - ) - q(status = 0) -} - -# Prioritise by failure volume, then apply --limit so one run tackles a bounded -# batch (the rest are picked up on the next run). -candidates <- candidates[order( - -vapply(candidates, function(c) c$build_count %||% 0L, integer(1L)) -)] -deferred <- 0L -if (!is.na(limit) && limit >= 0L && length(candidates) > limit) { - deferred <- length(candidates) - limit - candidates <- utils::head(candidates, limit) - cat(sprintf( - "\nLimiting to top %d candidate(s) by failure volume; %d deferred to a later run.\n", - limit, - deferred - )) -} - -cat(sprintf( - "\n%d candidate registry %s:\n", - length(candidates), - if (length(candidates) == 1L) "entry" else "entries" -)) -cat(strrep("=", 78L), "\n", sep = "") -for (c in candidates) { - j <- jsonlite::toJSON( - c$entry, - auto_unbox = TRUE, - pretty = TRUE, - null = "null" - ) - cat(sprintf( - "\n# %s [signature: %s, %s confidence]\n", - c$package, - c$signature, - c$confidence - )) - cat(j, "\n", sep = "") - cat(sprintf( - " acceptance gate: PGPASS=... Rscript local/trial-build-patch.R %s\n", - c$package - )) -} - -# --------------------------------------------------------------------------- -# Validate the candidate set against a temporary merged registry (never -# touches the real registry unless --write succeeds). -# --------------------------------------------------------------------------- -rscript <- file.path(R.home("bin"), "Rscript") -candidate_entries <- lapply(candidates, function(c) c$entry) -merged <- c(existing_entries, candidate_entries) - -validate_registry <- function(entries) { - tmp <- tempfile(fileext = ".json") - on.exit(unlink(tmp), add = TRUE) - jsonlite::write_json( - entries, - tmp, - auto_unbox = TRUE, - pretty = TRUE, - null = "null" - ) - status <- system2( - rscript, - file.path(script_dir, "validate-patches.R"), - env = c( - paste0("PATCH_DIR=", file.path(script_dir, "patches")), - paste0("REGISTRY_FILE=", tmp) - ), - stdout = TRUE, - stderr = TRUE - ) - cat(paste0(" ", status, "\n"), sep = "") - identical(attr(status, "status"), NULL) # NULL status attr == exit 0 -} - -cat("\n", strrep("=", 78L), "\n", sep = "") -cat("Validating candidate registry:\n") -ok <- validate_registry(merged) -if (!ok) { - stop("Candidate registry failed validation; not writing or proposing.") -} - -if (!is.na(json_out)) { - jsonlite::write_json( - candidates, - json_out, - auto_unbox = TRUE, - pretty = TRUE, - null = "null" - ) - cat(sprintf("Wrote candidate list to %s\n", json_out)) -} - -# --------------------------------------------------------------------------- -# Actions (default: none) -# --------------------------------------------------------------------------- -now <- format(Sys.time(), "%Y-%m-%d %H:%M:%S") -new_ledger_records <- lapply(candidates, function(c) { - list( - package = c$package, - signature = c$signature, - tier = c$tier, - confidence = c$confidence, - versions = c$entry$versions, - platforms = as.character(c$entry$platforms), - proposed_at = now, - status = "proposed" - ) -}) -load_ledger <- function() { - if (file.exists(ledger_file)) { - jsonlite::fromJSON(ledger_file, simplifyVector = FALSE) - } else { - list() - } -} -save_ledger <- function(led) { - jsonlite::write_json( - led, - ledger_file, - auto_unbox = TRUE, - pretty = TRUE, - null = "null" - ) -} - -if (do_write) { - jsonlite::write_json( - merged, - registry_file, - auto_unbox = TRUE, - pretty = TRUE, - null = "null" - ) - save_ledger(merge_ledger(load_ledger(), new_ledger_records)) - cat(sprintf( - "\nWrote %d entries to %s and updated %s.\n", - length(candidate_entries), - registry_file, - ledger_file - )) - cat( - "Next: run the acceptance-gate trial build(s), then commit and open a PR.\n" - ) -} else if (do_issue) { - forgejo_token <- Sys.getenv("FORGEJO_TOKEN") - if (nchar(forgejo_token) == 0L) { - stop("--open-issue requires FORGEJO_TOKEN.") - } - suppressPackageStartupMessages(library(httr2, quietly = TRUE)) - forgejo_base <- "https://git.devxy.io/api/v1" - repo <- "devxy/build-cran-binaries" - issue_title <- "Auto-proposed registry patches (classifier #115)" - body_lines <- c( - sprintf("_Generated %s from `single_builds` failures._", now), - "", - "The failure classifier proposes these registry entries for packages with no current entry.", - "Each is a known, safe fix lever; **review, trial-build, and open a PR** -- nothing is applied automatically.", - "" - ) - for (c in candidates) { - j <- jsonlite::toJSON( - c$entry, - auto_unbox = TRUE, - pretty = TRUE, - null = "null" - ) - body_lines <- c( - body_lines, - sprintf( - "### %s (%s, %s confidence)", - c$package, - c$signature, - c$confidence - ), - "", - "```json", - as.character(j), - "```", - sprintf( - "Acceptance gate: `PGPASS=... Rscript local/trial-build-patch.R %s`", - c$package - ), - "" - ) - } - new_body <- paste(body_lines, collapse = "\n") - - search_url <- sprintf( - "%s/repos/%s/issues?type=issues&state=open&q=%s&limit=50", - forgejo_base, - repo, - utils::URLencode(issue_title, reserved = TRUE) - ) - existing <- httr2::request(search_url) |> - httr2::req_headers(Authorization = paste("token", forgejo_token)) |> - httr2::req_perform() |> - httr2::resp_body_json(simplifyVector = FALSE) - match_idx <- which(vapply( - existing, - function(x) identical(x$title, issue_title), - logical(1L) - )) - if (length(match_idx) > 0L) { - num <- existing[[match_idx[1]]]$number - httr2::request(sprintf("%s/repos/%s/issues/%d", forgejo_base, repo, num)) |> - httr2::req_headers( - Authorization = paste("token", forgejo_token), - `Content-Type` = "application/json" - ) |> - httr2::req_body_json(list(body = new_body)) |> - httr2::req_method("PATCH") |> - httr2::req_perform() - cat(sprintf("Updated tracking issue #%d.\n", num)) - } else { - created <- httr2::request(sprintf( - "%s/repos/%s/issues", - forgejo_base, - repo - )) |> - httr2::req_headers( - Authorization = paste("token", forgejo_token), - `Content-Type` = "application/json" - ) |> - httr2::req_body_json(list(title = issue_title, body = new_body)) |> - httr2::req_perform() |> - httr2::resp_body_json() - cat(sprintf("Opened tracking issue #%d.\n", created$number)) - } - save_ledger(merge_ledger(load_ledger(), new_ledger_records)) -} else if (do_pr) { - forgejo_token <- Sys.getenv("FORGEJO_TOKEN") - if (nchar(forgejo_token) == 0L) { - stop("--open-pr requires FORGEJO_TOKEN (to open the PR).") - } - suppressPackageStartupMessages(library(httr2, quietly = TRUE)) - forgejo_base <- "https://git.devxy.io/api/v1" - repo <- "devxy/build-cran-binaries" - - # Write the entries + ledger, then commit them onto the reused auto branch. - jsonlite::write_json( - merged, - registry_file, - auto_unbox = TRUE, - pretty = TRUE, - null = "null" - ) - save_ledger(merge_ledger(load_ledger(), new_ledger_records)) - - git <- function(...) { - # system2() with captured output runs via /bin/sh, so shell-quote every arg - # (commit messages contain "()", refs contain "^{}", etc.). - st <- system2("git", shQuote(c(...)), stdout = TRUE, stderr = TRUE) - if (!identical(attr(st, "status"), NULL)) { - stop(sprintf( - "git %s failed:\n%s", - paste(..., collapse = " "), - paste(st, collapse = "\n") - )) - } - invisible(st) - } - git("config", "user.name", Sys.getenv("GIT_USER", "devxy-bot")) - git( - "config", - "user.email", - Sys.getenv("GIT_EMAIL", "bot@devxy.io") - ) - git("checkout", "-B", pr_branch) - git( - "add", - file.path(script_dir, "patches", "registry.json"), - ledger_file - ) - git( - "commit", - "-m", - sprintf( - "feat(patches): auto-propose %d registry %s from classified failures", - length(candidate_entries), - if (length(candidate_entries) == 1L) "entry" else "entries" - ) - ) - # Push over HTTPS with FORGEJO_TOKEN (same token used for the PR API), so no - # separate write-scoped secret is needed. The read-only `origin` clone URL - # can't push, so build an authenticated URL explicitly. - push_target <- sprintf( - "https://%s:%s@git.devxy.io/%s.git", - Sys.getenv("GIT_REMOTE_USER", "pat-s"), - forgejo_token, - repo - ) - git("push", "-f", push_target, sprintf("HEAD:refs/heads/%s", pr_branch)) - - pr_title <- sprintf( - "feat(patches): auto-proposed registry patches (%s)", - now - ) - body_lines <- c( - sprintf( - "_Auto-generated %s by `local/propose-patches.R --open-pr` from classified `single_builds` failures._", - now - ), - "", - sprintf( - "Adds %d known-lever registry %s (top by failure volume%s).", - length(candidate_entries), - if (length(candidate_entries) == 1L) "entry" else "entries", - if (deferred > 0L) { - sprintf("; %d deferred to a later run", deferred) - } else { - "" - } - ), - "", - "**Merge gate:** the `trial-build-registry` pipeline builds each new entry in its target build-env image; merge only once it is green.", - "Novel source diffs and unknown signatures are never auto-proposed.", - "", - "| package | signature | platforms |", - "| --- | --- | --- |" - ) - for (c in candidates) { - body_lines <- c( - body_lines, - sprintf( - "| %s | %s | %s |", - c$package, - c$signature, - toString(as.character(c$entry$platforms)) - ) - ) - } - new_body <- paste(body_lines, collapse = "\n") - - # One PR per reused branch: update if open, else create. - pulls_url <- sprintf( - "%s/repos/%s/pulls?state=open&limit=50", - forgejo_base, - repo - ) - open_pulls <- httr2::request(pulls_url) |> - httr2::req_headers(Authorization = paste("token", forgejo_token)) |> - httr2::req_perform() |> - httr2::resp_body_json(simplifyVector = FALSE) - match_idx <- which(vapply( - open_pulls, - function(p) identical(p$head$ref, pr_branch), - logical(1L) - )) - if (length(match_idx) > 0L) { - num <- open_pulls[[match_idx[1]]]$number - httr2::request(sprintf("%s/repos/%s/pulls/%d", forgejo_base, repo, num)) |> - httr2::req_headers( - Authorization = paste("token", forgejo_token), - `Content-Type` = "application/json" - ) |> - httr2::req_body_json(list(title = pr_title, body = new_body)) |> - httr2::req_method("PATCH") |> - httr2::req_perform() - cat(sprintf("\nUpdated auto-patch PR #%d (branch %s).\n", num, pr_branch)) - } else { - created <- httr2::request(sprintf( - "%s/repos/%s/pulls", - forgejo_base, - repo - )) |> - httr2::req_headers( - Authorization = paste("token", forgejo_token), - `Content-Type` = "application/json" - ) |> - httr2::req_body_json(list( - title = pr_title, - head = pr_branch, - base = "main", - body = new_body - )) |> - httr2::req_perform() |> - httr2::resp_body_json() - cat(sprintf( - "\nOpened auto-patch PR #%d (branch %s).\n", - created$number, - pr_branch - )) - } -} else { - cat( - "\nDry run: no changes made. Re-run with --write, --open-issue, or --open-pr to act.\n" - ) -} diff --git a/local/prune-stale-flat-binaries.R b/local/prune-stale-flat-binaries.R deleted file mode 100644 index a821d3f..0000000 --- a/local/prune-stale-flat-binaries.R +++ /dev/null @@ -1,176 +0,0 @@ -### Remove flat-slot binaries recorded as unable to load under some R minor. -# -# Usage: -# Rscript local/prune-stale-flat-binaries.R [--apply] [pkg ...] -# -# The list comes from `abi_flat_safety`, written by the flat-safety backfill -# from the binaries' own symbols, so it names exactly the objects that fail at -# dyn.load() somewhere. It deliberately does *not* use -# `abi_cache_risky_packages()`: that source heuristic calls 93% of compiled -# packages risky where the binaries say 4.3%, and pruning on it would delete -# roughly 3000 working objects per slot to fix about 230 broken ones. Selecting -# per object rather than per package is the same correction #129 made to the -# index writer. -# -# `upload_single_binary()` has written a non-portable package only to the -# per-minor slot since v5.3.0, so this is a one-time cleanup of objects -# uploaded before that, not a recurring sweep. The flat slot is what every -# client that cannot be routed by R minor receives, and such a binary was built -# under whichever R was primary at the time, so it fails at load under any -# minor that dropped a symbol it uses: -# -# base64enc.so: undefined symbol: SETLENGTH -# -# Deleting the flat object does not create a hole: bincraft's source fallback -# publishes the CRAN source under the same key, so the package stays installable -# everywhere and compiles against the client's own R. Clients that are routed -# keep getting the per-minor binary. -# -# Dry run by default. Nothing is deleted without --apply. - -options(error = function() { - cat("ERROR:", geterrmessage(), "\n", file = stdout()) - traceback(2) - q(status = 1) -}) - -library(bincraft, quietly = TRUE) - -args <- commandArgs(trailingOnly = TRUE) -apply_changes <- "--apply" %in% args -args <- args[args != "--apply"] -if (length(args) < 2L) { - stop( - "usage: prune-stale-flat-binaries.R [--apply] [pkg ...]", - call. = FALSE - ) -} -arch <- args[[1L]] -codename <- args[[2L]] -explicit <- args[-c(1L, 2L)] - -bucket <- "devxy-rpkgs-binaries" -s3fs::s3_file_system( - aws_access_key_id = Sys.getenv("B2_S3_ACCESS_KEY"), - aws_secret_access_key = Sys.getenv("B2_S3_SECRET_KEY"), - endpoint = "https://s3.eu-central-003.backblazeb2.com", - region_name = "eu-central-003", - refresh = TRUE -) - -contrib <- sprintf("%s/%s/%s/latest/src/contrib", bucket, arch, codename) -objects <- s3fs::s3_dir_ls(contrib, recurse = TRUE) -relative <- sub(sprintf("^(s3://)?%s/", contrib), "", objects) - -is_tarball <- grepl("\\.tar\\.gz$", relative) -# Flat objects only: no `/` prefix and not under Archive/. -is_flat <- is_tarball & !grepl("/", relative, fixed = TRUE) -flat_files <- relative[is_flat] -flat_pkg <- sub("_.*$", "", flat_files) - -if (length(explicit) > 0L) { - doomed <- flat_files[flat_pkg %in% explicit] - cat(sprintf( - "%s/%s: %d flat binaries, %d belong to the %d named package(s)\n", - arch, - codename, - length(flat_files), - length(doomed), - length(explicit) - )) -} else { - con <- DBI::dbConnect( - RPostgres::Postgres(), - dbname = "build_metadata", - host = "r-binaries.devxy.io", - port = 15432L, - user = "rpkgs", - password = Sys.getenv("PGPASS"), - sslmode = "verify-full", - sslrootcert = bincraft::postgres_sslrootcert("verify-full") - ) - on.exit(try(DBI::dbDisconnect(con), silent = TRUE), add = TRUE) - - # Every recorded-unsafe row, whichever minor it fails under: the flat object - # is served to clients on all of them, so one failing minor condemns it. - rows <- DBI::dbGetQuery( - con, - paste0( - "SELECT package, version FROM abi_flat_safety ", - "WHERE NOT safe AND codename = $1 AND arch = $2" - ), - params = list(codename, arch) - ) - if (nrow(rows) == 0L) { - stop( - "No unsafe objects are recorded for this slot. Refusing to proceed: that is indistinguishable from a slot whose flat-safety backfill never ran, and pruning nothing while reporting success would hide it.", # nolint - call. = FALSE - ) - } - - # Match the object, not the package. A package can have a safe flat binary at - # one version and an unsafe one at another, and deleting both would throw - # away a working binary. - unsafe_objects <- sprintf("%s_%s", rows$package, rows$version) - doomed <- flat_files[sub("\\.tar\\.gz$", "", flat_files) %in% unsafe_objects] - cat(sprintf( - "%s/%s: %d flat binaries, %d recorded unable to load under some R minor\n", - arch, - codename, - length(flat_files), - length(doomed) - )) -} - -# Never remove the last artifact of a package. The source fallback republishes -# the CRAN source under this key, but only for packages CRAN still ships, so -# confirm the source exists before deleting the binary. -cran <- tryCatch( - { - con <- gzcon(url( - "https://cloud.r-project.org/src/contrib/PACKAGES.gz", - open = "rb" - )) - on.exit(close(con), add = TRUE) - read.dcf(con, fields = "Package")[, "Package"] - }, - error = function(e) character(0) -) -if (length(cran) == 0L) { - stop("Could not read CRAN's index; refusing to prune blind.", call. = FALSE) -} - -orphaned <- doomed[!(sub("_.*$", "", doomed) %in% cran)] -if (length(orphaned) > 0L) { - cat(sprintf( - "Keeping %d object(s) whose package is no longer on CRAN, so there is no source to fall back to: %s\n", - length(orphaned), - paste(utils::head(orphaned, 5L), collapse = ", ") - )) - doomed <- setdiff(doomed, orphaned) -} - -if (length(doomed) == 0L) { - cat("Nothing to prune.\n") - quit(status = 0) -} - -for (f in doomed) { - cat(sprintf(" %s %s\n", if (apply_changes) "DELETE" else "would delete", f)) -} - -if (!apply_changes) { - cat(sprintf( - "\nDry run: %d object(s) left in place. Re-run with --apply to delete.\n", - length(doomed) - )) - quit(status = 0) -} - -for (f in doomed) { - s3fs::s3_file_delete(file.path(contrib, f)) -} -cat(sprintf( - "Deleted %d flat binary object(s). Re-index the slot so the source fallback republishes them.\n", - length(doomed) -)) diff --git a/local/query-pkgs-without-old-versions.R b/local/query-pkgs-without-old-versions.R deleted file mode 100644 index 29ba891..0000000 --- a/local/query-pkgs-without-old-versions.R +++ /dev/null @@ -1,39 +0,0 @@ -library(s3fs) - -# List all files under contrib// -all_files <- s3fs::s3_dir_ls( - "s3://devxy-r-package-binaries-hel1/arm64/alpine322/latest/src/contrib/", - recurse = TRUE, - type = "file" -) - -pattern <- ".*/src/contrib/([^/_]+)_.*" -matches <- regmatches(all_files, regexec(pattern, all_files)) -pkg_names <- unique( - vapply( - matches, - function(x) if (length(x) > 1) x[2] else NA_character_, - character(1) - ) -) -pkg_names <- pkg_names[!is.na(pkg_names)] - -# For each package, check if Archive// contains any files -no_archive_files <- character(0) -for (pkg in pkg_names) { - archive_dir1 <- sprintf( - "s3://devxy-r-package-binaries-hel1/arm64/alpine322/latest/src/contrib/Archive/%s", - pkg - ) - archive_files <- unique(c( - tryCatch( - s3fs::s3_dir_ls(archive_dir1, recurse = TRUE), - error = function(e) character(0) - ) - )) - if (length(archive_files) == 0) { - no_archive_files <- c(no_archive_files, pkg) - } -} - -print(no_archive_files) diff --git a/local/r-minor-helpers.R b/local/r-minor-helpers.R deleted file mode 100644 index b031265..0000000 --- a/local/r-minor-helpers.R +++ /dev/null @@ -1,63 +0,0 @@ -# Metadata-only ABI triage so the full build avoids downloading every source. -# Mirrors bincraft::abi_classify rules 1-2; "ambiguous" packages still need a -# source grep via bincraft::needs_per_minor_recompile(). - -classify_from_metadata <- function(needs_compilation, linking_to, risky_deps) { - nc <- if (length(needs_compilation) == 0L || is.na(needs_compilation)) { - "" - } else { - tolower(trimws(needs_compilation)) - } - if (!identical(nc, "yes")) { - return("not-sensitive") - } - lt <- if (length(linking_to) == 0L || is.na(linking_to)) "" else linking_to - linked <- trimws(unlist(strsplit(lt, "[,\n]"))) - linked <- sub("\\s*\\(.*\\)$", "", linked) # strip "(>= x)" constraints - linked <- linked[nzchar(linked)] - if (any(linked %in% risky_deps)) { - return("sensitive") - } - "ambiguous" -} - -parse_build_args <- function(args) { - sensitive_only <- "--sensitive-only" %in% args - pos <- args[!startsWith(args, "--")] - list( - sensitive_only = sensitive_only, - split_into = as.integer(pos[1L]), - split_index = as.integer(pos[2L]), - ncpus = as.integer(pos[3L]) - ) -} - -# The `single_builds` platform name for a bincraft codename, e.g. alpine324 -> -# "alpine-324", rhel9 -> "redhat-9". NA for a codename this repo does not build. -codename_platform <- function(codename) { - ubuntu <- c(jammy = "2204", noble = "2404", resolute = "2604") - if (codename %in% names(ubuntu)) { - return(paste0("ubuntu-", ubuntu[[codename]])) - } - if (grepl("^rhel[0-9]+$", codename)) { - return(sub("^rhel", "redhat-", codename)) - } - if (grepl("^alpine[0-9]+$", codename)) { - return(sub("^alpine", "alpine-", codename)) - } - NA_character_ -} - -# The wall-clock deadline a build loop must stop at, from BUILD_DEADLINE (epoch -# seconds). The pipeline sets it once per step, so every pass in the step shares -# one budget and the steps after the builds (archiving, the index upload) still -# get to run before Crow's timeout kills the step. Unset or unparsable means no -# deadline. -build_deadline <- function(value = Sys.getenv("BUILD_DEADLINE", unset = "")) { - deadline <- suppressWarnings(as.numeric(value)) - if (length(deadline) != 1L || is.na(deadline)) Inf else deadline -} - -deadline_reached <- function(deadline, now = as.numeric(Sys.time())) { - now >= deadline -} diff --git a/local/rebuild-missing-helpers.R b/local/rebuild-missing-helpers.R deleted file mode 100644 index 16a588e..0000000 --- a/local/rebuild-missing-helpers.R +++ /dev/null @@ -1,87 +0,0 @@ -# Pure helpers for local/rebuild-missing.R, kept separate so local/tests can -# source them without executing a rebuild. - -# Interleaved slice of the rebuild list. -# -# The list is alphabetical and build cost clusters by name (Rcpp*, Bioc*, -# rstan*), so contiguous thirds would be badly unbalanced. Interleaving also -# makes each shard's progress counter representative of the slot as a whole. -shard_slice <- function(pkgs, split_into, split_index) { - split_into <- as.integer(split_into) - split_index <- as.integer(split_index) - if (is.na(split_into) || is.na(split_index)) { - stop("shard_slice(): split_into and split_index must be integers") - } - if (split_into < 1L || split_index < 1L || split_index > split_into) { - stop(sprintf( - "shard_slice(): need 1 <= split_index <= split_into, got %s of %s", - split_index, - split_into - )) - } - # seq() errors on a descending range, which is what an empty list or a shard - # index past the end would produce. - if (length(pkgs) < split_index) { - return(pkgs[0L]) - } - pkgs[seq.int(split_index, length(pkgs), by = split_into)] -} - -# Packages that still need building, decided from the bucket rather than from -# remembered progress. -# -# This is bincraft's `check_s3_root_package()` evaluated in bulk: an object -# whose ETag equals CRAN's published MD5sum is byte-identical to CRAN's source, -# so the build that was supposed to replace it has not happened yet. -# -# `etag_by_file` named by `_.tar.gz`, values are unquoted ETags -# `cran_version` named by package -# `cran_md5` named by `_` -# -# Unknown always means "already a binary", never "rebuild it", so an unreadable -# CRAN index or a multipart ETag can never mass-schedule work. -outstanding_packages <- function(pkgs, etag_by_file, cran_version, cran_md5) { - if (length(pkgs) == 0L) { - return(pkgs) - } - - # An empty table indexes to zero length rather than to NA, which would - # recycle the whole result away and silently report "nothing to build". - lookup <- function(table, key) { - if (length(table) == 0L) { - return(rep(NA_character_, length(key))) - } - unname(as.character(table[key])) - } - - version <- lookup(cran_version, pkgs) - file <- sprintf("%s_%s.tar.gz", pkgs, version) - etag <- lookup(etag_by_file, file) - md5 <- lookup(cran_md5, paste(pkgs, version, sep = "_")) - - # No CRAN version means the package cannot be resolved to a tarball at all; - # leave it in and let bincraft report why. - unresolved <- is.na(version) - # No object at the key: never built, so it is outstanding by definition. - absent <- !unresolved & is.na(etag) - # A multipart upload carries a compound ETag rather than an MD5. - unknown <- !is.na(etag) & grepl("-", etag, fixed = TRUE) - - is_source <- !unresolved & - !is.na(etag) & - !unknown & - !is.na(md5) & - etag == md5 - - pkgs[unresolved | absent | is_source] -} - -parse_rebuild_args <- function(args) { - pos <- args[!startsWith(args, "--")] - budget <- as.numeric(pos[3L]) - list( - split_into = as.integer(pos[1L]), - split_index = as.integer(pos[2L]), - budget_hours = if (is.na(budget)) 20 else budget - ) -} diff --git a/local/rebuild-missing.R b/local/rebuild-missing.R deleted file mode 100644 index 5d518e0..0000000 --- a/local/rebuild-missing.R +++ /dev/null @@ -1,194 +0,0 @@ -### Rebuild one shard of a slot's missing-binary list. -# -# Usage: Rscript local/rebuild-missing.R [budget_hours] -# -# The list itself comes from local/fetch-rebuild-packages-from-issue.R, which -# writes $REBUILD_PKG_LIST (default /tmp/rebuild_pkgs.txt). -# -# Two properties matter here and are the reason this is a script rather than an -# `R -q -e` argument in the pipeline: -# -# * it is restartable. The outstanding set is re-derived from the bucket on -# every start, so a shard that died resumes where it stopped without any -# progress file, and without replaying thousands of per-package HEADs. -# * it terminates. A wall-clock budget stops the loop cleanly instead of the -# run having to be killed, which is what previously skipped the re-index and -# CDN purge and left rebuilt binaries hidden behind stale edge copies. - -options(error = function() { - cat("ERROR:", geterrmessage(), "\n", file = stdout()) - traceback(2) - q(status = 1) -}) - -library(bincraft, quietly = TRUE) - -source(file.path("local", "rebuild-missing-helpers.R")) - -args <- parse_rebuild_args(commandArgs(trailingOnly = TRUE)) -if (is.na(args$split_into) || is.na(args$split_index)) { - stop("usage: rebuild-missing.R [budget_hours]") -} - -list_file <- Sys.getenv("REBUILD_PKG_LIST", "/tmp/rebuild_pkgs.txt") -pkgs <- if (file.exists(list_file)) readLines(list_file) else character(0) -pkgs <- pkgs[nzchar(pkgs)] -if (length(pkgs) == 0L) { - cat("Nothing to rebuild\n") - q("no") -} - -excluded <- jsonlite::fromJSON("local/excluded-packages.json")[["package"]] -pkgs <- setdiff(pkgs, excluded) - -mine <- shard_slice(pkgs, args$split_into, args$split_index) -cat(sprintf( - "Shard %s/%s: %s of %s listed packages\n", - args$split_index, - args$split_into, - length(mine), - length(pkgs) -)) - -### Resume: ask the bucket what is still outstanding - -codename <- bincraft::set_codename(NULL) -local_machine <- Sys.info()[["machine"]] -arch <- if (grepl("arm64|aarch64", local_machine)) "arm64" else "amd64" -slot_dir <- sprintf( - "devxy-rpkgs-binaries/%s/%s/latest/src/contrib", - arch, - codename -) - -s3fs::s3_file_system( - aws_access_key_id = Sys.getenv("B2_S3_ACCESS_KEY"), - aws_secret_access_key = Sys.getenv("B2_S3_SECRET_KEY"), - endpoint = "https://s3.eu-central-003.backblazeb2.com", - region_name = "eu-central-003", - refresh = TRUE -) - -# One paginated listing instead of a HEAD per package. Not recursed: the -# rebuild passes no `is_r_minor_sensitive`, so it only ever targets the flat -# path, and the resume filter matches that scope deliberately. -info <- tryCatch(s3fs::s3_dir_info(slot_dir), error = function(e) NULL) -etag_by_file <- if (is.null(info) || nrow(info) == 0L) { - cat(sprintf( - "WARNING: could not list %s; building the whole shard\n", - slot_dir - )) - stats::setNames(character(), character()) -} else { - stats::setNames( - gsub('^"|"$', "", as.character(info$etag)), - basename(as.character(info$uri)) - ) -} - -cran <- tryCatch( - { - con <- gzcon(url( - "https://cloud.r-project.org/src/contrib/PACKAGES.gz", - open = "rb" - )) - on.exit(close(con), add = TRUE) - read.dcf(con, fields = c("Package", "Version", "MD5sum")) - }, - error = function(e) { - cat(sprintf( - "WARNING: could not read CRAN's index (%s)\n", - conditionMessage(e) - )) - NULL - } -) -cran_version <- stats::setNames(character(), character()) -cran_md5 <- stats::setNames(character(), character()) -if (!is.null(cran)) { - cran_version <- stats::setNames( - as.character(cran[, "Version"]), - as.character(cran[, "Package"]) - ) - keep <- !is.na(cran[, "MD5sum"]) - cran_md5 <- stats::setNames( - as.character(cran[keep, "MD5sum"]), - paste(cran[keep, "Package"], cran[keep, "Version"], sep = "_") - ) -} - -before <- length(mine) -mine <- outstanding_packages(mine, etag_by_file, cran_version, cran_md5) -cat(sprintf( - "Resume: %s of %s already carry a binary; %s outstanding\n", - before - length(mine), - before, - length(mine) -)) - -if (length(mine) == 0L) { - cat("Nothing outstanding for this shard\n") - q("no") -} - -### Build - -options( - crayon.enabled = TRUE, - Ncpus = as.integer(Sys.getenv("NCPUS", "2")), - future.globals.onReference = NULL -) - -started <- Sys.time() -n <- length(mine) -completed <- 0L -for (i in seq_along(mine)) { - elapsed <- as.numeric(difftime(Sys.time(), started, units = "hours")) - if (elapsed > args$budget_hours) { - cat(sprintf( - "Budget of %sh reached after %d/%d packages; stopping cleanly. The next run resumes from the bucket.\n", - args$budget_hours, - completed, - n - )) - break - } - - x <- mine[i] - cat(sprintf("[%d/%d] %s\n", i, n, x)) - tryCatch( - bincraft::build_binary_package( - x, - tag_limit = 1L, - patches = "local/patches", - 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"), - metadata_db_host = "r-binaries.devxy.io", - metadata_db_name = "build_metadata", - metadata_db_table = "single_builds", - metadata_db_user = "rpkgs", - metadata_db_password = Sys.getenv("PGPASS"), - metadata_db_sslmode = "verify-full", - metadata_db_port = 15432, - archive = TRUE, - upload = TRUE, - store_build_metadata = TRUE - ), - error = function(e) { - cat(sprintf("ERROR building %s - %s\n", x, conditionMessage(e))) - } - ) - completed <- completed + 1L -} - -cat(sprintf( - "Shard %s/%s finished: %d/%d packages processed in %.1fh\n", - args$split_index, - args$split_into, - completed, - n, - as.numeric(difftime(Sys.time(), started, units = "hours")) -)) diff --git a/local/repair-built-stamp.R b/local/repair-built-stamp.R deleted file mode 100644 index 190b145..0000000 --- a/local/repair-built-stamp.R +++ /dev/null @@ -1,274 +0,0 @@ -#!/usr/bin/env Rscript - -### Rewrite a broken `Built` stamp across one arch/codename slot. -### -### A slot's index can end up advertising a stamp whose platform triple is -### unusable, e.g. `Built: R 4.5.0; NA; ...`. uvr picks binary vs source by -### matching that triple plus the R minor, so no client matches it and the whole -### slot silently reverts to source-only, which makes uvr compile everything and -### fail wherever a system `-dev` library is missing. -### -### Rewriting it is not a matter of re-running the normal index update. -### `upload_package_index()` uses the slot's published `PACKAGES.rds` as its -### cache: a record whose tarball is still listed with the same ETag is reused, -### stamp included, and only new or replaced tarballs are read and stamped. A -### full re-read would mean 25k requests to raw.githubusercontent.com per slot -### and a real risk of being rate-limited part-way through. -### -### Only the `Built` column is wrong, so correct it in place instead: patch the -### column in the published `PACKAGES.rds`, put it back, and let -### `upload_package_index()` re-emit `PACKAGES*` from it. No tarball is re-read -### and nothing is fetched from GitHub. -### -### bincraft releases before the switch away from cranlike (bincraft#33) read -### the slot's `PACKAGES.db` instead, so with one of those installed the script -### patches that database, as it always did. -### -### The replacement comes from bincraft's `built_stamp()` under the R running -### this script, so run it under the R version the slot should advertise (the -### `R_VERSION` its entry in `.crow/process-updates.yaml` uses). That is what a -### healthy `upload_package_index()` run would have written. -### -### Usage, inside the platform's build image: -### Rscript local/repair-built-stamp.R [--apply] -### -### Without `--apply` it reports what it would change and touches nothing. - -suppressPackageStartupMessages({ - library(bincraft) -}) - -args <- commandArgs(trailingOnly = TRUE) -arch <- args[1L] -apply_changes <- "--apply" %in% args - -if (is.na(arch) || !nzchar(arch)) { - stop( - "Usage: Rscript local/repair-built-stamp.R [--apply]", - call. = FALSE - ) -} - -bucket <- "devxy-rpkgs-binaries" -endpoint <- "https://s3.eu-central-003.backblazeb2.com" -region <- "eu-central-003" - -codename <- bincraft::set_codename(NULL) -if (is.null(codename) || is.na(codename) || !nzchar(codename)) { - stop( - "Could not detect a codename from /etc/os-release; run this in a build image.", - call. = FALSE - ) -} - -# built_stamp() refuses an unusable platform, so a broken build image fails here -# rather than writing a second bad stamp over the first one. It is internal to -# bincraft, hence `:::`. -stamp <- bincraft:::built_stamp() -message(sprintf("Slot: %s/%s", arch, codename)) -message(sprintf("New stamp: %s", stamp)) - -s3fs::s3_file_system( - aws_access_key_id = Sys.getenv("B2_S3_ACCESS_KEY"), - aws_secret_access_key = Sys.getenv("B2_S3_SECRET_KEY"), - endpoint = endpoint, - region_name = region, - refresh = TRUE -) - -base_dir <- file.path(bucket, arch, codename, "latest", "src", "contrib") - -# A stamp is broken when its platform component is literally "NA" or empty. -broken_stamp <- function(built) { - !is.na(built) & grepl("; NA;|; ;", built) -} -# The same test for PACKAGES.db, which also counts a missing stamp as broken: -# the database never holds a deliberately cleared one. -broken_stamp_where <- paste( - "Built IS NULL", - "OR Built LIKE '%; NA;%'", - "OR Built LIKE '%; ;%'" -) - -# The generic slot plus every per-minor sub-slot, which carry the same stamp and -# are poisoned by the same run. -r_minors <- sub( - "^.*/R/([0-9]+\\.[0-9]+)\\.[0-9]+$", - "\\1", - list.dirs("/opt/R", recursive = FALSE) -) -r_minors <- unique(grep("^[0-9]+\\.[0-9]+$", r_minors, value = TRUE)) -slots <- c( - stats::setNames(base_dir, NA_character_), - stats::setNames(file.path(base_dir, r_minors), r_minors) -) - -# bincraft imports cranlike for as long as it keeps the index in PACKAGES.db. -uses_packages_db <- "cranlike" %in% loadedNamespaces() - -repair_packages_rds <- function(slot, r_minor) { - rds_remote <- file.path(slot, "PACKAGES.rds") - if (!s3fs::s3_file_exists(rds_remote)) { - message(sprintf(" %s: no PACKAGES.rds, skipping", slot)) - return(invisible(NULL)) - } - - rds_local <- tempfile(fileext = ".rds") - on.exit(unlink(rds_local), add = TRUE) - s3fs::s3_file_download(rds_remote, rds_local, overwrite = TRUE) - records <- readRDS(rds_local) - - # A per-minor index is published as a union with the generic slot, and only - # the rows carrying the slot's own `Path` are reused from it; the generic ones - # are re-read from the generic slot's index, which is repaired on its own. - own <- if (!("Path" %in% colnames(records))) { - rep(TRUE, nrow(records)) - } else if (is.na(r_minor)) { - is.na(records[, "Path"]) - } else { - records[, "Path"] %in% r_minor - } - # A missing stamp is not broken here: bincraft clears it on purpose for a - # package whose build failed and that is served as its CRAN source. - broken <- own & broken_stamp(records[, "Built"]) - - message(sprintf( - " %s: %s entries, %s broken", - slot, - sum(own), - sum(broken) - )) - if (!any(broken)) { - return(invisible(NULL)) - } - if (!apply_changes) { - message(" (dry run, pass --apply to rewrite)") - return(invisible(NULL)) - } - - records[broken, "Built"] <- stamp - saveRDS(records, rds_local, compress = "xz") - s3fs::s3_file_upload( - rds_local, - rds_remote, - overwrite = TRUE, - CacheControl = "no-store" - ) - message(sprintf( - " rewrote %s entries and uploaded PACKAGES.rds", - sum(broken) - )) - invisible(NULL) -} - -repair_packages_db <- function(slot, r_minor) { - db_remote <- file.path(slot, "PACKAGES.db") - if (!s3fs::s3_file_exists(db_remote)) { - message(sprintf(" %s: no PACKAGES.db, skipping", slot)) - return(invisible(NULL)) - } - - db_local <- tempfile(fileext = ".db") - s3fs::s3_file_download(db_remote, db_local, overwrite = TRUE) - - con <- DBI::dbConnect(RSQLite::SQLite(), db_local) - on.exit(DBI::dbDisconnect(con), add = TRUE) - - total <- DBI::dbGetQuery(con, "SELECT COUNT(*) AS n FROM packages")$n - broken <- DBI::dbGetQuery( - con, - sprintf("SELECT COUNT(*) AS n FROM packages WHERE %s", broken_stamp_where) - )$n - - message(sprintf(" %s: %s entries, %s broken", slot, total, broken)) - if (broken == 0L) { - return(invisible(NULL)) - } - if (!apply_changes) { - message(" (dry run, pass --apply to rewrite)") - return(invisible(NULL)) - } - - DBI::dbExecute( - con, - sprintf("UPDATE packages SET Built = ? WHERE %s", broken_stamp_where), - params = list(stamp) - ) - DBI::dbDisconnect(con) - on.exit() - - s3fs::s3_file_upload(db_local, db_remote, overwrite = TRUE) - message(sprintf(" rewrote %s entries and uploaded PACKAGES.db", broken)) - invisible(NULL) -} - -repair_slot <- if (uses_packages_db) repair_packages_db else repair_packages_rds -message(sprintf( - "Patching: %s", - if (uses_packages_db) "PACKAGES.db" else "PACKAGES.rds" -)) -invisible(Map(repair_slot, slots, names(slots))) - -if (!apply_changes) { - message("Dry run complete; nothing was changed.") - quit(save = "no") -} - -# Re-emit PACKAGES/PACKAGES.gz/PACKAGES.rds from the corrected records. Nothing -# is reparsed, because no tarball changed. -message("Re-emitting index files from the corrected records...") -bincraft::upload_package_index( - codename = codename, - s3_endpoint = endpoint, - s3_region = region, - s3_bucket = bucket, - s3_access_key_id = Sys.getenv("B2_S3_ACCESS_KEY"), - s3_secret_access_key = Sys.getenv("B2_S3_SECRET_KEY") -) -# A per-minor index reads the ABI classifier cache and the flat-object safety -# table from the build database. A failed minor does not stop the others, but -# it does fail the run once they are done. -failed_minors <- character(0L) -for (minor in r_minors) { - ok <- tryCatch( - { - bincraft::upload_package_index( - codename = codename, - r_minor = minor, - s3_endpoint = endpoint, - s3_region = region, - s3_bucket = bucket, - s3_access_key_id = Sys.getenv("B2_S3_ACCESS_KEY"), - s3_secret_access_key = Sys.getenv("B2_S3_SECRET_KEY"), - metadata_db_host = "r-binaries.devxy.io", - metadata_db_name = "build_metadata", - metadata_db_port = 15432L, - metadata_db_user = "rpkgs", - metadata_db_password = Sys.getenv("PGPASS"), - metadata_db_sslmode = "verify-full" - ) - TRUE - }, - error = function(e) { - message(sprintf("Re-indexing %s failed: %s", minor, conditionMessage(e))) - FALSE - } - ) - if (!ok) { - failed_minors <- c(failed_minors, minor) - } -} -if (length(failed_minors) > 0L) { - stop( - "Could not republish the per-minor index for: ", - paste(failed_minors, collapse = ", "), - call. = FALSE - ) -} - -message("Done. Verify with:") -message(sprintf( - " curl -sS https://cran.devxy.io/%s/%s/latest/src/contrib/PACKAGES | grep '^Built:' | sort | uniq -c", - arch, - codename -)) diff --git a/local/retire-slot.R b/local/retire-slot.R deleted file mode 100644 index 383fd2c..0000000 --- a/local/retire-slot.R +++ /dev/null @@ -1,240 +0,0 @@ -### Retire a slot: strip it from the pipelines and delete its objects from S3. -# -# Rscript local/retire-slot.R [--apply] [--config-only|--assets-only] -# -# Retiring a distro retires both architectures, because `local.rpkgs_slots` in -# `cdn.tf` is a setproduct over them. -# -# Order: remove the slot from `local.rpkgs_slots` (and the website's -# `DistroId`) and apply that first, then run this. Deleting objects while a -# pipeline still targets the slot just means the next nightly rebuilds them. -# -# Cron jobs live on the Crow server, not here, and are printed at the end. -# -# Only structural YAML is edited. Prose mentioning the slot is left alone, so -# grep for the name afterwards. -# -# Dry run by default. - -options(error = function() { - cat("ERROR:", geterrmessage(), "\n", file = stdout()) - q(status = 1) -}) - -args <- commandArgs(trailingOnly = TRUE) -apply_changes <- "--apply" %in% args -config_only <- "--config-only" %in% args -assets_only <- "--assets-only" %in% args -args <- args[!args %in% c("--apply", "--config-only", "--assets-only")] -if (length(args) != 1L || (config_only && assets_only)) { - stop( - "usage: retire-slot.R [--apply] [--config-only|--assets-only]", - call. = FALSE - ) -} -codename <- args[[1L]] - -# The bucket and `CODENAME:` say `alpine322`; `OS:` and the options say -# `alpine-322`. Both have to go. -pipeline_os <- if (grepl("^rhel[0-9]+$", codename)) { - sub("^rhel", "redhat-", codename) -} else if (grepl("^alpine[0-9]+$", codename)) { - sub("^alpine", "alpine-", codename) -} else { - # Single bracket so an unknown codename yields NA, not an error. - c(resolute = "ubuntu-2604", noble = "ubuntu-2404", jammy = "ubuntu-2204")[ - codename - ] -} -if (is.na(pipeline_os) || length(pipeline_os) == 0L) { - stop(sprintf("Unrecognised codename '%s'.", codename), call. = FALSE) -} - -# The `OS_VERSION` dropdowns are keyed on the image tag, not the slot name. -image_tag <- if (grepl("^alpine-", pipeline_os)) { - sub("^alpine-([0-9])([0-9]+)$", "\\1.\\2", pipeline_os) -} else if (grepl("^redhat-", pipeline_os)) { - sub("^redhat-", "", pipeline_os) -} else { - codename -} - -# Refuse a slot that is still routed: deleting its objects would leave the edge -# serving indexes that name files which no longer exist. -tf <- readLines("cdn.tf", warn = FALSE) -start <- grep("rpkgs_slots\\s*=", tf) -if (length(start) != 1L) { - stop( - "Could not find exactly one `rpkgs_slots` local in cdn.tf.", - call. = FALSE - ) -} -block <- paste(tf[start:min(start + 10L, length(tf))], collapse = "\n") -if (grepl(sprintf('"%s"', codename), block, fixed = TRUE)) { - stop( - sprintf( - "'%s' is still listed in `local.rpkgs_slots` in cdn.tf, so the edge still routes it. Remove it there (and from the website's DistroId union) and apply the OpenTofu change first.", # nolint - codename - ), - call. = FALSE - ) -} - -cat(sprintf( - "Retiring %s (pipelines call it '%s', images tag it '%s')\n\n", - codename, - pipeline_os, - image_tag -)) - -## 1. Pipeline definitions ---------------------------------------------------- - -# Line-based on purpose: a YAML round trip would reflow all 18 files. -strip_slot <- function(lines) { - keep <- rep(TRUE, length(lines)) - i <- 1L - while (i <= length(lines)) { - line <- lines[[i]] - row <- regexec( - sprintf( - "^(\\s*)-\\s*(OS|CODENAME):\\s*(%s|%s)\\s*$", - pipeline_os, - codename - ), - line - ) - m <- regmatches(line, row)[[1L]] - if (length(m) == 4L) { - indent <- nchar(m[[2L]]) - keep[[i]] <- FALSE - j <- i + 1L - while (j <= length(lines)) { - nxt <- lines[[j]] - if ( - !nzchar(trimws(nxt)) || nchar(sub("^(\\s*).*$", "\\1", nxt)) <= indent - ) { - break - } - keep[[j]] <- FALSE - j <- j + 1L - } - i <- j - next - } - if (grepl(sprintf("^\\s*-\\s*%s-(amd64|arm64)\\s*$", pipeline_os), line)) { - keep[[i]] <- FALSE - } - if (grepl(sprintf("^\\s*-\\s*'%s'\\s*$", image_tag), line)) { - keep[[i]] <- FALSE - } - i <- i + 1L - } - out <- lines[keep] - # A dropdown cannot default to an option that no longer exists. - bad_default <- grepl(sprintf("^\\s*default:\\s*'%s'\\s*$", image_tag), out) - if (any(bad_default)) { - for (k in which(bad_default)) { - opts <- grep("^\\s*-\\s*'[^']+'\\s*$", out[seq_len(k - 1L)]) - if (length(opts) == 0L) { - next - } - # Walk back to this block's first option, not the nearest one. - first <- max(opts) - while (first > 1L && grepl("^\\s*-\\s*'[^']+'\\s*$", out[[first - 1L]])) { - first <- first - 1L - } - replacement <- sub("^\\s*-\\s*'([^']+)'\\s*$", "\\1", out[[first]]) - out[[k]] <- sub("'[^']+'", sprintf("'%s'", replacement), out[[k]]) - cat(sprintf(" default moved to '%s'\n", replacement)) - } - } - out -} - -if (!assets_only) { - files <- sort(list.files(".crow", pattern = "\\.yaml$", full.names = TRUE)) - touched <- 0L - for (f in files) { - lines <- readLines(f, warn = FALSE) - out <- strip_slot(lines) - if (length(out) == length(lines)) { - next - } - touched <- touched + 1L - cat(sprintf( - " %s %-45s -%d lines\n", - if (apply_changes) "EDIT " else "would edit", - f, - length(lines) - length(out) - )) - if (apply_changes) { - writeLines(out, f) - } - } - if (touched == 0L) { - cat(" No pipeline references the slot.\n") - } else if (apply_changes) { - cat(sprintf( - " %d file(s) edited. Verify with `crow lint .crow/` and `Rscript local/check-slots.R`.\n", - touched - )) - } - cat("\n") -} - -## 2. Bucket objects ---------------------------------------------------------- - -if (!config_only) { - library(s3fs, quietly = TRUE) - if (!nzchar(Sys.getenv("B2_S3_ACCESS_KEY"))) { - stop( - "B2_S3_ACCESS_KEY is unset. B2 lists nothing without credentials, which is indistinguishable from an already-clean slot.", # nolint - call. = FALSE - ) - } - bucket <- "devxy-rpkgs-binaries" - s3fs::s3_file_system( - aws_access_key_id = Sys.getenv("B2_S3_ACCESS_KEY"), - aws_secret_access_key = Sys.getenv("B2_S3_SECRET_KEY"), - endpoint = "https://s3.eu-central-003.backblazeb2.com", - region_name = "eu-central-003", - refresh = TRUE - ) - - for (arch in c("amd64", "arm64")) { - prefix <- sprintf("%s/%s/%s", bucket, arch, codename) - if (!s3fs::s3_dir_exists(prefix)) { - cat(sprintf(" %s/%s: nothing in the bucket.\n", arch, codename)) - next - } - objects <- s3fs::s3_dir_ls(prefix, recurse = TRUE) - cat(sprintf( - " %s %s/%s: %d object(s)\n", - if (apply_changes) "DELETE" else "would delete", - arch, - codename, - length(objects) - )) - if (apply_changes && length(objects) > 0L) { - s3fs::s3_dir_delete(prefix) - cat(sprintf(" deleted s3://%s\n", prefix)) - } - } - cat("\n") -} - -## 3. Crons ------------------------------------------------------------------ - -if (!apply_changes) { - cat("Dry run: nothing was edited or deleted. Re-run with --apply.\n\n") -} - -cat("Crons still to remove on the Crow server (they are not in this repo):\n") -cat(sprintf( - " crow-at ci.devxy.io repo cron ls devxy/build-cran-binaries | grep %s\n", - pipeline_os -)) -cat(" # `crow repo cron rm` 404s here; the API base is /api/v1\n") -cat(" eval \"$(crow-at --export ci.devxy.io)\"\n") -cat(" curl -s -X DELETE -H \"Authorization: Bearer $CROW_TOKEN\" \\\n") -cat(" https://ci.devxy.io/api/v1/repos/5/cron/\n") diff --git a/local/seed-helpers.R b/local/seed-helpers.R deleted file mode 100644 index a3d8e57..0000000 --- a/local/seed-helpers.R +++ /dev/null @@ -1,162 +0,0 @@ -# Pure helpers for local/seed-pure-r.R, kept separate so local/tests can source -# them without touching S3 or the metadata DB. - -# "alpine" for alpine324, "rhel" for rhel9. Seeding only ever crosses versions -# within one family: a pure-R binary has no compiled code, but install-time R -# code can still capture the build system's paths and tools. -codename_family <- function(codename) { - sub("[0-9]+$", "", codename) -} - -per_minor_key <- function(keys) { - grepl("^[0-9]+\\.[0-9]+/", keys) -} - -# Split `_.tar.gz` file names; NA where a name does not parse. -split_tarball_name <- function(files) { - m <- regmatches(files, regexec("^([A-Za-z0-9.]+)_([^_]+)\\.tar\\.gz$", files)) - part <- function(i) { - vapply(m, function(x) if (length(x) == 3L) x[[i]] else NA_character_, "") - } - list(package = part(2L), version = part(3L)) -} - -# Donor objects worth downloading and verifying for the target slot. -# -# `donor_keys`/`donor_etags` describe the donor slot, keys relative to its -# contrib dir (`curl_5.0.tar.gz`, `Archive/curl/curl_4.3.tar.gz`). -# `target_keys` are the target slot's keys, same form. -# `release_pkgs` packages on CRAN now; the build scope. -# `compiled_pkgs` packages whose current CRAN release needs compilation. Their -# archive versions are skipped as well: a seed only saves time, so guessing -# wrong in this direction costs a build, never a broken binary. -# `cran_md5` CRAN's MD5 per `_`. An ETag equal to it is CRAN's source -# tarball served as a fallback, never a binary worth copying. -# -# Anything already present in the target, under any non-per-minor key, is left -# alone: that is either a build or an earlier seed. -seed_candidates <- function( - donor_keys, - donor_etags, - target_keys, - release_pkgs, - compiled_pkgs, - cran_md5, - exclude = character() -) { - files <- basename(donor_keys) - parsed <- split_tarball_name(files) - md5 <- if (length(cran_md5) == 0L) { - rep(NA_character_, length(files)) - } else { - unname(cran_md5[paste(parsed$package, parsed$version, sep = "_")]) - } - is_source <- !is.na(md5) & !is.na(donor_etags) & donor_etags == md5 - present <- basename(target_keys[!per_minor_key(target_keys)]) - - keep <- !is.na(parsed$package) & - !per_minor_key(donor_keys) & - parsed$package %in% release_pkgs & - !parsed$package %in% compiled_pkgs & - !parsed$package %in% exclude & - !files %in% present & - !is_source - out <- data.frame( - key = donor_keys, - package = parsed$package, - version = parsed$version, - stringsAsFactors = FALSE - )[keep, , drop = FALSE] - # The same version can sit both flat and under Archive/ while the donor waits - # for process_unarchived_pkgs(); copy it once, flat first. - out <- out[order(grepl("^Archive/", out$key)), , drop = FALSE] - out <- out[!duplicated(basename(out$key)), , drop = FALSE] - rownames(out) <- NULL - out -} - -# `Built: R 4.5.3; ; 2026-09-01 10:00:00 UTC; unix` -> R version and platform. -# The platform is empty exactly when the package has no compiled code. -parse_built <- function(built) { - parts <- trimws(strsplit(built, ";", fixed = TRUE)[[1L]]) - list( - r_version = sub("^R\\s+", "", parts[1L]), - platform = if (length(parts) >= 2L) parts[2L] else NA_character_ - ) -} - -# Whether one downloaded donor tarball may be published in the target slot. -# -# Every check has to pass; anything unreadable is a refusal, never a guess, -# because a refusal only means the package gets built the normal way. -# * it is a binary: DESCRIPTION carries a `Built` field (a CRAN source -# fallback does not); -# * it has no compiled code: empty `Built` platform and no libs/ directory; -# * it was built by the target's primary R minor, the one whose binaries the -# flat slot holds; -# * `abi_verdict` (bincraft's upload-time symbol inspection) calls it portable -# across every installed minor, exactly the decision a fresh upload would -# make before writing to the flat slot. -seed_verdict <- function(tarball, package, version, target_minor, abi_verdict) { - reject <- function(reason) { - list(seed = FALSE, reason = reason, unsupported = character()) - } - read_members <- function() { - tryCatch( - utils::untar(tarball, list = TRUE), - error = function(e) NULL, - warning = function(w) NULL - ) - } - members <- read_members() - if (is.null(members)) { - return(reject("unreadable")) - } - desc <- paste0(package, "/DESCRIPTION") - if (!desc %in% members) { - return(reject("unreadable")) - } - if (any(startsWith(members, paste0(package, "/libs/")))) { - return(reject("compiled")) - } - - dir <- tempfile("seed_desc_") - on.exit(unlink(dir, recursive = TRUE, force = TRUE), add = TRUE) - fields <- tryCatch( - { - utils::untar(tarball, files = desc, exdir = dir) - read.dcf( - file.path(dir, desc), - fields = c("Package", "Version", "Built") - ) - }, - error = function(e) NULL, - warning = function(w) NULL - ) - if (is.null(fields) || nrow(fields) != 1L) { - return(reject("unreadable")) - } - if ( - !identical(unname(fields[1L, "Package"]), package) || - !identical(unname(fields[1L, "Version"]), version) - ) { - return(reject("mismatch")) - } - if (is.na(fields[1L, "Built"])) { - return(reject("source")) - } - built <- parse_built(fields[1L, "Built"]) - if (is.na(built$platform) || nzchar(built$platform)) { - return(reject("compiled")) - } - built_minor <- sub("^(\\d+\\.\\d+).*$", "\\1", built$r_version) - if (!identical(built_minor, target_minor)) { - return(reject("r-minor")) - } - - verdict <- abi_verdict(tarball) - if (!isTRUE(verdict$inspected) || !identical(verdict$sensitive, FALSE)) { - return(reject("abi")) - } - list(seed = TRUE, reason = "seeded", unsupported = verdict$unsupported) -} diff --git a/local/seed-pure-r.R b/local/seed-pure-r.R deleted file mode 100644 index 4268224..0000000 --- a/local/seed-pure-r.R +++ /dev/null @@ -1,323 +0,0 @@ -# Seed a new slot with the pure-R binaries of an existing one. -# -# Usage: Rscript local/seed-pure-r.R DONOR [DONOR...] [--workers=N] [--dry-run] -# e.g. Rscript local/seed-pure-r.R alpine324 alpine323 -# -# Three quarters of the versions a full rebuild targets have no compiled code. -# Building one costs about 20s, nearly all of it dependency installs and -# bookkeeping, and the result is the same R objects every other slot already -# serves: R6 2.6.1 deparses identically on amd64/alpine323, amd64/alpine324 and -# arm64/rhel9. Copying those from a slot of the same OS family and arch saves -# roughly 340 shard-hours per arch and leaves build-all with the compiled rest. -# -# Each candidate is downloaded and checked before it is copied server-side (see -# seed_verdict()): a binary, no compiled code, built by this image's primary R -# minor, and portable across every installed minor by bincraft's own symbol -# inspection. A seeded object then gets the two metadata rows an upload would -# have written: a successful `single_builds` row, so build-all skips it, and an -# `abi_flat_safety` row, without which the per-minor indexes drop it. -# -# Donors are tried in order; the first one with a valid binary wins. Re-running -# is safe: whatever the target already holds is skipped, and the metadata rows -# of earlier copies are re-written idempotently. - -source(file.path("local", "seed-helpers.R")) -source(file.path("local", "r-minor-helpers.R")) - -args <- commandArgs(trailingOnly = TRUE) -donors <- args[!startsWith(args, "--")] -if (length(donors) == 0L) { - stop("Usage: seed-pure-r.R DONOR [DONOR...] [--workers=N] [--dry-run]") -} -dry_run <- "--dry-run" %in% args -workers_arg <- sub("^--workers=", "", grep("^--workers=", args, value = TRUE)) -workers <- if (length(workers_arg)) as.integer(workers_arg[1L]) else 8L -batch_size <- 400L - -local_machine <- Sys.info()[["machine"]] -arch <- if (grepl("arm64|aarch64", local_machine)) "arm64" else "amd64" -target <- bincraft::set_codename(NULL) -platform <- codename_platform(target) -target_minor <- paste( - R.version$major, - strsplit(R.version$minor, ".", fixed = TRUE)[[1L]][1L], - sep = "." -) -for (donor in donors) { - if (identical(donor, target)) { - stop(sprintf("Donor %s is the target slot itself", donor)) - } - if (!identical(codename_family(donor), codename_family(target))) { - stop(sprintf( - "Donor %s is not an %s slot; seeding only copies within one OS family", - donor, - codename_family(target) - )) - } -} -if (is.na(platform)) { - stop(sprintf("No single_builds platform name for codename %s", target)) -} - -# Computed once: bincraft would otherwise run nm over every libR per tarball. -symbol_sets <- bincraft:::installed_r_symbol_sets() -if (is.null(symbol_sets)) { - stop( - "Fewer than two R minors under /opt/R; ABI portability cannot be ", - "verified, so nothing is seeded" - ) -} -message(sprintf( - "Seeding %s/%s (R %s) from %s; ABI checked against R %s", - arch, - target, - target_minor, - paste(donors, collapse = ", "), - paste(names(symbol_sets), collapse = ", ") -)) - -s3fs::s3_file_system( - aws_access_key_id = Sys.getenv("B2_S3_ACCESS_KEY"), - aws_secret_access_key = Sys.getenv("B2_S3_SECRET_KEY"), - endpoint = "https://s3.eu-central-003.backblazeb2.com", - region_name = "eu-central-003", - refresh = TRUE -) -slot_dir <- function(codename) { - sprintf("devxy-rpkgs-binaries/%s/%s/latest/src/contrib", arch, codename) -} -# Keys relative to the contrib dir with unquoted ETags. A listing failure is -# fatal: an empty target listing would mean re-copying everything. -list_slot <- function(codename) { - info <- s3fs::s3_dir_info(slot_dir(codename), recurse = TRUE) - uri <- as.character(info$uri) - is_tarball <- grepl("\\.tar\\.gz$", uri) - data.frame( - key = sub( - sprintf("^(s3://)?%s/", slot_dir(codename)), - "", - uri[is_tarball] - ), - etag = gsub('^"|"$', "", as.character(info$etag[is_tarball])), - stringsAsFactors = FALSE - ) -} - -cran <- tools::CRAN_package_db() -compiled_pkgs <- cran$Package[tolower(cran$NeedsCompilation) %in% "yes"] -cran_md5 <- bincraft:::cran_source_md5() -exclude <- jsonlite::fromJSON("local/excluded-packages.json")[["package"]] - -db_connect <- function() { - DBI::dbConnect( - RPostgres::Postgres(), - dbname = "build_metadata", - host = "r-binaries.devxy.io", - port = 15432, - user = "rpkgs", - password = Sys.getenv("PGPASS"), - sslmode = "verify-full", - sslrootcert = bincraft::postgres_sslrootcert("verify-full") - ) -} - -# The rows an upload would have written for these objects. Idempotent, so a -# re-run can repair rows a failed write left out. Pure-R objects reference no R -# symbols, hence an empty `unsupported`. -record_seeded <- function(packages, versions) { - if (length(packages) == 0L) { - return(invisible(TRUE)) - } - ok <- tryCatch( - { - con <- db_connect() - on.exit(DBI::dbDisconnect(con), add = TRUE) - bincraft:::ensure_flat_safety_table(con, "abi_flat_safety") - DBI::dbWithTransaction(con, { - DBI::dbWriteTable( - con, - "seed_rows", - data.frame( - name = packages, - tag = versions, - stringsAsFactors = FALSE - ), - temporary = TRUE, - overwrite = TRUE - ) - DBI::dbExecute( - con, - paste( - "INSERT INTO single_builds (name, tag, platform, arch,", - "error_occurred, error_text, size, timestamp, duration, removed,", - "r_version)", - "SELECT s.name, s.tag, $1, $2, FALSE, NULL, NULL, now(), NULL,", - "FALSE, $3 FROM seed_rows s WHERE NOT EXISTS (SELECT 1 FROM", - "single_builds b WHERE b.name = s.name AND b.tag = s.tag", - "AND b.platform = $1 AND b.arch = $2 AND b.r_version = $3)" - ), - params = list(platform, arch, target_minor) - ) - DBI::dbExecute( - con, - paste( - "INSERT INTO abi_flat_safety (package, version, codename, arch,", - "safe, unsupported) SELECT s.name, s.tag, $1, $2, TRUE, ''", - "FROM seed_rows s ON CONFLICT (package, version, codename, arch)", - "DO UPDATE SET safe = EXCLUDED.safe,", - "unsupported = EXCLUDED.unsupported, checked_at = now()" - ), - params = list(target, arch) - ) - }) - TRUE - }, - error = function(e) { - message(sprintf( - "WARNING: could not record %d seeded object(s): %s. Re-run to repair.", - length(packages), - conditionMessage(e) - )) - FALSE - } - ) - invisible(ok) -} - -target_listing <- list_slot(target) -message(sprintf("Target %s holds %d tarball(s)", target, nrow(target_listing))) - -future::plan(future::multisession, workers = workers) -tally <- integer() -count <- function(reasons) { - for (r in reasons) { - tally[[r]] <<- (if (is.na(tally[r])) 0L else tally[[r]]) + 1L - } -} - -for (donor in donors) { - donor_listing <- list_slot(donor) - - # Byte-identical copies an earlier run made: make sure their rows exist. - same <- merge(donor_listing, target_listing, by = c("key", "etag")) - same <- same[!per_minor_key(same$key), , drop = FALSE] - parsed <- split_tarball_name(basename(same$key)) - ours <- !is.na(parsed$package) & !parsed$package %in% compiled_pkgs - if (any(ours) && !dry_run) { - record_seeded(parsed$package[ours], parsed$version[ours]) - } - - candidates <- seed_candidates( - donor_listing$key, - donor_listing$etag, - target_listing$key, - cran$Package, - compiled_pkgs, - cran_md5, - exclude - ) - message(sprintf( - "%s: %d tarball(s), %d candidate(s) after the metadata filters", - donor, - nrow(donor_listing), - nrow(candidates) - )) - if (dry_run || nrow(candidates) == 0L) { - next - } - - batches <- split( - seq_len(nrow(candidates)), - ceiling(seq_len(nrow(candidates)) / batch_size) - ) - for (b in seq_along(batches)) { - batch <- candidates[batches[[b]], , drop = FALSE] - dl_dir <- tempfile("seed_") - dir.create(dl_dir) - local_files <- file.path(dl_dir, basename(batch$key)) - downloaded <- tryCatch( - { - s3fs::s3_file_download( - file.path(slot_dir(donor), batch$key), - local_files, - overwrite = TRUE - ) - TRUE - }, - error = function(e) { - message(sprintf( - "Batch %d: download failed (%s); leaving it to build-all", - b, - conditionMessage(e) - )) - FALSE - } - ) - if (!downloaded) { - count(rep("download-failed", nrow(batch))) - unlink(dl_dir, recursive = TRUE) - next - } - - verdicts <- future.apply::future_lapply( - seq_len(nrow(batch)), - function(i) { - seed_verdict( - local_files[i], - batch$package[i], - batch$version[i], - target_minor, - function(t) bincraft:::tarball_abi_verdict(t, symbol_sets) - ) - }, - future.seed = NULL - ) - unlink(dl_dir, recursive = TRUE) - seed <- vapply(verdicts, function(v) isTRUE(v$seed), logical(1L)) - count(vapply(verdicts, function(v) v$reason, "")) - - if (any(seed)) { - copied <- tryCatch( - { - s3fs::s3_file_copy( - paste0("s3://", file.path(slot_dir(donor), batch$key[seed])), - paste0("s3://", file.path(slot_dir(target), batch$key[seed])), - overwrite = TRUE - ) - TRUE - }, - error = function(e) { - message(sprintf( - "Batch %d: copy failed (%s); leaving it to build-all", - b, - conditionMessage(e) - )) - FALSE - } - ) - if (copied) { - record_seeded(batch$package[seed], batch$version[seed]) - target_listing <- rbind( - target_listing, - data.frame(key = batch$key[seed], etag = NA_character_) - ) - } else { - count(rep("copy-failed", sum(seed))) - tally[["seeded"]] <- tally[["seeded"]] - sum(seed) - } - } - message(sprintf( - "%s batch %d/%d: %d of %d seeded", - donor, - b, - length(batches), - sum(seed), - nrow(batch) - )) - } -} - -message( - "Seed summary: ", - paste(sprintf("%s=%d", names(tally), tally), collapse = ", ") -) diff --git a/local/test-package-loading.R b/local/test-package-loading.R deleted file mode 100644 index a3b7a28..0000000 --- a/local/test-package-loading.R +++ /dev/null @@ -1,337 +0,0 @@ -# Installs every CRAN package one by one and checks that it loads. Dependencies -# go through uvr via local/uvr-install.sh, which bootstraps the uvr binary on -# first use and installs into .libPaths()[1]. -uvr_install <- function(pkg) { - Sys.setenv( - UVR_R_BIN = file.path(R.home("bin"), "R"), - UVR_TARGET_LIB = .libPaths()[1L] - ) - status <- system2("local/uvr-install.sh", shQuote(pkg)) - if (!identical(status, 0L)) { - stop( - sprintf("uvr failed to install %s (exit %s)", pkg, status), - call. = FALSE - ) - } -} - -all_pkgs <- rownames(available.packages()) - -to_skip <- c("ABRSQOL", "ACA", "ACE.CoCo") -all_pkgs <- setdiff(all_pkgs, to_skip) - -for (i in all_pkgs) { - message(sprintf("\nInstalling %s", i)) - uvr_install(i) - library(i, character.only = TRUE) -} - - -# Example data -all_pkgs <- rownames(available.packages()) -to_skip <- c( - "ABRSQOL", - "ACA", - "ACE.CoCo", - "ACEsimFit", - "ACNE", - "absorber", - "adapt4pv", - "adaptMCMC", - "addhaz", - "ADDT", - "ahaz", - "arm", - "arules", - "arulesCBA", - "aster2", - "BayesFactor", - "bc3net", - "bgsmtr", - "biglasso", - "BinNonNor", - "BinNor", - "bioassayR", - "birankr", - "BiRewire", - "bolasso", - "Boptbd", - "Brobdingnag", - "BSW", - "BTLLasso", - "bvartools", - "cAIC4", - "Category", - "celda", - "centiserve", - "cjoint", - "clinical", - "clipper", - "CodataGS", - "conos", - "CopulaInference", - "covEB", - "cplm", - "CRTgeeDR", - "cthreshER", - "ctmcmove", - "curephEM", - "CVST", - "dcGSA", - "dclone", - "dcsvm", - "DelayedArray", - "dglars", - "dhglm", - "disordR", - "distrom", - "dmm", - "DNABarcodes", - "DoubleCone", - "DRR", - "DTRlearn2", - "DWDLargeR", - "eds", - "EMCluster", - "EMMREML", - "evalITR", - "EventPointer", - "evola", - "excursions", - "expm", - "fanc", - "FAS", - "fastadi", - "fastPLS", - "fastRG", - "fdaPDE", - "flare", - "FoReco", - "frailtyHL", - "freebird", - "FSTpackage", - "gamlr", - "gamlss.lasso", - "gamm4", - "gbmt", - "gdim", - "gdistance", - "GeDS", - "geeM", - "genlasso", - "GenOrd", - "GenoScan", - "geomorph", - "geostatsp", - "GhostKnockoff", - "GIGSEA", - "GlarmaVarSel", - "glmm", - "glmmrBase", - "glmmrOptim", - "glmnet", - "glober", - "GPvam", - "graphpcor", - "gremlin", - "growthrate", - "grpCox", - "GSD", - "HelpersMG", - "hglm", - "hglm.data", - "hibayes", - "hierSDR", - "HMTL", - "hsem", - "ibmdbR", - "inca", - "INLAspacetime", - "INLAtools", - "invertiforms", - "irlba", - "islasso", - "ISLET", - "isotonic.pen", - "jordan", - "kinship2", - "KnockoffScreen", - "lcpm", - "leidenAlg", - "lfe", - "lingmatch", - "LKT", - "lme4", - "lme4breeding", - "lme4GS", - "logcondiscr", - "LPmerge", - "LRMF3", - "MAP", - "marcox", - "markovchain", - "MatrixExtra", - "matter", - "MBC", - "mcen", - "mclogit", - "MCMCglmm", - "mdhglm", - "MDPtoolbox", - "mediation", - "mefa4", - "metafor", - "mgwrsar", - "mi", - "midasml", - "mind", - "monocle", - "msda", - "MuData", - "MultiGlarmaVarSel", - "MultiOrd", - "MultiVarSel", - "mvglmmRank", - "N2R", - "nadiv", - "NBtsVarSel", - "NegBinBetaBinreg", - "NetworkRiskMeasures", - "neuroim2", - "NOISeq", - "numbat", - "optbdmaeAT", - "optimbase", - "OptimModel", - "optrcdmaeAT", - "OrdNor", - "pagoda2", - "PCovR", - "pedgene", - "pedigree", - "pedigreemm", - "pense", - "PERMANOVA", - "phateR", - "PhylogeneticEM", - "pleio", - "POINT", - "PoisBinNonNor", - "PoisBinOrd", - "PoisBinOrdNonNor", - "PoisBinOrdNor", - "PoisNonNor", - "PoisNor", - "PRISMA", - "ProbitSpatial", - "prodest", - "psqn", - "qlcMatrix", - "qpcR", - "QRM", - "quadrupen", - "QZ", - "ramps", - "randnet", - "randPedPCA", - "rBMF", - "RCBR", - "RealVAMS", - "REBayes", - "recommenderlab", - "Rediscover", - "reglogit", - "RESET", - "RGE", - "RGENERATEPREC", - "riemtan", - "RNewsflow", - "robustlmm", - "rsparse", - "rSPDE", - "rwc", - "S4Arrays", - "saeMSPE", - "sbw", - "scITD", - "scoup", - "sdwd", - "SEAGLE", - "sensory", - "serrsBayes", - "sglasso", - "sharpPen", - "SiPSiC", - "SKAT", - "snpReady", - "snpStats", - "softImpute", - "sommer", - "soptdmaeA", - "SOR", - "SparseArray", - "SparseChol", - "sparseLRMatrix", - "sparsenet", - "sparsenetgls", - "sparsestep", - "spatialprobit", - "spatialreg", - "spatstat.sparse", - "speedglm", - "sRDA", - "sSDR", - "ssfa", - "stcos", - "StratifiedSampling", - "sureLDA", - "survey", - "surveyvoi", - "svydiags", - "systemfit", - "TargetScore", - "text2map", - "textir", - "textmineR", - "textTinyR", - "tmvtnorm", - "TPEA", - "triversity", - "tsapp", - "tvReg", - "uwot", - "vagam", - "VAM", - "WaveSampling", - "WGScan", - "wordspace", - "workflowsets", - "ACSSpack", - "ADDT", - "AER" -) - -# Find the position of the last package in to_skip within all_pkgs -last_skip <- tail(to_skip, 1) - -# Find its position in all_pkgs (returns NA if not found) -start_pos <- match(last_skip, all_pkgs) - -# If not found, start from the beginning; else, start after last_skip -if (is.na(start_pos)) { - to_process <- all_pkgs -} else { - to_process <- all_pkgs[(start_pos + 1):length(all_pkgs)] -} - -if (length(to_process) == 0) { - message("All packages have been processed.") -} else { - for (i in to_process) { - message(sprintf("\nInstalling %s", i)) - uvr_install(i) - library(i, character.only = TRUE) - } - # Update to_skip to include all up to the last processed - to_skip <- all_pkgs[1:(last_skip_pos + length(to_process))] -} diff --git a/local/tests/test-build-all-args.R b/local/tests/test-build-all-args.R deleted file mode 100644 index 3308fc3..0000000 --- a/local/tests/test-build-all-args.R +++ /dev/null @@ -1,13 +0,0 @@ -source(file.path("..", "r-minor-helpers.R")) - -test_that("parse_build_args splits flags from positionals", { - a <- parse_build_args(c("--sensitive-only", "4", "2", "8")) - expect_true(a$sensitive_only) - expect_identical(a$split_into, 4L) - expect_identical(a$split_index, 2L) - expect_identical(a$ncpus, 8L) - - b <- parse_build_args(c("4", "2", "8")) - expect_false(b$sensitive_only) - expect_identical(b$split_into, 4L) -}) diff --git a/local/tests/test-failing-builds-classify.R b/local/tests/test-failing-builds-classify.R deleted file mode 100644 index d4df9f5..0000000 --- a/local/tests/test-failing-builds-classify.R +++ /dev/null @@ -1,165 +0,0 @@ -source(file.path("..", "failing-builds-classify.R")) - -test_that("normalise_error collapses temp paths, versions, and package tokens", { - a <- normalise_error( - "In file /tmp/RtmpAb12/foo.c: RcppParallel 5.1.9 failed at 0xdeadbeef", - package = "RcppParallel" - ) - expect_false(grepl("RtmpAb12", a)) - expect_false(grepl("5\\.1\\.9", a)) - expect_false(grepl("0xdeadbeef", a)) - expect_true(grepl("", a)) - expect_true(grepl("", a)) - - # Same root error across two versions collapses to one fingerprint. - e1 <- "StanHeaders 2.32.1: tbb/tbb_stddef.h: No such file or directory" - e2 <- "StanHeaders 2.33.0: tbb/tbb_stddef.h: No such file or directory" - expect_identical( - fingerprint_error(e1, "StanHeaders"), - fingerprint_error(e2, "StanHeaders") - ) -}) - -test_that("normalise_error is safe on NA/empty input", { - expect_identical(normalise_error(NA_character_), "") - expect_identical(normalise_error(""), "") - expect_identical(fingerprint_error(NA_character_), "") -}) - -test_that("fingerprint_error picks the salient error line, not the last line", { - txt <- paste( - "* installing *source* package 'foo' ...", - "error: bar.h: No such file or directory", - "* removing '/tmp/lib/foo'", - sep = "\n" - ) - fp <- fingerprint_error(txt, "foo") - expect_true(grepl("no such file", fp)) - expect_false(grepl("removing", fp)) -}) - -test_that("classify_error matches the removed TBB header signature (makevars, auto)", { - sig <- classify_error( - "fatal error: tbb/tbb_stddef.h: No such file or directory" - ) - expect_identical(sig$id, "tbb-stddef-removed") - expect_identical(sig$tier, "makevars") - expect_true(sig$auto) - expect_true(sig$matched) -}) - -test_that("classify_error matches RcppParallel bundled-TBB failures", { - sig <- classify_error( - "Error: USE_TBB=Linux is not supported on this toolchain" - ) - expect_identical(sig$id, "rcppparallel-bundled-tbb") - expect_identical(sig$tier, "patch") - expect_true(sig$auto) -}) - -test_that("system libuv link leak is classified but stays human-only (novel diff)", { - sig <- classify_error("cannot open shared object file: libuv.so.1") - expect_identical(sig$id, "system-libuv-link-leak") - expect_true(sig$matched) - expect_false(sig$auto) -}) - -test_that("unknown signatures are never guessed at", { - sig <- classify_error("segfault: memory not mapped at address") - expect_identical(sig$id, "unclassified") - expect_false(sig$matched) - expect_false(sig$auto) - expect_true(is.na(sig$tier)) -}) - -test_that("propose_registry_entry fills a schema-valid entry for a known lever", { - sig <- classify_error("tbb/tbb_stddef.h: No such file") - json <- propose_registry_entry(sig, "StanHeaders", c("alpine", "ubuntu-2604")) - entry <- jsonlite::fromJSON(json, simplifyVector = FALSE) - expect_identical(entry$package, "StanHeaders") - expect_identical(entry$versions, "*") - expect_identical(entry$platforms, list("alpine", "ubuntu-2604")) - expect_identical(entry$makevars$CPPFLAGS, "-DTBB_INTERFACE_NEW") - expect_true(nzchar(entry$reason)) - - # No template -> no proposal (unclassified path). - expect_null(propose_registry_entry(classify_error("weird"), "x", "alpine")) -}) - -test_that("RcppParallel dependents are blocked, not proposed a per-package patch", { - # Hundreds of packages fail on ubuntu-2604 only because their RcppParallel - # dependency fails to build, so they carry RcppParallel's TBB error text. - failures <- data.frame( - name = c("ACEsimFit", "AovBay", "AdaptGauss"), - platform = "ubuntu-2604", - arch = "amd64", - error_text = "Error: USE_TBB=Linux is not supported on this toolchain", - stringsAsFactors = FALSE - ) - report <- build_triage_report(failures, registered_pkgs = character(0L)) - grp <- Filter(function(g) g$signature == "rcppparallel-bundled-tbb", report)[[ - 1L - ]] - # No bogus per-dependent entries (the patch targets RcppParallel's source). - expect_null(grp$proposed_entries) - expect_identical(grp$blocked_on, "RcppParallel") -}) - -test_that("failing_dependency names the dependency that actually failed", { - # A leaf package (BFpack) that fails building its rstan dependency. - txt <- paste( - "Error in installing dependencies for package BFpack with tag 1.6.1", - "Failed to build source package rstan.", - "ERROR: compilation failed for package ‘rstan’", - sep = "\n" - ) - expect_identical(failing_dependency(txt, "BFpack"), "rstan") - # A package failing in its OWN compilation is not a cascade. - own <- "ERROR: compilation failed for package ‘BFpack’" - expect_true(is.na(failing_dependency(own, "BFpack"))) - expect_true(is.na(failing_dependency(NA_character_, "x"))) - expect_true(is.na(failing_dependency("some unrelated error", "x"))) -}) - -test_that("Stan packages blocked on rstan are not proposed a per-package entry", { - # BFpack/GMLTM fail building rstan; the tbb error is in rstan's compile. - cascade <- paste( - "Failed to build source package rstan.", - "fatal error: tbb/tbb_stddef.h: No such file or directory", - sep = "\n" - ) - failures <- data.frame( - name = c("BFpack", "GMLTM", "someOwnPkg"), - platform = "ubuntu-2604", - arch = "amd64", - error_text = c( - cascade, - cascade, - # someOwnPkg fails in its OWN compile on the same header -> fixable. - "someOwnPkg.cpp: fatal error: tbb/tbb_stddef.h: No such file or directory" - ), - stringsAsFactors = FALSE - ) - report <- build_triage_report(failures, registered_pkgs = character(0L)) - grp <- Filter(function(g) g$signature == "tbb-stddef-removed", report)[[1L]] - # Only the own-compile package is proposed; the rstan cascades are blocked. - expect_identical(names(grp$proposed_entries), "someOwnPkg") - expect_setequal(grp$blocked_packages, c("BFpack", "GMLTM")) - expect_identical(grp$blocked_on, "rstan") -}) - -test_that("RcppParallel itself is still proposed when it is the failing package", { - failures <- data.frame( - name = "RcppParallel", - platform = "ubuntu-2604", - arch = "amd64", - error_text = "Error: USE_TBB=Linux is not supported on this toolchain", - stringsAsFactors = FALSE - ) - report <- build_triage_report(failures, registered_pkgs = character(0L)) - grp <- report[[1L]] - expect_identical(grp$signature, "rcppparallel-bundled-tbb") - expect_false(is.null(grp$proposed_entries)) - expect_true("RcppParallel" %in% names(grp$proposed_entries)) - expect_null(grp$blocked_on) # RcppParallel is the target, not a dependent -}) diff --git a/local/tests/test-newer-r-helpers.R b/local/tests/test-newer-r-helpers.R deleted file mode 100644 index ad4ca49..0000000 --- a/local/tests/test-newer-r-helpers.R +++ /dev/null @@ -1,149 +0,0 @@ -source(file.path("..", "newer-r-helpers.R")) -source(file.path("..", "rebuild-missing-helpers.R")) - -test_that("R constraints respect patch versions, bounds, and missing fields", { - expect_true(r_requirement_satisfied(NA_character_, "4.4.3")) - expect_true(r_requirement_satisfied( - "Matrix (>= 1.4-0), R (>= 4.5.0)", - "4.5.3" - )) - expect_false(r_requirement_satisfied("R (>= 4.5.0)", "4.4.3")) - expect_false(r_requirement_satisfied("R (>= 4.5.4)", "4.5.3")) - expect_true(r_requirement_satisfied("R (>= 4.5), R (< 4.6)", "4.5.3")) - expect_false(r_requirement_satisfied("R (>= 4.5), R (< 4.6)", "4.6.0")) - expect_true(r_requirement_satisfied("R (== 4.5.3)", "4.5.3")) - expect_true(r_requirement_satisfied("R (> 4.5.2), R (<= 4.5.3)", "4.5.3")) - expect_true(r_requirement_satisfied("R, Rcpp (>= 1.0)", "4.4.3")) - expect_error(r_requirement_satisfied("R (~ 4.5)", "4.5.3"), "Cannot parse") -}) - -fixture <- function() { - data.frame( - Package = c( - "arules", - "arulesSequences", - "indirect", - "optional", - "ordinary", - "future", - "blocked" - ), - Version = rep("1.0", 7L), - Depends = c( - "R (>= 4.5.0)", - "arules", - NA, - NA, - "R (>= 4.0)", - "R (>= 4.7)", - NA - ), - Imports = c(NA, NA, "arulesSequences", NA, NA, NA, "arules, future"), - LinkingTo = NA_character_, - Suggests = c(NA, NA, NA, "arules", NA, NA, NA) - ) -} - -test_that("every compatible newer minor includes required dependents only", { - db <- fixture() - for (target in c("4.5.3", "4.6.0")) { - expect_identical( - newer_r_candidates(db, "4.4.3", target)$Package, - c("arules", "arulesSequences", "indirect") - ) - } - expect_equal(nrow(newer_r_candidates(db, "4.4.3", "4.4.3")), 0L) - expect_equal(nrow(newer_r_candidates(db, "4.5.3", "4.4.3")), 0L) - expect_equal(nrow(newer_r_candidates(db, "4.5.3", "4.6.0")), 0L) -}) - -test_that("LinkingTo, dependency cycles, Windows and empty metadata are handled", { - db <- fixture() - db$LinkingTo[5L] <- "arules" - db$Imports[1L] <- "ordinary" - db$OS_type <- c(NA, "windows", rep(NA_character_, 5L)) - expect_identical( - newer_r_candidates(db, "4.4.3", "4.6.0")$Package, - c("arules", "indirect", "ordinary") - ) - expect_equal(nrow(newer_r_candidates(db[FALSE, ], "4.4.3", "4.6.0")), 0L) -}) - -test_that("R-devel Recommended copies cannot block ordinary CRAN dependencies", { - db <- fixture() - db$Path <- NA_character_ - future_copy <- db[1L, ] - future_copy$Depends <- "R (>= 4.7)" - future_copy$Path <- "4.7.0/Recommended" - expect_identical( - newer_r_candidates(rbind(future_copy, db), "4.4.3", "4.6.1")$Package, - c("arules", "arulesSequences", "indirect") - ) -}) - -candidates <- function() { - data.frame( - Package = c( - "flat_done", - "flat_todo", - "minor_done", - "minor_flat_only", - "unclassified", - "fallback" - ), - Version = c("1.0", "1.0", "2.0", "2.0", "3.0", "4.0") - ) -} - -verdicts <- c( - flat_done_1.0 = FALSE, - flat_todo_1.0 = FALSE, - minor_done_2.0 = TRUE, - minor_flat_only_2.0 = TRUE, - fallback_4.0 = FALSE -) - -flat <- c( - flat_done_1.0.tar.gz = "aaa", - minor_flat_only_2.0.tar.gz = "bbb", - unclassified_3.0.tar.gz = "ccc", - fallback_4.0.tar.gz = "c0ffee" -) -minor <- c(minor_done_2.0.tar.gz = "ddd") -md5 <- c(fallback_4.0 = "c0ffee") - -test_that("newer_r_outstanding skips only binaries at the routed path", { - expect_identical( - newer_r_outstanding(candidates(), verdicts, flat, minor, md5)$Package, - # flat_todo: absent; minor_flat_only: sensitive, so a flat copy does not - # count; unclassified: no verdict, left to bincraft; fallback: CRAN source - c("flat_todo", "minor_flat_only", "unclassified", "fallback") - ) -}) - -test_that("newer_r_outstanding keeps a route whose slot could not be listed", { - expect_identical( - newer_r_outstanding(candidates(), verdicts, NULL, minor, md5)$Package, - c("flat_done", "flat_todo", "minor_flat_only", "unclassified", "fallback") - ) - expect_identical( - newer_r_outstanding(candidates(), verdicts, flat, NULL, md5)$Package, - c("flat_todo", "minor_done", "minor_flat_only", "unclassified", "fallback") - ) -}) - -test_that("newer_r_outstanding without verdicts or listings changes nothing", { - expect_identical( - newer_r_outstanding(candidates(), logical(), flat, minor, md5), - candidates() - ) - empty <- stats::setNames(character(), character()) - expect_identical( - nrow(newer_r_outstanding(candidates(), verdicts, empty, empty, md5)), - nrow(candidates()) - ) - expect_identical( - nrow(newer_r_outstanding(candidates()[0L, ], verdicts, flat, minor, md5)), - 0L - ) -}) diff --git a/local/tests/test-proposal-tracking-lib.R b/local/tests/test-proposal-tracking-lib.R deleted file mode 100644 index 869d2b3..0000000 --- a/local/tests/test-proposal-tracking-lib.R +++ /dev/null @@ -1,246 +0,0 @@ -source(file.path("..", "proposal-tracking-lib.R")) -source(file.path("..", "failing-builds-classify.R")) - -mk_failures <- function() { - data.frame( - name = c("StanHeaders", "rstan", "RcppParallel", "somepkg"), - platform = c("alpine-321", "alpine-321", "alpine-320", "redhat-9"), - arch = c("amd64", "arm64", "amd64", "amd64"), - error_text = c( - "fatal error: tbb/tbb_stddef.h: No such file or directory", - "In file: tbb/tbb_stddef.h: No such file or directory", - "Error: USE_TBB=Linux is not supported; bundled TBB on musl", - "some unmatched failure" - ), - stringsAsFactors = FALSE - ) -} - -test_that("merge_ledger appends new proposals and preserves existing history", { - existing <- list(list( - package = "fs", - signature = "system-libuv-link-leak", - status = "merged" - )) - new <- list( - list( - package = "fs", - signature = "system-libuv-link-leak", - status = "proposed" - ), - list( - package = "StanHeaders", - signature = "tbb-stddef-removed", - status = "proposed" - ) - ) - merged <- merge_ledger(existing, new) - expect_length(merged, 2L) # fs is deduped, StanHeaders added - fs <- Filter(function(r) r$package == "fs", merged)[[1L]] - expect_identical(fs$status, "merged") # existing status preserved, not clobbered -}) - -test_that("merge_ledger handles an empty/NULL starting ledger", { - new <- list(list(package = "x", signature = "s")) - expect_length(merge_ledger(NULL, new), 1L) - expect_length(merge_ledger(list(), new), 1L) -}) - -test_that("dedupe_candidates keeps single-signature pkgs, routes conflicts to triage", { - candidates <- list( - list(package = "StanHeaders", signature = "tbb-stddef-removed"), - list(package = "hmmTMB", signature = "tbb-stddef-removed"), - list(package = "hmmTMB", signature = "rcppparallel-bundled-tbb") # conflict - ) - out <- dedupe_candidates(candidates) - kept <- vapply(out$keep, function(c) c$package, character(1L)) - expect_identical(sort(kept), "StanHeaders") # hmmTMB dropped as ambiguous - expect_true("hmmTMB" %in% names(out$ambiguous)) - expect_setequal( - out$ambiguous$hmmTMB, - c("tbb-stddef-removed", "rcppparallel-bundled-tbb") - ) -}) - -test_that("dedupe_candidates collapses a package repeated under one signature", { - candidates <- list( - list(package = "rstan", signature = "tbb-stddef-removed"), - list(package = "rstan", signature = "tbb-stddef-removed") - ) - out <- dedupe_candidates(candidates) - expect_length(out$keep, 1L) - expect_length(out$ambiguous, 0L) -}) - -test_that("dedupe_candidates handles the empty list", { - out <- dedupe_candidates(list()) - expect_length(out$keep, 0L) - expect_length(out$ambiguous, 0L) -}) - -test_that("signature_hit_rate splits addressed vs open per signature", { - report <- build_triage_report(mk_failures(), registered_pkgs = "RcppParallel") - hit <- signature_hit_rate(report, registered_pkgs = "RcppParallel") - tbb <- Filter(function(h) h$signature == "tbb-stddef-removed", hit)[[1L]] - expect_identical(tbb$packages, 2L) # StanHeaders + rstan - expect_identical(tbb$addressed, 0L) - expect_identical(tbb$open, 2L) - expect_true(tbb$auto_proposable) - - rcpp <- Filter(function(h) h$signature == "rcppparallel-bundled-tbb", hit)[[ - 1L - ]] - expect_identical(rcpp$addressed, 1L) # already registered - expect_identical(rcpp$open, 0L) - - # Unclassified failures never appear as a signature. - expect_false( - "unclassified" %in% vapply(hit, function(h) h$signature, character(1L)) - ) -}) - -test_that("proposed_vs_merged marks a package merged once it is registered", { - ledger <- list( - list( - package = "StanHeaders", - signature = "tbb-stddef-removed", - status = "proposed" - ), - list( - package = "rstan", - signature = "tbb-stddef-removed", - status = "proposed" - ) - ) - pvm <- proposed_vs_merged(ledger, registered_pkgs = "StanHeaders") - expect_identical(pvm$total, 2L) - expect_identical(pvm$merged, 1L) - stan <- Filter(function(r) r$package == "StanHeaders", pvm$records)[[1L]] - expect_identical(stan$status, "merged") -}) - -test_that("unclassified_summary ranks unknown groups and caps output", { - failures <- data.frame( - name = c("a", "b", "c", "d", "solo"), - platform = "ubuntu-2604", - arch = "amd64", - error_text = c( - # 4 builds share one unknown fingerprint; 1 build a different unknown. - rep("mystery linker meltdown at stage 3", 4L), - "a totally different unknown boom" - ), - stringsAsFactors = FALSE - ) - report <- build_triage_report(failures, registered_pkgs = character(0L)) - s <- unclassified_summary(report, max_groups = 30L, max_pkgs = 2L) - expect_identical(s$total_groups, 2L) - expect_identical(s$total_builds, 5L) - # Largest group first, and its example packages are capped at max_pkgs. - expect_identical(s$groups[[1L]]$build_count, 4L) - expect_length(s$groups[[1L]]$packages, 2L) - expect_true(s$groups[[1L]]$packages_truncated) - - # max_groups cap is reported, not silently dropped. - capped <- unclassified_summary(report, max_groups = 1L) - expect_length(capped$groups, 1L) - expect_identical(capped$dropped_groups, 1L) -}) - -test_that("blocked_by_dependency aggregates across groups, deduped and ranked", { - # RcppParallel dependents split across platforms/fingerprints -> separate - # groups, but one aggregated line; a dependent seen twice is counted once. - failures <- data.frame( - name = c("ACEsimFit", "AovBay", "AdaptGauss", "ACEsimFit", "loner"), - platform = c( - "ubuntu-2604", - "ubuntu-2604", - "alpine-324", - "alpine-324", - "ubuntu-2604" - ), - arch = "amd64", - error_text = c( - rep("Error: USE_TBB=Linux is not supported on this toolchain", 4L), - "Failed to build source package rstan.\nfatal error: tbb/tbb_stddef.h" - ), - stringsAsFactors = FALSE - ) - report <- build_triage_report(failures, registered_pkgs = character(0L)) - agg <- blocked_by_dependency(report, max_pkgs = 2L) - deps <- vapply(agg, function(b) b$dependency, character(1L)) - expect_true("RcppParallel" %in% deps && "rstan" %in% deps) - rcpp <- Filter(function(b) b$dependency == "RcppParallel", agg)[[1L]] - # ACEsimFit appears in two groups -> counted once (3 distinct dependents). - expect_identical(rcpp$n_packages, 3L) - expect_true(rcpp$packages_truncated) # capped at max_pkgs = 2 - # Ranked by dependent count: RcppParallel (3) before rstan (1). - expect_identical(deps[[1L]], "RcppParallel") -}) - -test_that("entry_applies_to_os matches codename, family, and wildcard", { - expect_true(entry_applies_to_os(list("ubuntu-2604"), "ubuntu-2604")) - expect_true(entry_applies_to_os(list("ubuntu"), "ubuntu-2604")) # family - expect_true(entry_applies_to_os(list("*"), "ubuntu-2604")) - expect_true(entry_applies_to_os(list("alpine", "ubuntu-2604"), "ubuntu-2604")) - expect_false(entry_applies_to_os(list("alpine-324"), "ubuntu-2604")) - expect_false(entry_applies_to_os(list("ubuntu-2404"), "ubuntu-2604")) # other codename -}) - -test_that("new_registry_packages returns only added entries for the platform", { - base <- list( - list( - package = "RcppParallel", - platforms = list("alpine", "ubuntu-2604"), - versions = "*" - ) - ) - current <- list( - base[[1L]], # unchanged -> not "new" - list(package = "BFpack", platforms = list("ubuntu-2604"), versions = "*"), - list( - package = "someAlpinePkg", - platforms = list("alpine-324"), - versions = "*" - ) - ) - # For ubuntu-2604: only the newly-added BFpack (RcppParallel is unchanged, - # someAlpinePkg does not apply to this OS). - expect_identical( - new_registry_packages(current, base, os = "ubuntu-2604"), - "BFpack" - ) - # For alpine-324: the alpine package is new and applies. - expect_identical( - new_registry_packages(current, base, os = "alpine-324"), - "someAlpinePkg" - ) - # Without an OS filter, both additions are returned. - expect_setequal( - new_registry_packages(current, base), - c("BFpack", "someAlpinePkg") - ) - # A changed platform set on the same package counts as a new entry. - widened <- list(list( - package = "RcppParallel", - platforms = list("*"), - versions = "*" - )) - expect_identical(new_registry_packages(widened, base), "RcppParallel") -}) - -test_that("retirement_candidates flags entries whose package no longer fails", { - entries <- list( - list(package = "RcppParallel"), - list(package = "oldpkg") - ) - # RcppParallel still fails; oldpkg does not -> only oldpkg is retirable. - out <- retirement_candidates( - entries, - failing_pkgs = c("RcppParallel", "StanHeaders") - ) - expect_identical(out, "oldpkg") - expect_length( - retirement_candidates(entries, failing_pkgs = c("RcppParallel", "oldpkg")), - 0L - ) -}) diff --git a/local/tests/test-r-minor-helpers.R b/local/tests/test-r-minor-helpers.R deleted file mode 100644 index 2beb6c1..0000000 --- a/local/tests/test-r-minor-helpers.R +++ /dev/null @@ -1,45 +0,0 @@ -source(file.path("..", "r-minor-helpers.R")) - -test_that("pure-r (NeedsCompilation != yes) is not sensitive", { - expect_identical(classify_from_metadata("no", NA, c("Rcpp")), "not-sensitive") - expect_identical( - classify_from_metadata("", "Rcpp", c("Rcpp")), - "not-sensitive" - ) -}) - -test_that("LinkingTo a risky dep is sensitive (version constraints stripped)", { - expect_identical( - classify_from_metadata("yes", "Rcpp (>= 1.0)", c("Rcpp")), - "sensitive" - ) - expect_identical( - classify_from_metadata("yes", "R6,\n cpp11", c("Rcpp", "cpp11")), - "sensitive" - ) -}) - -test_that("compiled but no risky LinkingTo is ambiguous (needs source)", { - expect_identical( - classify_from_metadata("yes", "R6", c("Rcpp", "cpp11")), - "ambiguous" - ) - expect_identical(classify_from_metadata("yes", NA, c("Rcpp")), "ambiguous") -}) - -test_that("codename_platform names the single_builds platform", { - expect_identical(codename_platform("alpine325"), "alpine-325") - expect_identical(codename_platform("rhel9"), "redhat-9") - expect_identical(codename_platform("noble"), "ubuntu-2404") - expect_identical(codename_platform("resolute"), "ubuntu-2604") - expect_identical(codename_platform("bogus"), NA_character_) -}) - -test_that("build_deadline reads BUILD_DEADLINE and defaults to none", { - expect_identical(build_deadline(""), Inf) - expect_identical(build_deadline("not a number"), Inf) - expect_identical(build_deadline("1700000000"), 1700000000) - expect_false(deadline_reached(Inf)) - expect_true(deadline_reached(100, now = 100)) - expect_false(deadline_reached(100, now = 99)) -}) diff --git a/local/tests/test-rebuild-missing.R b/local/tests/test-rebuild-missing.R deleted file mode 100644 index a5e70b9..0000000 --- a/local/tests/test-rebuild-missing.R +++ /dev/null @@ -1,94 +0,0 @@ -source(file.path("..", "rebuild-missing-helpers.R")) - -test_that("shard_slice partitions the list without gaps or overlap", { - pkgs <- letters[1:10] - parts <- lapply(1:3, function(i) shard_slice(pkgs, 3, i)) - - expect_identical(parts[[1]], c("a", "d", "g", "j")) - expect_identical(parts[[2]], c("b", "e", "h")) - expect_identical(parts[[3]], c("c", "f", "i")) - - expect_identical(sort(unlist(parts)), sort(pkgs)) - expect_identical(anyDuplicated(unlist(parts)), 0L) -}) - -test_that("shard_slice is deterministic and survives short lists", { - expect_identical( - shard_slice(letters[1:10], 3, 2), - shard_slice(letters[1:10], 3, 2) - ) - expect_identical(shard_slice(character(0), 3, 1), character(0)) - # more shards than packages: the tail shards get nothing rather than erroring - expect_identical(shard_slice(c("a"), 3, 1), "a") - expect_identical(shard_slice(c("a"), 3, 2), character(0)) -}) - -test_that("shard_slice rejects an out-of-range index", { - expect_error(shard_slice(letters, 3, 4), "split_index") - expect_error(shard_slice(letters, 3, 0), "split_index") -}) - -test_that("outstanding_packages keeps source fallbacks and drops real binaries", { - cran_version <- c(httr = "1.4.8", R6 = "2.6.1", curl = "7.1.0") - cran_md5 <- c( - httr_1.4.8 = "8756015b94a9cff6f410ca4de8557f12", - R6_2.6.1 = "f01b1787f12797c29194d63c9afd5d70", - curl_7.1.0 = "8af2ccbf5d85dc18866f45f1f26f348d" - ) - etag <- c( - # byte-identical to CRAN: the build never happened - "httr_1.4.8.tar.gz" = "8756015b94a9cff6f410ca4de8557f12", - # a real binary was published - "R6_2.6.1.tar.gz" = "9d6087ee9adda3f0a3b8067cfc652c05" - # curl has no object at all - ) - - out <- outstanding_packages( - c("httr", "R6", "curl"), - etag, - cran_version, - cran_md5 - ) - expect_identical(out, c("httr", "curl")) -}) - -test_that("outstanding_packages treats unknowns as already built", { - cran_version <- c(a = "1.0", b = "1.0") - cran_md5 <- c(a_1.0 = "aaaa") - - # a multipart ETag carries no MD5, and `b` is missing from CRAN's index: - # neither may schedule a rebuild - etag <- c("a_1.0.tar.gz" = "abc-3", "b_1.0.tar.gz" = "bbbb") - - expect_identical( - outstanding_packages(c("a", "b"), etag, cran_version, cran_md5), - character(0) - ) -}) - -test_that("outstanding_packages keeps a package CRAN has no version for", { - out <- outstanding_packages( - "ghost", - c(), - c(other = "1.0"), - c(other_1.0 = "aaaa") - ) - expect_identical(out, "ghost") -}) - -test_that("outstanding_packages handles an empty list", { - expect_identical( - outstanding_packages(character(0), c(), c(), c()), - character(0) - ) -}) - -test_that("parse_rebuild_args defaults the budget", { - a <- parse_rebuild_args(c("3", "2")) - expect_identical(a$split_into, 3L) - expect_identical(a$split_index, 2L) - expect_identical(a$budget_hours, 20) - - b <- parse_rebuild_args(c("3", "2", "1.5")) - expect_identical(b$budget_hours, 1.5) -}) diff --git a/local/tests/test-seed-helpers.R b/local/tests/test-seed-helpers.R deleted file mode 100644 index 87fdd6a..0000000 --- a/local/tests/test-seed-helpers.R +++ /dev/null @@ -1,126 +0,0 @@ -source(file.path("..", "seed-helpers.R")) - -# A minimal tarball laid out like R CMD INSTALL --build output. -make_tarball <- function( - package = "R6", - version = "2.6.1", - built = "R 4.5.3; ; 2026-09-01 10:00:00 UTC; unix", - libs = FALSE -) { - root <- tempfile("pkg_") - dir.create(file.path(root, package, "R"), recursive = TRUE) - fields <- c(Package = package, Version = version) - if (!is.na(built)) { - fields <- c(fields, Built = built) - } - write.dcf(t(fields), file.path(root, package, "DESCRIPTION")) - writeLines("", file.path(root, package, "R", package)) - if (libs) { - dir.create(file.path(root, package, "libs")) - writeLines("", file.path(root, package, "libs", paste0(package, ".so"))) - } - tarball <- tempfile(fileext = ".tar.gz") - old <- setwd(root) - on.exit(setwd(old), add = TRUE) - utils::tar(tarball, package, compression = "gzip", tar = "internal") - tarball -} - -portable <- function(t) { - list(inspected = TRUE, sensitive = FALSE, unsupported = character()) -} - -test_that("seed_verdict accepts a pure-R binary from the target minor", { - v <- seed_verdict(make_tarball(), "R6", "2.6.1", "4.5", portable) - expect_true(v$seed) - expect_identical(v$reason, "seeded") -}) - -test_that("seed_verdict refuses what a fresh build would not publish flat", { - verdict <- function(tarball, minor = "4.5", abi = portable) { - seed_verdict(tarball, "R6", "2.6.1", minor, abi)$reason - } - expect_identical(verdict(make_tarball(built = NA)), "source") - expect_identical( - verdict(make_tarball( - built = "R 4.5.3; x86_64-pc-linux-musl; 2026-09-01; unix" - )), - "compiled" - ) - expect_identical(verdict(make_tarball(libs = TRUE)), "compiled") - expect_identical(verdict(make_tarball(), minor = "4.6"), "r-minor") - expect_identical(verdict(make_tarball(version = "2.6.0")), "mismatch") - # Unknown is a refusal, as is a verdict that some minor cannot load it. - expect_identical( - verdict(make_tarball(), abi = function(t) list(inspected = FALSE)), - "abi" - ) - expect_identical( - verdict( - make_tarball(), - abi = function(t) list(inspected = TRUE, sensitive = TRUE) - ), - "abi" - ) - junk <- tempfile(fileext = ".tar.gz") - writeLines("not a tarball", junk) - expect_identical(verdict(junk), "unreadable") -}) - -test_that("seed_candidates keeps only uncopied pure-R binaries in scope", { - donor <- c( - "R6_2.6.1.tar.gz", - "Archive/R6/R6_2.5.1.tar.gz", - "curl_7.0.0.tar.gz", - "4.6/R6_2.6.1.tar.gz", - "glue_1.8.0.tar.gz", - "gone_1.0.tar.gz", - "done_1.0.tar.gz", - "skipme_1.0.tar.gz", - "PACKAGES.tar.gz" - ) - etags <- c("a", "b", "c", "d", "c0ffee", "e", "f", "g", "h") - out <- seed_candidates( - donor, - etags, - target_keys = c("done_1.0.tar.gz", "4.6/R6_2.5.1.tar.gz"), - release_pkgs = c("R6", "curl", "glue", "done", "skipme"), - compiled_pkgs = "curl", - cran_md5 = c(glue_1.8.0 = "c0ffee", R6_2.6.1 = "zzz"), - exclude = "skipme" - ) - expect_identical(out$key, c("R6_2.6.1.tar.gz", "Archive/R6/R6_2.5.1.tar.gz")) - expect_identical(out$package, c("R6", "R6")) - expect_identical(out$version, c("2.6.1", "2.5.1")) -}) - -test_that("seed_candidates copies a version listed twice once, flat first", { - out <- seed_candidates( - c("Archive/R6/R6_2.6.1.tar.gz", "R6_2.6.1.tar.gz"), - c("a", "a"), - character(), - "R6", - character(), - character() - ) - expect_identical(out$key, "R6_2.6.1.tar.gz") -}) - -test_that("parse_built separates the R version from the platform", { - b <- parse_built("R 4.5.3; ; 2026-09-01 10:00:00 UTC; unix") - expect_identical(b$r_version, "4.5.3") - expect_identical(b$platform, "") - expect_identical( - parse_built("R 4.4.3; aarch64-alpine-linux-musl; 2026; unix")$platform, - "aarch64-alpine-linux-musl" - ) -}) - -test_that("codename_family groups versions of one distribution", { - expect_identical(codename_family("alpine325"), "alpine") - expect_identical(codename_family("alpine324"), codename_family("alpine325")) - expect_false(identical( - codename_family("rhel9"), - codename_family("alpine324") - )) -}) diff --git a/local/trial-build-patch.R b/local/trial-build-patch.R deleted file mode 100644 index 2229074..0000000 --- a/local/trial-build-patch.R +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env Rscript - -# Acceptance gate for a proposed registry patch (issue #115, step 3): build one -# package in isolation with the current `local/patches` registry applied, and -# report whether it succeeds. Nothing is uploaded, archived, or written to the -# metadata DB -- `patchhash` keeps the trial binary out of the real cache. -# -# Must run inside a build-env image (the same image the failing platform uses), -# because it invokes the real compiler toolchain via bincraft. -# -# Usage: -# Rscript local/trial-build-patch.R [tag] -# -# Exit status: 0 if the patched build succeeds, 1 otherwise -- so it can gate a -# CI step or a manual pre-merge check. - -args <- commandArgs(trailingOnly = TRUE) -if (length(args) < 1L) { - stop("usage: Rscript local/trial-build-patch.R [tag]") -} -package <- args[[1L]] -tag <- if (length(args) >= 2L) args[[2L]] else NULL - -script_path <- local({ - a <- commandArgs(trailingOnly = FALSE) - f <- sub("^--file=", "", a[grepl("^--file=", a)]) - if (length(f) == 1L && nzchar(f)) normalizePath(f) else NA_character_ -}) -patches_dir <- file.path( - if (is.na(script_path)) "local" else dirname(script_path), - "patches" -) - -suppressPackageStartupMessages(library(bincraft, quietly = TRUE)) - -cat(sprintf( - "Trial build: %s%s with registry %s (no upload/archive/metadata)\n", - package, - if (is.null(tag)) "" else sprintf(" @ %s", tag), - patches_dir -)) - -# build_binary_package() catches build failures internally and RETURNS "error" -# for the failed tag rather than throwing (bincraft >= v4.4.7), so inspect the -# return value -- checking only for a thrown exception reports a broken build as -# passing (false green). -res <- tryCatch( - bincraft::build_binary_package( - package, - tag_limit = 1L, - patches = patches_dir, - archive = FALSE, - upload = FALSE, - store_build_metadata = FALSE - ), - error = function(e) { - cat(sprintf("Trial build FAILED (threw): %s\n", conditionMessage(e))) - "error" - } -) -flat <- as.character(unlist(res)) -ok <- length(flat) > 0L && !("error" %in% flat) - -if (ok) { - cat(sprintf("Trial build OK: %s builds with the proposed patch.\n", package)) - q(status = 0) -} -q(status = 1) diff --git a/local/trial-build-registry.R b/local/trial-build-registry.R deleted file mode 100644 index 9708408..0000000 --- a/local/trial-build-registry.R +++ /dev/null @@ -1,163 +0,0 @@ -#!/usr/bin/env Rscript - -# Merge gate for the auto-patch PR (issue #115, step 3): for every registry -# entry the PR ADDS that applies to this platform, trial-build the package with -# the registry applied, in this platform's own build-env image. Nothing is -# uploaded, archived, or written to the metadata DB. -# -# Exit 0 only if every new entry's package builds; exit 1 if any fails, so it -# gates the PR. A platform with no new entries is a fast no-op. -# -# Usage (inside a build-env image): -# PLATFORM=ubuntu-2604 Rscript local/trial-build-registry.R [base_ref] -# base_ref git ref to diff the registry against (default: origin/main) - -options(error = function() { - cat("ERROR:", geterrmessage(), "\n", file = stdout()) - q(status = 1) -}) - -suppressPackageStartupMessages({ - library(jsonlite, quietly = TRUE) - library(bincraft, quietly = TRUE) -}) - -script_path <- local({ - a <- commandArgs(trailingOnly = FALSE) - f <- sub("^--file=", "", a[grepl("^--file=", a)]) - if (length(f) == 1L && nzchar(f)) normalizePath(f) else NA_character_ -}) -script_dir <- if (is.na(script_path)) "local" else dirname(script_path) -source(file.path(script_dir, "proposal-tracking-lib.R")) - -args <- commandArgs(trailingOnly = TRUE) -base_ref <- if (length(args) >= 1L) { - args[[1L]] -} else { - Sys.getenv("BASE_REF", "origin/main") -} -os <- Sys.getenv("PLATFORM", "") -if (!nzchar(os)) { - stop("PLATFORM env var is not set (e.g. ubuntu-2604).") -} - -patches_dir <- file.path(script_dir, "patches") -registry_file <- file.path(patches_dir, "registry.json") -current <- if (file.exists(registry_file)) { - jsonlite::fromJSON(registry_file, simplifyVector = FALSE) -} else { - list() -} -# Read the registry at base_ref. Fail loud if the ref or file can't be read: -# silently treating the base as empty would trial-build the WHOLE registry -# instead of just the entries the branch adds. -registry_rel <- "local/patches/registry.json" -# system2() with captured output runs via /bin/sh, so shell-quote the git args -# (refs contain "^{}" and ":" that the shell would otherwise mangle). -ref_ok <- suppressWarnings(system2( - "git", - shQuote(c( - "rev-parse", - "--verify", - "--quiet", - sprintf("%s^{commit}", base_ref) - )), - stdout = TRUE, - stderr = FALSE -)) -if (!is.null(attr(ref_ok, "status"))) { - stop(sprintf("base ref %s does not resolve to a commit.", base_ref)) -} -in_base <- suppressWarnings(system2( - "git", - shQuote(c("ls-tree", base_ref, "--", registry_rel)), - stdout = TRUE, - stderr = FALSE -)) -file_in_base <- length(in_base) > 0L && any(nzchar(in_base)) -base_json <- suppressWarnings(system2( - "git", - shQuote(c("show", sprintf("%s:%s", base_ref, registry_rel))), - stdout = TRUE, - stderr = FALSE -)) -show_ok <- is.null(attr(base_json, "status")) -if (file_in_base && !show_ok) { - stop(sprintf( - "could not read %s at %s; refusing to build the whole registry.", - registry_rel, - base_ref - )) -} -base <- if (show_ok && length(base_json) > 0L) { - jsonlite::fromJSON(paste(base_json, collapse = "\n"), simplifyVector = FALSE) -} else { - list() # file genuinely absent at base -> every entry is new -} - -pkgs <- new_registry_packages(current, base, os = os) -if (length(pkgs) == 0L) { - cat(sprintf( - "No new registry entries apply to %s; nothing to trial-build.\n", - os - )) - q(status = 0) -} - -cat(sprintf( - "Trial-building %d new registry %s on %s (vs %s):\n %s\n", - length(pkgs), - if (length(pkgs) == 1L) "entry" else "entries", - os, - base_ref, - toString(pkgs) -)) - -results <- vapply( - pkgs, - function(pkg) { - cat(sprintf("\n=== trial build: %s ===\n", pkg)) - # bincraft::build_binary_package() catches build failures internally and - # RETURNS "error" for the failed tag rather than throwing, so a green gate - # must inspect the return value -- checking only for a thrown exception - # reports a broken build as passing. - res <- tryCatch( - bincraft::build_binary_package( - pkg, - tag_limit = 1L, - patches = patches_dir, - archive = FALSE, - upload = FALSE, - store_build_metadata = FALSE - ), - error = function(e) { - cat(sprintf("FAILED %s (threw): %s\n", pkg, conditionMessage(e))) - "error" - } - ) - flat <- as.character(unlist(res)) - ok <- length(flat) > 0L && !("error" %in% flat) - if (!ok) { - cat(sprintf( - "FAILED %s: build did not succeed (result: %s)\n", - pkg, - if (length(flat) > 0L) toString(flat) else "" - )) - } - ok - }, - logical(1L) -) - -failed <- pkgs[!results] -cat(sprintf( - "\n%d/%d passed on %s.%s\n", - sum(results), - length(results), - os, - if (length(failed) > 0L) sprintf(" Failed: %s", toString(failed)) else "" -)) -if (length(failed) > 0L) { - q(status = 1) -} -q(status = 0) diff --git a/local/uvr-install.sh b/local/uvr-install.sh deleted file mode 100755 index f8c71eb..0000000 --- a/local/uvr-install.sh +++ /dev/null @@ -1,127 +0,0 @@ -#!/bin/sh -# Install R packages into the CI library with uvr (https://github.com/nbafrank/uvr). -# -# Usage: -# local/uvr-install.sh httr2 jsonlite -# local/uvr-install.sh forgejo::codefloe.com/rpkgs/bincraft@v4.4.3 -# -# Replaces `pak::pak(...)`. uvr is project-scoped: `uvr add` refuses to run -# outside a project and always writes to `.uvr/library/`, and only -# `uvr sync --library` can target an existing library. The project is therefore -# minted in a scratch directory under TMPDIR and thrown away afterwards; that -# also keeps `uvr init`'s `.Rprofile` out of the repo checkout, where it would -# hijack `.libPaths()` for every other R call in the pipeline. -# -# Pruning is a no-op here: uvr disables it whenever `--library` is passed, -# precisely because such a target may be shared (`/mnt/cache/R-pkgs` holds -# bincraft and its dependencies alongside whatever this script installs). -# -# System dependencies come from uvr's vendored r-system-requirements rules, -# with explicit prerequisites below for gaps in Alpine support. -# -# Environment: -# UVR_R_BIN R interpreter to install for; set by install-bincraft.R so -# the per-R-minor passes target their own R, not the primary -# R_VERSION fallback interpreter selector (/opt/R//bin/R) -# UVR_TARGET_LIB target library; defaults to R_LIBS_USER, then to the -# active R's .libPaths()[1] (which is where pak wrote) -# UVR_INSTALL_DIR where the uvr binary lands (default /usr/local/bin) - -set -eu - -# renovate: datasource=github-releases depName=nbafrank/uvr -UVR_PIN="v0.4.8" - -if [ "$#" -eq 0 ]; then - echo "usage: $0 ..." >&2 - exit 2 -fi - -# The build images keep R under /opt/R/ and off PATH. uvr resolves the -# interpreter via PATH and never downloads one unless `uvr r install` is run, so -# put the requested R first. -r_bin="${UVR_R_BIN:-}" -if [ -z "$r_bin" ] && [ -n "${R_VERSION:-}" ] && [ -x "/opt/R/${R_VERSION}/bin/R" ]; then - r_bin="/opt/R/${R_VERSION}/bin/R" -fi -if [ -n "$r_bin" ]; then - PATH="$(dirname "$r_bin"):$PATH" - export PATH -else - r_bin="$(command -v R)" -fi - -target_lib="${UVR_TARGET_LIB:-${R_LIBS_USER:-}}" -if [ -z "$target_lib" ]; then - target_lib="$("$r_bin" --no-echo --no-save -e 'cat(.libPaths()[1])')" -fi -if [ -z "$target_lib" ]; then - echo "error: could not determine a target library; set UVR_TARGET_LIB" >&2 - exit 2 -fi -mkdir -p "$target_lib" - -# Pin the manifest to the active R so the lockfile's R stays in step with the -# library's R sentinel. Without that, uvr can decide the library is ABI-stale -# and wipe it -- and this target is shared with bincraft. uvr only discovers R -# via PATH/R_HOME (it does not scan /opt/R), so the R put on PATH above is the -# only candidate this constraint can resolve to. -# shellcheck disable=SC2016 # $major/$minor are R expressions, not shell vars -r_full="$("$r_bin" --no-echo --no-save -e 'cat(paste(R.version$major, R.version$minor, sep = "."))')" - -install_dir="${UVR_INSTALL_DIR:-/usr/local/bin}" -uvr_bin="${install_dir}/uvr" -if [ ! -x "$uvr_bin" ]; then - echo "Bootstrapping uvr ${UVR_PIN} into ${install_dir}" - UVR_INSTALL_DIR="$install_dir" UVR_VERSION="$UVR_PIN" \ - sh -c 'curl -fsSL https://raw.githubusercontent.com/nbafrank/uvr/main/install.sh | sh' -fi - -project_dir="${TMPDIR:-/tmp}/uvr-ci-$$" -rm -rf "$project_dir" -mkdir -p "$project_dir" -trap 'rm -rf "$project_dir"' EXIT -cd "$project_dir" - -"$uvr_bin" init --here --r-version "$r_full" -# --no-install resolves and locks only; retry because concurrent shards can -# expose short-lived DNS or CRAN-index failures and uvr rolls the manifest back -# cleanly after an unsuccessful resolution. -add_attempt=1 -while ! "$uvr_bin" add --no-install "$@"; do - if [ "$add_attempt" -ge 4 ]; then - echo "error: uvr add failed after ${add_attempt} attempts" >&2 - exit 1 - fi - add_delay=$((add_attempt * 10)) - echo "warning: uvr add attempt ${add_attempt} failed; retrying in ${add_delay}s" >&2 - sleep "$add_delay" - add_attempt=$((add_attempt + 1)) -done - -# TEMPORARY (drop once the images ship a uvr above v0.4.5): the sync below runs -# `apt-get install` for every resolved system dependency without refreshing the -# index first, and the ubuntu build images end their apt layers with -# `rm -rf /var/lib/apt/lists/*`. With no index apt cannot resolve a package that -# exists and is enabled, so `igraph needs: libglpk-dev` fails the whole build -# with `E: Unable to locate package libglpk-dev` on ubuntu 26.04. -# -# Fixed upstream in `e491b2e`, tagged one day after v0.4.5 (nbafrank/uvr#250), -# and the images pick it up via build-env-images#23 — but only after an image -# rebuild is triggered, which is why this runs here too. -# -# apt only: `apk add` fetches its index implicitly and dnf refreshes expired -# metadata on its own. Non-fatal, since a refresh failure still leaves whatever -# index is already there, and the install's own error is the more actionable one. -if command -v apt-get >/dev/null 2>&1; then - apt-get update -qq || echo "warning: apt-get update failed; continuing" >&2 -fi - -# Alpine's build images lack libintl.h, which data.table needs when R enables -# NLS. uvr does not resolve this prerequisite on Alpine, so install it before -# compiling bincraft's dependencies (including when the library cache is cold). -if command -v apk >/dev/null 2>&1; then - apk add --no-cache gettext-dev -fi - -"$uvr_bin" sync --library "$target_lib" --install-system-deps diff --git a/local/validate-patches.R b/local/validate-patches.R deleted file mode 100644 index b20aea1..0000000 --- a/local/validate-patches.R +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env Rscript -# Validate local/patches/registry.json: schema, referenced patch files, and -# ambiguous overlaps. Exits 1 on any problem. Used by pre-commit and CI. -# -# Defaults to local/patches/registry.json. To validate a candidate registry -# without touching the real one (e.g. from the patch proposer), set: -# PATCH_DIR directory patch-file paths resolve against (default local/patches) -# REGISTRY_FILE registry.json to validate (default /registry.json) - -dir <- Sys.getenv("PATCH_DIR", unset = "local/patches") -registry_file <- Sys.getenv( - "REGISTRY_FILE", - unset = file.path(dir, "registry.json") -) -if (!file.exists(registry_file)) { - cat("No registry.json found; nothing to validate.\n") - quit(status = 0L) -} - -or_q <- function(x) if (is.null(x)) "?" else x - -reg <- jsonlite::fromJSON(registry_file, simplifyVector = FALSE) -required <- c("package", "versions", "platforms", "reason") -errs <- character(0L) - -for (i in seq_along(reg)) { - e <- reg[[i]] - missing <- setdiff(required, names(e)) - if (length(missing) > 0L) { - errs <- c( - errs, - sprintf( - "entry %d (%s): missing %s", - i, - if (is.null(e$package)) "?" else e$package, - toString(missing) - ) - ) - } - if (!is.null(e$patch)) { - p <- file.path(dir, e$patch) - if (!file.exists(p)) { - errs <- c( - errs, - sprintf("entry %d (%s): patch file '%s' missing", i, e$package, p) - ) - } - } -} - -# Ambiguous overlap: two entries for the same package with identical platforms -# and versions. -keys <- vapply( - reg, - function(e) { - sprintf( - "%s|%s|%s", - or_q(e$package), - paste(sort(as.character(unlist(e$platforms))), collapse = ","), - or_q(e$versions) - ) - }, - character(1L) -) -dups <- keys[duplicated(keys)] -if (length(dups) > 0L) { - errs <- c( - errs, - sprintf("ambiguous duplicate entries: %s", toString(unique(dups))) - ) -} - -if (length(errs) > 0L) { - cat("Patch registry validation FAILED:\n") - cat(paste0(" - ", errs, "\n")) - quit(status = 1L) -} -cat(sprintf( - "Patch registry OK (%d %s).\n", - length(reg), - if (length(reg) == 1L) "entry" else "entries" -)) diff --git a/local/verify-repo-routing.R b/local/verify-repo-routing.R deleted file mode 100644 index c19494d..0000000 --- a/local/verify-repo-routing.R +++ /dev/null @@ -1,193 +0,0 @@ -# Check that a published slot serves an installable, loadable binary for the R -# running this script, through one of the URL forms a user can configure. -# -# Rscript local/verify-repo-routing.R
-# -# One process per form on purpose: `available.packages()` caches its index in -# `tempdir()` keyed by repository URL, and the `arch` and `flat` forms share a -# URL. In a single process the second form would silently read the first form's -# index and the run would prove nothing. -# -# Forms: -# arch https://cran.rpkgs.com///latest with R's own agent -# generic https://cran.rpkgs.com/ with an agent naming the distribution -# flat the arch URL with a curl agent, so the edge cannot read an R minor -# from the request and the flat slot answers instead of a per-minor -# one -# -# `arch` and `generic` are contractual: they are what the website tells people -# to configure, so a failure there fails the run. `flat` measures what a client -# hiding its R minor is exposed to; it is reported and never fatal. - -args <- commandArgs(trailingOnly = TRUE) -if (length(args) != 3L) { - stop("usage: verify-repo-routing.R ", call. = FALSE) -} -arch <- args[[1L]] -codename <- args[[2L]] -form <- args[[3L]] - -# Compiled packages that exercise the R C API broadly, plus one pure-R package -# as a control: if `brew` fails too, the problem is the repository rather than -# the ABI. -PACKAGES <- c( - "Rcpp", - "data.table", - "stringi", - "xml2", - "curl", - "jsonlite", - "digest", - "base64enc", - "yaml", - "lobstr", - "brew" -) - -arch_url <- sprintf("https://cran.rpkgs.com/%s/%s/latest", arch, codename) - -# The agent the website's generic snippet builds, so this exercises the string -# real users send rather than an approximation of it. -generic_agent <- function() { - os_release <- readLines("/etc/os-release", warn = FALSE) - field <- function(key) { - line <- grep(sprintf("^%s=", key), os_release, value = TRUE) - if (length(line) == 0L) { - return("") - } - gsub('"', "", sub("^[^=]+=", "", line[[1L]])) - } - os <- paste(field("NAME"), field("VERSION_ID")) - codename_id <- field("VERSION_CODENAME") - if (nzchar(codename_id)) { - os <- sprintf("%s; codename=%s", os, codename_id) - } - sprintf( - "R/%s (%s) (%s)", - getRversion(), - os, - paste(R.version["platform"], R.version["arch"], R.version["os"]) - ) -} - -settings <- switch( - form, - arch = list(repo = arch_url, agent = getOption("HTTPUserAgent")), - generic = list(repo = "https://cran.rpkgs.com/", agent = generic_agent()), - flat = list(repo = arch_url, agent = "curl/8.5.0"), - stop(sprintf("unknown form '%s'", form), call. = FALSE) -) - -# No CRAN in `repos`: a package missing from our index must fail loudly rather -# than be quietly compiled from source, which would hide exactly the gap this -# script exists to find. -options(HTTPUserAgent = settings$agent, repos = c(rpkgs = settings$repo)) - -r_minor <- paste(getRversion()[1L, 1:2], collapse = ".") -rscript <- file.path(R.home("bin"), "Rscript") - -emit <- function(package, status, built = "", secs = NA_real_) { - cat( - sprintf( - "ROW\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", - form, - arch, - codename, - r_minor, - package, - status, - # `%.1f` renders NA as the literal "NAs", which reads as a unit rather - # than as a missing measurement. A package that was never in the index - # has no timing at all. - if (is.na(secs)) built else sprintf("%s|%.1fs", built, secs) - ) - ) -} - -# `library()` in this process would abort the whole run on a bad `dyn.load()`, -# and the point of the exercise is to survive that and report it. -loads <- function(package, lib) { - status <- suppressWarnings(system2( - rscript, - c("-e", shQuote(sprintf('library("%s")', package))), - env = sprintf("R_LIBS=%s", lib), - stdout = FALSE, - stderr = FALSE - )) - identical(as.integer(status), 0L) -} - -built_field <- function(package, lib) { - desc <- file.path(lib, package, "DESCRIPTION") - if (!file.exists(desc)) { - return("") - } - value <- read.dcf(desc, fields = "Built")[[1L]] - if (is.na(value)) "" else sub(";.*$", "", value) -} - -available <- tryCatch( - rownames(available.packages()), - error = function(e) { - message(sprintf( - "index unreadable at %s: %s", - settings$repo, - conditionMessage(e) - )) - character() - } -) - -failures <- 0L -for (package in PACKAGES) { - if (!package %in% available) { - emit(package, "MISSING_FROM_INDEX") - failures <- failures + 1L - next - } - - lib <- file.path(tempdir(), sprintf("lib-%s-%s", form, package)) - dir.create(lib, showWarnings = FALSE, recursive = TRUE) - started <- Sys.time() - ok <- tryCatch( - { - # Hard dependencies come from the same repository and must be present - # for `R CMD INSTALL` to succeed, so they are installed too; Suggests are - # not, since a missing one does not stop a package loading. - install.packages( - package, - lib = lib, - dependencies = c("Depends", "Imports", "LinkingTo"), - quiet = TRUE - ) - package %in% rownames(installed.packages(lib.loc = lib)) - }, - error = function(e) FALSE - ) - secs <- as.numeric(difftime(Sys.time(), started, units = "secs")) - - if (!ok) { - emit(package, "INSTALL_FAILED", secs = secs) - failures <- failures + 1L - } else if (!loads(package, lib)) { - emit(package, "LOAD_FAILED", built_field(package, lib), secs) - failures <- failures + 1L - } else { - emit(package, "OK", built_field(package, lib), secs) - } - unlink(lib, recursive = TRUE, force = TRUE) -} - -message(sprintf( - "%s/%s R %s via %s: %d of %d packages usable", - arch, - codename, - r_minor, - form, - length(PACKAGES) - failures, - length(PACKAGES) -)) - -if (failures > 0L && !identical(form, "flat")) { - quit(status = 1L) -} diff --git a/local/weekly-missing-binaries-audit.R b/local/weekly-missing-binaries-audit.R index c999e37..c6b67e5 100644 --- a/local/weekly-missing-binaries-audit.R +++ b/local/weekly-missing-binaries-audit.R @@ -7,6 +7,7 @@ options(error = function() { suppressPackageStartupMessages(library(data.table)) library(DBI, quietly = TRUE) library(RPostgres, quietly = TRUE) +library(s3fs, quietly = TRUE) library(jsonlite, quietly = TRUE) library(httr2, quietly = TRUE) @@ -14,14 +15,10 @@ library(httr2, quietly = TRUE) # Environment / config # --------------------------------------------------------------------------- platform <- Sys.getenv("PLATFORM") -arch <- Sys.getenv("ARCH") +arch <- Sys.getenv("ARCH") -if (nchar(platform) == 0) { - stop("PLATFORM env var is not set") -} -if (nchar(arch) == 0) { - stop("ARCH env var is not set") -} +if (nchar(platform) == 0) stop("PLATFORM env var is not set") +if (nchar(arch) == 0) stop("ARCH env var is not set") # Map platform names to S3 codenames s3_codename <- gsub("-", "", platform) @@ -40,36 +37,29 @@ os_family <- if (grepl("^ubuntu", platform)) { platform } -cat(sprintf( - "Platform: %s | Arch: %s | S3 codename: %s | OS family: %s\n", - platform, - arch, - s3_codename, - os_family -)) +cat(sprintf("Platform: %s | Arch: %s | S3 codename: %s | OS family: %s\n", + platform, arch, s3_codename, os_family)) # --------------------------------------------------------------------------- -# 1. Query PostgreSQL for known build failures (before anything that uses curl, -# to avoid C++ pointer conflicts between curl and RPostgres/libpq) +# 1. Query PostgreSQL for known build failures (before s3fs init to avoid +# C++ pointer conflicts between s3fs/curl and RPostgres/libpq) # --------------------------------------------------------------------------- cat("Connecting to PostgreSQL...\n") con <- DBI::dbConnect( RPostgres::Postgres(), - dbname = "build_metadata", - host = "r-binaries.devxy.io", - port = 15432, - user = "rpkgs", + dbname = "build_metadata", + host = "r-binaries.devxy.io", + port = 15432, + user = "rpkgs", password = Sys.getenv("PGPASS"), - sslmode = "verify-full", - sslrootcert = bincraft::postgres_sslrootcert("verify-full") + sslmode = "require" ) errored_pkgs <- DBI::dbGetQuery( con, sprintf( "SELECT name, tag FROM single_builds WHERE error_occurred = TRUE AND platform = '%s' AND arch = '%s'", - platform, - arch + platform, arch ) ) DBI::dbDisconnect(con) @@ -79,12 +69,7 @@ if (nrow(errored_dt) > 0) { setnames(errored_dt, c("Package", "Version")) setkey(errored_dt, Package, Version) } -cat(sprintf( - "Found %d known build failures for %s/%s\n", - nrow(errored_dt), - platform, - arch -)) +cat(sprintf("Found %d known build failures for %s/%s\n", nrow(errored_dt), platform, arch)) # --------------------------------------------------------------------------- # 2. CRAN release packages (uses curl internally - must come after PG) @@ -97,71 +82,49 @@ cran_dt <- data.table( ) # --------------------------------------------------------------------------- -# 3. Published binaries +# 3. S3 tarballs # --------------------------------------------------------------------------- -# Read the slot's own index rather than listing the bucket. An object being -# present does not mean a binary was built: when a build fails, bincraft -# publishes the CRAN source tarball in its place so the package stays -# installable, and a bucket listing cannot tell the two apart. That is how -# amd64/alpine324 came to hold 13,547 CRAN sources that this audit never -# reported. bincraft stamps `Built` only on records it actually built, so the -# index answers the question a listing cannot. -# -# A slot last indexed by a bincraft that predates the source-fallback fix -# stamps `Built` on every record, including the fallbacks, so this reports -# exactly what it used to until that slot is re-indexed. -index_url <- sprintf( - "https://cran.rpkgs.com/%s/%s/latest/src/contrib/PACKAGES.gz", - arch, - s3_codename +cat("Connecting to S3...\n") +s3fs::s3_file_system( + aws_access_key_id = Sys.getenv("B2_S3_ACCESS_KEY"), + aws_secret_access_key = Sys.getenv("B2_S3_SECRET_KEY"), + endpoint = "https://s3.eu-central-003.backblazeb2.com", + region_name = "eu-central-003", + refresh = TRUE ) -cat(sprintf("Reading package index: %s\n", index_url)) -index <- tryCatch( - { - con <- gzcon(url(index_url, open = "rb")) - on.exit(close(con), add = TRUE) - read.dcf(con, fields = c("Package", "Version", "Built")) - }, +s3_path <- sprintf("devxy-rpkgs-binaries/%s/%s/latest/src/contrib", arch, s3_codename) +cat(sprintf("Listing S3 path: %s\n", s3_path)) + +s3_pkgs <- tryCatch( + s3fs::s3_dir_ls(s3_path, recurse = FALSE), error = function(e) { - cat(sprintf( - "WARNING: Could not read %s: %s\n", - index_url, - conditionMessage(e) - )) - NULL + cat(sprintf("WARNING: Could not list S3 path %s: %s\n", s3_path, conditionMessage(e))) + character(0) } ) -if (is.null(index) || nrow(index) == 0) { - binary_dt <- data.table(Package = character(0), Version = character(0)) +file_names <- basename(s3_pkgs) +matches <- regexec("^([A-Za-z0-9.]+)_([0-9][^/]*)\\.tar\\.gz$", file_names) +parts <- regmatches(file_names, matches) +parts <- parts[sapply(parts, length) == 3] +if (length(parts) == 0) { + s3_dt <- data.table(Package = character(0), Version = character(0)) } else { - built <- !is.na(index[, "Built"]) - binary_dt <- data.table( - Package = as.character(index[built, "Package"]), - Version = as.character(index[built, "Version"]) + s3_dt <- data.table( + Package = sapply(parts, `[`, 2), + Version = sapply(parts, `[`, 3) ) - cat(sprintf( - "Index holds %d records, %d of them built binaries (%d served as CRAN source)\n", - nrow(index), - sum(built), - sum(!built) - )) } -cat(sprintf( - "S3 contains %d binaries for %s/%s\n", - nrow(binary_dt), - arch, - s3_codename -)) +cat(sprintf("S3 contains %d tarballs for %s/%s\n", nrow(s3_dt), arch, s3_codename)) # --------------------------------------------------------------------------- -# 4. Find missing packages (CRAN release version without a binary in S3) +# 4. Find missing packages (CRAN release version not in S3) # --------------------------------------------------------------------------- setkey(cran_dt, Package, Version) -setkey(binary_dt, Package, Version) -missing_dt <- cran_dt[!binary_dt] +setkey(s3_dt, Package, Version) +missing_dt <- cran_dt[!s3_dt] cat(sprintf("%d CRAN release packages missing from S3\n", nrow(missing_dt))) # --------------------------------------------------------------------------- @@ -169,15 +132,9 @@ cat(sprintf("%d CRAN release packages missing from S3\n", nrow(missing_dt))) # --------------------------------------------------------------------------- script_dir <- tryCatch( dirname(normalizePath( - if (exists("ofile", envir = sys.frame(1), inherits = FALSE)) { - sys.frame(1)$ofile - } else { - commandArgs(trailingOnly = FALSE)[grepl( - "--file=", - commandArgs(trailingOnly = FALSE) - )] |> - sub("--file=", "", x = _) - }, + if (exists("ofile", envir = sys.frame(1), inherits = FALSE)) sys.frame(1)$ofile + else commandArgs(trailingOnly = FALSE)[grepl("--file=", commandArgs(trailingOnly = FALSE))] |> + sub("--file=", "", x = _), mustWork = FALSE )), error = function(e) "local" @@ -186,23 +143,13 @@ excluded_path <- file.path(script_dir, "excluded-packages.json") excluded_pkgs <- data.table(package = character(0), reason = character(0)) if (file.exists(excluded_path)) { - excluded_raw <- jsonlite::fromJSON(excluded_path) + excluded_raw <- jsonlite::fromJSON(excluded_path) excluded_pkgs <- as.data.table(excluded_raw) - cat(sprintf( - "Loaded %d excluded packages from %s\n", - nrow(excluded_pkgs), - excluded_path - )) + cat(sprintf("Loaded %d excluded packages from %s\n", nrow(excluded_pkgs), excluded_path)) missing_dt <- missing_dt[!Package %in% excluded_pkgs$package] - cat(sprintf( - "%d packages remain after removing exclusions\n", - nrow(missing_dt) - )) + cat(sprintf("%d packages remain after removing exclusions\n", nrow(missing_dt))) } else { - cat(sprintf( - "No excluded-packages.json found at %s -- skipping exclusion step\n", - excluded_path - )) + cat(sprintf("No excluded-packages.json found at %s -- skipping exclusion step\n", excluded_path)) } # --------------------------------------------------------------------------- @@ -210,34 +157,24 @@ if (file.exists(excluded_path)) { # --------------------------------------------------------------------------- if (nrow(errored_dt) > 0) { known_failures_dt <- missing_dt[errored_dt, nomatch = 0] - rebuildable_dt <- missing_dt[!errored_dt] + rebuildable_dt <- missing_dt[!errored_dt] } else { known_failures_dt <- missing_dt[0] - rebuildable_dt <- missing_dt + rebuildable_dt <- missing_dt } -cat(sprintf( - "Rebuildable: %d | Known failures: %d\n", - nrow(rebuildable_dt), - nrow(known_failures_dt) -)) +cat(sprintf("Rebuildable: %d | Known failures: %d\n", + nrow(rebuildable_dt), nrow(known_failures_dt))) # --------------------------------------------------------------------------- # 7. Write rebuildable package names to cache RDS # --------------------------------------------------------------------------- -cache_dir <- "/mnt/cache/packages" -cache_file <- file.path( - cache_dir, - sprintf("weekly_rebuild_%s_%s.rds", platform, arch) -) +cache_dir <- "/mnt/cache/packages" +cache_file <- file.path(cache_dir, sprintf("weekly_rebuild_%s_%s.rds", platform, arch)) if (dir.exists(cache_dir)) { saveRDS(rebuildable_dt$Package, cache_file) - cat(sprintf( - "Wrote %d rebuildable packages to %s\n", - nrow(rebuildable_dt), - cache_file - )) + cat(sprintf("Wrote %d rebuildable packages to %s\n", nrow(rebuildable_dt), cache_file)) } else { cat(sprintf("Cache dir %s does not exist -- skipping RDS write\n", cache_dir)) } @@ -249,47 +186,29 @@ forgejo_token <- Sys.getenv("FORGEJO_TOKEN") if (nchar(forgejo_token) == 0) { cat("FORGEJO_TOKEN not set -- skipping issue update\n") } else { - issue_title <- sprintf( - "Missing package binaries for latest version (%s)", - os_family - ) + issue_title <- sprintf("Missing package binaries for latest version (%s)", os_family) - n_missing <- nrow(missing_dt) - n_rebuild <- nrow(rebuildable_dt) + n_missing <- nrow(missing_dt) + n_rebuild <- nrow(rebuildable_dt) - arch_lines <- sprintf( - "### %s (%d missing, %d to rebuild)", - arch, - n_missing, - n_rebuild - ) + arch_lines <- sprintf("### %s (%d missing, %d to rebuild)", arch, n_missing, n_rebuild) if (nrow(rebuildable_dt) > 0) { - arch_lines <- c( - arch_lines, + arch_lines <- c(arch_lines, paste0("- ", rebuildable_dt$Package, " (", rebuildable_dt$Version, ")") ) } else { arch_lines <- c(arch_lines, "_None_") } if (nrow(known_failures_dt) > 0) { - arch_lines <- c( - arch_lines, + arch_lines <- c(arch_lines, "", "#### Known build failures", - paste0( - "- ", - known_failures_dt$Package, - " (", - known_failures_dt$Version, - ")" - ) + paste0("- ", known_failures_dt$Package, " (", known_failures_dt$Version, ")") ) } build_excluded_footer <- function() { - if (nrow(excluded_pkgs) == 0) { - return(character(0)) - } + if (nrow(excluded_pkgs) == 0) return(character(0)) entries <- paste( paste0(excluded_pkgs$package, " (", excluded_pkgs$reason, ")"), collapse = ", " @@ -298,12 +217,11 @@ if (nchar(forgejo_token) == 0) { } forgejo_base <- "https://git.devxy.io/api/v1" - repo <- "devxy/build-cran-binaries" + repo <- "devxy/build-cran-binaries" search_url <- sprintf( "%s/repos/%s/issues?type=issues&state=open&q=%s&limit=50", - forgejo_base, - repo, + forgejo_base, repo, utils::URLencode(issue_title, reserved = TRUE) ) search_resp <- httr2::request(search_url) |> @@ -312,19 +230,15 @@ if (nchar(forgejo_token) == 0) { existing_issues <- httr2::resp_body_json(search_resp, simplifyVector = FALSE) - match_idx <- which( - sapply(existing_issues, function(x) x$title) == issue_title - ) + match_idx <- which(sapply(existing_issues, function(x) x$title) == issue_title) today_str <- format(Sys.Date(), "%Y-%m-%d") if (length(match_idx) > 0) { # ---- Update existing issue ---- issue_number <- existing_issues[[match_idx[1]]]$number - old_body <- existing_issues[[match_idx[1]]]$body - if (is.null(old_body)) { - old_body <- "" - } + old_body <- existing_issues[[match_idx[1]]]$body + if (is.null(old_body)) old_body <- "" lines <- strsplit(old_body, "\n", fixed = TRUE)[[1]] @@ -337,17 +251,14 @@ if (nchar(forgejo_token) == 0) { } plat_header <- sprintf("## %s", platform) + arch_header <- sprintf("### %s", arch) plat_idx <- which(lines == plat_header) if (length(plat_idx) == 0) { # Platform section missing -- insert before --- footer footer_idx <- which(lines == "---") - insert_at <- if (length(footer_idx) > 0) { - footer_idx[length(footer_idx)] - } else { - length(lines) + 1 - } + insert_at <- if (length(footer_idx) > 0) footer_idx[length(footer_idx)] else length(lines) + 1 new_plat_block <- c(sprintf("## %s", platform), "", arch_lines, "") lines <- c( @@ -360,58 +271,39 @@ if (nchar(forgejo_token) == 0) { # End of platform section: next ## or --- at a higher level, or EOF next_section <- which(grepl("^## |^---", lines) & seq_along(lines) > pi) - plat_end <- if (length(next_section) > 0) { - next_section[1] - 1 + plat_end <- if (length(next_section) > 0) next_section[1] - 1 else length(lines) + + plat_lines <- lines[seq(pi, plat_end)] + arch_local_idx <- which(plat_lines == arch_header) + + if (length(arch_local_idx) == 0) { + # Append arch subsection at end of platform block + lines <- c( + lines[seq_len(plat_end)], + "", + arch_lines, + lines[seq(plat_end + 1, length(lines))] + ) } else { - length(lines) + ai <- pi + arch_local_idx[1] - 1 # absolute line index + + # End of arch subsection + next_arch <- which(grepl("^### |^## |^---", lines) & seq_along(lines) > ai) + arch_end <- if (length(next_arch) > 0) next_arch[1] - 1 else plat_end + + lines <- c( + lines[seq_len(ai - 1)], + arch_lines, + lines[seq(arch_end + 1, length(lines))] + ) } - - plat_lines <- lines[seq(pi, plat_end)] - - # Arch subsection headers within the platform block (### arm64 / ### amd64). - # Match by prefix: headers carry a " (N missing, M to rebuild)" suffix, so - # exact-equality matching never found the existing block and silently - # appended a duplicate on every run. Remove *all* blocks for this arch - # (collapsing any previously accumulated duplicates), then write one fresh - # block, so the issue holds a single current subsection per arch. - sub_hdr <- which(grepl("^### ", plat_lines)) - arch_re <- sprintf("^### %s( |$)", arch) - - if (length(sub_hdr) == 0) { - # No arch subsections yet -- append after the platform header/preamble. - new_plat_lines <- c(plat_lines, "", arch_lines) - } else { - preamble <- plat_lines[seq_len(sub_hdr[1] - 1)] - # Each subsection runs from its ### header to the line before the next - # ### header (#### known-failures stays inside its own block). - sub_end <- c(sub_hdr[-1] - 1, length(plat_lines)) - kept <- character(0) - for (k in seq_along(sub_hdr)) { - block <- plat_lines[seq(sub_hdr[k], sub_end[k])] - if (!grepl(arch_re, block[1])) { - kept <- c(kept, block) - } - } - new_plat_lines <- c(preamble, kept, "", arch_lines) - } - - tail_lines <- if (plat_end < length(lines)) { - lines[seq(plat_end + 1, length(lines))] - } else { - character(0) - } - lines <- c(lines[seq_len(pi - 1)], new_plat_lines, tail_lines) } # Rebuild excluded footer excl_hdr_idx <- which(lines == "## Excluded packages") if (length(excl_hdr_idx) > 0) { - pre_dash <- which(lines == "---" & seq_along(lines) < excl_hdr_idx[1]) - remove_from <- if (length(pre_dash) > 0) { - pre_dash[length(pre_dash)] - } else { - excl_hdr_idx[1] - } + pre_dash <- which(lines == "---" & seq_along(lines) < excl_hdr_idx[1]) + remove_from <- if (length(pre_dash) > 0) pre_dash[length(pre_dash)] else excl_hdr_idx[1] lines <- lines[seq_len(remove_from - 1)] } footer <- build_excluded_footer() @@ -421,15 +313,10 @@ if (nchar(forgejo_token) == 0) { new_body <- paste(lines, collapse = "\n") - patch_url <- sprintf( - "%s/repos/%s/issues/%d", - forgejo_base, - repo, - issue_number - ) + patch_url <- sprintf("%s/repos/%s/issues/%d", forgejo_base, repo, issue_number) httr2::request(patch_url) |> httr2::req_headers( - Authorization = paste("token", forgejo_token), + Authorization = paste("token", forgejo_token), `Content-Type` = "application/json" ) |> httr2::req_body_json(list(body = new_body)) |> @@ -437,6 +324,7 @@ if (nchar(forgejo_token) == 0) { httr2::req_perform() cat(sprintf("Updated Forgejo issue #%d: %s\n", issue_number, issue_title)) + } else { # ---- Create new issue ---- body_lines <- c( @@ -454,21 +342,17 @@ if (nchar(forgejo_token) == 0) { post_url <- sprintf("%s/repos/%s/issues", forgejo_base, repo) create_resp <- httr2::request(post_url) |> httr2::req_headers( - Authorization = paste("token", forgejo_token), + Authorization = paste("token", forgejo_token), `Content-Type` = "application/json" ) |> httr2::req_body_json(list( title = issue_title, - body = paste(body_lines, collapse = "\n") + body = paste(body_lines, collapse = "\n") )) |> httr2::req_perform() new_issue <- httr2::resp_body_json(create_resp) - cat(sprintf( - "Created Forgejo issue #%d: %s\n", - new_issue$number, - issue_title - )) + cat(sprintf("Created Forgejo issue #%d: %s\n", new_issue$number, issue_title)) } } diff --git a/provider.tf b/provider.tf index 85b6aa4..0a9ba15 100644 --- a/provider.tf +++ b/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { bunnynet = { source = "registry.terraform.io/BunnyWay/bunnynet" - version = "~> 0.20" + version = "~> 0.14" } } } diff --git a/renovate.json b/renovate.json index 3723172..97ca6ad 100644 --- a/renovate.json +++ b/renovate.json @@ -1,12 +1,10 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["local>devxy/renovate-config"], - "automergeStrategy": "squash", + "extends": [ + "local>devxy/renovate-config" + ], "ignorePaths": [ - "docker/**", - ".crow/process-updates.yaml", - ".crow/build-all-versions.yaml", - ".crow/weekly-rebuild-missing.yaml" + "docker/**" ], "customManagers": [ { @@ -20,13 +18,6 @@ "packageNameTemplate": "https://codefloe.com/rpkgs/bincraft.git", "datasourceTemplate": "git-tags", "extractVersionTemplate": "^v?(?.+)$" - }, - { - "customType": "regex", - "fileMatch": ["^local/uvr-install\\.sh$"], - "matchStrings": [ - "# renovate: datasource=(?\\S+) depName=(?\\S+)\\s+UVR_PIN=\"(?[^\"]+)\"" - ] } ] } diff --git a/scripts/purge_cdn_cache.sh b/scripts/purge_cdn_cache.sh index b525a44..a4e34c3 100644 --- a/scripts/purge_cdn_cache.sh +++ b/scripts/purge_cdn_cache.sh @@ -1,44 +1,64 @@ -#!/usr/bin/env bash -# -# Purge BunnyCDN edge cache for the index files of one ARCH+OS_ID -# combination across one or more domains. -# -# Usage: -# purge_cdn_cache.sh [...] -# -set -euo pipefail +#!/bin/bash -if (( $# < 4 )); then - echo "usage: $0 [...]" >&2 - exit 2 -fi +set -o pipefail +set -x -api_key="$1" -arch="$2" -os_id="$3" -shift 3 - -resources=( - "src/contrib/PACKAGES" - "src/contrib/PACKAGES.gz" - "src/contrib/PACKAGES.rds" - "src/contrib/PACKAGES.db" - "src/contrib/Meta/archive.rds" -) - -purge_one() { - local target="$1" - # --data-urlencode encodes value of `url=` for us; -G forces GET. - curl -sS -G -X POST \ - -H "AccessKey: ${api_key}" \ - --data-urlencode "url=${target}" \ - --data "async=false" \ - "https://api.bunny.net/purge" - echo +# Function to URL-encode a string using Python +urlencode() { + python3 -c "import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1], safe=''))" "$1" } -for domain in "$@"; do +# Function to send the purge request using the provided API key +purge() { + local api_key="$1" + local url="$2" + curl -vL -X POST -H "AccessKey: $api_key" "$url" +} + +# Function to generate the purge URLs for a given domain, arch, and OS ID +generate_urls() { + local domain="$1" + local arch="$2" + local os_id="$3" + + # Array of resource paths (can be modified or extended as needed) + local resources=( + "src/contrib/PACKAGES" + "src/contrib/PACKAGES.gz" + "src/contrib/PACKAGES.rds" + "src/contrib/PACKAGES.db" + ) + + local urls=() for resource in "${resources[@]}"; do - purge_one "https://${domain}/${arch}/${os_id}/latest/${resource}" + local target_url="https://${domain}/${arch}/${os_id}/latest/${resource}" + local encoded + encoded=$(urlencode "$target_url") + urls+=( "https://api.bunny.net/purge?url=${encoded}&async=false" ) done -done + + echo "${urls[@]}" +} + +# Function to process multiple domains. +# Usage: process_domains domain1 [domain2 ... domainN] +purge_cdn_cache() { + local api_key="$1" + local arch="$2" + local os_id="$3" + shift 3 # Remove the first three arguments, leaving the domains + + for domain in "$@"; do + # Generate the list of URLs for the current domain + local urls + urls=($(generate_urls "$domain" "$arch" "$os_id")) + + # Purge each URL + for url in "${urls[@]}"; do + purge "$api_key" "$url" + done + done +} + +# Example usage: +# purge_cdn_cache "$BUNNYNET_API_KEY" "$ARCH" "$OS_ID" "domain1.com" "domain2.com" diff --git a/scripts/purge_cdn_zone.sh b/scripts/purge_cdn_zone.sh deleted file mode 100755 index 8e85cb6..0000000 --- a/scripts/purge_cdn_zone.sh +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env bash -# -# Purge the entire BunnyCDN pull zone. -# -# `purge_cdn_cache.sh` purges the five index files by URL, which is right after -# a normal update: new packages arrive at new URLs, so only the index is stale. -# -# A rebuild is different. It replaces an object *in place*: a package whose -# build failed was published as its CRAN source, and the rebuilt binary takes -# exactly the same URL. The zone caches tarballs for ~370 days -# (`cache_expiration_time` in cdn.tf), so without a purge every client keeps -# receiving the source tarball for up to a year, and nothing about it looks -# wrong from the outside. -# -# Purging per URL would mean one API call per replaced package -- ~13.5k per -# arch against a rate-limited endpoint, where a single missed call leaves a -# silently stale package. One zone purge is a single call regardless of how many -# objects were replaced. The cost is a cold cache for everything else, which is -# why this is not used by the daily update path. -# -# The public hostnames currently use separate pull zones, so callers must pass -# every zone that serves the repository. A zone can be identified by its -# numeric ID or by one of its hostnames; hostname lookup avoids persisting IDs -# that change when a zone is recreated. -# -# Usage: -# purge_cdn_zone.sh [...] -# -set -euo pipefail - -if (($# < 2)); then - echo "usage: $0 [...]" >&2 - exit 2 -fi - -api_key="$1" -shift - -resolve_zone_id() { - local zone="$1" - local response_file - local zone_id - - if [[ "${zone}" =~ ^[0-9]+$ ]]; then - echo "${zone}" - return - fi - - response_file=$(mktemp) - local status - status=$( - curl -sS -o "${response_file}" -w '%{http_code}' \ - -H "AccessKey: ${api_key}" \ - "https://api.bunny.net/pullzone?perPage=1000" - ) - - if [[ "${status}" != "200" ]]; then - echo "Listing BunnyCDN pull zones failed with HTTP ${status}:" >&2 - head -c 500 "${response_file}" >&2 - echo >&2 - rm -f "${response_file}" - exit 1 - fi - - # The endpoint answers with a bare array on some accounts and a paginated - # object on others. `.Items // .` looks like it covers both but does not: - # indexing an array with a string is an *error*, and `//` only substitutes - # for null, so the array case aborted with - # "Cannot index array with string" and the zone was never purged. - zone_id=$( - jq -r --arg hostname "${zone}" \ - '(if type == "object" then (.Items // []) else . end)[] - | select(any(.Hostnames[]?; .Value == $hostname)) - | .Id' \ - "${response_file}" - ) - rm -f "${response_file}" - - if [[ -z "${zone_id}" ]]; then - echo "Could not find BunnyCDN pull zone for hostname ${zone}" >&2 - exit 1 - fi - - # Two zones sharing a hostname would purge only whichever jq emitted first. - if [[ $(wc -l <<<"${zone_id}") -gt 1 ]]; then - echo "Hostname ${zone} matched multiple pull zones: ${zone_id//$'\n'/ }" >&2 - exit 1 - fi - - echo "${zone_id}" -} - -for zone in "$@"; do - zone_id=$(resolve_zone_id "${zone}") - echo "Purging BunnyCDN pull zone ${zone_id}" - - response_file="/tmp/purge_zone_response_${zone_id}.txt" - status=$( - curl -sS -o "${response_file}" -w '%{http_code}' -X POST \ - -H "AccessKey: ${api_key}" \ - -H "Content-Length: 0" \ - "https://api.bunny.net/pullzone/${zone_id}/purgeCache" - ) - - if [[ "${status}" != "200" && "${status}" != "204" ]]; then - echo "Purge of pull zone ${zone_id} failed with HTTP ${status}:" >&2 - cat "${response_file}" >&2 - exit 1 - fi - - echo "Purged pull zone ${zone_id} (HTTP ${status})" -done diff --git a/scripts/verify-r-minor-routing.sh b/scripts/verify-r-minor-routing.sh deleted file mode 100755 index 190245a..0000000 --- a/scripts/verify-r-minor-routing.sh +++ /dev/null @@ -1,434 +0,0 @@ -#!/usr/bin/env bash -# -# Verify per-R-minor index routing for cran.rpkgs.com across every published -# / slot. -# -# The edge router (edge/rpkgs-router.ts) rewrites PACKAGES* requests to -# `contrib//` when the slot is listed in UNION_SLOTS and the client's -# User-Agent carries an R minor. Two properties have to hold before a slot may -# be added to UNION_SLOTS: -# -# 1. the per-minor index is a UNION of the per-minor and flat slots, so -# routing to it hides nothing the flat index carries; and -# 2. every R minor a client might report resolves to an index that exists, -# because contribPath() does not check existence and has no fallback. -# -# Modes: -# (default) Resolve routing decisions without depending on UNION_SLOTS being -# set. Safe to run before enabling: it reads the per-minor indexes -# directly and reproduces the router's target path. -# --live Additionally drive the real CDN with R User-Agents and assert the -# bytes served match the expected index. Only meaningful once the -# slot is in UNION_SLOTS. -# -# Usage: -# scripts/verify-r-minor-routing.sh -# scripts/verify-r-minor-routing.sh --live -# MINORS="4.4 4.5" SAMPLE=10 scripts/verify-r-minor-routing.sh -# -# Exits non-zero if any check fails. - -set -uo pipefail - -BASE=${BASE:-https://cran.rpkgs.com} -ARCHES=${ARCHES:-"amd64 arm64"} -DISTROS=${DISTROS:-"resolute noble jammy rhel8 rhel9 rhel10 alpine323 alpine324"} -# The supported window: the current R minor plus the two previous, matching -# build-env-images' R_VERSION_LATEST/PREV1/PREV2 and cdn.tf's -# local.rpkgs_supported_minors. Each of these must have a published index. -MINORS=${MINORS:-"4.4 4.5 4.6"} -# Minors we deliberately do not serve. These must have NO published index and, -# once routing is live, must be sent to CRAN for sources rather than 404ing or -# being handed binaries built under another minor. -EXCLUDED_MINORS=${EXCLUDED_MINORS:-"4.3"} -# How many Path: targets to HEAD-check per slot/minor. 0 disables. -SAMPLE=${SAMPLE:-5} -# Package-count shortfall against the best minor on the same slot, above which -# coverage is reported as uneven. Reported, not failed on: the packages a -# non-primary minor lacks are ABI-risky ones built under the primary minor, -# which a client on another minor cannot safely load anyway, so their absence -# is correct. This gates the *claim* ("full coverage for ABI-sensitive -# packages"), not whether routing is safe to enable - MAX_REGRESSIONS does -# that. -PARITY_TOLERANCE=${PARITY_TOLERANCE:-25} -# Source fallbacks are reported, not failed on. Since bincraft learned to keep -# a matching-minor generic binary out of a fallback's shadow, a remaining -# fallback means the generic slot's binary was built under a *different* minor, -# which is unsafe for this client anyway: serving source there is correct, just -# slow. The gate below is what actually matters. -# -# A REGRESSION is a package this client would receive as source through -# per-minor routing but as a binary built under its own minor from the generic -# slot. That is strictly worse than not routing at all, and must be zero before -# a slot is added to UNION_SLOTS. -MAX_REGRESSIONS=${MAX_REGRESSIONS:-0} -LIVE=0 - -for arg in "$@"; do - case "$arg" in - --live) LIVE=1 ;; - -h | --help) - sed -n '2,32p' "$0" - exit 0 - ;; - *) - echo "unknown argument: $arg" >&2 - exit 2 - ;; - esac -done - -WORK=$(mktemp -d) -trap 'rm -rf "$WORK"' EXIT - -PASS=0 -FAIL=0 -FAILURES="" - -ok() { - PASS=$((PASS + 1)) - printf ' ok %s\n' "$1" -} - -bad() { - FAIL=$((FAIL + 1)) - FAILURES="${FAILURES}\n - $1" - printf ' FAIL %s\n' "$1" -} - -# Fetch a URL into a file, echoing the HTTP status. Cached per URL. -fetch() { - local url=$1 dest=$2 ua=${3:-} - if [ -s "$dest" ]; then - cat "$dest.status" - return 0 - fi - local status - # -L: the router answers an index request with a redirect, so the bytes a - # client ends up with are only visible by following it. - # - # no-cache: a purge is asynchronous, so a run started right after a reindex - # otherwise measures whatever the edge still holds. - if [ -n "$ua" ]; then - status=$(curl -sSL -A "$ua" -H 'Cache-Control: no-cache' -o "$dest" -w '%{http_code}' --max-time 120 "$url" 2>/dev/null) - else - status=$(curl -sSL -H 'Cache-Control: no-cache' -o "$dest" -w '%{http_code}' --max-time 120 "$url" 2>/dev/null) - fi - echo "$status" > "$dest.status" - echo "$status" -} - -head_status() { - curl -sS -o /dev/null -w '%{http_code}' -I --max-time 60 "$1" 2>/dev/null -} - -# Package names from a gzipped PACKAGES index, sorted. -pkg_names() { - gunzip -c "$1" 2>/dev/null | awk '/^Package:/ {print $2}' | sort -u -} - -# " " for a per-minor index: how many entries carry a -# Path: field, and how many of those lack a Built: field (i.e. are sources). -fallback_counts() { - gunzip -c "$1" 2>/dev/null | awk ' - /^Package:/ { pkg = $2; path = ""; built = "" } - /^Path:/ { path = $2 } - /^Built:/ { built = $2 } - /^$/ { if (pkg != "" && path != "") { n++; if (built == "") s++ } pkg = "" } - END { if (pkg != "" && path != "") { n++; if (built == "") s++ } - printf "%d %d\n", n, s } - ' -} - -# Packages this index serves from the generic slot with a binary built under a -# different R minor, while some other per-minor slot carries a build of them - -# which proves the ABI classifier called them risky. Serving those is the -# load-time crash the per-minor slots exist to prevent. bincraft drops them at -# index time, so a non-zero count means the slot has not been reindexed since -# that guard shipped. -abi_unsafe_count() { - local minor_file=$1 minor=$2 risky_file=$3 - gunzip -c "$minor_file" 2>/dev/null | awk -v m="$minor" ' - /^Package:/ { pkg = $2; path = ""; built = "" } - /^Path:/ { path = $2 } - /^Built:/ { built = $2 " " $3 } - /^$/ { if (pkg != "" && path == "" && built != "" && built !~ ("^R " m "\\.")) print pkg; pkg = "" } - ' | sort -u > "$minor_file.mismatched" - comm -12 "$minor_file.mismatched" "$risky_file" | wc -l -} - -# How many packages a client of would receive as source through -# per-minor routing while the generic slot holds a binary built under that very -# minor. Zero is the bar for enabling a slot. -regression_count() { - local minor_file=$1 flat_file=$2 minor=$3 - gunzip -c "$flat_file" 2>/dev/null | awk -v m="$minor" ' - /^Package:/ { pkg = $2; built = "" } - /^Built:/ { built = $2 " " $3 } - /^$/ { if (pkg != "" && built ~ ("^R " m "\\.")) print pkg; pkg = "" } - ' | sort -u > "$minor_file.flatbin" - gunzip -c "$minor_file" 2>/dev/null | awk ' - /^Package:/ { pkg = $2; path = ""; built = "" } - /^Path:/ { path = $2 } - /^Built:/ { built = $2 } - /^$/ { if (pkg != "" && path != "" && built == "") print pkg; pkg = "" } - ' | sort -u > "$minor_file.src" - comm -12 "$minor_file.src" "$minor_file.flatbin" | wc -l -} - -# " " pairs for entries that carry a Path: field. -path_entries() { - gunzip -c "$1" 2>/dev/null | awk ' - /^Package:/ { pkg = $2; ver = ""; path = "" } - /^Version:/ { ver = $2 } - /^Path:/ { path = $2 } - /^$/ { if (pkg != "" && path != "") print pkg, ver, path; pkg = "" } - END { if (pkg != "" && path != "") print pkg, ver, path } - ' -} - -# An R User-Agent of the shape R actually sends. -r_user_agent() { - printf 'R/%s.0 (Ubuntu 24.04; codename=noble) (x86_64-pc-linux-gnu x86_64 linux-gnu)' "$1" -} - -echo "verify-r-minor-routing: $BASE" -echo " slots: $(echo "$ARCHES" | wc -w) arch x $(echo "$DISTROS" | wc -w) os" -echo " minors: $MINORS (excluded: $EXCLUDED_MINORS)" -echo " live: $LIVE" -echo - -for arch in $ARCHES; do - for distro in $DISTROS; do - slot="$arch/$distro" - echo "$slot" - - flat_url="$BASE/$slot/latest/src/contrib/PACKAGES.gz" - flat_file="$WORK/${arch}-${distro}-flat.gz" - flat_status=$(fetch "$flat_url" "$flat_file") - - if [ "$flat_status" != "200" ]; then - bad "$slot flat index unreachable (HTTP $flat_status)" - continue - fi - - pkg_names "$flat_file" > "$flat_file.names" - flat_count=$(wc -l < "$flat_file.names") - if [ "$flat_count" -lt 1000 ]; then - bad "$slot flat index has only $flat_count packages" - continue - fi - ok "$slot flat index: $flat_count packages" - - for minor in $MINORS; do - minor_url="$BASE/$slot/latest/src/contrib/$minor/PACKAGES.gz" - minor_file="$WORK/${arch}-${distro}-${minor}.gz" - minor_status=$(fetch "$minor_url" "$minor_file") - - # A minor the router would route to must exist, or clients on that R - # version get a 404 and see no packages at all. - if [ "$minor_status" != "200" ]; then - bad "$slot R $minor index missing (HTTP $minor_status) - routing would 404 for R $minor clients" - continue - fi - - pkg_names "$minor_file" > "$minor_file.names" - minor_count=$(wc -l < "$minor_file.names") - - # Union property: nothing the flat index carries may be missing here. - # bincraft deliberately drops an ABI-risky package whose only binary was - # built under another R minor: serving it is the load-time crash the - # per-minor slots exist to prevent. Those absences are correct. - # - # What must never go missing is a generic package built under *this* - # minor, which is safe to serve and has no reason to disappear. - comm -23 "$flat_file.names" "$minor_file.names" > "$minor_file.absent" - absent_count=$(wc -l < "$minor_file.absent") - gunzip -c "$flat_file" 2>/dev/null | awk -v m="$minor" ' - /^Package:/ { pkg = $2; built = "" } - /^Built:/ { built = $2 " " $3 } - /^$/ { if (pkg != "" && built ~ ("^R " m "\\.")) print pkg; pkg = "" } - ' | sort -u > "$minor_file.flatsame" - lost=$(comm -12 "$minor_file.absent" "$minor_file.flatsame" | wc -l) - - if [ "${lost:-0}" -ne 0 ]; then - bad "$slot R $minor index dropped $lost generic package(s) built under R $minor, which were safe to serve" - else - ok "$slot R $minor index: $minor_count packages, union holds ($absent_count ABI-unsafe dropped)" - fi - - # A per-minor entry that is a source fallback resolves fine but makes the - # client compile. Routing to a slot that is mostly fallbacks does not - # deliver the binaries we advertise. - read -r steered fallbacks <<< "$(fallback_counts "$minor_file")" - if [ "${steered:-0}" -gt 0 ]; then - pct=$((fallbacks * 100 / steered)) - printf ' note: %s/%s per-minor entries are source fallbacks (%s%%)\n' \ - "$fallbacks" "$steered" "$pct" - fi - - # The gate: nothing may arrive as source here that the generic slot would - # have served as a binary built under this same minor. - regressions=$(regression_count "$minor_file" "$flat_file" "$minor") - if [ "${regressions:-0}" -gt "$MAX_REGRESSIONS" ]; then - bad "$slot R $minor: $regressions packages would be served as source but exist as an R $minor binary in the generic slot" - else - ok "$slot R $minor: no regression against the generic slot" - fi - - # Path: entries steer to per-minor binaries; they must resolve. - if [ "$SAMPLE" -gt 0 ]; then - path_entries "$minor_file" > "$minor_file.paths" - total_paths=$(wc -l < "$minor_file.paths") - broken=0 - checked=0 - while read -r pkg ver path; do - [ -z "${pkg:-}" ] && continue - tarball="$BASE/$slot/latest/src/contrib/$path/${pkg}_${ver}.tar.gz" - status=$(head_status "$tarball") - checked=$((checked + 1)) - if [ "$status" != "200" ]; then - broken=$((broken + 1)) - [ "$broken" -le 2 ] && printf ' broken target: %s (HTTP %s)\n' "$tarball" "$status" - fi - done < <(shuf -n "$SAMPLE" "$minor_file.paths" 2>/dev/null || head -n "$SAMPLE" "$minor_file.paths") - - if [ "$broken" -ne 0 ]; then - bad "$slot R $minor: $broken/$checked sampled Path: targets do not resolve (of $total_paths total)" - elif [ "$checked" -gt 0 ]; then - ok "$slot R $minor: $checked/$checked sampled Path: targets resolve (of $total_paths total)" - fi - fi - - # Live routing: what a real R client on this minor actually receives. - if [ "$LIVE" -eq 1 ]; then - ua=$(r_user_agent "$minor") - live_file="$WORK/${arch}-${distro}-${minor}-live.gz" - live_status=$(fetch "$flat_url" "$live_file" "$ua") - if [ "$live_status" != "200" ]; then - bad "$slot R $minor live request failed (HTTP $live_status)" - elif cmp -s "$live_file" "$minor_file"; then - ok "$slot R $minor live request served the per-minor index" - elif cmp -s "$live_file" "$flat_file"; then - bad "$slot R $minor live request served the FLAT index - slot not in UNION_SLOTS?" - else - bad "$slot R $minor live request served neither the per-minor nor the flat index" - fi - fi - done - - # Coverage parity across minors. The union property only guarantees no - # client loses packages relative to the flat index; it says nothing about a - # 4.4 client seeing fewer packages than a 4.5 client on the same slot. - best=0 - for minor in $MINORS; do - f="$WORK/${arch}-${distro}-${minor}.gz.names" - [ -s "$f" ] || continue - c=$(wc -l < "$f") - [ "$c" -gt "$best" ] && best=$c - done - if [ "$best" -gt 0 ]; then - uneven="" - for minor in $MINORS; do - f="$WORK/${arch}-${distro}-${minor}.gz.names" - [ -s "$f" ] || continue - c=$(wc -l < "$f") - gap=$((best - c)) - [ "$gap" -gt "$PARITY_TOLERANCE" ] && uneven="$uneven R$minor:-$gap" - done - if [ -n "$uneven" ]; then - printf ' note: %s coverage uneven across minors (vs best %s):%s\n' \ - "$slot" "$best" "$uneven" - else - ok "$slot coverage parity across minors (best $best, all within $PARITY_TOLERANCE)" - fi - fi - - # Packages carrying a Path in any per-minor index are risky by construction. - : > "$WORK/${arch}-${distro}.risky" - for minor in $MINORS; do - f="$WORK/${arch}-${distro}-${minor}.gz" - [ -s "$f" ] || continue - gunzip -c "$f" 2>/dev/null | awk ' - /^Package:/ { pkg = $2; path = "" } - /^Path:/ { path = $2 } - /^$/ { if (pkg != "" && path != "") print pkg; pkg = "" } - ' >> "$WORK/${arch}-${distro}.risky" - done - sort -u -o "$WORK/${arch}-${distro}.risky" "$WORK/${arch}-${distro}.risky" - - for minor in $MINORS; do - f="$WORK/${arch}-${distro}-${minor}.gz" - [ -s "$f" ] || continue - unsafe=$(abi_unsafe_count "$f" "$minor" "$WORK/${arch}-${distro}.risky") - if [ "${unsafe:-0}" -gt 0 ]; then - bad "$slot R $minor serves $unsafe ABI-risky package(s) built under another R minor - reindex this slot" - else - ok "$slot R $minor serves no ABI-risky package from another minor" - fi - done - - # Excluded minors: no published index, and under --live a redirect to CRAN. - for minor in $EXCLUDED_MINORS; do - ex_url="$BASE/$slot/latest/src/contrib/$minor/PACKAGES.gz" - ex_status=$(curl -sS -o /dev/null -w '%{http_code}' --max-time 60 "$ex_url" 2>/dev/null) - if [ "$ex_status" = "200" ]; then - bad "$slot R $minor is excluded but an index is published - the two lists disagree" - else - ok "$slot R $minor correctly has no published index" - fi - - if [ "$LIVE" -eq 1 ]; then - loc=$(curl -sS -o /dev/null -w '%{redirect_url}' -A "$(r_user_agent "$minor")" \ - --max-time 60 "$flat_url" 2>/dev/null) - case "$loc" in - https://cran.r-project.org/*) - ok "$slot R $minor is sent to CRAN ($loc)" - ;; - "") - bad "$slot R $minor was served directly instead of being sent to CRAN" - ;; - *) - bad "$slot R $minor redirected somewhere unexpected: $loc" - ;; - esac - fi - done - - # A client whose User-Agent carries no R version must keep getting the flat - # index, never a per-minor one. - if [ "$LIVE" -eq 1 ]; then - plain_file="$WORK/${arch}-${distro}-plain.gz" - plain_status=$(fetch "$flat_url" "$plain_file" "curl/8.0.0") - if [ "$plain_status" != "200" ]; then - bad "$slot non-R User-Agent request failed (HTTP $plain_status)" - elif cmp -s "$plain_file" "$flat_file"; then - ok "$slot non-R User-Agent still served the flat index" - else - bad "$slot non-R User-Agent was routed away from the flat index" - fi - - # Tarball requests must never be rewritten into a per-minor directory: - # flat-slot packages do not live there. - sample_pkg=$(gunzip -c "$flat_file" | awk '/^Package:/ {p=$2} /^Version:/ {print p, $2; exit}') - if [ -n "$sample_pkg" ]; then - # shellcheck disable=SC2086 # deliberate split into $1 (package) and $2 (version) - set -- $sample_pkg - tb="$BASE/$slot/latest/src/contrib/${1}_${2}.tar.gz" - tb_status=$(curl -sS -o /dev/null -w '%{http_code}' -A "$(r_user_agent 4.5)" --max-time 60 "$tb" 2>/dev/null) - if [ "$tb_status" = "200" ]; then - ok "$slot tarball request under an R User-Agent still resolves" - else - bad "$slot tarball ${1}_${2}.tar.gz broke under an R User-Agent (HTTP $tb_status)" - fi - fi - fi - done -done - -echo -echo "passed: $PASS failed: $FAIL" -if [ "$FAIL" -ne 0 ]; then - printf 'failures:%b\n' "$FAILURES" - exit 1 -fi diff --git a/stats/README.md b/stats/README.md deleted file mode 100644 index 133b4d9..0000000 --- a/stats/README.md +++ /dev/null @@ -1,64 +0,0 @@ -# Download statistics - -This directory turns the cran.rpkgs.com CDN access logs into the public download numbers on [rpkgs.com/stats](https://rpkgs.com/stats). -The `download-stats` pipeline runs it every hour. - -## Data flow - -1. `collect.ts` reads the last 70 hours of access logs from the Bunny Logging API v2 and inserts each request into `download_stats.events` in the build metadata database. -2. `classify.ts` derives what each request was (package download, index fetch, redirect, probe, noise) from its path, status and User-Agent. -3. `publish.ts` aggregates the events into `stats/downloads.json` in the binaries bucket and purges its CDN copy, so it is served at . -4. `packages.ts` writes one file per package, `stats/packages/.json`, with its daily series and its versions, distributions, R versions and architectures for each window. The dashboard fetches one only when that package is opened, so the main file does not grow with the number of packages. - -Bunny keeps access logs for three days. -Each hourly run re-reads almost all of that window, and events are keyed by Bunny's request id, so re-reading never double counts and up to two days of failed runs lose nothing. -Every run is recorded in `download_stats.runs`, and the dashboard marks any hour that no run covered. - -## Privacy - -Bunny anonymizes IPs at the edge to /24 (IPv4) or /64 (IPv6) before they reach the logs. -Not even that prefix is stored: each event keeps only `client`, an HMAC (keyed with `STATS_CLIENT_SALT`) of the prefix, the network (ASN) and the client platform from the User-Agent. -The public JSON contains counts only, never a client hash, IP or User-Agent. -Countries seen from fewer than three clients are folded into "other". - -## What counts - -| Metric | Definition | -| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Download | A distinct (client, package, version) served on one UTC day. Raw tarball requests are reported separately, because one CI job can re-download the same package many times a day. | -| Client | A distinct `client` hash that fetched an index or a package. Several machines behind one /24 count once, and one laptop on two networks counts twice, so this is an estimate. | -| Client-day | A client active on a given day, roughly one install session. | - -The same R session seen with and without renv's User-Agent prefix counts as one client, since `clientPlatform()` keys on the R part of the User-Agent. - -## What is separated or excluded - -- **Cloud and CI networks** are kept but reported separately: Microsoft/GitHub, AWS, Google, Hetzner, OVH and other hosting ASNs, plus any network whose name says hosting, cloud or data centre. -- **Our own CI runners** (`STATS_OWN_NETWORKS`) are excluded from every public number and only counted as excluded requests. -- **Internal redirects** (`minor_routing`, `slot_resolution`, `https`) are not counted, only the request they lead to. -- **Redirects away from us** are counted as their own metrics: `unsupported_r_minor` (demand for R versions we do not build), `archive_fallback` (old versions we have no binary for), `unknown_distro` and `macos`. -- **Probes**: renv and pak request `__api__/status` to check for Posit Package Manager. -- **Noise**: vulnerability scanners, crawlers and anything outside the repository layout. - -## Changing the rules - -Change `classify.ts`, add a test case to `classify.test.ts` and bump `RULESET`. -Then recompute every stored event: - -```sh -bun stats/collect.ts --reclassify -``` - -The raw path, status, User-Agent and network are stored for exactly this reason. -Whether a request came from our own runners is decided at ingest, so changing `STATS_OWN_NETWORKS` only affects new events. - -## Running locally - -The secrets are in OpenBao: the Bunny key at `development/agent-dev/bunny`, the database password at `development/agent-dev/rpkgs-metadata-db` and the salt and own networks at `development/agent-dev/rpkgs-download-stats`. - -```sh -bun test stats -bun stats/collect.ts -# write the JSON locally instead of uploading it -bun stats/publish.ts --out downloads.json -``` diff --git a/stats/classify.test.ts b/stats/classify.test.ts deleted file mode 100644 index 09c96f8..0000000 --- a/stats/classify.test.ts +++ /dev/null @@ -1,139 +0,0 @@ -import { describe, expect, test } from 'bun:test'; -import { classify, clientPlatform, parseNetworks, toEvent, tool, type LogEntry } from './classify'; - -const R_RHEL = 'R/4.5.3 R (4.5.3 x86_64-pc-linux-gnu x86_64 linux-gnu)'; -const RENV_RHEL = 'renv (1.2.3); R/4.5.3 R (4.5.3 x86_64-pc-linux-gnu x86_64 linux-gnu)'; -const R_ALPINE = 'R/4.6.1 (Alpine Linux 3.24.1) (aarch64-unknown-linux-musl aarch64 linux-musl)'; -const R_43 = 'R (4.3.2 x86_64-pc-linux-gnu x86_64 linux-gnu)'; - -const base = { status: 200, user_agent: R_RHEL, asn: 3303, asn_org: 'Swisscom', own: false }; - -describe('classify', () => { - test('flat tarball is a download with package, version and slot', () => { - const d = classify({ ...base, path: '/amd64/rhel9/latest/src/contrib/data.table_1.17.8.tar.gz' }); - expect(d).toMatchObject({ - kind: 'download', - outcome: 'served', - slot: 'amd64/rhel9', - arch: 'amd64', - os: 'rhel9', - package: 'data.table', - version: '1.17.8', - r_minor: '4.5', - r_version: '4.5.3', - tool: 'R', - network: 'other', - }); - }); - - test('per-minor tarball and index keep the slot', () => { - expect(classify({ ...base, path: '/arm64/alpine324/latest/src/contrib/4.6/Rcpp_1.1.0.tar.gz' })).toMatchObject({ - kind: 'download', - slot: 'arm64/alpine324', - package: 'Rcpp', - }); - expect(classify({ ...base, path: '/amd64/rhel9/latest/src/contrib/4.5/PACKAGES.rds' }).kind).toBe('index'); - }); - - test('index redirect with a known minor is internal minor routing', () => { - const d = classify({ ...base, status: 302, path: '/amd64/rhel9/latest/src/contrib/PACKAGES.rds' }); - expect(d).toMatchObject({ kind: 'index', outcome: 'redirect', redirect_reason: 'minor_routing' }); - }); - - test('redirect for an R minor we do not build is unsupported_r_minor', () => { - const d = classify({ ...base, user_agent: R_43, status: 302, path: '/amd64/noble/latest/src/contrib/PACKAGES' }); - expect(d).toMatchObject({ redirect_reason: 'unsupported_r_minor', r_minor: '4.3' }); - }); - - test('archived version without a binary falls back to CRAN', () => { - const d = classify({ - ...base, - status: 302, - path: '/amd64/rhel9/latest/src/contrib/Archive/renv/renv_1.2.3.tar.gz', - }); - expect(d).toMatchObject({ kind: 'download', redirect_reason: 'archive_fallback', package: 'renv' }); - }); - - test('bare URL: identified distro resolves to a slot, stock R UA goes to CRAN', () => { - expect( - classify({ ...base, user_agent: R_ALPINE, status: 302, path: '/src/contrib/PACKAGES.rds' }).redirect_reason, - ).toBe('slot_resolution'); - expect(classify({ ...base, status: 302, path: '/src/contrib/PACKAGES.rds' }).redirect_reason).toBe( - 'unknown_distro', - ); - }); - - test('renv and pak probing for Posit Package Manager is a probe', () => { - expect(classify({ ...base, status: 404, path: '/amd64/__api__/status' }).kind).toBe('probe'); - }); - - test('scanner paths are noise', () => { - for (const path of ['/.env', '/wp-content/plugins/x.php', '/.git/config', '/xwpg.php']) { - expect(classify({ ...base, status: 404, user_agent: 'Mozilla/5.0', path }).kind).toBe('noise'); - } - }); - - test('the stats file is not counted as repository use', () => { - expect(classify({ ...base, path: '/stats/downloads.json' }).kind).toBe('stats'); - }); - - test('cloud networks are labelled, own networks win over cloud', () => { - expect(classify({ ...base, asn: 8075, asn_org: 'Microsoft Corporation', path: '/' }).network).toBe('cloud'); - expect(classify({ ...base, asn: null, asn_org: 'Some Hosting Ltd', path: '/' }).network).toBe('cloud'); - expect(classify({ ...base, asn: 24940, own: true, path: '/' }).network).toBe('own'); - }); - - test('query strings and doubled slashes do not change the result', () => { - expect(classify({ ...base, path: '/amd64//rhel9/latest/src/contrib/PACKAGES.rds?x=1' }).kind).toBe('index'); - }); -}); - -describe('client identity', () => { - test('renv and plain R from the same machine share one platform key', () => { - expect(clientPlatform(RENV_RHEL)).toBe(clientPlatform(R_RHEL)); - expect(clientPlatform(R_ALPINE)).not.toBe(clientPlatform(R_RHEL)); - }); - - test('tool detection', () => { - expect(tool(RENV_RHEL)).toBe('renv'); - expect(tool(R_RHEL)).toBe('R'); - expect(tool('pak/0.9.0 R/4.5.1 (...)')).toBe('pak'); - expect(tool('curl/8.5.0')).toBe('curl'); - expect(tool('-')).toBe('none'); - expect(tool('Mozilla/5.0 (Windows NT 10.0)')).toBe('browser'); - }); - - test('own networks match by prefix for IPv4 and IPv6', () => { - const own = parseNetworks('203.0.113.0/24, 2001:db8:1:a100::/64'); - const matches = (ip: string) => own.some((m) => m(ip)); - expect(matches('203.0.113.0')).toBe(true); - expect(matches('203.0.114.0')).toBe(false); - expect(matches('2001:db8:1:a100::')).toBe(true); - expect(matches('2001:db8:1:a101::')).toBe(false); - expect(parseNetworks('')).toHaveLength(0); - }); - - test('toEvent hashes the client and never keeps the IP', () => { - const entry: LogEntry = { - timestamp: '2026-11-14T11:45:33.689+00:00', - pullZoneId: 3857050, - requestId: 'abc', - cacheStatus: 'HIT', - statusCode: 200, - bytesSent: 1000, - remoteIp: '203.0.113.0', - countryCode: 'CH', - host: 'cran.rpkgs.com', - path: '/amd64/rhel9/latest/src/contrib/rlang_1.1.6.tar.gz', - userAgent: RENV_RHEL, - asn: 3303, - asnOrganization: 'Swisscom', - }; - const event = toEvent(entry, (key) => `h(${key.length})`, parseNetworks('203.0.113.0/24')); - expect(event).not.toBeNull(); - expect(JSON.stringify(event)).not.toContain('203.0.113'); - expect(event!.own).toBe(true); - expect(event!.network).toBe('own'); - expect(toEvent({ ...entry, requestId: null }, (k) => k, [])).toBeNull(); - }); -}); diff --git a/stats/classify.ts b/stats/classify.ts deleted file mode 100644 index ab09ef6..0000000 --- a/stats/classify.ts +++ /dev/null @@ -1,410 +0,0 @@ -/** - * Turns one Bunny access-log entry into a classified download event. - * - * Everything here is pure so the rules can be unit-tested and re-run over the - * stored events (`collect.ts --reclassify`) whenever they change. Bump RULESET - * on any change that alters a derived column, so the public JSON can say which - * rules produced it. - * - * The rules mirror `edge/rpkgs-router.ts`: a redirect is classified by what the - * router would have done with that path and User-Agent, because the Location - * header is not in the logs. - */ - -export const RULESET = 1; - -/** R minors with a per-minor slot; keep in sync with KNOWN_MINORS in cdn.tf. */ -export const KNOWN_MINORS = new Set(['4.4', '4.5', '4.6']); - -export type Kind = - /** A package tarball. */ - | 'download' - /** `PACKAGES*`: one per repository per `install.packages()` call. */ - | 'index' - /** Other repository metadata, e.g. `Meta/archive.rds`. */ - | 'metadata' - /** renv and pak asking whether this is a Posit Package Manager (`__api__/…`). */ - | 'probe' - /** The repository root or `/src/contrib` without a file. */ - | 'root' - /** Our own `stats/` files, so the dashboard does not count itself. */ - | 'stats' - /** Anything else: vulnerability scanners, crawlers, typos. */ - | 'noise'; - -export type Outcome = 'served' | 'redirect' | 'error'; - -export type RedirectReason = - /** Internal hop: index sent to its per-R-minor slot. Not a user-visible event. */ - | 'minor_routing' - /** Internal hop: bare `cran.rpkgs.com` URL resolved to a slot. */ - | 'slot_resolution' - /** Client runs an R minor we do not build for; sent to CRAN for source. */ - | 'unsupported_r_minor' - /** Bare URL from a distro we could not identify; sent to CRAN. */ - | 'unknown_distro' - /** Archived version we have no binary for; sent to the CRAN source tarball. */ - | 'archive_fallback' - /** macOS client; sent to CRAN's macOS binaries. */ - | 'macos' - /** `http://` to `https://`. */ - | 'https' - | 'other'; - -export type Tool = 'R' | 'renv' | 'pak' | 'rig' | 'curl' | 'wget' | 'python' | 'browser' | 'none' | 'other'; - -export type Network = 'cloud' | 'other' | 'own'; - -export interface LogEntry { - timestamp: string; - pullZoneId: number; - requestId: string | null; - cacheStatus: string | null; - statusCode: number; - bytesSent: number; - remoteIp: string | null; - countryCode: string | null; - host: string | null; - path: string | null; - userAgent: string | null; - asn: number | null; - asnOrganization: string | null; -} - -export interface Derived { - ruleset: number; - kind: Kind; - outcome: Outcome; - redirect_reason: RedirectReason | null; - slot: string | null; - arch: string | null; - os: string | null; - r_minor: string | null; - r_version: string | null; - package: string | null; - version: string | null; - tool: Tool; - network: Network; -} - -/** The raw columns kept per event; everything Derived is recomputed from these. */ -export interface RawEvent { - request_id: string; - ts: string; - zone_id: number; - host: string | null; - status: number; - cache_status: string | null; - bytes: number; - path: string; - user_agent: string | null; - country: string | null; - asn: number | null; - asn_org: string | null; - /** HMAC of the (already anonymized) IP prefix, network and client platform. */ - client: string; - /** Matched one of our own networks at ingest. The IP itself is not kept. */ - own: boolean; -} - -export type Event = RawEvent & Derived; - -const SLOT_REGEX = /^\/(amd64|arm64)\/([a-z0-9._-]+)\/latest\/src\/contrib(?:\/(.*))?$/; -const BARE_REGEX = /^\/src\/contrib(?:\/(.*))?$/; -const MACOS_REGEX = /^\/bin\/macosx\/[^/]+\/contrib\/(\d+\.\d+)\/(.+)$/; -const MINOR_DIR_REGEX = /^(\d+\.\d+)\/(.*)$/; -const INDEX_REGEX = /^PACKAGES(\.gz|\.rds|\.json)?$/; -const TARBALL_REGEX = /(?:^|\/)([A-Za-z][A-Za-z0-9.]*)_([0-9][^/_]*)\.(?:tar\.gz|tgz)$/; -const R_VERSION_REGEXES = [/\bR\/(\d+\.\d+\.\d+)/, /\bR \((\d+\.\d+\.\d+)/]; -const ARCH_REGEX = /\b(x86_64|aarch64|arm64)\b/; -/** The distro forms `parseSlot()` in the router recognises. */ -const DISTRO_REGEX = /(almalinux|rocky)[^\d]*\d+|Ubuntu \d+\.\d+|Alpine Linux|alpine-\d/i; - -/** - * Networks whose clients are almost always machines: public clouds, CI - * providers and hosting companies. A request from one of these is reported as - * "cloud / CI" rather than dropped, since a CI pipeline is a real user too, - * just not a person at a laptop. - */ -const CLOUD_ASNS = new Map([ - [8075, 'Microsoft (incl. GitHub Actions runners)'], - [8068, 'Microsoft'], - [8069, 'Microsoft'], - [36459, 'GitHub'], - [16509, 'Amazon'], - [14618, 'Amazon'], - [15169, 'Google'], - [396982, 'Google Cloud'], - [24940, 'Hetzner'], - [213230, 'Hetzner Cloud'], - [212317, 'Hetzner'], - [16276, 'OVH'], - [14061, 'DigitalOcean'], - [51167, 'Contabo'], - [40021, 'Contabo US'], - [63949, 'Akamai / Linode'], - [31898, 'Oracle'], - [45102, 'Alibaba'], - [37963, 'Alibaba'], - [132203, 'Tencent'], - [45090, 'Tencent'], - [13335, 'Cloudflare'], - [62240, 'Clouvider'], - [12876, 'Scaleway'], - [20473, 'Vultr'], - [197540, 'netcup'], - [9009, 'M247'], - [60068, 'Datacamp / CDN77'], - [36352, 'ColoCrossing'], - [47583, 'Hostinger'], - [207990, 'HostRoyale'], -]); - -const CLOUD_ORG_REGEX = /\b(hosting|cloud|server(s)?|data ?cent(er|re)|colo(cation)?|vps|dedicated)\b/i; - -export function isCloudNetwork(asn: number | null, org: string | null): boolean { - if (asn !== null && CLOUD_ASNS.has(asn)) return true; - return org !== null && CLOUD_ORG_REGEX.test(org); -} - -export function normalizePath(path: string): string { - const withoutQuery = path.split('?')[0] ?? ''; - return withoutQuery.replace(/\/{2,}/g, '/'); -} - -export function rVersion(userAgent: string): string | null { - for (const regex of R_VERSION_REGEXES) { - const match = userAgent.match(regex); - if (match) return match[1]; - } - return null; -} - -export function rMinor(version: string | null): string | null { - if (!version) return null; - const [major, minor] = version.split('.'); - return `${major}.${minor}`; -} - -export function tool(userAgent: string): Tool { - const ua = userAgent.trim(); - if (ua === '' || ua === '-') return 'none'; - if (/^renv\b/i.test(ua)) return 'renv'; - if (/\bpak\b/i.test(ua)) return 'pak'; - if (/\brig\b/i.test(ua)) return 'rig'; - if (/^R[ /(]/.test(ua)) return 'R'; - if (/^curl\//i.test(ua)) return 'curl'; - if (/^wget\//i.test(ua)) return 'wget'; - if (/python|aiohttp|httpx/i.test(ua)) return 'python'; - if (/^Mozilla\//.test(ua)) return 'browser'; - return 'other'; -} - -/** - * The part of the User-Agent that identifies the machine rather than the tool. - * - * `renv (1.2.3); R/4.5.3 R (4.5.3 x86_64-pc-linux-gnu …)` and - * `R/4.5.3 R (4.5.3 x86_64-pc-linux-gnu …)` are the same R session, one going - * through renv and one not. Keying distinct clients on the full User-Agent - * would count that machine twice. - */ -export function clientPlatform(userAgent: string): string { - const version = rVersion(userAgent); - if (!version) return userAgent; - const rPart = userAgent.slice(userAgent.search(/\bR[/ ]\(?\d/)); - return rPart.replace(/\bR\/\d+\.\d+\.\d+\s*/, '').trim() || version; -} - -function slotParts(slot: string | null): { arch: string | null; os: string | null } { - if (!slot) return { arch: null, os: null }; - const [arch, os] = slot.split('/'); - return { arch: arch ?? null, os: os ?? null }; -} - -function archFromUserAgent(userAgent: string): string | null { - const match = userAgent.match(ARCH_REGEX); - if (!match) return null; - return match[1] === 'x86_64' ? 'amd64' : 'arm64'; -} - -function fileKind(rest: string): Kind { - if (rest === '') return 'root'; - if (INDEX_REGEX.test(rest)) return 'index'; - if (TARBALL_REGEX.test(rest)) return 'download'; - if (/^Meta\//.test(rest) || /^PACKAGES/.test(rest)) return 'metadata'; - return 'noise'; -} - -function outcome(status: number): Outcome { - if (status === 301 || status === 302 || status === 303 || status === 307 || status === 308) return 'redirect'; - if (status >= 200 && status < 400) return 'served'; - return 'error'; -} - -export function classify( - raw: Pick, - scheme = 'https', -): Derived { - const path = normalizePath(raw.path); - const userAgent = raw.user_agent ?? ''; - const version = rVersion(userAgent); - const minor = rMinor(version); - const result: Derived = { - ruleset: RULESET, - kind: 'noise', - outcome: outcome(raw.status), - redirect_reason: null, - slot: null, - arch: null, - os: null, - r_minor: minor, - r_version: version, - package: null, - version: null, - tool: tool(userAgent), - network: raw.own ? 'own' : isCloudNetwork(raw.asn, raw.asn_org) ? 'cloud' : 'other', - }; - - let rest: string | null = null; - let area: 'slot' | 'bare' | 'macos' | null = null; - - const slot = path.match(SLOT_REGEX); - const bare = path.match(BARE_REGEX); - const macos = path.match(MACOS_REGEX); - - if (path.includes('/__api__/')) { - result.kind = 'probe'; - } else if (path.startsWith('/stats/')) { - result.kind = 'stats'; - } else if (path === '/') { - result.kind = 'root'; - area = 'bare'; - } else if (slot) { - area = 'slot'; - result.slot = `${slot[1]}/${slot[2]}`; - rest = slot[3] ?? ''; - } else if (bare) { - area = 'bare'; - rest = bare[1] ?? ''; - } else if (macos) { - area = 'macos'; - result.os = 'macos'; - rest = macos[2]; - } - - if (rest !== null) { - const minorDir = rest.match(MINOR_DIR_REGEX); - const file = minorDir ? minorDir[2] : rest; - result.kind = fileKind(file); - const tarball = file.match(TARBALL_REGEX); - if (tarball) { - result.package = tarball[1]; - result.version = tarball[2]; - } - } - - const parts = slotParts(result.slot); - result.arch = parts.arch ?? archFromUserAgent(userAgent); - result.os = parts.os ?? result.os; - - if (result.outcome === 'redirect') { - result.redirect_reason = redirectReason(raw.status, area, rest, minor, scheme, userAgent); - } - - return result; -} - -function redirectReason( - status: number, - area: 'slot' | 'bare' | 'macos' | null, - rest: string | null, - minor: string | null, - scheme: string, - userAgent: string, -): RedirectReason { - if (status === 301 || scheme === 'http') return 'https'; - if (area === 'macos' || (area === 'bare' && /darwin/.test(userAgent))) return 'macos'; - if (minor !== null && !KNOWN_MINORS.has(minor) && (area === 'slot' || area === 'bare')) { - return 'unsupported_r_minor'; - } - if (area === 'slot') { - if (rest !== null && rest.startsWith('Archive/')) return 'archive_fallback'; - if (rest !== null && INDEX_REGEX.test(rest)) return 'minor_routing'; - return 'other'; - } - if (area === 'bare') { - // The router resolves a bare URL only when it can identify the distro from - // the User-Agent; otherwise it sends the client to CRAN. A stock R - // User-Agent (`R (4.5.3 x86_64-pc-linux-gnu …)`) names no distro. - return DISTRO_REGEX.test(userAgent) && ARCH_REGEX.test(userAgent) ? 'slot_resolution' : 'unknown_distro'; - } - return 'other'; -} - -/** Parse `"a.b.c.0/24,2001:db8::/64"` into prefix matchers for our own networks. */ -export function parseNetworks(spec: string): ((ip: string) => boolean)[] { - return spec - .split(',') - .map((cidr) => cidr.trim()) - .filter((cidr) => cidr.length > 0) - .map((cidr) => { - const [base, bitsText] = cidr.split('/'); - const v6 = base.includes(':'); - const bits = Number(bitsText ?? (v6 ? 128 : 32)); - const baseBits = ipBits(base); - return (ip: string) => { - if (ip.includes(':') !== v6) return false; - const candidate = ipBits(ip); - return baseBits !== null && candidate !== null && candidate.slice(0, bits) === baseBits.slice(0, bits); - }; - }); -} - -function ipBits(ip: string): string | null { - if (!ip.includes(':')) { - const octets = ip.split('.').map(Number); - if (octets.length !== 4 || octets.some((o) => !Number.isInteger(o) || o < 0 || o > 255)) return null; - return octets.map((o) => o.toString(2).padStart(8, '0')).join(''); - } - const [head, tail] = ip.split('::'); - const headGroups = head ? head.split(':') : []; - const tailGroups = tail ? tail.split(':') : []; - const missing = 8 - headGroups.length - tailGroups.length; - if (ip.includes('::') ? missing < 0 : missing !== 0) return null; - const groups = [...headGroups, ...Array(Math.max(missing, 0)).fill('0'), ...tailGroups]; - return groups - .map((g) => - parseInt(g || '0', 16) - .toString(2) - .padStart(16, '0'), - ) - .join(''); -} - -/** Build the stored event. Returns null for entries without a request id. */ -export function toEvent( - entry: LogEntry, - hashClient: (key: string) => string, - ownNetworks: ((ip: string) => boolean)[], -): Event | null { - if (!entry.requestId) return null; - const ip = entry.remoteIp ?? ''; - const userAgent = entry.userAgent ?? ''; - const raw: RawEvent = { - request_id: entry.requestId, - ts: entry.timestamp, - zone_id: entry.pullZoneId, - host: entry.host, - status: entry.statusCode, - cache_status: entry.cacheStatus, - bytes: entry.bytesSent, - path: entry.path ?? '', - user_agent: entry.userAgent, - country: entry.countryCode, - asn: entry.asn, - asn_org: entry.asnOrganization, - client: hashClient(`${ip}|${entry.asn ?? ''}|${clientPlatform(userAgent)}`), - own: ip !== '' && ownNetworks.some((matches) => matches(ip)), - }; - return { ...raw, ...classify(raw) }; -} diff --git a/stats/collect.ts b/stats/collect.ts deleted file mode 100644 index 432c064..0000000 --- a/stats/collect.ts +++ /dev/null @@ -1,157 +0,0 @@ -/** - * Pull the CDN access logs into `download_stats.events`. - * - * bun stats/collect.ts # fetch the last 70 hours, insert what is new - * bun stats/collect.ts --reclassify # recompute derived columns after a rule change - * - * Bunny keeps logs for three days, so every run re-reads almost all of that - * window. Events are keyed by Bunny's request id, which makes re-reading free - * of double counts, and a run that fails is simply covered by the next one. - * - * Environment: BUNNYNET_API_KEY, PGPASS, STATS_CLIENT_SALT, and optionally - * STATS_PULL_ZONE (default: cran-rpkgs) and STATS_OWN_NETWORKS (comma-separated - * CIDRs of our own CI runners, kept out of the public numbers). - */ -import { classify, parseNetworks, toEvent, type Event, type LogEntry } from './classify'; -import { connect, migrate } from './db'; - -const PULL_ZONE = Number(process.env.STATS_PULL_ZONE ?? 3857050); -const WINDOW_HOURS = 70; -const PAGE_SIZE = 10000; - -const COLUMNS = [ - 'request_id', - 'ts', - 'zone_id', - 'host', - 'status', - 'cache_status', - 'bytes', - 'path', - 'user_agent', - 'country', - 'asn', - 'asn_org', - 'client', - 'own', - 'ruleset', - 'kind', - 'outcome', - 'redirect_reason', - 'slot', - 'arch', - 'os', - 'r_minor', - 'r_version', - 'package', - 'version', - 'tool', - 'network', -] as const; - -function requireEnv(name: string): string { - const value = process.env[name]; - if (!value) throw new Error(`${name} is not set`); - return value; -} - -async function fetchPage( - apiKey: string, - from: Date, - to: Date, - offset: number, -): Promise<{ data: LogEntry[]; hasMore: boolean }> { - const url = new URL(`https://logging.bunnycdn.com/v2/pullzones/${PULL_ZONE}/logs`); - url.searchParams.set('from', from.toISOString()); - url.searchParams.set('to', to.toISOString()); - url.searchParams.set('order', 'asc'); - url.searchParams.set('limit', String(PAGE_SIZE)); - url.searchParams.set('offset', String(offset)); - - for (let attempt = 1; ; attempt++) { - const response = await fetch(url, { headers: { AccessKey: apiKey, Accept: 'application/json' } }); - if (response.ok) { - const body = (await response.json()) as { data: LogEntry[]; pagination: { hasMore: boolean } }; - return { data: body.data, hasMore: body.pagination.hasMore }; - } - if ((response.status === 429 || response.status >= 500) && attempt < 6) { - await Bun.sleep(2000 * attempt); - continue; - } - throw new Error(`Bunny logging API returned ${response.status}: ${await response.text()}`); - } -} - -async function collect(): Promise { - const apiKey = requireEnv('BUNNYNET_API_KEY'); - const salt = requireEnv('STATS_CLIENT_SALT'); - const ownNetworks = parseNetworks(process.env.STATS_OWN_NETWORKS ?? ''); - const hashClient = (key: string) => new Bun.CryptoHasher('sha256', salt).update(key).digest('hex').slice(0, 20); - - // Fixing `to` up front keeps offset pagination stable while new requests - // keep arriving. - const to = new Date(); - const from = new Date(to.getTime() - WINDOW_HOURS * 3600 * 1000); - - const events: Event[] = []; - let fetched = 0; - for (let offset = 0; ;) { - const page = await fetchPage(apiKey, from, to, offset); - fetched += page.data.length; - for (const entry of page.data) { - const event = toEvent(entry, hashClient, ownNetworks); - if (event) events.push(event); - } - if (!page.hasMore || page.data.length === 0) break; - offset += page.data.length; - } - - const sql = connect(); - await migrate(sql); - let inserted = 0; - for (let i = 0; i < events.length; i += 1000) { - const batch = events.slice(i, i + 1000); - const rows = await sql` - insert into download_stats.events ${sql(batch, ...COLUMNS)} - on conflict (request_id) do nothing - returning 1`; - inserted += rows.length; - } - await sql` - insert into download_stats.runs (zone_id, window_from, window_to, fetched, inserted) - values (${PULL_ZONE}, ${from}, ${to}, ${fetched}, ${inserted})`; - await sql.close(); - - console.log( - `fetched ${fetched} log entries from ${from.toISOString()} to ${to.toISOString()}, inserted ${inserted} new`, - ); -} - -async function reclassify(): Promise { - const sql = connect(); - await migrate(sql); - const rows: Event[] = - await sql`select request_id, path, status, user_agent, asn, asn_org, own from download_stats.events`; - let updated = 0; - for (let i = 0; i < rows.length; i += 1000) { - const batch = rows.slice(i, i + 1000).map((row) => ({ request_id: row.request_id, ...classify(row) })); - await sql.begin(async (tx) => { - for (const row of batch) { - await tx` - update download_stats.events set - ruleset = ${row.ruleset}, kind = ${row.kind}, outcome = ${row.outcome}, - redirect_reason = ${row.redirect_reason}, slot = ${row.slot}, arch = ${row.arch}, os = ${row.os}, - r_minor = ${row.r_minor}, r_version = ${row.r_version}, package = ${row.package}, - version = ${row.version}, tool = ${row.tool}, network = ${row.network} - where request_id = ${row.request_id}`; - } - }); - updated += batch.length; - } - await sql.close(); - console.log(`reclassified ${updated} events`); -} - -if (import.meta.main) { - await (process.argv.includes('--reclassify') ? reclassify() : collect()); -} diff --git a/stats/db.ts b/stats/db.ts deleted file mode 100644 index 2169149..0000000 --- a/stats/db.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { SQL } from 'bun'; - -/** - * Download events live in their own `download_stats` schema in the build - * metadata database, next to (but never joined with) `single_builds`. - * - * No IP address is stored, not even the /24 prefix Bunny logs: only a salted - * HMAC of it (`client`) and whether it matched one of our own networks. - */ -const SCHEMA = ` -create schema if not exists download_stats; - -create table if not exists download_stats.events ( - request_id text primary key, - ts timestamptz not null, - zone_id integer not null, - host text, - status smallint not null, - cache_status text, - bytes bigint not null, - path text not null, - user_agent text, - country text, - asn integer, - asn_org text, - client text not null, - own boolean not null, - ruleset smallint not null, - kind text not null, - outcome text not null, - redirect_reason text, - slot text, - arch text, - os text, - r_minor text, - r_version text, - package text, - version text, - tool text not null, - network text not null -); - -create index if not exists events_ts_idx on download_stats.events (ts); -create index if not exists events_package_idx on download_stats.events (package) where kind = 'download'; - --- One row per collection run. The union of successful windows is what the --- dashboard reports as covered; anything outside it is shown as a gap. -create table if not exists download_stats.runs ( - id bigserial primary key, - zone_id integer not null, - started_at timestamptz not null default now(), - window_from timestamptz not null, - window_to timestamptz not null, - fetched integer not null, - inserted integer not null -); -`; - -export function connect(): SQL { - const password = process.env.PGPASS; - if (!password) throw new Error('PGPASS is not set'); - return new SQL({ - hostname: process.env.PGHOST ?? 'r-binaries.devxy.io', - port: Number(process.env.PGPORT ?? 15432), - database: process.env.PGDATABASE ?? 'build_metadata', - username: process.env.PGUSER ?? 'rpkgs', - password, - tls: true, - max: 2, - }); -} - -export async function migrate(sql: SQL): Promise { - await sql.unsafe(SCHEMA); -} diff --git a/stats/packages.test.ts b/stats/packages.test.ts deleted file mode 100644 index c143bd8..0000000 --- a/stats/packages.test.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { expect, test } from 'bun:test'; -import { compareVersions } from './packages'; - -test('versions order numerically, not as text', () => { - expect(['1.10.0', '1.9.2', '1.2-3', '1.2-10'].sort(compareVersions)).toEqual(['1.2-3', '1.2-10', '1.9.2', '1.10.0']); - expect(compareVersions('3.6.6', '3.6.6')).toBe(0); - expect(compareVersions('1.0', '1.0.1')).toBeLessThan(0); -}); diff --git a/stats/packages.ts b/stats/packages.ts deleted file mode 100644 index 5f186af..0000000 --- a/stats/packages.ts +++ /dev/null @@ -1,139 +0,0 @@ -/** - * Per-package statistics, one file per package at `stats/packages/.json`. - * - * Kept out of `downloads.json` so the main file stays small however many - * packages are served: the dashboard only fetches a package's file when that - * package is opened. - * - * The same rules as the repository numbers apply: our own runners are left out, - * and a download is a distinct (client, package, version) on one UTC day. - */ -import type { SQL } from 'bun'; -import type { Breakdown } from './publish'; - -export interface PackageWindow { - downloads: number; - clients: number; - versions: Breakdown[]; - os: Breakdown[]; - rMinor: Breakdown[]; - arch: Breakdown[]; -} - -export interface PackageFile { - schema: 1; - name: string; - generatedAt: string; - /** Highest version seen downloaded, by `numeric_version` ordering. */ - latestVersion: string | null; - /** Position by downloads in the last 30 days, 1-based; null without downloads in that window. */ - rank30d: number | null; - firstDay: string | null; - daily: { date: string; downloads: number; clients: number }[]; - windows: { last7: PackageWindow; last30: PackageWindow; all: PackageWindow }; -} - -const WINDOWS = { last7: 7, last30: 30, all: null } as const; - -type Dimension = 'versions' | 'os' | 'rMinor' | 'arch'; - -export function compareVersions(a: string, b: string): number { - const pa = a.split(/[.-]/).map(Number); - const pb = b.split(/[.-]/).map(Number); - for (let i = 0; i < Math.max(pa.length, pb.length); i++) { - const d = (pa[i] ?? 0) - (pb[i] ?? 0); - if (d !== 0) return d; - } - return 0; -} - -const emptyWindow = (): PackageWindow => ({ downloads: 0, clients: 0, versions: [], os: [], rMinor: [], arch: [] }); - -export async function buildPackageFiles(sql: SQL, generatedAt: string): Promise { - const files = new Map(); - const file = (name: string): PackageFile => { - let f = files.get(name); - if (!f) { - f = { - schema: 1, - name, - generatedAt, - latestVersion: null, - rank30d: null, - firstDay: null, - daily: [], - windows: { last7: emptyWindow(), last30: emptyWindow(), all: emptyWindow() }, - }; - files.set(name, f); - } - return f; - }; - - const daily: { package: string; date: string; downloads: number; clients: number }[] = await sql` - with dl as ( - select distinct client, package, version, os, r_minor, arch, (ts at time zone 'UTC')::date as day - from download_stats.events - where network <> 'own' and outcome = 'served' and kind = 'download' and package is not null - ) - select package, day::text as date, count(distinct (client, version))::int as downloads, - count(distinct client)::int as clients - from dl group by package, day order by package, day`; - for (const row of daily) { - const f = file(row.package); - f.daily.push({ date: row.date, downloads: row.downloads, clients: row.clients }); - f.firstDay ??= row.date; - } - - for (const [windowId, days] of Object.entries(WINDOWS) as [keyof typeof WINDOWS, number | null][]) { - const since = days === null ? new Date(0) : new Date(Date.now() - days * 86400000); - const rows: { - package: string; - dimension: Dimension | null; - key: string | null; - downloads: number; - clients: number; - }[] = await sql` - with dl as ( - select distinct client, package, version, os, r_minor, arch, (ts at time zone 'UTC')::date as day - from download_stats.events - where network <> 'own' and outcome = 'served' and kind = 'download' and package is not null - and ts >= ${since} - ) - select package, - case - when grouping(version) = 0 then 'versions' - when grouping(os) = 0 then 'os' - when grouping(r_minor) = 0 then 'rMinor' - when grouping(arch) = 0 then 'arch' - end as dimension, - coalesce(version, os, r_minor, arch) as key, - count(distinct (client, version, day))::int as downloads, - count(distinct client)::int as clients - from dl - group by package, grouping sets ((), (version), (os), (r_minor), (arch))`; - for (const row of rows) { - const w = file(row.package).windows[windowId]; - if (row.dimension === null) { - w.downloads = row.downloads; - w.clients = row.clients; - } else { - w[row.dimension].push({ key: row.key ?? 'unknown', clients: row.clients, downloads: row.downloads }); - } - } - } - - const ranked = [...files.values()] - .filter((f) => f.windows.last30.downloads > 0) - .sort((a, b) => b.windows.last30.downloads - a.windows.last30.downloads || a.name.localeCompare(b.name)); - ranked.forEach((f, i) => (f.rank30d = i + 1)); - - for (const f of files.values()) { - const versions = f.windows.all.versions.map((v) => v.key).filter((v) => v !== 'unknown'); - f.latestVersion = versions.sort(compareVersions).at(-1) ?? null; - for (const w of Object.values(f.windows)) { - w.versions.sort((a, b) => compareVersions(b.key, a.key)); - for (const dim of ['os', 'rMinor', 'arch'] as const) w[dim].sort((a, b) => b.clients - a.clients); - } - } - return [...files.values()]; -} diff --git a/stats/publish.ts b/stats/publish.ts deleted file mode 100644 index e0f21e3..0000000 --- a/stats/publish.ts +++ /dev/null @@ -1,392 +0,0 @@ -/** - * Aggregate `download_stats.events` into the public `stats/downloads.json`. - * - * bun stats/publish.ts --out downloads.json # write locally only - * bun stats/publish.ts # upload to the bucket and purge the CDN copy - * - * The output holds counts only. Distinct clients are counted from the stored - * HMAC, which never leaves the database, and countries seen from fewer than - * MIN_CLIENTS clients are folded into "other" so no single client can be - * picked out by where it is. - * - * Every number excludes our own CI runners. Cloud and CI networks are kept but - * reported separately, since one pipeline can outweigh every person combined. - */ -import { S3Client, type SQL } from 'bun'; -import { KNOWN_MINORS, RULESET } from './classify'; -import { connect, migrate } from './db'; -import { buildPackageFiles, type PackageFile } from './packages'; - -const MIN_CLIENTS = 3; -const PUBLIC_URL = 'https://cran.rpkgs.com/stats/downloads.json'; -const OBJECT_KEY = 'stats/downloads.json'; -const PACKAGES_PREFIX = 'stats/packages/'; - -/** Split of a count by network class. */ -export interface Split { - total: number; - cloud: number; - other: number; -} - -export interface DayStats { - date: string; - /** Hours of this UTC day for which logs were collected (24 = complete). */ - coveredHours: number; - /** Tarball requests served, before any de-duplication. */ - requests: number; - /** Distinct (client, package, version) served on the day. */ - downloads: Split; - /** Distinct clients that fetched an index or a package. */ - clients: Split; - /** Distinct clients sent to CRAN because we do not build for their R minor. */ - unsupportedMinorClients: number; - bytes: number; -} - -export interface WindowStats { - days: number; - downloads: Split; - /** Distinct clients across the whole window. */ - clients: Split; - /** Sum of daily distinct clients: roughly, install sessions. */ - clientDays: Split; - /** Distinct packages with at least one download. */ - packages: number; - /** Bytes served for packages and indexes. */ - bytes: number; -} - -export interface Breakdowns { - network: Breakdown[]; - os: Breakdown[]; - arch: Breakdown[]; - rMinor: Breakdown[]; - tool: Breakdown[]; - country: Breakdown[]; -} - -export interface Breakdown { - key: string; - clients: number; - downloads: number; -} - -export interface PackageStats { - name: string; - downloads7d: number; - clients7d: number; - downloads30d: number; - clients30d: number; - downloadsAll: number; - clientsAll: number; -} - -export interface PublicStats { - schema: 1; - ruleset: number; - generatedAt: string; - firstDay: string | null; - lastDay: string | null; - supportedMinors: string[]; - daily: DayStats[]; - windows: { last7: WindowStats; last30: WindowStats; all: WindowStats }; - /** Distribution of distinct packages fetched per client per day (30 days). */ - packagesPerClientDay: { median: number; p90: number }; - /** Last 30 days. */ - breakdowns: Breakdowns; - /** The same breakdowns for every window; `breakdowns` is `last30`, kept for older readers. */ - breakdownsByWindow: { last7: Breakdowns; last30: Breakdowns; all: Breakdowns }; - /** Last 30 days: clients we sent elsewhere, and why. */ - redirects: { reason: string; clients: number; requests: number }[]; - unsupportedMinors: Breakdown[]; - /** Last 30 days: requests that were not repository use at all. */ - excluded: { ownRunners: number; probes: number; noise: number; errors: number }; - packages: PackageStats[]; -} - -const split = (row: Record, prefix: string): Split => ({ - total: Number(row[`${prefix}_total`] ?? 0), - cloud: Number(row[`${prefix}_cloud`] ?? 0), - other: Number(row[`${prefix}_other`] ?? 0), -}); - -async function coverage(sql: SQL): Promise> { - const runs: { window_from: Date; window_to: Date }[] = - await sql`select window_from, window_to from download_stats.runs order by window_from`; - const merged: [number, number][] = []; - for (const run of runs) { - const from = run.window_from.getTime(); - const to = run.window_to.getTime(); - const last = merged.at(-1); - if (last && from <= last[1]) last[1] = Math.max(last[1], to); - else merged.push([from, to]); - } - const hours = new Map(); - const DAY = 86400000; - for (const [from, to] of merged) { - for (let day = Math.floor(from / DAY) * DAY; day < to; day += DAY) { - const overlap = Math.min(to, day + DAY) - Math.max(from, day); - const key = new Date(day).toISOString().slice(0, 10); - hours.set(key, (hours.get(key) ?? 0) + overlap / 3600000); - } - } - return hours; -} - -async function windowStats(sql: SQL, days: number | null): Promise { - const since = days === null ? new Date(0) : new Date(Date.now() - days * 86400000); - const [row] = await sql` - with ev as ( - select client, network, kind, package, version, (ts at time zone 'UTC')::date as day - from download_stats.events - where network <> 'own' and outcome = 'served' and kind in ('download', 'index') and ts >= ${since} - ), - dl as (select distinct client, network, package, version, day from ev where kind = 'download'), - cd as (select distinct client, network, day from ev) - select - (select count(*) from dl) as downloads_total, - (select count(*) from dl where network = 'cloud') as downloads_cloud, - (select count(*) from dl where network = 'other') as downloads_other, - (select count(distinct client) from ev) as clients_total, - (select count(distinct client) from ev where network = 'cloud') as clients_cloud, - (select count(distinct client) from ev where network = 'other') as clients_other, - (select count(*) from cd) as client_days_total, - (select count(*) from cd where network = 'cloud') as client_days_cloud, - (select count(*) from cd where network = 'other') as client_days_other, - (select count(distinct package) from dl) as packages, - (select coalesce(sum(bytes), 0) from download_stats.events - where network <> 'own' and outcome = 'served' and kind in ('download', 'index') and ts >= ${since}) as bytes, - (select min(day) from ev) as first_day`; - const firstDay = row.first_day ? new Date(row.first_day) : null; - const span = firstDay ? Math.max(1, Math.ceil((Date.now() - firstDay.getTime()) / 86400000)) : 0; - return { - days: days === null ? span : Math.min(days, span), - downloads: split(row, 'downloads'), - clients: split(row, 'clients'), - clientDays: split(row, 'client_days'), - packages: Number(row.packages), - bytes: Number(row.bytes), - }; -} - -async function breakdown(sql: SQL, column: string, since: Date): Promise { - const rows: { key: string | null; clients: number; downloads: number }[] = await sql` - with ev as ( - select ${sql(column)}::text as key, client, kind, package, version, (ts at time zone 'UTC')::date as day - from download_stats.events - where network <> 'own' and outcome = 'served' and kind in ('download', 'index') and ts >= ${since} - ) - select key, count(distinct client)::int as clients, - (select count(*) from (select distinct client, package, version, day from ev e2 - where e2.kind = 'download' and e2.key is not distinct from ev.key) d)::int as downloads - from ev group by key order by clients desc`; - return rows.map((row) => ({ key: row.key ?? 'unknown', clients: row.clients, downloads: row.downloads })); -} - -/** Fold rows below the client threshold into one "other" row. */ -function suppress(rows: Breakdown[]): Breakdown[] { - const kept = rows.filter((row) => row.clients >= MIN_CLIENTS); - const folded = rows.filter((row) => row.clients < MIN_CLIENTS); - if (folded.length === 0) return kept; - return [ - ...kept, - { - key: 'other', - clients: folded.reduce((sum, row) => sum + row.clients, 0), - downloads: folded.reduce((sum, row) => sum + row.downloads, 0), - }, - ]; -} - -async function breakdowns(sql: SQL, since: Date): Promise { - return { - network: await breakdown(sql, 'network', since), - os: await breakdown(sql, 'os', since), - arch: await breakdown(sql, 'arch', since), - rMinor: await breakdown(sql, 'r_minor', since), - tool: await breakdown(sql, 'tool', since), - country: suppress(await breakdown(sql, 'country', since)), - }; -} - -export async function buildStats(sql: SQL): Promise { - const since30 = new Date(Date.now() - 30 * 86400000); - const byWindow = { - last7: await breakdowns(sql, new Date(Date.now() - 7 * 86400000)), - last30: await breakdowns(sql, since30), - all: await breakdowns(sql, new Date(0)), - }; - const covered = await coverage(sql); - - const dailyRows: Record[] = await sql` - with ev as ( - select *, (ts at time zone 'UTC')::date as day from download_stats.events where network <> 'own' - ), - served as (select * from ev where outcome = 'served' and kind in ('download', 'index')), - dl as (select distinct client, network, package, version, day from served where kind = 'download'), - cl as (select distinct client, network, day from served) - select d.day::text as date, - (select count(*) from served s where s.day = d.day and s.kind = 'download')::int as requests, - (select count(*) from dl where dl.day = d.day)::int as downloads_total, - (select count(*) from dl where dl.day = d.day and network = 'cloud')::int as downloads_cloud, - (select count(*) from dl where dl.day = d.day and network = 'other')::int as downloads_other, - (select count(*) from cl where cl.day = d.day)::int as clients_total, - (select count(*) from cl where cl.day = d.day and network = 'cloud')::int as clients_cloud, - (select count(*) from cl where cl.day = d.day and network = 'other')::int as clients_other, - (select count(distinct client) from ev e where e.day = d.day and e.redirect_reason = 'unsupported_r_minor')::int - as unsupported, - (select coalesce(sum(bytes), 0) from served s where s.day = d.day)::bigint as bytes - from (select distinct day from ev) d order by d.day`; - - const daily: DayStats[] = dailyRows.map((row) => ({ - date: String(row.date), - coveredHours: Math.round(Math.min(24, covered.get(String(row.date)) ?? 0) * 10) / 10, - requests: Number(row.requests), - downloads: split(row, 'downloads'), - clients: split(row, 'clients'), - unsupportedMinorClients: Number(row.unsupported), - bytes: Number(row.bytes), - })); - - const [perSession] = await sql` - with per as ( - select client, (ts at time zone 'UTC')::date as day, count(distinct (package, version)) as n - from download_stats.events - where network <> 'own' and outcome = 'served' and kind = 'download' and ts >= ${since30} - group by 1, 2 - ) - select coalesce(percentile_cont(0.5) within group (order by n), 0) as median, - coalesce(percentile_cont(0.9) within group (order by n), 0) as p90 - from per`; - - const redirects: { reason: string; clients: number; requests: number }[] = await sql` - select redirect_reason as reason, count(distinct client)::int as clients, count(*)::int as requests - from download_stats.events - where network <> 'own' and outcome = 'redirect' and ts >= ${since30} - and redirect_reason not in ('minor_routing', 'slot_resolution', 'https') - group by 1 order by clients desc`; - - const unsupportedMinors: Breakdown[] = await sql` - select r_minor as key, count(distinct client)::int as clients, count(*)::int as downloads - from download_stats.events - where network <> 'own' and redirect_reason = 'unsupported_r_minor' and ts >= ${since30} - group by 1 order by clients desc`; - - const [excluded] = await sql` - select - count(*) filter (where network = 'own')::int as own, - count(*) filter (where network <> 'own' and kind = 'probe')::int as probes, - count(*) filter (where network <> 'own' and kind = 'noise')::int as noise, - count(*) filter (where network <> 'own' and kind in ('download', 'index') and outcome = 'error')::int as errors - from download_stats.events where ts >= ${since30}`; - - const packages: PackageStats[] = ( - await sql` - with dl as ( - select distinct client, package, version, (ts at time zone 'UTC')::date as day, ts >= ${since30} as recent, - ts >= ${new Date(Date.now() - 7 * 86400000)} as week - from download_stats.events - where network <> 'own' and outcome = 'served' and kind = 'download' and package is not null - ) - select package as name, - count(distinct (client, version, day)) filter (where week)::int as downloads7d, - count(distinct client) filter (where week)::int as clients7d, - count(distinct (client, version, day)) filter (where recent)::int as downloads30d, - count(distinct client) filter (where recent)::int as clients30d, - count(distinct (client, version, day))::int as downloadsall, - count(distinct client)::int as clientsall - from dl group by package order by downloads30d desc, downloadsall desc, name` - ).map((row: Record) => ({ - name: String(row.name), - downloads7d: Number(row.downloads7d), - clients7d: Number(row.clients7d), - downloads30d: Number(row.downloads30d), - clients30d: Number(row.clients30d), - downloadsAll: Number(row.downloadsall), - clientsAll: Number(row.clientsall), - })); - - return { - schema: 1, - ruleset: RULESET, - generatedAt: new Date().toISOString(), - firstDay: daily[0]?.date ?? null, - lastDay: daily.at(-1)?.date ?? null, - supportedMinors: [...KNOWN_MINORS], - daily, - windows: { - last7: await windowStats(sql, 7), - last30: await windowStats(sql, 30), - all: await windowStats(sql, null), - }, - packagesPerClientDay: { median: Number(perSession.median), p90: Number(perSession.p90) }, - breakdowns: byWindow.last30, - breakdownsByWindow: byWindow, - redirects, - unsupportedMinors, - excluded: { - ownRunners: Number(excluded.own), - probes: Number(excluded.probes), - noise: Number(excluded.noise), - errors: Number(excluded.errors), - }, - packages, - }; -} - -async function purge(url: string): Promise { - const target = new URL('https://api.bunny.net/purge'); - target.searchParams.set('url', url); - target.searchParams.set('async', 'false'); - const response = await fetch(target, { method: 'POST', headers: { AccessKey: process.env.BUNNYNET_API_KEY ?? '' } }); - if (!response.ok) throw new Error(`purging ${url} failed with ${response.status}: ${await response.text()}`); -} - -async function upload(body: string, packages: PackageFile[]): Promise { - const s3 = new S3Client({ - accessKeyId: process.env.B2_S3_ACCESS_KEY, - secretAccessKey: process.env.B2_S3_SECRET_KEY, - bucket: process.env.STATS_BUCKET ?? 'devxy-rpkgs-binaries', - endpoint: 'https://s3.eu-central-003.backblazeb2.com', - region: 'eu-central-003', - }); - // Package files first, so the main file never lists a package whose own - // file is not there yet. - for (let i = 0; i < packages.length; i += 10) { - await Promise.all( - packages - .slice(i, i + 10) - .map((p) => s3.write(`${PACKAGES_PREFIX}${p.name}.json`, JSON.stringify(p), { type: 'application/json' })), - ); - } - await s3.write(OBJECT_KEY, body, { type: 'application/json' }); - - // The pull zone overrides origin caching with a one-year TTL, so the edge - // copies have to be purged for the new files to show up. - await purge(`https://cran.rpkgs.com/${PACKAGES_PREFIX}*`); - await purge(PUBLIC_URL); -} - -if (import.meta.main) { - const sql = connect(); - await migrate(sql); - const stats = await buildStats(sql); - const packages = await buildPackageFiles(sql, stats.generatedAt); - await sql.close(); - const body = JSON.stringify(stats); - - const outIndex = process.argv.indexOf('--out'); - if (outIndex !== -1) { - const out = process.argv[outIndex + 1]; - await Bun.write(out, JSON.stringify(stats, null, 2)); - const dir = `${out.replace(/[^/]*$/, '')}packages`; - for (const p of packages) await Bun.write(`${dir}/${p.name}.json`, JSON.stringify(p, null, 2)); - console.log(`wrote ${out} (${body.length} bytes) and ${packages.length} files in ${dir}`); - } else { - await upload(body, packages); - console.log( - `published ${PUBLIC_URL} (${body.length} bytes, ${stats.daily.length} days, ${stats.packages.length} packages)`, - ); - } -} diff --git a/vars.tf b/vars.tf index b831269..aad56ff 100644 --- a/vars.tf +++ b/vars.tf @@ -17,11 +17,3 @@ variable "B2_S3_SECRET_KEY" { type = string sensitive = true } - -variable "cdn_block_ips" { - description = "IP addresses to block at the BunnyCDN pullzones (cran.devxy.io, cran.rpkgs.com)." - type = list(string) - default = [ - "185.172.53.0", - ] -}