Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into feature/copy-lock-file
Browse files Browse the repository at this point in the history
# Conflicts:
#	cli/commands/terraform/action.go
  • Loading branch information
rodrigorfk committed Apr 16, 2024
2 parents 3ab235d + 734a278 commit 2140d73
Show file tree
Hide file tree
Showing 260 changed files with 8,077 additions and 2,227 deletions.
226 changes: 165 additions & 61 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,26 @@ orbs:
env: &env
environment:
GRUNTWORK_INSTALLER_VERSION: v0.0.39
MODULE_CI_VERSION: v0.52.6
MODULE_CI_VERSION: v0.53.3

defaults: &defaults
docker:
- image: 087285199408.dkr.ecr.us-east-1.amazonaws.com/circle-ci-test-image-base:go1.21-tf1.5-tg39.1-pck1.8-ci50.7
- image: 087285199408.dkr.ecr.us-east-1.amazonaws.com/circle-ci-test-image-base:go1.21.7-tf1.5-tg39.1-pck1.8-ci50.7

# Install Terraform which is not available in the default image
install_terraform_latest: &install_terraform_latest
name: Install the latest Terraform
command: |
pushd .
cd /tmp
export TERRAFORM_VERSION=1.8.0
curl -L "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" -o terraform.zip
unzip -o terraform.zip
sudo install -m 0755 terraform /usr/local/bin/terraform
rm -rf terraform
rm -rf terraform.zip
popd
terraform --version
install_tofu: &install_tofu
name: Install OpenTofu
Expand All @@ -27,7 +42,7 @@ install_tofu: &install_tofu
tofu --version
install_tflint: &install_tflint
name: Install Tflint
name: Install TFlint
command: |
pushd .
cd /tmp
Expand All @@ -39,6 +54,37 @@ install_tflint: &install_tflint
popd
tflint --version
setup_test_environment: &setup_test_environment
name: Setup integration tests environment
command: |
# Make GCP Service Account creds available as a file
echo $GCLOUD_SERVICE_KEY > ${HOME}/gcloud-service-key.json
echo 'export GOOGLE_APPLICATION_CREDENTIALS=${HOME}/gcloud-service-key.json' >> $BASH_ENV
# Import test / dev key for SOPS
gpg --import --no-tty --batch --yes ./test/fixture-sops/test_pgp_key.asc
mkdir -p logs
no_output_timeout: 30m

run_integration_test: &run_integration_test
name: Run integration tests
command: |
run-go-tests --packages "$(go list ./... | grep /test | tr '\n' ' ')" | tee logs/integration.log
no_output_timeout: 30m

run_tflint_test: &run_tflint_test
name: Run TFlint tests
command: |
run-go-tests --packages "-tags tflint -run TestTflint ./test" | tee logs/integration.log
no_output_timeout: 30m

run_terratest_log_parser: &run_terratest_log_parser
name: Terratest log parser
command: |
gruntwork-install --binary-name 'terratest_log_parser' --repo 'https://github.com/gruntwork-io/terratest' --tag 'v0.30.0'
terratest_log_parser --testlog logs/integration.log --outputdir logs
when: always


version: 2.1
jobs:
test_windows:
Expand Down Expand Up @@ -75,6 +121,8 @@ jobs:
go test -v ./... -run TestCanonicalPath -timeout 45m
go test -v ./... -run TestJoinTerraformModulePath -timeout 45m
go test -v ./... -run TestIncludeInCopy -timeout 45m
go test -v ./... -run TestWindowsScaffold -timeout 45m
go test -v ./... -run TestWindowsScaffoldRef -timeout 45m
go test -tags windows -v -un -run TestWindows ./test -timeout 45m
- run:
name: Run go tofu tests
Expand All @@ -90,6 +138,8 @@ jobs:
go test -v ./... -run TestCanonicalPath -timeout 45m
go test -v ./... -run TestJoinTerraformModulePath -timeout 45m
go test -v ./... -run TestIncludeInCopy -timeout 45m
go test -v ./... -run TestWindowsScaffold -timeout 45m
go test -v ./... -run TestWindowsScaffoldRef -timeout 45m
go test -tags windows -v -un -run TestWindows ./test -timeout 45m
# We're running unit tests separately from integration tests - with no parallelization.
# With heavy parallelization coupled with re-use of test fixtures we've witnessed slight
Expand Down Expand Up @@ -121,6 +171,7 @@ jobs:
mkdir -p logs
go mod tidy
run-go-tests --parallelism 1 --packages "$(go list ./... | grep -v /test | tr '\n' ' ')" | tee logs/unit.log
go test -run=TestParseDependencyBlockMultiple -race ./config | tee -a logs/unit.log
- run:
command: terratest_log_parser --testlog logs/unit.log --outputdir logs
when: always
Expand All @@ -129,110 +180,136 @@ jobs:
- store_test_results:
path: logs

