Skip to content

Commit

Permalink
chore: Add additional tests (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryantbiggs authored Nov 12, 2022
1 parent 24276ce commit 3411591
Show file tree
Hide file tree
Showing 21 changed files with 2,070 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 16

Expand Down
66 changes: 40 additions & 26 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,56 @@ on:
- main

jobs:
versionExtract:
name: Extract Min/Max Versions
collectInputs:
name: Collect workflow inputs
runs-on: ubuntu-latest
outputs:
directories: ${{ steps.dirs.outputs.directories }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Extract Terraform min/max versions
id: minMax
uses: ./
with:
directory: tests/0.13
outputs:
minVersion: ${{ steps.minMax.outputs.minVersion }}
maxVersion: ${{ steps.minMax.outputs.maxVersion }}
- name: Get root directories
id: dirs
uses: clowdhaus/terraform-composite-actions/[email protected]

versionEvaluate:
name: Evaluate Min/Max Versions
preCommit:
name: Pre-commit
needs: collectInputs
runs-on: ubuntu-latest
needs: versionExtract
strategy:
matrix:
version:
- ${{ needs.versionExtract.outputs.minVersion }}
- ${{ needs.versionExtract.outputs.maxVersion }}
directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Terraform min/max versions
id: minMax
uses: ./
with:
directory: ${{ matrix.directory }}

# Min version
- name: Remove default Terraform
run: rm -rf $(which terraform)

- name: Install Terraform ${{ steps.minMax.outputs.minVersion }}
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ steps.minMax.outputs.minVersion }}

- name: Terraform validate ${{ steps.minMax.outputs.minVersion }}
run: terraform init && terraform validate

# Max version
- name: Remove min Terraform
run: rm -rf $(which terraform)

- name: Install Terraform v${{ matrix.version }}
uses: hashicorp/setup-terraform@v1
- name: Install Terraform ${{ steps.minMax.outputs.maxVersion }}
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ matrix.version }}
terraform_version: ${{ steps.minMax.outputs.maxVersion }}

- name: Initialize and validate v${{ matrix.version }}
run: |
cd tests/0.13
terraform init
terraform validate
- name: Terraform validate ${{ steps.minMax.outputs.maxVersion }}
run: terraform init && terraform validate
32 changes: 32 additions & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.DS_Store

# Local .terraform directories
**/.terraform/*

# Terraform lockfile
.terraform.lock.hcl

# .tfstate files
*.tfstate
*.tfstate.*
*.tfplan

# Crash log files
crash.log

# Exclude all .tfvars files, which are likely to contain sentitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Ignore CLI configuration files
.terraformrc
terraform.rc
7 changes: 7 additions & 0 deletions tests/0.12/main.tf → tests/0.12/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@ provider "aws" {

terraform {
required_version = "~> 0.12"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.27"
}
}
}
2 changes: 1 addition & 1 deletion tests/0.13/main.tf → tests/0.13/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.9"
version = ">= 4.27"
}
}
}
Loading

0 comments on commit 3411591

Please sign in to comment.