Cannot run tests from Github Actions - ""tofu": executable file not found in $PATH; } "
Describe the bug I am trying to run the terratests from Github Actions. It works fine locally, but I am getting below error when running from the GH Runner.
To Reproduce
name: Integration Tests
on:
workflow_dispatch
jobs:
go-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Create module
working-directory: terraform/tests
run: go mod init "mymod"
- name: Go mod tidy
working-directory: terraform/tests
run: go mod tidy
- name: Run Tests
working-directory: terraform/tests
run: go test -v -tags mytag
Expected behavior Tests are getting executed.
Terminal output
[Integration Tests/go-tests] ⭐ Run Main Run Tests [Integration Tests/go-tests] 🐳 docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/4] user= workdir=terraform/tests | === RUN MyTestFunction1 | === PAUSE MyTestFunction1 | === CONT MyTestFunction1 | myTest.go:31: mLaAA7 | MyTestFunction1 2024-01-25T16:54:12Z retry.go:91: tofu [init -upgrade=false] | MyTestFunction1 2024-01-25T16:54:12Z logger.go:66: Running command tofu with args [init -upgrade=false] | MyTestFunction1 2024-01-25T16:54:12Z retry.go:99: Returning due to fatal error: FatalError{Underlying: error while running command: exec: "tofu": executable file not found in $PATH; } | apply.go:15: | Error Trace: /root/go/pkg/mod/github.com/gruntwork-io/[email protected]/modules/terraform/apply.go:15 | /mnt/c/repos/terraform-templates-deployment/terraform/tests/myTest.go:48 | Error: Received unexpected error: | FatalError{Underlying: error while running command: exec: "tofu": executable file not found in $PATH; } | Test: MyTestFunction1 | MyTestFunction1 2024-01-25T16:54:12Z retry.go:91: tofu [destroy -auto-approve -input=false -var postfix=mlaaa7 -lock=false] | MyTestFunction1 2024-01-25T16:54:12Z logger.go:66: Running command tofu with args [destroy -auto-approve -input=false -var postfix=mlaaa7 -lock=false] | MyTestFunction1 2024-01-25T16:54:12Z retry.go:99: Returning due to fatal error: FatalError{Underlying: error while running command: exec: "tofu": executable file not found in $PATH; } | destroy.go:11: | Error Trace: /root/go/pkg/mod/github.com/gruntwork-io/[email protected]/modules/terraform/destroy.go:11 | /opt/hostedtoolcache/go/1.21.6/x64/src/runtime/panic.go:523 | /opt/hostedtoolcache/go/1.21.6/x64/src/testing/testing.go:999 | /root/go/pkg/mod/github.com/gruntwork-io/[email protected]/modules/terraform/apply.go:15 | /mnt/c/repos/terraform-templates-deployment/terraform/tests/myTest.go:48 | Error: Received unexpected error: | FatalError{Underlying: error while running command: exec: "tofu": executable file not found in $PATH; } | Test: MyTestFunction1 | --- FAIL: MyTestFunction1 (0.00s) | FAIL | exit status 1
Versions
- Terratest version: v0.46.11
- Environment details : ubuntu 22.04
** Additional ** I don't want to use tofu. I want to use terraform. I tried installing terraform as part of the Github action workflow, but that does not make any difference.
I had a similar problem locally. The same error occurred when the terraform command was not available in the terminal. Make sure that Terraform is installed and the path to the directory where the Terraform executable exists is in the PATH environment variable. Try running the terraform --version command via the workflow to verify it
Check this out for more information #1333 https://github.com/gruntwork-io/terratest/releases/tag/v0.46.0
No activity for the past 1 year. Closing the issue. Feel free to reopen it if it's still required.