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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 74 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
# Triggers:
# - workflow_dispatch : manually, with configurable GDAL version + force flag
# - push to tag : gdal-v* (e.g. git tag gdal-v3.13.1)
# - schedule : weekly upstream check only — compares the latest
# OSGeo/gdal release against our newest published
# gdal-v* bundle and opens a tracking issue when a
# newer GDAL exists. Never builds or publishes on its
# own; a human dispatches the build after review.
#
# Artefact strategy (every run produces durable output):
# Workflow artifact : upload-artifact@v5 retention=30d no compression
Expand All @@ -32,6 +37,8 @@ on:
gdal_version:
description: 'GDAL git tag to build (e.g. v3.13.1)'
required: true
# current bundle baseline — keep in sync with env.GDAL_VERSION below
# and the "Latest GDAL runtime release" line in README.md
default: 'v3.13.1'
force_rebuild_gdal:
description: 'Force full GDAL rebuild, ignoring cache'
Expand All @@ -50,21 +57,86 @@ on:
tags:
- 'gdal-v*' # e.g. gdal-v3.13.1

schedule:
- cron: '0 6 * * 1' # Mondays 06:00 UTC — upstream release check only

# Required by softprops/action-gh-release to create releases and upload assets.
# Using minimum required scope — contents:write only.
# Using minimum required scope — contents:write only (the scheduled upstream
# check job narrows/extends its own permissions at job level).
permissions:
contents: write

# Centralise defaults for manual runs.
# keep the fallback in sync with the gdal_version input default above
env:
GDAL_VERSION: ${{ github.event.inputs.gdal_version || 'v3.13.1' }}

# ─────────────────────────────────────────────────────────────────────────────
# JOB 1 — Build GDAL from source
# JOB 0 — Scheduled upstream release check (schedule trigger only)
# ─────────────────────────────────────────────────────────────────────────────
jobs:
check-upstream:
name: "Check upstream GDAL release"
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Compare upstream GDAL release with newest published bundle
run: |
set -euo pipefail

upstream_tag=$(gh api repos/OSGeo/gdal/releases/latest --jq '.tag_name')
ours_tag=$(gh api "repos/${GITHUB_REPOSITORY}/releases?per_page=100" \
--jq '[.[] | select(.draft == false and .prerelease == false) | .tag_name | select(startswith("gdal-v"))][0] // empty')
ours_version="${ours_tag#gdal-}"

echo "upstream: ${upstream_tag}"
echo "ours: ${ours_version:-<none>} (${ours_tag:-no gdal-v* release})"

# sort -V puts the newest version last; equal versions mean up to date
newest=$(printf '%s\n%s\n' "${upstream_tag}" "${ours_version:-v0.0.0}" | sort -V | tail -n 1)
if [ "${newest}" = "${ours_version}" ] || [ "${upstream_tag}" = "${ours_version}" ]; then
echo "Bundle is up to date with upstream GDAL."
exit 0
fi

issue_title="upstream: GDAL ${upstream_tag} released — build new runtime bundle"
existing=$(gh issue list --repo "${GITHUB_REPOSITORY}" --state open \
--search "\"${issue_title}\" in:title" --json number --jq 'length')
if [ "${existing}" -gt 0 ]; then
echo "Tracking issue already open; nothing to do."
exit 0
fi

