-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Optimize CI caches #37387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
silverwind
merged 27 commits into
go-gitea:main
from
silverwind:ci-go-cache-per-job-key
Apr 26, 2026
Merged
Optimize CI caches #37387
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
df93b46
CI: give each Go test job its own build cache key
silverwind 57dd81a
CI: drop -coverprofile from unit-tests to enable Go test result cache
silverwind 2c590a1
restart ci
silverwind 32e46ab
CI: rotate Go cache key per-run so new entries persist
silverwind 536377d
CI: drop trailing hyphens from Go cache restore-keys
silverwind a91e03e
restart ci
silverwind 37290d2
CI: split Go module cache to shared, add arch, cover e2e + lint jobs
silverwind 9309543
CI: drop -race from pgsql and mysql integration tests
silverwind 1c09071
CI: drop per-job build cache on checks-backend and test-e2e
silverwind f896743
CI: consolidate Go caches into composite action
silverwind 3df7952
CI: share gobuild cache slot and add main-branch seeder
silverwind 12f0856
CI: fix lint-yaml in cache-seeder matrix
silverwind 80ce1eb
Apply suggestion from @silverwind
silverwind 9313735
CI: restore description field on composite action
silverwind b41542d
CI: extend test-unit cache fallback to shared seeded slot
silverwind a6193b1
restart ci
silverwind c650c36
Merge branch 'main' into ci-go-cache-per-job-key
silverwind 74c7cb8
CI: narrow cache-seeder paths to keys that actually invalidate the seed
silverwind 6c77c7c
CI: rename composite action input 'name' to 'cache-name'
silverwind 2d6206b
CI: document PR cache consumption path in seeder header
silverwind 42d438a
Apply suggestion from @silverwind
silverwind 9820fae
Merge branch 'main' into ci-go-cache-per-job-key
silverwind ad3bf75
CI: reword boolean input descriptions to 'Whether to …' form
silverwind 39fa0ce
Merge branch 'main' into ci-go-cache-per-job-key
silverwind e0e4e59
CI: pin third-party actions to commit hashes
silverwind de9cad5
Merge branch 'main' into ci-go-cache-per-job-key
bircni d233488
Merge branch 'main' into ci-go-cache-per-job-key
GiteaBot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: go-caches | ||
| description: Restore and save go module, build, and golangci-lint caches | ||
|
|
||
| inputs: | ||
| cache-name: | ||
| description: Short identifier used in the per-caller build cache key | ||
| required: true | ||
| build-cache: | ||
| description: Whether to include ~/.cache/go-build | ||
| default: "true" | ||
| build-cache-rotate: | ||
| description: Whether to rotate the build cache key per run so Go's test result cache can accumulate across runs | ||
| default: "false" | ||
| lint-cache: | ||
| description: Whether to include ~/.cache/golangci-lint | ||
| default: "false" | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | ||
| with: | ||
| path: ~/go/pkg/mod | ||
| key: gomod-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('go.sum') }} | ||
| restore-keys: gomod-${{ runner.os }}-${{ runner.arch }} | ||
| - if: ${{ inputs.build-cache == 'true' && inputs.build-cache-rotate == 'true' }} | ||
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | ||
| with: | ||
| path: ~/.cache/go-build | ||
| key: gobuild-${{ runner.os }}-${{ runner.arch }}-${{ inputs.cache-name }}-${{ hashFiles('go.sum') }}-${{ github.run_id }} | ||
| restore-keys: | | ||
| gobuild-${{ runner.os }}-${{ runner.arch }}-${{ inputs.cache-name }}-${{ hashFiles('go.sum') }} | ||
| gobuild-${{ runner.os }}-${{ runner.arch }}-${{ inputs.cache-name }} | ||
| gobuild-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('go.sum') }} | ||
| gobuild-${{ runner.os }}-${{ runner.arch }} | ||
| - if: ${{ inputs.build-cache == 'true' && inputs.build-cache-rotate != 'true' }} | ||
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | ||
| with: | ||
| path: ~/.cache/go-build | ||
| key: gobuild-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('go.sum') }} | ||
| restore-keys: gobuild-${{ runner.os }}-${{ runner.arch }} | ||
|
silverwind marked this conversation as resolved.
|
||
| - if: ${{ inputs.lint-cache == 'true' }} | ||
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | ||
| with: | ||
| path: ~/.cache/golangci-lint | ||
| key: golangci-${{ runner.os }}-${{ runner.arch }}-${{ inputs.cache-name }}-${{ hashFiles('go.sum', '.golangci.yml') }} | ||
| restore-keys: golangci-${{ runner.os }}-${{ runner.arch }}-${{ inputs.cache-name }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Populates the go module, build, and golangci-lint caches under the default | ||
| # branch's cache scope so that PR runs have a warm fallback to restore from. | ||
| # | ||
| # GitHub Actions caches are scoped per ref: a PR run can only write to its own | ||
| # branch's scope, but can read from the base branch's scope as a fallback. | ||
| # PRs therefore cannot seed main's scope themselves. Running the same cache | ||
| # steps on push-to-main is the only opportunity to populate that fallback | ||
| # scope so fresh PR branches start with a useful cache on first run. | ||
|
|
||
| # A PR job's exact key lives in its own PR-scope (empty on first run, filled | ||
|
silverwind marked this conversation as resolved.
|
||
| # by later runs of the same PR); on miss, actions/cache's restore-keys fall | ||
| # back to prefix matches against entries this seeder saves in main's scope. | ||
|
|
||
| name: cache-seeder | ||
|
wxiaoguang marked this conversation as resolved.
|
||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - "go.sum" | ||
| - ".golangci.yml" | ||
| - ".github/actions/go-cache/action.yml" | ||
| - ".github/workflows/cache-seeder.yml" | ||
|
|
||
| concurrency: | ||
| group: cache-seeder | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| gobuild: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 | ||
| with: | ||
| go-version-file: go.mod | ||
| check-latest: true | ||
| cache: false | ||
| - uses: ./.github/actions/go-cache | ||
| with: | ||
| cache-name: seed | ||
| - run: make deps-backend | ||
| - run: TAGS="bindata" make backend | ||
| - run: TAGS="bindata sqlite sqlite_unlock_notify" make backend | ||
| - run: TAGS="bindata gogit sqlite sqlite_unlock_notify" GOEXPERIMENT="" make backend | ||
|
silverwind marked this conversation as resolved.
|
||
|
|
||
| lint: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - { job: lint-backend, tags: "bindata sqlite sqlite_unlock_notify", target: "lint-backend" } | ||
| - { job: lint-go-windows, tags: "bindata sqlite sqlite_unlock_notify", target: "lint-go-windows" } | ||
| - { job: lint-go-gogit, tags: "bindata sqlite sqlite_unlock_notify gogit", target: "lint-go" } | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 | ||
| with: | ||
| go-version-file: go.mod | ||
| check-latest: true | ||
| cache: false | ||
| - uses: ./.github/actions/go-cache | ||
| with: | ||
| cache-name: ${{ matrix.job }} | ||
| lint-cache: "true" | ||
| - run: make deps-backend deps-tools | ||
| - run: make ${{ matrix.target }} | ||
| env: | ||
| TAGS: ${{ matrix.tags }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.