From a2f7c80278fe32166be960be4290f1f3436e39bf Mon Sep 17 00:00:00 2001 From: adelnizamutdinov Date: Sun, 27 Sep 2026 03:21:26 +0300 Subject: [PATCH 1/2] Reuse user-level Go caches across worktrees --- .github/workflows/ci.yaml | 9 ++++----- .moon/tasks/all.yml | 3 +-- README.md | 7 ++++++- moon.yml | 4 +--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dce363f..25683e6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,17 +29,16 @@ jobs: path: | ~/go/pkg/mod ~/.cache/go-build - .cache/golangci-lint - key: go-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.go.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}-${{ github.sha }} + ~/.cache/golangci-lint + key: go-v2-${{ runner.os }}-${{ runner.arch }}-${{ steps.go.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}-${{ github.sha }} restore-keys: | - go-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.go.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}- - go-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.go.outputs.go-version }}- + go-v2-${{ runner.os }}-${{ runner.arch }}-${{ steps.go.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}- + go-v2-${{ runner.os }}-${{ runner.arch }}-${{ steps.go.outputs.go-version }}- - uses: moonrepo/setup-toolchain@v0 with: moon-version: "2.5.5" - run: rustup toolchain install 1.98.1 --profile minimal - run: rustup default 1.98.1 - - run: mkdir -p "$HOME/.cache/go-build" - name: Check affected tasks id: ci run: moon ci diff --git a/.moon/tasks/all.yml b/.moon/tasks/all.yml index 4dc1d06..b7ae3b5 100644 --- a/.moon/tasks/all.yml +++ b/.moon/tasks/all.yml @@ -1,6 +1,5 @@ env: - GOCACHE: ${HOME}/.cache/go-build - GOTMPDIR: ${HOME}/.cache/go-build + GOLANGCI_LINT_CACHE: ${HOME}/.cache/golangci-lint taskOptions: cache: false unixShell: bash diff --git a/README.md b/README.md index 18f19f3..40d6abd 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,12 @@ history, source-based affected selection, and plain `moon ci`. It runs the same project tasks used locally; aggregate checks and maintenance commands are excluded from automatic selection. The same `moon.yml` also works as a Listenbox submodule. -Go modules, compiler output, and golangci-lint data are cached. Moon task results +Go modules and compiler output use Go's user-level caches (`go env GOMODCACHE +GOCACHE`), shared with direct Go commands and other worktrees. Moon uses +`~/.cache/golangci-lint` for linter data; temporary files use the system temp +directory. The same cache locations apply in standalone and parent workspaces. +The lint task allows parallel runners without the global linter lock. +Moon task results are not restored across CI runs. Sources, module files, fixtures, templates, and configuration determine affected tasks; `$CI` is not an input. CI verifies formatting, and selected Go tests bypass Go's test-result cache. Native Moon diff --git a/moon.yml b/moon.yml index 3998b95..19967b2 100644 --- a/moon.yml +++ b/moon.yml @@ -47,9 +47,7 @@ tasks: gofmt -w . fi go vet ./... - mkdir -p .cache/golangci-lint-tmp - GOLANGCI_LINT_CACHE="${GOLANGCI_LINT_CACHE:-$PWD/.cache/golangci-lint}" \ - TMPDIR="$PWD/.cache/golangci-lint-tmp" go tool golangci-lint run ./... + go tool golangci-lint run --allow-parallel-runners ./... options: cache: true check: From c52a1e2a29246a53c09a53d2c0f63d2bd42a561f Mon Sep 17 00:00:00 2001 From: adelnizamutdinov Date: Sun, 27 Sep 2026 03:27:23 +0300 Subject: [PATCH 2/2] Set the shared Go build cache through Moon --- .moon/tasks/all.yml | 1 + README.md | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.moon/tasks/all.yml b/.moon/tasks/all.yml index b7ae3b5..04a0e9d 100644 --- a/.moon/tasks/all.yml +++ b/.moon/tasks/all.yml @@ -1,4 +1,5 @@ env: + GOCACHE: ${HOME}/.cache/go-build GOLANGCI_LINT_CACHE: ${HOME}/.cache/golangci-lint taskOptions: cache: false diff --git a/README.md b/README.md index 40d6abd..a232068 100644 --- a/README.md +++ b/README.md @@ -155,8 +155,8 @@ history, source-based affected selection, and plain `moon ci`. It runs the same project tasks used locally; aggregate checks and maintenance commands are excluded from automatic selection. The same `moon.yml` also works as a Listenbox submodule. -Go modules and compiler output use Go's user-level caches (`go env GOMODCACHE -GOCACHE`), shared with direct Go commands and other worktrees. Moon uses +Moon sets `GOCACHE` to `~/.cache/go-build` on macOS and Linux, shared across +worktrees. Modules use Go's shared module cache (`go env GOMODCACHE`). Moon uses `~/.cache/golangci-lint` for linter data; temporary files use the system temp directory. The same cache locations apply in standalone and parent workspaces. The lint task allows parallel runners without the global linter lock.