Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

ci: cache Go builds per check job and skip unused Node setup

shoudi zhenga8a3c58c2513
diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml
index f94e1185..21511ad1 100644
--- a/.github/actions/setup/action.yml
+++ b/.github/actions/setup/action.yml
@@ -1,6 +1,14 @@
name: Set up the toolchain
description: Node, pnpm and Go at the repository's pinned versions, with workspace dependencies installed, and a BASE that shares history with HEAD.
+inputs:
+ node:
+ description: Set up Node. Checks that run no JavaScript pass false.
+ default: "true"
+ install:
+ description: Set up pnpm and install workspace dependencies; needs node. Checks that only run Node scripts with builtin modules pass false.
+ default: "true"
+
runs:
using: composite
steps:
@@ -16,17 +24,20 @@ runs:
fi
# Reads the version from packageManager in package.json.
- uses: pnpm/action-setup@v4
+ if: inputs.install == 'true'
- uses: actions/setup-node@v4
+ if: inputs.node == 'true'
with:
node-version-file: .node-version
- cache: pnpm
+ cache: ${{ inputs.install == 'true' && 'pnpm' || '' }}
+ # The caller caches Go per job: setup-go's one shared entry is saved by
+ # whichever job finishes first, often one that compiled no Go, and its key
+ # never changes while go.sum stays the same.
- uses: actions/setup-go@v5
with:
go-version-file: apps/teamhub/go.mod
- cache-dependency-path: |
- apps/teamhub/go.sum
- apps/computer/local-daemon/go.sum
- contracts/generated/go/go.sum
+ cache: false
# No install scripts: none of the checks that run here loads a native addon.
- shell: bash
+ if: inputs.install == 'true'
run: pnpm install --frozen-lockfile --ignore-scripts
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index de1ab35f..56a846a8 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -171,6 +171,26 @@ jobs:
fetch-depth: 0
- uses: ./.github/actions/setup
if: needs.changes.outputs[matrix.app] == 'true'
+ # teamhub runs only Go. computer-go's tests run the managed-tools
+ # scripts, which need the pinned Node but no workspace packages.
+ with:
+ node: ${{ matrix.app != 'teamhub' }}
+ install: ${{ matrix.app != 'teamhub' && matrix.app != 'computer-go' }}
+ # Each Go check keeps its own build and module cache, so one job's save
+ # never replaces another's. Pull requests and merge-queue builds restore
+ # main's latest entry; only pushes to main save. Go trims build cache
+ # entries unused for five days, so the restored cache does not grow
+ # without bound.
+ - uses: actions/cache/restore@v4
+ if: contains(fromJSON('["teamhub","computer-go","desktop","contracts"]'), matrix.app) && needs.changes.outputs[matrix.app] == 'true'
+ with:
+ path: |
+ ~/.cache/go-build
+ ~/go/pkg/mod
+ key: go-${{ matrix.app }}-${{ runner.os }}-${{ hashFiles('apps/teamhub/go.sum', 'apps/computer/local-daemon/go.sum', 'contracts/generated/go/go.sum') }}-${{ github.sha }}
+ restore-keys: |
+ go-${{ matrix.app }}-${{ runner.os }}-${{ hashFiles('apps/teamhub/go.sum', 'apps/computer/local-daemon/go.sum', 'contracts/generated/go/go.sum') }}-
+ go-${{ matrix.app }}-${{ runner.os }}-
# Pinned golangci-lint and sqlc binaries; building them takes about 60 s
# each. Their file names carry the tool and Go versions, and the key
# hashes the files that pin both, so a version bump misses and rebuilds.
@@ -195,3 +215,10 @@ jobs:
with:
path: ~/.cache/golangci-lint
key: golangci-lint-${{ runner.os }}-${{ hashFiles('apps/teamhub/go.sum', '.golangci.yml') }}-${{ github.sha }}
+ - uses: actions/cache/save@v4
+ if: always() && github.event_name == 'push' && contains(fromJSON('["teamhub","computer-go","desktop","contracts"]'), matrix.app) && needs.changes.outputs[matrix.app] == 'true'
+ with:
+ path: |
+ ~/.cache/go-build
+ ~/go/pkg/mod
+ key: go-${{ matrix.app }}-${{ runner.os }}-${{ hashFiles('apps/teamhub/go.sum', 'apps/computer/local-daemon/go.sum', 'contracts/generated/go/go.sum') }}-${{ github.sha }}