integration_test_terraform:
resource_class: large
integration_test_terraform_1_5:
resource_class: xlarge
<<: *defaults
steps:
- checkout
- run: gruntwork-install --binary-name 'terratest_log_parser' --repo 'https://github.com/gruntwork-io/terratest' --tag 'v0.30.0'
- run:
<<: *install_tflint
- run:
<<: *setup_test_environment
- run:
<<: *run_integration_test
- run:
<<: *run_terratest_log_parser
- store_artifacts:
path: logs
- store_test_results:
path: logs

integration_test_terraform_with_provider_cache:
resource_class: xlarge
<<: *defaults
steps:
- checkout
- run:
# Install Terraform 1.6 for integration tests
command: |
pushd .
cd /tmp
curl -L "https://releases.hashicorp.com/terraform/1.6.2/terraform_1.6.2_linux_amd64.zip" -o terraform.zip
unzip -o terraform.zip
sudo install -m 0755 terraform /usr/local/bin/terraform
rm -rf terraform
rm -rf terraform.zip
popd
terraform --version
<<: *install_tflint
- run:
<<: *setup_test_environment
- run:
<<: *run_integration_test
environment:
TERRAGRUNT_PROVIDER_CACHE: "1"
- run:
<<: *run_terratest_log_parser
- store_artifacts:
path: logs
- store_test_results:
path: logs

# Make GCP Service Account creds available as a file
- run: echo $GCLOUD_SERVICE_KEY > ${HOME}/gcloud-service-key.json
- run: echo 'export GOOGLE_APPLICATION_CREDENTIALS=${HOME}/gcloud-service-key.json' >> $BASH_ENV
# Import test / dev key for SOPS
integration_test_terraform_latest:
resource_class: xlarge
<<: *defaults
steps:
- checkout
- run:
command: |
gpg --import --no-tty --batch --yes ./test/fixture-sops/test_pgp_key.asc
mkdir -p logs
run-go-tests --packages "$(go list ./... | grep /test | tr '\n' ' ')" | tee logs/integration.log
no_output_timeout: 30m
<<: *install_terraform_latest
- run:
command: terratest_log_parser --testlog logs/integration.log --outputdir logs
when: always
<<: *install_tflint
- run:
<<: *setup_test_environment
- run:
<<: *run_integration_test
- run:
<<: *run_terratest_log_parser
- store_artifacts:
path: logs
- store_test_results:
path: logs

integration_test_tofu:
resource_class: large
resource_class: xlarge
<<: *defaults
steps:
- checkout
- run: gruntwork-install --binary-name 'terratest_log_parser' --repo 'https://github.com/gruntwork-io/terratest' --tag 'v0.30.0'
- run:
<<: *install_tofu
- run:
<<: *install_tflint
# Make GCP Service Account creds available as a file
- run: echo $GCLOUD_SERVICE_KEY > ${HOME}/gcloud-service-key.json
- run: echo 'export GOOGLE_APPLICATION_CREDENTIALS=${HOME}/gcloud-service-key.json' >> $BASH_ENV
# Import test / dev key for SOPS
- run:
command: |
gpg --import --no-tty --batch --yes ./test/fixture-sops/test_pgp_key.asc
# remove terraform
sudo rm -f $(which terraform)
mkdir -p logs
run-go-tests --packages "$(go list ./... | grep /test | tr '\n' ' ')" | tee logs/integration.log
no_output_timeout: 30m
<<: *setup_test_environment
- run:
# Remove terraform
sudo rm -f $(which terraform)
- run:
<<: *run_integration_test
environment:
# use tofu as wrapper
TERRAGRUNT_TFPATH: tofu
- run:
command: terratest_log_parser --testlog logs/integration.log --outputdir logs
when: always
<<: *run_terratest_log_parser
- store_artifacts:
path: logs
- store_test_results:
path: logs

