- Notifications
You must be signed in to change notification settings - Fork1k
chore: cache terraform providers between CI test runs#17373
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
4 commits Select commitHold shift + click to select a range
f11fea6
set up a terraform providers mirror for tests
hugodutka3a9e0b3
add cache to CI
hugodutka2236dd4
address feedback: hashing, file exists check, cache clean up
hugodutkad56aaa7
address feedback: use separate save and restore steps, use os-and-arc…
hugodutkaFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
50 changes: 50 additions & 0 deletions.github/actions/test-cache/download/action.yml
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,50 @@ | ||
name: "Download Test Cache" | ||
description: | | ||
Downloads the test cache and outputs today's cache key. | ||
A PR job can use a cache if it was created by its base branch, its current | ||
branch, or the default branch. | ||
https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache | ||
outputs: | ||
cache-key: | ||
description: "Today's cache key" | ||
value: ${{ steps.vars.outputs.cache-key }} | ||
inputs: | ||
key-prefix: | ||
description: "Prefix for the cache key" | ||
required: true | ||
cache-path: | ||
description: "Path to the cache directory" | ||
required: true | ||
# This path is defined in testutil/cache.go | ||
default: "~/.cache/coderv2-test" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Get date values and cache key | ||
id: vars | ||
shell: bash | ||
run: | | ||
export YEAR_MONTH=$(date +'%Y-%m') | ||
export PREV_YEAR_MONTH=$(date -d 'last month' +'%Y-%m') | ||
export DAY=$(date +'%d') | ||
echo "year-month=$YEAR_MONTH" >> $GITHUB_OUTPUT | ||
echo "prev-year-month=$PREV_YEAR_MONTH" >> $GITHUB_OUTPUT | ||
echo "cache-key=${{ inputs.key-prefix }}-${YEAR_MONTH}-${DAY}" >> $GITHUB_OUTPUT | ||
# TODO: As a cost optimization, we could remove caches that are older than | ||
# a day or two. By default, depot keeps caches for 14 days, which isn't | ||
# necessary for the test cache. | ||
# https://depot.dev/docs/github-actions/overview#cache-retention-policy | ||
- name: Download test cache | ||
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | ||
with: | ||
path: ${{ inputs.cache-path }} | ||
key: ${{ steps.vars.outputs.cache-key }} | ||
# > If there are multiple partial matches for a restore key, the action returns the most recently created cache. | ||
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#matching-a-cache-key | ||
# The second restore key allows non-main branches to use the cache from the previous month. | ||
# This prevents PRs from rebuilding the cache on the first day of the month. | ||
# It also makes sure that once a month, the cache is fully reset. | ||
restore-keys: | | ||
${{ inputs.key-prefix }}-${{ steps.vars.outputs.year-month }}- | ||
${{ github.ref != 'refs/heads/main' && format('{0}-{1}-', inputs.key-prefix, steps.vars.outputs.prev-year-month) || '' }} |
20 changes: 20 additions & 0 deletions.github/actions/test-cache/upload/action.yml
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,20 @@ | ||
name: "Upload Test Cache" | ||
description: Uploads the test cache. Only works on the main branch. | ||
inputs: | ||
cache-key: | ||
description: "Cache key" | ||
required: true | ||
cache-path: | ||
description: "Path to the cache directory" | ||
required: true | ||
# This path is defined in testutil/cache.go | ||
default: "~/.cache/coderv2-test" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Upload test cache | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | ||
with: | ||
path: ${{ inputs.cache-path }} | ||
key: ${{ inputs.cache-key }} |
55 changes: 55 additions & 0 deletions.github/workflows/ci.yaml
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
8 changes: 6 additions & 2 deletionsprovisioner/terraform/executor.go
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
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.