~bigbes/sr-ht-dolt

93a10f4843f643c67f30bd2605f4e6134cab324b — Eugene Blikh 13 days ago 1760deb
ci: pin Go caches inside the APKBUILD, not the env

Builds #256/#257 failed in cache_save because abuild redirects GOCACHE
into its throwaway $tmpdir and an upstream typo in abuild.in assigns
GOMODCACHE from ${GOCACHE:-...}, so any GOMODCACHE exported beforehand
is clobbered. Exporting both paths inside build() runs after abuild's
own exports and therefore sticks; the buildenv exports are dropped.
2 files changed, 10 insertions(+), 7 deletions(-)

M .build.yml
M APKBUILD
M .build.yml => .build.yml +4 -7
@@ 25,7 25,7 @@ environment:
  # Must track the srht deployment's SRHT_CORE_VER, or this service's theme
  # drifts from the rest of the instance. BOOTSTRAP_REV is the submodule commit
  # core.sr.ht pins at that tag; bump the two together.
  CORE_VER: "0.84.5"
  CORE_VER: "0.83.8"
  BOOTSTRAP_REV: 779ad9f174ea5ab7e755f6df0ec9e5912d67dd16
submitter:
  git.sr.ht:


@@ 87,12 87,9 @@ tasks:
      KEY_MOD=$(cacher key "gomod/{hash}.tar.zst" --hash-from "$REPO/go.sum")
      KEY_GOC=$(cacher key "gocache/{hash}.tar.zst" --hash-from "$REPO/go.sum")
      echo "export KEY_MOD=$KEY_MOD KEY_GOC=$KEY_GOC" >> ~/.buildenv
      # abuild's default.conf points GOMODCACHE/GOCACHE into $srcdir and cleans
      # it after packaging, which would discard everything we restore. Both
      # defaults are ${VAR:-...}, so pre-set env wins — pin the caches to the
      # stable home locations for every later task.
      echo "export GOMODCACHE=$HOME/go/pkg/mod" >> ~/.buildenv
      echo "export GOCACHE=$HOME/.cache/go-build" >> ~/.buildenv
      # abuild redirects the Go caches into its throwaway $tmpdir (and an
      # upstream typo slaves GOMODCACHE to GOCACHE), so env exports here can't
      # stick — the APKBUILD's build() re-pins both to these home locations.
      cacher dir download "$KEY_MOD" ~/go/pkg/mod || true
      cacher dir download "$KEY_GOC" ~/.cache/go-build || true
  - build: |

M APKBUILD => APKBUILD +6 -0
@@ 29,6 29,12 @@ export GO_TAGS="gms_pure_go"

build() {
	cd "$builddir"
	# abuild redirects GOCACHE into $tmpdir (wiped after packaging), and an
	# upstream typo makes GOMODCACHE follow GOCACHE's value rather than its
	# own. Re-pin both to the stable home locations here — after abuild's own
	# exports — so CI's cache_restore/cache_save tasks see them survive.
	export GOCACHE="$HOME/.cache/go-build"
	export GOMODCACHE="$HOME/go/pkg/mod"
	# `make all` is all-bin ONLY — this Makefile deliberately keeps the CSS off
	# the default path because sassc/minify aren't always on a dev machine. So
	# `css` has to be asked for by name; building `all` alone silently produces