integration_test_tofu_with_provider_cache:
resource_class: xlarge
<<: *defaults
steps:
- checkout
- run:
<<: *install_tofu
- run:
<<: *install_tflint
- run:
<<: *setup_test_environment
- run:
# Remove terraform
sudo rm -f $(which terraform)
- run:
<<: *run_integration_test
environment:
TERRAGRUNT_TFPATH: tofu
TERRAGRUNT_PROVIDER_CACHE: "1"
- run:
<<: *run_terratest_log_parser
- store_artifacts:
path: logs
- store_test_results:
path: logs

# Run TFLint tests separately as tflint during execution change working directory.
integration_test_tflint:
resource_class: large
<<: *defaults
steps:
- checkout
- run: gruntwork-install --binary-name 'terratest_log_parser' --repo 'https://github.com/gruntwork-io/terratest' --tag 'v0.30.0'
- run:
<<: *install_tofu
- run:
<<: *install_tflint
# Make GCP Service Account creds available as a file
- run: echo $GCLOUD_SERVICE_KEY > ${HOME}/gcloud-service-key.json
- run: echo 'export GOOGLE_APPLICATION_CREDENTIALS=${HOME}/gcloud-service-key.json' >> $BASH_ENV
# Import test / dev key for SOPS
- run:
command: |
gpg --import --no-tty --batch --yes ./test/fixture-sops/test_pgp_key.asc
no_output_timeout: 30m
# Run TFLint tests separately as tflint during execution change working directory.
<<: *setup_test_environment
- run:
command: |
mkdir -p logs
run-go-tests --packages "-tags tflint -run TestTflint ./test" | tee logs/integration.log
no_output_timeout: 30m
<<: *run_tflint_test
- run:
command: terratest_log_parser --testlog logs/integration.log --outputdir logs
when: always
<<: *run_terratest_log_parser
- store_artifacts:
path: logs
- store_test_results:
path: logs

build:
resource_class: large
<<: *defaults
Expand Down Expand Up @@ -262,7 +339,10 @@ jobs:
- run:
name: Compile and sign the binaries
command: |
sign-binary --install-macos-sign-dependencies --os mac .gon_amd64.hcl
export AC_PASSWORD=${MACOS_AC_PASSWORD}
export AC_PROVIDER=${MACOS_AC_PROVIDER}
sign-binary --os mac --install-macos-sign-dependencies .gon_amd64.hcl
sign-binary --os mac .gon_arm64.hcl
echo "Done signing the binary"
Expand Down Expand Up @@ -298,7 +378,23 @@ workflows:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- integration_test_terraform:
- integration_test_terraform_1_5:
filters:
tags:
only: /^v.*/
context:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- integration_test_terraform_latest:
filters:
tags:
only: /^v.*/
context:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- integration_test_terraform_with_provider_cache:
filters:
tags:
only: /^v.*/
Expand All @@ -314,6 +410,14 @@ workflows:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- integration_test_tofu_with_provider_cache:
filters:
tags:
only: /^v.*/
context:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- integration_test_tflint:
filters:
tags:
Expand Down
1 change: 0 additions & 1 deletion .gon_amd64.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ bundle_id = "io.gruntwork.app.terragrunt"

apple_id {
username = "machine.apple@gruntwork.io"
password = "@env:MACOS_AC_PASSWORD"
}

sign {
Expand Down
1 change: 0 additions & 1 deletion .gon_arm64.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ bundle_id = "io.gruntwork.app.terragrunt"

apple_id {
username = "machine.apple@gruntwork.io"
password = "@env:MACOS_AC_PASSWORD"
}

sign {
Expand Down
2 changes: 1 addition & 1 deletion _ci/install-terraform.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Install terraform using Chocolatey
choco install terraform --version 1.5.0 -y
choco install terraform --version 1.8.0 -y
# Verify installation
Get-Command terraform
terraform version
Loading

0 comments on commit 2140d73

Please sign in to comment.