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

Fix exitcode bug introduced in PR/125 #429

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/data/failure/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "random_pet" "pet" {
1invalid_key= ""
}

output "pet" {
value = random_pet.pet.id
}
33 changes: 32 additions & 1 deletion .github/workflows/setup-terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,38 @@ jobs:

- name: Terraform Plan
id: plan
run: terraform plan
run: terraform plan -detailed-exitcode

- name: Print Terraform Plan
run: echo "${{ steps.plan.outputs.stdout }}"

terraform-run-local-failures:
name: 'Terraform Run Local Failures'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
defaults:
run:
shell: bash
working-directory: ./.github/workflows/data/failure
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Setup Terraform
uses: ./

# coerce initial command exit code in order to verify it did fail
- name: Terraform Init
run: terraform init || $(exit 10) && $(exit 1) || [ $? -eq 10 ]

- name: Terraform Format
run: terraform fmt -check || $(exit 10) && $(exit 1) || [ $? -eq 10 ]

- name: Terraform Plan
id: plan
run: terraform plan -detailed-exitcode || $(exit 10) && $(exit 1) || [ $? -eq 10 ]

- name: Print Terraform Plan
run: echo "${{ steps.plan.outputs.stdout }}"
Expand Down
3 changes: 2 additions & 1 deletion dist/index1.js
Original file line number Diff line number Diff line change
Expand Up @@ -27973,7 +27973,8 @@ async function checkTerraform () {
core.setOutput('stderr', stderr.contents);
core.setOutput('exitcode', exitCode.toString(10));

if (exitCode === 0 || exitCode === 2) {
const usingDetailedExitcode = args.filter(arg => arg.toLowerCase().endsWith('-detailed-exitcode')).length > 0;
if (exitCode === 0 || (exitCode === 2 && usingDetailedExitcode)) {
// A exitCode of 0 is considered a success
// An exitCode of 2 may be returned when the '-detailed-exitcode' option
// is passed to plan. This denotes Success with non-empty
Expand Down
3 changes: 2 additions & 1 deletion wrapper/terraform.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ async function checkTerraform () {
core.setOutput('stderr', stderr.contents);
core.setOutput('exitcode', exitCode.toString(10));

if (exitCode === 0 || exitCode === 2) {
const usingDetailedExitcode = args.filter(arg => arg.toLowerCase().endsWith('-detailed-exitcode')).length > 0;
if (exitCode === 0 || (exitCode === 2 && usingDetailedExitcode)) {
// A exitCode of 0 is considered a success
// An exitCode of 2 may be returned when the '-detailed-exitcode' option
// is passed to plan. This denotes Success with non-empty
Expand Down