Feat: allow using terratag as a validation tool - add dryrun #447
This file contains 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
name: ci | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
jobs: | |
unit-tests: | |
name: Unit Tests | |
timeout-minutes: 10 | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Install Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.19 | |
- name: Go fmt | |
run: | | |
! go fmt ./... | read | |
- name: Go vet | |
run: | | |
! go vet ./... | read | |
- name: Go staticcheck | |
uses: dominikh/[email protected] | |
with: | |
version: "2023.1.3" | |
install-go: false | |
- name: Go Test | |
run: SKIP_INTEGRATION_TESTS=1 go test -v ./... | |
integration-tests: | |
name: Integration Tests | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
terraform_version: ['12','13','14','15','latest'] | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.19 | |
id: go | |
- name: Get dependencies | |
run: | | |
go mod tidy | |
- name: Install tfenv | |
run: | | |
git clone https://github.com/tfutils/tfenv.git $GITHUB_WORKSPACE/.tfenv | |
echo "$GITHUB_WORKSPACE/.tfenv/bin" >> $GITHUB_PATH | |
- name: Install terraform | |
working-directory: test/tfenvconf/terraform_${{ matrix.terraform_version }} | |
run: | | |
tfenv install | |
tfenv use | |
- name: Print Terraform version | |
run: | | |
terraform --version | |
- name: Set Test-Suite | |
id: test-suite | |
env: | |
TF_VERSION: ${{ matrix.terraform_version }} | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
console.log(`Setting test suite version based on ${process.env.TF_VERSION}`) | |
const suite = process.env.TF_VERSION.replace('.', 'o') | |
console.log(`Test suite set to ${suite}`) | |
return suite | |
result-encoding: string | |
- name: Test | |
run: | | |
go test -v -run ^TestTerraform${{ steps.test-suite.outputs.result }} | |
terragrunt-integration-tests: | |
name: Terragrunt Integration Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.19 | |
id: go | |
- name: Get dependencies | |
run: | | |
go mod tidy | |
- name: Install Terraform | |
uses: hashicorp/setup-terraform@v2 | |
with: | |
terraform_version: 1.2.5 | |
- name: Print Terraform version | |
run: | | |
terraform --version | |
- name: Install Terragrunt | |
uses: autero1/[email protected] | |
with: | |
terragrunt_version: 0.38.5 | |
- name: Print Terragrunt version | |
run: | | |
terragrunt --version | |
- name: Test | |
run: | | |
go test -v -run ^TestTerragruntWithCache$ |