diff --git a/apply-failure/action.yml b/apply-failure/action.yml index a7eceeb..ddff0cb 100644 --- a/apply-failure/action.yml +++ b/apply-failure/action.yml @@ -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' @@ -17,7 +19,6 @@ runs: # Apply the Terraform config - name: Terraform Apply - if: matrix.shells != 'true' id: apply continue-on-error: true shell: sh @@ -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 diff --git a/matrix/action.yml b/matrix/action.yml index 204c396..d8e295a 100644 --- a/matrix/action.yml +++ b/matrix/action.yml @@ -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\"]") @@ -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