Extend tests to use lockfile if available

This commints allows the test framework to use a lockfile generated
within the tools/lockfile directory. This allows reusing the provider
cache and also running tests in parallel.
This commit is contained in:
Julio Castillo
2023-04-23 00:40:05 +02:00
parent 84a7b988a3
commit b097d297ff
4 changed files with 76 additions and 1 deletions

View File

@@ -46,6 +46,17 @@ runs:
echo 'disable_checkpoint = true' \
| tee -a /home/runner/.terraformrc
mkdir -p ${{ env.TF_PLUGIN_CACHE_DIR }}
- uses: actions/download-artifact@v3
with:
name: lockfile
- name: Cache Terraform
uses: actions/cache@v3
with:
path: ${{ env.TF_PLUGIN_CACHE_DIR }}
key: ${{ runner.os }}-terraform-${{ hashFiles('tools/lockfile/.terraform.lock.hcl') }}
# avoid conflicts with user-installed providers on local machines
- name: Pin provider versions
shell: bash

View File

@@ -31,8 +31,37 @@ env:
TF_VERSION: 1.4.4
jobs:
setup-tf-providers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}
terraform_wrapper: false
- name: Cache Terraform
uses: actions/cache@v3
with:
path: ${{ env.TF_PLUGIN_CACHE_DIR }}
key: ${{ runner.os }}-terraform-${{ hashFiles('tools/lockfile/.terraform.lock.hcl') }}
- shell: bash
run: |
mkdir -p ${{ env.TF_PLUGIN_CACHE_DIR }}
cd tools/lockfile
terraform init
- uses: actions/upload-artifact@v3
with:
name: lockfile
path: tools/lockfile/.terraform.lock.hcl
examples-blueprints:
runs-on: ubuntu-latest
needs: setup-tf-providers
steps:
- uses: actions/checkout@v3
@@ -47,6 +76,7 @@ jobs:
examples-modules:
runs-on: ubuntu-latest
needs: setup-tf-providers
steps:
- uses: actions/checkout@v3
@@ -61,6 +91,7 @@ jobs:
blueprints:
runs-on: ubuntu-latest
needs: setup-tf-providers
steps:
- uses: actions/checkout@v3
@@ -75,6 +106,7 @@ jobs:
modules:
runs-on: ubuntu-latest
needs: setup-tf-providers
steps:
- uses: actions/checkout@v3
@@ -89,6 +121,7 @@ jobs:
fast:
runs-on: ubuntu-latest
needs: setup-tf-providers
steps:
- uses: actions/checkout@v3