Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run tests from Github Actions - ""tofu": executable file not found in $PATH; } " #1388

Open
mrybson opened this issue Jan 25, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@mrybson
Copy link

mrybson commented Jan 25, 2024

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.

@mrybson mrybson added the bug Something isn't working label Jan 25, 2024
@msl0
Copy link

msl0 commented Aug 30, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants