Add refresh action and input for plan/apply #61
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test terraform-test | |
on: | |
- pull_request | |
permissions: | |
contents: read | |
jobs: | |
default: | |
runs-on: ubuntu-24.04 | |
name: Default inputs | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test | |
uses: ./terraform-test | |
id: test | |
env: | |
TERRAFORM_VERSION: 1.10.0 | |
with: | |
path: tests/workflows/test-test/local | |
- name: Check Passed | |
env: | |
FAILURE_REASON: ${{ steps.test.outputs.failure-reason }} | |
JUNIT_XML_PATH: ${{ steps.test.outputs.junit-xml-path }} | |
run: | | |
if [[ "$FAILURE_REASON" != "" ]]; then | |
echo "::error:: failure-reason not set correctly" | |
exit 1 | |
fi | |
if [[ "$JUNIT_XML_PATH" != "" ]]; then | |
echo "::error:: junit-xml-path should not be set" | |
exit 1 | |
fi | |
junit: | |
runs-on: ubuntu-24.04 | |
name: Junit support | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test | |
uses: ./terraform-test | |
id: test | |
env: | |
TERRAFORM_VERSION: 1.11.0 | |
with: | |
path: tests/workflows/test-test/local | |
- name: Check Passed | |
env: | |
FAILURE_REASON: ${{ steps.test.outputs.failure-reason }} | |
JUNIT_XML_PATH: ${{ steps.test.outputs.junit-xml-path }} | |
run: | | |
if [[ "$FAILURE_REASON" != "" ]]; then | |
echo "::error:: failure-reason not set correctly" | |
exit 1 | |
fi | |
if [[ "$JUNIT_XML_PATH" == "" ]]; then | |
echo "::error:: junit-xml-path should be set" | |
exit 1 | |
fi | |
# Check the output looks right | |
if [[ ! -f "$JUNIT_XML_PATH" ]]; then | |
echo "::error:: junit-xml-path does not point to a file" | |
exit 1 | |
fi | |
if [[ "$(grep -c '<testsuites' "$JUNIT_XML_PATH")" -ne 1 ]]; then | |
echo "::error:: junit-xml-path does not contain a testsuites tag" | |
exit 1 | |
fi | |
filter: | |
runs-on: ubuntu-24.04 | |
name: Default path with a filter | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test | |
uses: ./terraform-test | |
id: test | |
with: | |
path: tests/workflows/test-test/local | |
test_filter: tests/main.tftest.hcl | |
- name: Check Passed | |
env: | |
FAILURE_REASON: ${{ steps.test.outputs.failure-reason }} | |
run: | | |
if [[ "$FAILURE_REASON" != "" ]]; then | |
echo "::error:: failure-reason not set correctly" | |
exit 1 | |
fi | |
test_dir: | |
runs-on: ubuntu-24.04 | |
name: Custom test directory | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test | |
uses: ./terraform-test | |
id: test | |
with: | |
path: tests/workflows/test-test/local | |
test_directory: custom-test-dir | |
test_filter: | | |
custom-test-dir/another.tftest.hcl | |
custom-test-dir/a-third.tftest.hcl | |
- name: Check Passed | |
env: | |
FAILURE_REASON: ${{ steps.test.outputs.failure-reason }} | |
run: | | |
if [[ "$FAILURE_REASON" != "" ]]; then | |
echo "::error:: failure-reason not set correctly" | |
exit 1 | |
fi | |
nonexistent_test_dir: | |
runs-on: ubuntu-24.04 | |
name: Missing test directory | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test | |
uses: ./terraform-test | |
id: nonexistent_test_dir | |
continue-on-error: true | |
with: | |
path: tests/workflows/test-test/local | |
test_directory: i-dont-exist | |
- name: Check failure | |
env: | |
OUTCOME: ${{ steps.nonexistent_test_dir.outcome }} | |
FAILURE_REASON: ${{ steps.nonexistent_test_dir.outputs.failure-reason }} | |
run: | | |
if [[ "$OUTCOME" != "failure" ]]; then | |
echo "Test did not fail correctly" | |
exit 1 | |
fi | |
if [[ "$FAILURE_REASON" != "no-tests" ]]; then | |
echo "::error:: failure-reason not set correctly" | |
exit 1 | |
fi | |
faulty_filter: | |
runs-on: ubuntu-24.04 | |
name: Filter matches no tests | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test | |
uses: ./terraform-test | |
id: faulty_filter | |
continue-on-error: true | |
with: | |
path: tests/workflows/test-test/local | |
test_filter: | | |
tests/this-test-does-not-exist.tftest.hcl | |
tests/nor-does-this-one.tftest.hcl | |
- name: Check failure | |
env: | |
OUTCOME: ${{ steps.faulty_filter.outcome }} | |
FAILURE_REASON: ${{ steps.faulty_filter.outputs.failure-reason }} | |
run: | | |
if [[ "$OUTCOME" != "failure" ]]; then | |
echo "Test did not fail correctly" | |
exit 1 | |
fi | |
if [[ "$FAILURE_REASON" != "no-tests" ]]; then | |
echo "::error:: failure-reason not set correctly" | |
exit 1 | |
fi | |
failing: | |
runs-on: ubuntu-24.04 | |
name: A failing test using variables | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test | |
uses: ./terraform-test | |
id: failing | |
continue-on-error: true | |
with: | |
path: tests/workflows/test-test/local | |
test_filter: tests/main.tftest.hcl | |
variables: | | |
length = 1 | |
- name: Check failure-reason | |
env: | |
OUTCOME: ${{ steps.failing.outcome }} | |
FAILURE_REASON: ${{ steps.failing.outputs.failure-reason }} | |
run: | | |
if [[ "$OUTCOME" != "failure" ]]; then | |
echo "Test did not fail correctly" | |
exit 1 | |
fi | |
if [[ "$FAILURE_REASON" != "tests-failed" ]]; then | |
echo "::error:: failure-reason not set correctly" | |
exit 1 | |
fi |