Skip to content

Improve parsing of tf files #691

Improve parsing of tf files

Improve parsing of tf files #691

Workflow file for this run

name: Test terraform-validate
on:
- pull_request
permissions:
contents: read
jobs:
valid:
runs-on: ubuntu-24.04
name: valid
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: validate
uses: ./terraform-validate
id: validate
with:
path: tests/workflows/test-validate/valid
- name: Check valid
env:
FAILURE_REASON: ${{ steps.validate.outputs.failure-reason }}
run: |
if [[ "$FAILURE_REASON" != "" ]]; then
echo "::error:: failure-reason not set correctly"
exit 1
fi
invalid:
runs-on: ubuntu-24.04
name: Invalid terraform configuration
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: validate
uses: ./terraform-validate
id: validate
continue-on-error: true
with:
path: tests/workflows/test-validate/invalid
- name: Check invalid
env:
OUTCOME: ${{ steps.validate.outcome }}
FAILURE_REASON: ${{ steps.validate.outputs.failure-reason }}
run: |
if [[ "$OUTCOME" != "failure" ]]; then
echo "Validate did not fail correctly"
exit 1
fi
if [[ "$FAILURE_REASON" != "validate-failed" ]]; then
echo "::error:: failure-reason not set correctly"
exit 1
fi
validate_workspace:
runs-on: ubuntu-24.04
name: Use workspace name during validation
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: validate prod
uses: ./terraform-validate
with:
path: tests/workflows/test-validate/workspace_eval
workspace: prod
- name: validate dev
uses: ./terraform-validate
with:
path: tests/workflows/test-validate/workspace_eval
workspace: dev
- name: validate nonexistant workspace
uses: ./terraform-validate
id: validate
continue-on-error: true
with:
path: tests/workflows/test-validate/workspace_eval
- name: Check invalid
env:
OUTCOME: ${{ steps.validate.outcome }}
FAILURE_REASON: ${{ steps.validate.outputs.failure-reason }}
run: |
if [[ "$OUTCOME" != "failure" ]]; then
echo "Validate did not fail correctly"
exit 1
fi
if [[ "$FAILURE_REASON" != "validate-failed" ]]; then
echo "::error:: failure-reason not set correctly"
exit 1
fi
validate_remote_workspace:
runs-on: ubuntu-24.04
name: Use workspace name during validation
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: validate prod
uses: ./terraform-validate
with:
path: tests/workflows/test-validate/workspace_eval_remote
workspace: prod
validate_unterminated_string:
runs-on: ubuntu-24.04
name: Validate with unterminated string
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: validate
uses: ./terraform-validate
with:
path: tests/workflows/test-validate/unterminated-string
id: validate
continue-on-error: true
- name: Check invalid
env:
OUTCOME: ${{ steps.validate.outcome }}
FAILURE_REASON: ${{ steps.validate.outputs.failure-reason }}
run: |
if [[ "$OUTCOME" != "failure" ]]; then
echo "Validate did not fail correctly"
exit 1
fi
if [[ "$FAILURE_REASON" != "validate-failed" ]]; then
echo "::error:: failure-reason not set correctly"
exit 1
fi