gh issue create --repo "${GITHUB_REPOSITORY}" \
--title "${issue_title}" \
--label upstream,build \
--body "$(printf '%s\n' \
"The scheduled upstream check found a newer GDAL release." \
"" \
"- Upstream: [\`${upstream_tag}\`](https://github.com/OSGeo/gdal/releases/tag/${upstream_tag})" \
"- Newest published bundle: \`${ours_tag:-none}\`" \
"" \
"To build and publish a new runtime bundle after reviewing upstream release notes:" \
"" \
'```bash' \
"git tag gdal-${upstream_tag} && git push origin gdal-${upstream_tag}" \
'```' \
"" \
"or dispatch the Build GDAL (Windows) workflow with \`gdal_version=${upstream_tag}\`." \
"" \
"After publishing, rebuild gdalraster against the new bundle and verify with \`gdalraster.windows::verify_gdalraster_runtime()\`, then update the README latest-release line and the default \`gdal_version\` in build.yml.")"

# ─────────────────────────────────────────────────────────────────────────────
# JOB 1 — Build GDAL from source
# ─────────────────────────────────────────────────────────────────────────────
build-gdal:
name: "Build GDAL"
if: github.event_name != 'schedule'
runs-on: windows-latest

outputs:
Expand Down
131 changes: 131 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# =============================================================================
# e2e.yml — End-to-end verification of the full user workflow on a clean
# Windows machine (#20).
#
# Proves the documented workflow exactly as a user machine would run it:
# 1. install the package (local checkout)
# 2. install_gdal_runtime() — published GDAL runtime bundle
# 3. install_gdalraster() — source build against the bundle
# 4. verify_gdalraster_runtime() — Algorithm API registry is populated
# 5. add_gdal_rprofile_hook() — startup hook, verified in a fresh
# R session via plain library(gdalraster)
#
# This workflow only consumes exported package functionality — build, link,
# and activation logic are never reimplemented in CI (see AGENTS.md
# responsibility split). gdalraster's own R dependencies are installed as
# CRAN binaries so the only from-source compile is gdalraster itself.
#
# Triggers:
# - workflow_dispatch : manually, optionally pinning a runtime release tag
# - schedule : weekly (Mondays 08:00 UTC, after the upstream check)
# - release published : gdal-v* bundle releases, so every new bundle is
# proven against gdalraster automatically
# =============================================================================

name: E2E Runtime Verification

on:
workflow_dispatch:
inputs:
runtime_tag:
description: 'GDAL runtime release tag to install (or "latest")'
required: false
default: 'latest'
schedule:
- cron: '0 8 * * 1'
release:
types: [published]

permissions: read-all

jobs:
e2e:
name: "E2E: runtime + gdalraster + hook"
# release trigger fires for package releases (v*) too; only bundle
# releases are relevant here
if: github.event_name != 'release' || startsWith(github.event.release.tag_name, 'gdal-v')
runs-on: windows-latest
timeout-minutes: 90
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
RUNTIME_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || github.event.inputs.runtime_tag || 'latest' }}
steps:
- uses: actions/checkout@v6

- uses: r-lib/actions/setup-r@v2
with:
r-version: 'release'
use-public-rspm: true

# installs gdalraster.windows (local checkout) plus its dependencies
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pak, local::.

- name: Install GDAL runtime bundle
shell: Rscript {0}
run: |
tag <- Sys.getenv("RUNTIME_TAG", unset = "latest")
if (!nzchar(tag)) tag <- "latest"
gdalraster.windows::install_gdal_runtime(tag = tag)

- name: Install gdalraster R dependencies (CRAN binaries)
shell: Rscript {0}
run: |
src <- file.path(tempdir(), "gdalraster-src.tar.gz")
utils::download.file(
"https://codeload.github.com/firelab/gdalraster/tar.gz/HEAD",
destfile = src, mode = "wb", quiet = TRUE
)
exdir <- file.path(tempdir(), "gdalraster-src")
utils::untar(src, exdir = exdir)
pkg_dir <- list.dirs(exdir, recursive = FALSE)[[1]]
pak::local_install_deps(pkg_dir)

- name: Build gdalraster from source against the bundle
shell: Rscript {0}
run: |
gdalraster.windows::install_gdalraster()

- name: Verify algorithm API (explicit load)
shell: Rscript {0}
run: |
ok <- gdalraster.windows::verify_gdalraster_runtime()
stopifnot(isTRUE(ok))

- name: Verify algorithm API (startup hook, fresh session)
shell: Rscript {0}
run: |
rprofile <- file.path(getwd(), "e2e-hook.Rprofile")
gdalraster.windows::add_gdal_rprofile_hook(rprofile = rprofile)

script <- file.path(getwd(), "e2e-hook-check.R")
writeLines(
c(
"library(gdalraster)",
"n <- length(gdalraster::gdal_global_reg_names())",
"cat('algorithm registry entries:', n, '\n')",
"stopifnot(n > 0L)"
),
con = script
)

status <- withr::with_envvar(
c(R_PROFILE_USER = rprofile),
system2(file.path(R.home("bin"), "Rscript.exe"), args = script)
)
stopifnot(identical(status, 0L))

- name: Write summary
if: always()
shell: pwsh
run: |
@"
## E2E runtime verification

| Item | Value |
|------|-------|
| Runtime tag | ``$env:RUNTIME_TAG`` |
| Trigger | ``${{ github.event_name }}`` |
| Result | ${{ job.status }} |
"@ | Out-File -Append -Encoding utf8 $env:GITHUB_STEP_SUMMARY
14 changes: 11 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,20 @@ gdalraster::gdal_global_reg_names()

## responsibility split

- CI's only responsibility is the GDAL runtime bundle: build, verify the
bundle contract, and publish durable artifacts (workflow artifact + release
asset).
- The build workflow's only responsibility is the GDAL runtime bundle: build,
verify the bundle contract, and publish durable artifacts (workflow artifact
+ release asset). A scheduled job in the same workflow checks upstream OSGeo/gdal
releases and opens a tracking issue when a newer GDAL exists (never builds
or publishes on its own).
- Building `gdalraster` against the bundle is package functionality
(`install_gdalraster()` with scoped Makevars via `withr`), exercised on user
machines and by package tests — never reimplemented inside CI.
- The e2e workflow ([`.github/workflows/e2e.yml`](.github/workflows/e2e.yml))
proves the full user workflow on a clean Windows runner by consuming the
exported package functions (`install_gdal_runtime()`,
`install_gdalraster()`, `verify_gdalraster_runtime()`,
`add_gdal_rprofile_hook()`) exactly as a user machine would; it runs on
dispatch, weekly, and whenever a `gdal-v*` bundle release is published.

## source of truth

Expand Down
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: gdalraster.windows
Title: Windows GDAL Runtime and gdalraster Bootstrap Tools
Version: 0.3.0
Version: 0.3.0.9000
Authors@R:
person("Jimmy", "Briggs", , "jimmy.briggs@jimbrig.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-7489-8787"))
Expand All @@ -13,6 +13,7 @@ URL: https://github.com/jimbrig/gdalraster.windows,
BugReports: https://github.com/jimbrig/gdalraster.windows/issues
Imports:
cli,
gitcreds,
httr2,
rlang,
stats,
Expand Down
13 changes: 13 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,22 @@ export(verify_gdalraster_runtime)
importFrom(cli,cli_alert_info)
importFrom(cli,cli_alert_warning)
importFrom(cli,cli_inform)
importFrom(gitcreds,gitcreds_get)
importFrom(httr2,req_auth_bearer_token)
importFrom(httr2,req_error)
importFrom(httr2,req_perform)
importFrom(httr2,req_user_agent)
importFrom(httr2,request)
importFrom(httr2,resp_body_json)
importFrom(httr2,resp_body_raw)
importFrom(httr2,resp_status)
importFrom(rlang,"%||%")
importFrom(rlang,local_use_cli)
importFrom(rlang,new_environment)
importFrom(rlang,on_load)
importFrom(rlang,run_on_load)
importFrom(rlang,try_fetch)
importFrom(stats,setNames)
importFrom(utils,packageVersion)
importFrom(withr,with_envvar)
importFrom(withr,with_makevars)
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# gdalraster.windows (development version)

## Fixes

- `install_gdal_runtime(tag = "latest")` no longer trusts GitHub's single "latest release" pointer, which broke the default install path whenever an R package release (`v*`, no bundle asset) was marked latest. "latest" now scans the release list and selects the newest non-draft, non-prerelease release that publishes a runtime bundle asset matching `asset_pattern`, decoupling the package release track from the GDAL bundle release track.
- GitHub API requests are now authenticated when a token is available — resolved from the git credential store (`gitcreds`), then the `GITHUB_PAT` and `GITHUB_TOKEN` environment variables — avoiding anonymous rate limits in CI and behind shared networks. Release-asset selection also tolerates assets with a missing `name` field.

# gdalraster.windows 0.3.0

## Documentation
Expand Down
41 changes: 41 additions & 0 deletions R/aaa.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

# ------------------------------------------------------------------------
#
# Title : Shared Package Resources
# By : Jimmy Briggs
# Date : 2026-07-03
#
# ------------------------------------------------------------------------

# github repositories ------------------------------------------------------

#' Repository publishing the GDAL runtime bundle releases (`gdal-v*` tags)
#' @noRd
#' @keywords internal
.bundle_repo <- "jimbrig/gdalraster.windows"

#' Upstream repository providing the gdalraster source tarball
#' @noRd
#' @keywords internal
.gdalraster_repo <- "firelab/gdalraster"

# release assets ------------------------------------------------------------

#' Regex selecting a runtime bundle zip among release assets
#' @noRd
#' @keywords internal
.bundle_asset_pattern <- "gdal-(bundle|ucrt64)-.*\\.zip$"

# runtime dll naming --------------------------------------------------------

#' Regex matching the top-level GDAL runtime DLL (SONAME discovered by glob,
#' never hardcoded; see #2)
#' @noRd
#' @keywords internal
.gdal_dll_pattern <- "^libgdal-[0-9]+\\.dll$"

#' Concrete-but-arbitrary DLL filename used only to produce missing-file
#' error paths when no runtime DLL exists yet; never dyn.load()ed
#' @noRd
#' @keywords internal
.gdal_dll_fallback <- "libgdal-39.dll"
Loading