mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: cache terraform providers between CI test runs (#17373)
Addresses https://github.com/coder/internal/issues/322. This PR starts caching Terraform providers used by `TestProvision` in `provisioner/terraform/provision_test.go`. The goal is to improve the reliability of this test by cutting down on the number of network calls to external services. It leverages GitHub Actions cache, which [on depot runners is persisted for 14 days by default](https://depot.dev/docs/github-actions/overview#cache-retention-policy). Other than the aforementioned `TestProvision`, I couldn't find any other tests which depend on external terraform providers.
This commit is contained in:
@@ -341,6 +341,12 @@ jobs:
|
||||
- name: Setup Terraform
|
||||
uses: ./.github/actions/setup-tf
|
||||
|
||||
- name: Download Test Cache
|
||||
id: download-cache
|
||||
uses: ./.github/actions/test-cache/download
|
||||
with:
|
||||
key-prefix: test-go-${{ runner.os }}-${{ runner.arch }}
|
||||
|
||||
- name: Test with Mock Database
|
||||
id: test
|
||||
shell: bash
|
||||
@@ -365,6 +371,11 @@ jobs:
|
||||
gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" \
|
||||
--packages="./..." -- $PARALLEL_FLAG -short -failfast
|
||||
|
||||
- name: Upload Test Cache
|
||||
uses: ./.github/actions/test-cache/upload
|
||||
with:
|
||||
cache-key: ${{ steps.download-cache.outputs.cache-key }}
|
||||
|
||||
- name: Upload test stats to Datadog
|
||||
timeout-minutes: 1
|
||||
continue-on-error: true
|
||||
@@ -462,6 +473,12 @@ jobs:
|
||||
if: runner.os == 'Windows'
|
||||
uses: ./.github/actions/setup-imdisk
|
||||
|
||||
- name: Download Test Cache
|
||||
id: download-cache
|
||||
uses: ./.github/actions/test-cache/download
|
||||
with:
|
||||
key-prefix: test-go-pg-${{ runner.os }}-${{ runner.arch }}
|
||||
|
||||
- name: Test with PostgreSQL Database
|
||||
env:
|
||||
POSTGRES_VERSION: "13"
|
||||
@@ -476,6 +493,11 @@ jobs:
|
||||
|
||||
make test-postgres
|
||||
|
||||
- name: Upload Test Cache
|
||||
uses: ./.github/actions/test-cache/upload
|
||||
with:
|
||||
cache-key: ${{ steps.download-cache.outputs.cache-key }}
|
||||
|
||||
- name: Upload test stats to Datadog
|
||||
timeout-minutes: 1
|
||||
continue-on-error: true
|
||||
@@ -514,6 +536,12 @@ jobs:
|
||||
- name: Setup Terraform
|
||||
uses: ./.github/actions/setup-tf
|
||||
|
||||
- name: Download Test Cache
|
||||
id: download-cache
|
||||
uses: ./.github/actions/test-cache/download
|
||||
with:
|
||||
key-prefix: test-go-pg-16-${{ runner.os }}-${{ runner.arch }}
|
||||
|
||||
- name: Test with PostgreSQL Database
|
||||
env:
|
||||
POSTGRES_VERSION: "16"
|
||||
@@ -521,6 +549,11 @@ jobs:
|
||||
run: |
|
||||
make test-postgres
|
||||
|
||||
- name: Upload Test Cache
|
||||
uses: ./.github/actions/test-cache/upload
|
||||
with:
|
||||
cache-key: ${{ steps.download-cache.outputs.cache-key }}
|
||||
|
||||
- name: Upload test stats to Datadog
|
||||
timeout-minutes: 1
|
||||
continue-on-error: true
|
||||
@@ -551,6 +584,12 @@ jobs:
|
||||
- name: Setup Terraform
|
||||
uses: ./.github/actions/setup-tf
|
||||
|
||||
- name: Download Test Cache
|
||||
id: download-cache
|
||||
uses: ./.github/actions/test-cache/download
|
||||
with:
|
||||
key-prefix: test-go-race-${{ runner.os }}-${{ runner.arch }}
|
||||
|
||||
# We run race tests with reduced parallelism because they use more CPU and we were finding
|
||||
# instances where tests appear to hang for multiple seconds, resulting in flaky tests when
|
||||
# short timeouts are used.
|
||||
@@ -559,6 +598,11 @@ jobs:
|
||||
run: |
|
||||
gotestsum --junitfile="gotests.xml" -- -race -parallel 4 -p 4 ./...
|
||||
|
||||
- name: Upload Test Cache
|
||||
uses: ./.github/actions/test-cache/upload
|
||||
with:
|
||||
cache-key: ${{ steps.download-cache.outputs.cache-key }}
|
||||
|
||||
- name: Upload test stats to Datadog
|
||||
timeout-minutes: 1
|
||||
continue-on-error: true
|
||||
@@ -589,6 +633,12 @@ jobs:
|
||||
- name: Setup Terraform
|
||||
uses: ./.github/actions/setup-tf
|
||||
|
||||
- name: Download Test Cache
|
||||
id: download-cache
|
||||
uses: ./.github/actions/test-cache/download
|
||||
with:
|
||||
key-prefix: test-go-race-pg-${{ runner.os }}-${{ runner.arch }}
|
||||
|
||||
# We run race tests with reduced parallelism because they use more CPU and we were finding
|
||||
# instances where tests appear to hang for multiple seconds, resulting in flaky tests when
|
||||
# short timeouts are used.
|
||||
@@ -600,6 +650,11 @@ jobs:
|
||||
make test-postgres-docker
|
||||
DB=ci gotestsum --junitfile="gotests.xml" -- -race -parallel 4 -p 4 ./...
|
||||
|
||||
- name: Upload Test Cache
|
||||
uses: ./.github/actions/test-cache/upload
|
||||
with:
|
||||
cache-key: ${{ steps.download-cache.outputs.cache-key }}
|
||||
|
||||
- name: Upload test stats to Datadog
|
||||
timeout-minutes: 1
|
||||
continue-on-error: true
|
||||
|
||||
Reference in New Issue
Block a user