Skip to content

Commit

Permalink
Fix for old "shells" parameter; add stderr output check (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleKotowick authored Dec 26, 2024
1 parent 89deb3b commit 073d48a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 10 additions & 2 deletions apply-failure/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ inputs:
description: "Arguments to provide to Terraform (e.g. -var=\"key1=value1\" -var=\"key2=value2\")."
required: false
default: ""
stderr_contains:
description: "A string value to assert that is contained in the stderr output"

runs:
using: 'composite'
Expand All @@ -17,7 +19,6 @@ runs:

# Apply the Terraform config
- name: Terraform Apply
if: matrix.shells != 'true'
id: apply
continue-on-error: true
shell: sh
Expand All @@ -26,8 +27,15 @@ runs:

# Ensure that the outcome was a failure
- name: Check for Failure
if: matrix.shells != 'true' && steps.apply.outcome != 'failure'
if: steps.apply.outcome != 'failure'
shell: sh
run: |
echo "Apply had a status other than the expected failure: ${{ steps.apply.outcome }}"
exit 1
- name: Check for stderr string
if: inputs.stderr_contains != '' && !contains(steps.apply.outputs.stderr, inputs.stderr_contains)
shell: sh
run: |
echo "stderr does not contain the expected string (${{ inputs.stderr_contains }})"
exit 1
8 changes: 4 additions & 4 deletions matrix/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ runs:
id: images
shell: bash
run: |
images='["alpine:latest", "redhat/ubi9:latest", "fedora:latest", "centos:latest", "ubuntu:latest", "amazonlinux:latest"]'
images='["alpine:latest", "redhat/ubi9:latest", "fedora:latest", "centos:latest", "amazonlinux:latest"]'
IFS=',' read -r -a additional_images <<< $(echo "${{ inputs.additional_images }}" | sed 's/[[:blank:]]//g')
for image in "${additional_images[@]}"; do
images=$(echo "$images" | jq -r ". + [\"$image\"]")
Expand Down Expand Up @@ -136,20 +136,20 @@ runs:
minor=$(echo $version | cut -d. -f2)
# Exclude Amazon Linux 1/2 with any version less than 14
if ! ( [ $major -eq 0 ] && [ $minor -lt 14 ] && ( [ "$image" = "amazonlinux:1" ] || [ "$image" = "amazonlinux:2" ] )) then
matrix+=("{\"container\": {\"image\": \"$image\"}, \"runs-on\": \"ubuntu-latest\", \"terraform_version\": \"$version\", \"shells\": \"false\"}")
matrix+=("{\"container\": {\"image\": \"$image\"}, \"runs-on\": \"ubuntu-latest\", \"terraform_version\": \"$version\"}")
fi
done
done
# Add the Linux shell configurations
for version in $(echo "${tf_versions}" | jq -r '.[]'); do
matrix+=("{\"container\": \"\", \"runs-on\": \"ubuntu-latest\", \"terraform_version\": \"$version\", \"shells\": \"true\"}")
matrix+=("{\"container\": \"\", \"runs-on\": \"ubuntu-latest\", \"terraform_version\": \"$version\"}")
done
# Add the non-Linux configurations
for os in $(echo "${runners}" | jq -r '.[]'); do
for version in $(echo "${tf_versions}" | jq -r '.[]'); do
matrix+=("{\"container\": \"\", \"runs-on\": \"$os\", \"terraform_version\": \"$version\", \"shells\": \"false\"}")
matrix+=("{\"container\": \"\", \"runs-on\": \"$os\", \"terraform_version\": \"$version\"}")
done
done
Expand Down

0 comments on commit 073d48a

Please sign in to comment.