Skip to content

Commit

Permalink
Added separated integration test for tofu
Browse files Browse the repository at this point in the history
  • Loading branch information
denis256 committed Oct 5, 2023
1 parent f3158e0 commit 3d4d498
Showing 1 changed file with 62 additions and 4 deletions.
66 changes: 62 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ install_gruntwork_utils: &install_gruntwork_utils
sudo tar -C /usr/local -xzf "go${GO_VERSION}.linux-amd64.tar.gz"
sudo ln -s /usr/local/go/bin/go /usr/bin/go
echo "The installed version of Go is now $(go version)"
# Install OpenTofu
install_tofu: &install_tofu
name: Install OpenTofu
command: |
curl -L "https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha1/tofu_1.6.0-alpha1_linux_amd64.zip" -o tofu.zip
unzip -o tofu.zip
sudo install -m 0755 tofu /usr/local/bin/tofu
Expand Down Expand Up @@ -166,7 +168,8 @@ jobs:
paths:
- project

test:
# run tests with terraform binary
test_terraform:
<<: *defaults
resource_class: large
steps:
Expand Down Expand Up @@ -203,6 +206,48 @@ jobs:
- store_test_results:
path: /tmp/logs

# run tests with tofu binary
test_tofu:
<<: *defaults
resource_class: large
steps:
- attach_workspace:
at: /home/circleci

- run:
<<: *install_gruntwork_utils
- run:
<<: *install_docker_buildx
- run:
<<: *install_tofu

# The weird way you have to set PATH in Circle 2.0
- run: |
echo 'export PATH=$HOME/.local/bin:$HOME/terraform:$HOME/packer:$PATH' >> $BASH_ENV
# remove terraform binary so tofu will be used
sudo rm -f $(which terraform)
# Run the tests. Note that we set the "-p 1" flag to tell Go to run tests in each package sequentially. Without
# this, Go buffers all log output until all packages are done, which with slower running tests can cause CircleCI
# to kill the build after more than 10 minutes without log output.
# NOTE: because this doesn't build with the kubernetes tag, it will not run the kubernetes tests. See
# kubernetes_test build steps.
- run: mkdir -p /tmp/logs
# check we can compile the azure code, but don't actually run the tests
- run: run-go-tests --packages "-p 1 -tags=azure -run IDontExist ./modules/azure"
- run: run-go-tests --packages "-p 1 ./..." | tee /tmp/logs/test_output.log

- run:
command: |
./cmd/bin/terratest_log_parser_linux_amd64 --testlog /tmp/logs/test_output.log --outputdir /tmp/logs
when: always

# Store test result and log artifacts for browsing purposes
- store_artifacts:
path: /tmp/logs
- store_test_results:
path: /tmp/logs

# We run the GCP tests in a separate build step using the Docker executor for better isolation and resiliency. Using
# The Docker executor ensures GCP tests do not erroneously make metadata network calls within CircleCI's private
# environment. For more information see: https://github.com/gruntwork-io/terratest/pull/765.
Expand Down Expand Up @@ -371,7 +416,20 @@ workflows:
tags:
only: /^v.*/

- test:
- test_terraform:
context:
- AWS__PHXDEVOPS__circle-ci-test
- GITHUB__PAT__gruntwork-ci
- SLACK__TOKEN__refarch-deployer-test
- SLACK__WEBHOOK__refarch-deployer-test
- SLACK__CHANNEL__test-workflow-approvals
requires:
- setup
filters:
tags:
only: /^v.*/

- test_tofu:
context:
- AWS__PHXDEVOPS__circle-ci-test
- GITHUB__PAT__gruntwork-ci
Expand Down

0 comments on commit 3d4d498

Please sign in to comment.