Skip to content

Improve parsing of tf files #549

Improve parsing of tf files

Improve parsing of tf files #549

Workflow file for this run

name: Test actions using registry
on:
- pull_request
permissions:
contents: read
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
registry_module:
runs-on: ubuntu-24.04
name: Use registry module
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Create dummy credential file
env:
RUNNER_TEMP_D: ${{ runner.temp }}
run: |
mkdir -p "$RUNNER_TEMP_D/_github_home"
cp tests/workflows/test-registry/terraformrc "$RUNNER_TEMP_D/_github_home/.terraformrc"
ls -la "$RUNNER_TEMP_D"
- name: Plan
uses: ./terraform-plan
env:
TERRAFORM_CLOUD_TOKENS: app.terraform.io=${{ secrets.TF_API_TOKEN }}
with:
path: tests/workflows/test-registry
label: test-registry registry_module
- name: Apply
uses: ./terraform-apply
id: output
with:
path: tests/workflows/test-registry
label: test-registry registry_module
env:
TERRAFORM_CLOUD_TOKENS: app.terraform.io=${{ secrets.TF_API_TOKEN }}
- name: Verify outputs
env:
WORD: ${{ steps.output.outputs.word }}
RUNNER_TEMP_D: ${{ runner.temp }}
run: |
if [[ "$WORD" != "hello" ]]; then
echo "::error:: output not set correctly"
exit 1
fi
# Check that terraformrc is as before
diff tests/workflows/test-registry/terraformrc "$RUNNER_TEMP_D/_github_home/.terraformrc"
multiple_registry_module:
runs-on: ubuntu-24.04
name: Multiple registries
permissions:
contents: read
pull-requests: write
env:
TERRAFORM_CLOUD_TOKENS: |
terraform.example.com = Registry doesn't exist
app.terraform.io = ${{ secrets.TF_API_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Plan
uses: ./terraform-plan
with:
path: tests/workflows/test-registry
label: test-registry multiple_registry_module
- name: Apply
uses: ./terraform-apply
id: output
with:
path: tests/workflows/test-registry
label: test-registry multiple_registry_module
- name: Verify outputs
env:
WORD: ${{ steps.output.outputs.word }}
run: |
if [[ "$WORD" != "hello" ]]; then
echo "::error:: output not set correctly"
exit 1
fi
nonsense_credentials:
runs-on: ubuntu-24.04
name: Nonsense cloud credentials
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Plan
uses: ./terraform-plan
id: plan
continue-on-error: true
env:
TERRAFORM_CLOUD_TOKENS: No thanks
with:
path: tests/workflows/test-registry
- name: Check failed
env:
OUTCOME: ${{ steps.plan.outcome }}
run: |
if [[ "$OUTCOME" != "failure" ]]; then
echo "did not fail correctly with nonsense credentials"
exit 1
fi