Skip to content

Commit

Permalink
fix: Caches are great ... until they are not
Browse files Browse the repository at this point in the history
  • Loading branch information
bryantbiggs committed Mar 15, 2024
1 parent 13f80b9 commit 776488c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-title.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5.3.0
- uses: amannn/action-semantic-pull-request@v5.4.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
44 changes: 9 additions & 35 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ permissions: read-all

env:
TERRAFORM_DOCS_VERSION: v0.16.0
TFSEC_VERSION: v1.28.1
TF_PLUGIN_CACHE_DIR: ${{ github.workspace }}/.terraform.d/plugin-cache
TFLINT_VERSION: v0.45.0
TFLINT_VERSION: v0.50.3

concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
Expand All @@ -33,7 +31,7 @@ jobs:

- name: Get root directories
id: dirs
uses: clowdhaus/terraform-composite-actions/directories@v1.8.3
uses: clowdhaus/terraform-composite-actions/directories@v1.9.0

preCommitMinVersions:
name: Min TF pre-commit
Expand All @@ -49,7 +47,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: changes
with:
# We only need to check Terraform files for the current directory
Expand All @@ -59,35 +57,23 @@ jobs:
src:
- '${{ matrix.directory }}/*.tf'
- name: Config Terraform plugin cache
if: steps.changes.outputs.src== 'true'
run: mkdir --parents ${{ env.TERRAFORM_DOCS_VERSION }}

- name: Cache Terraform
uses: actions/cache@v3
if: steps.changes.outputs.src== 'true'
with:
path: ${{ env.TERRAFORM_DOCS_VERSION }}
key: ${{ runner.os }}-terraform-${{ hashFiles('**/.terraform.lock.hcl') }}
restore-keys: ${{ runner.os }}-terraform-

- name: Terraform min/max versions
uses: clowdhaus/terraform-min-max@v1.2.7
uses: clowdhaus/terraform-min-max@v1.3.0
if: steps.changes.outputs.src== 'true'
id: minMax
with:
directory: ${{ matrix.directory }}

- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0
# Run only validate pre-commit check on min version supported
if: ${{ matrix.directory != '.' && steps.changes.outputs.src== 'true' }}
with:
terraform-version: ${{ steps.minMax.outputs.minVersion }}
args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'

- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0
# Run only validate pre-commit check on min version supported
if: ${{ matrix.directory == '.' && steps.changes.outputs.src== 'true' }}
with:
Expand All @@ -105,32 +91,20 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
src:
- '**/*.tf'
- name: Config Terraform plugin cache
if: steps.changes.outputs.src== 'true'
run: mkdir --parents ${{ env.TERRAFORM_DOCS_VERSION }}

- name: Cache Terraform
uses: actions/cache@v3
if: steps.changes.outputs.src== 'true'
with:
path: ${{ env.TF_PLUGIN_CACHE_DIR }}
key: ${{ runner.os }}-terraform-${{ hashFiles('**/.terraform.lock.hcl') }}
restore-keys: ${{ runner.os }}-terraform-

- name: Terraform min/max versions
id: minMax
uses: clowdhaus/terraform-min-max@v1.2.7
uses: clowdhaus/terraform-min-max@v1.3.0
if: steps.changes.outputs.src== 'true'

- name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.8.3
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0
if: steps.changes.outputs.src== 'true'
with:
terraform-version: ${{ steps.minMax.outputs.maxVersion }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale-issue-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v8
- uses: actions/stale@v9
id: stale
with:
ascending: true
Expand Down

0 comments on commit 776488c

Please sign in to comment.