Improve parsing of tf files #691
Workflow file for this run
This file contains 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-version | |
on: | |
- pull_request | |
permissions: | |
contents: read | |
jobs: | |
required_version: | |
runs-on: ubuntu-24.04 | |
name: specific required_version | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version | |
with: | |
path: tests/workflows/test-version/required_version | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "0.12.26" ]]; then | |
echo "::error:: Terraform version not set from required_version" | |
exit 1 | |
fi | |
required_version_range: | |
runs-on: ubuntu-24.04 | |
name: required_version range | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version | |
with: | |
path: tests/workflows/test-version/range | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "0.12.5" ]]; then | |
echo "::error:: Terraform version not set from required_version range" | |
exit 1 | |
fi | |
required_version_v_prefix: | |
runs-on: ubuntu-24.04 | |
name: required_version with a v prefix | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version | |
with: | |
path: tests/workflows/test-version/v-prefix | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "0.12.26" ]]; then | |
echo "::error:: Terraform version not set from required_version range" | |
exit 1 | |
fi | |
tfswitch: | |
runs-on: ubuntu-24.04 | |
name: tfswitch | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version | |
with: | |
path: tests/workflows/test-version/tfswitch | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "1.1.0" ]]; then | |
echo "::error:: Terraform version not set from .tfswitchrc" | |
exit 1 | |
fi | |
tfenv: | |
runs-on: ubuntu-24.04 | |
name: tfenv | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version | |
with: | |
path: tests/workflows/test-version/tfenv | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "0.12.17" ]]; then | |
echo "::error:: Terraform version not set from .terraform-version" | |
exit 1 | |
fi | |
tofuenv: | |
runs-on: ubuntu-24.04 | |
name: tofuenv | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test tofu-version | |
uses: ./tofu-version | |
id: tofu-version | |
with: | |
path: tests/workflows/test-version/tofuenv | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.tofu-version.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "1.8.5" ]]; then | |
echo "::error:: Terraform version not set from .opentofu-version" | |
exit 1 | |
fi | |
asdf: | |
runs-on: ubuntu-24.04 | |
name: asdf | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test getting version from .tools-versions | |
uses: ./terraform-version | |
id: terraform-version | |
with: | |
path: tests/workflows/test-version/asdf | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "0.12.11" ]]; then | |
echo "::error:: Terraform version not set from .tool-versions" | |
exit 1 | |
fi | |
mv tests/workflows/test-version/asdf/.tool-versions .tool-versions | |
- name: Test getting version from root .tools-versions | |
uses: ./terraform-version | |
id: root-version | |
with: | |
path: tests/workflows/test-version/asdf | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.root-version.outputs.terraform }} | |
run: | | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "0.12.11" ]]; then | |
echo "::error:: Terraform version not set from .tool-versions" | |
exit 1 | |
fi | |
env: | |
runs-on: ubuntu-24.04 | |
name: TERRAFORM_VERSION range | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version | |
env: | |
TERRAFORM_VERSION: ">=0.12.0,<=0.12.5" | |
with: | |
path: tests/workflows/test-version/empty | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "0.12.5" ]]; then | |
echo "::error:: Terraform version not set from required_version range" | |
exit 1 | |
fi | |
tfc_workspace: | |
runs-on: ubuntu-24.04 | |
name: TFC Workspace | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Create workspace | |
uses: ./terraform-new-workspace | |
env: | |
TERRAFORM_VERSION: 0.12.13 | |
with: | |
path: tests/workflows/test-version/terraform-cloud | |
workspace: test-1 | |
backend_config: token=${{ secrets.TF_API_TOKEN }} | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version | |
with: | |
path: tests/workflows/test-version/terraform-cloud | |
workspace: test-1 | |
backend_config: token=${{ secrets.TF_API_TOKEN }} | |
- name: Destroy workspace | |
uses: ./terraform-destroy-workspace | |
with: | |
path: tests/workflows/test-version/terraform-cloud | |
workspace: test-1 | |
backend_config: token=${{ secrets.TF_API_TOKEN }} | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "0.12.13" ]]; then | |
echo "::error:: Terraform version not set from remote workspace" | |
exit 1 | |
fi | |
tfc_cloud_workspace: | |
runs-on: ubuntu-24.04 | |
name: TFC Cloud Configuration | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Create workspace | |
uses: ./terraform-new-workspace | |
env: | |
TERRAFORM_VERSION: 1.1.2 | |
TERRAFORM_CLOUD_TOKENS: app.terraform.io=${{ secrets.TF_API_TOKEN }} | |
with: | |
path: tests/workflows/test-version/cloud | |
workspace: tfc_cloud_workspace-1 | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version | |
env: | |
TERRAFORM_CLOUD_TOKENS: app.terraform.io=${{ secrets.TF_API_TOKEN }} | |
with: | |
path: tests/workflows/test-version/cloud | |
workspace: tfc_cloud_workspace-1 | |
- name: Destroy workspace | |
uses: ./terraform-destroy-workspace | |
env: | |
TERRAFORM_CLOUD_TOKENS: app.terraform.io=${{ secrets.TF_API_TOKEN }} | |
with: | |
path: tests/workflows/test-version/cloud | |
workspace: tfc_cloud_workspace-1 | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "1.1.2" ]]; then | |
echo "::error:: Terraform version not set from remote workspace" | |
exit 1 | |
fi | |
tfc_partial_cloud_workspace: | |
runs-on: ubuntu-24.04 | |
name: Partial TFC Cloud Configuration | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Create workspace | |
uses: ./terraform-new-workspace | |
env: | |
TERRAFORM_VERSION: 1.2.1 | |
TERRAFORM_CLOUD_TOKENS: app.terraform.io=${{ secrets.TF_API_TOKEN }} | |
TF_CLOUD_ORGANIZATION: flooktech | |
with: | |
path: tests/workflows/test-version/partial-cloud | |
workspace: tfc_partial_cloud_workspace-1 | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version | |
env: | |
TERRAFORM_CLOUD_TOKENS: app.terraform.io=${{ secrets.TF_API_TOKEN }} | |
TF_CLOUD_ORGANIZATION: flooktech | |
with: | |
path: tests/workflows/test-version/partial-cloud | |
workspace: tfc_partial_cloud_workspace-1 | |
- name: Destroy workspace | |
uses: ./terraform-destroy-workspace | |
env: | |
TERRAFORM_CLOUD_TOKENS: app.terraform.io=${{ secrets.TF_API_TOKEN }} | |
TF_CLOUD_ORGANIZATION: flooktech | |
with: | |
path: tests/workflows/test-version/partial-cloud | |
workspace: tfc_partial_cloud_workspace-1 | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "1.2.1" ]]; then | |
echo "::error:: Terraform version not set from remote workspace" | |
exit 1 | |
fi | |
tfc_partial_cloud_tags_workspace: | |
runs-on: ubuntu-24.04 | |
name: Partial TFC Cloud Configuration with tags | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Create workspace | |
uses: ./terraform-new-workspace | |
env: | |
TERRAFORM_VERSION: 1.2.1 | |
TERRAFORM_CLOUD_TOKENS: app.terraform.io=${{ secrets.TF_API_TOKEN }} | |
TF_CLOUD_ORGANIZATION: flooktech | |
with: | |
path: tests/workflows/test-version/partial-cloud-tags | |
workspace: tfc_partial_cloud_tags_workspace-1 | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version | |
env: | |
TERRAFORM_CLOUD_TOKENS: app.terraform.io=${{ secrets.TF_API_TOKEN }} | |
TF_CLOUD_ORGANIZATION: flooktech | |
with: | |
path: tests/workflows/test-version/partial-cloud-tags | |
workspace: tfc_partial_cloud_tags_workspace-1 | |
- name: Destroy workspace | |
uses: ./terraform-destroy-workspace | |
env: | |
TERRAFORM_CLOUD_TOKENS: app.terraform.io=${{ secrets.TF_API_TOKEN }} | |
TF_CLOUD_ORGANIZATION: flooktech | |
with: | |
path: tests/workflows/test-version/partial-cloud-tags | |
workspace: tfc_partial_cloud_tags_workspace-1 | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "1.2.1" ]]; then | |
echo "::error:: Terraform version not set from remote workspace" | |
exit 1 | |
fi | |
local_state: | |
runs-on: ubuntu-24.04 | |
name: Local State file | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version | |
with: | |
path: tests/workflows/test-version/local | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version.outputs.terraform }} | |
run: | | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "0.15.4" ]]; then | |
echo "::error:: Terraform version not set from state file" | |
exit 1 | |
fi | |
remote_state: | |
runs-on: ubuntu-24.04 | |
name: Remote State file | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Apply default workspace | |
uses: ./terraform-apply | |
env: | |
TERRAFORM_VERSION: 0.12.9 | |
with: | |
variables: my_variable="hello" | |
path: tests/workflows/test-version/state | |
auto_approve: true | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version | |
with: | |
path: tests/workflows/test-version/state | |
- name: Destroy default workspace | |
uses: ./terraform-destroy | |
with: | |
path: tests/workflows/test-version/state | |
variables: my_variable="goodbye" | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "0.12.9" ]]; then | |
echo "::error:: Terraform version not set from state file" | |
exit 1 | |
fi | |
- name: Create second workspace | |
uses: ./terraform-new-workspace | |
env: | |
TERRAFORM_VERSION: 1.1.0 | |
with: | |
path: tests/workflows/test-version/state | |
workspace: second | |
- name: Apply second workspace | |
uses: ./terraform-apply | |
with: | |
variables: my_variable="goodbye" | |
path: tests/workflows/test-version/state | |
workspace: second | |
auto_approve: true | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version-second | |
with: | |
path: tests/workflows/test-version/state | |
workspace: second | |
- name: Destroy second workspace | |
uses: ./terraform-destroy-workspace | |
with: | |
path: tests/workflows/test-version/state | |
workspace: second | |
variables: my_variable="goodbye" | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version-second.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "1.1.0" ]]; then | |
echo "::error:: Terraform version not set from state file" | |
exit 1 | |
fi | |
- name: Create third workspace | |
uses: ./terraform-new-workspace | |
env: | |
TERRAFORM_VERSION: 0.13.0 | |
with: | |
path: tests/workflows/test-version/state | |
workspace: third | |
- name: Apply third workspace | |
uses: ./terraform-apply | |
with: | |
variables: my_variable="goodbye" | |
path: tests/workflows/test-version/state | |
workspace: third | |
auto_approve: true | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version-third | |
with: | |
path: tests/workflows/test-version/state | |
workspace: third | |
- name: Destroy third workspace | |
uses: ./terraform-destroy-workspace | |
with: | |
path: tests/workflows/test-version/state | |
workspace: third | |
variables: my_variable="goodbye" | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version-third.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "0.13.0" ]]; then | |
echo "::error:: Terraform version not set from state file" | |
exit 1 | |
fi | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version-fourth | |
with: | |
path: tests/workflows/test-version/state | |
workspace: fourth | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version-fourth.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "1."* ]]; then | |
echo "::error:: Terraform version not set to latest when no existing state" | |
exit 1 | |
fi | |
empty_path: | |
runs-on: ubuntu-24.04 | |
name: latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version | |
with: | |
path: tests/workflows/test-version/empty | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != *"1.10"* ]]; then | |
echo "::error:: Latest version was not used" | |
exit 1 | |
fi | |
- name: Version doesn't exist | |
uses: ./terraform-new-workspace | |
continue-on-error: true | |
id: no-such-version | |
env: | |
TERRAFORM_VERSION: 99.0.0 | |
with: | |
path: tests/workflows/test-version/empty | |
- name: Check failed to download no such version | |
env: | |
OUTCOME: ${{ steps.no-such-version.outcome }} | |
run: | | |
if [[ "$OUTCOME" != "failure" ]]; then | |
echo "Did not fail correctly" | |
exit 1 | |
fi | |
provider_versions: | |
runs-on: ubuntu-24.04 | |
name: provider versions | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test terraform-version with 0.12 | |
uses: ./terraform-version | |
id: terraform-version-12 | |
with: | |
path: tests/workflows/test-version/providers/0.12 | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version-12.outputs.terraform }} | |
DETECTED_RANDOM_VERSION: ${{ steps.terraform-version-12.outputs.random }} | |
DETECTED_ACME_VERSION: ${{ steps.terraform-version-12.outputs.acme }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
echo "The random version was $DETECTED_RANDOM_VERSION" | |
echo "The acme version was $DETECTED_ACME_VERSION" | |
if [[ "$DETECTED_RANDOM_VERSION" != "2.2.0" ]]; then | |
echo "::error:: random provider version has not been set" | |
exit 1 | |
fi | |
if [[ -z "$DETECTED_ACME_VERSION" ]]; then | |
echo "::error:: acme provider version has not been set" | |
exit 1 | |
fi | |
- name: Test terraform-version with 0.13 | |
uses: ./terraform-version | |
id: terraform-version-13 | |
with: | |
path: tests/workflows/test-version/providers/0.13 | |
- name: Check versions | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version-13.outputs.terraform }} | |
DETECTED_RANDOM_VERSION: ${{ steps.terraform-version-13.outputs.random }} | |
DETECTED_ACME_VERSION: ${{ steps.terraform-version-13.outputs.acme }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
echo "The random version was $DETECTED_RANDOM_VERSION" | |
echo "The acme version was $DETECTED_ACME_VERSION" | |
if [[ "$DETECTED_RANDOM_VERSION" != "2.2.0" ]]; then | |
echo "::error:: random provider version has not been set" | |
exit 1 | |
fi | |
if [[ -z "$DETECTED_ACME_VERSION" ]]; then | |
echo "::error:: acme provider version has not been set" | |
exit 1 | |
fi | |
- name: Test terraform-version with 0.11 | |
uses: ./terraform-version | |
id: terraform-version-11 | |
with: | |
path: tests/workflows/test-version/providers/0.11 | |
- name: Check versions | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version-11.outputs.terraform }} | |
DETECTED_RANDOM_VERSION: ${{ steps.terraform-version-11.outputs.random }} | |
DETECTED_ACME_VERSION: ${{ steps.terraform-version-11.outputs.acme }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
echo "The random version was $DETECTED_RANDOM_VERSION" | |
echo "The acme version was $DETECTED_ACME_VERSION" | |
if [[ "$DETECTED_RANDOM_VERSION" != "2.2.0" ]]; then | |
echo "::error:: random provider version has not been set" | |
exit 1 | |
fi | |
if [[ -z "$DETECTED_ACME_VERSION" ]]; then | |
echo "::error:: acme provider version has not been set" | |
exit 1 | |
fi | |
# arm64: | |
# runs-on: buildjet-2vcpu-ubuntu-2204-arm | |
# name: Version detection on arm | |
# steps: | |
# - name: Checkout | |
# uses: actions/checkout@v4 | |
# with: | |
# persist-credentials: false | |
# | |
# - name: Version unsupported on arm | |
# uses: ./terraform-version | |
# continue-on-error: true | |
# id: arm-unsupported | |
# env: | |
# TERRAFORM_VERSION: 0.12.0 | |
# with: | |
# path: tests/workflows/test-version/empty | |
# | |
# - name: Check failed to download unsupported platform | |
# run: | | |
# if [[ "${{ steps.arm-unsupported.outcome }}" != "failure" ]]; then | |
# echo "Did not fail correctly" | |
# exit 1 | |
# fi | |
# | |
# - name: Version doesn't exist | |
# uses: ./terraform-version | |
# continue-on-error: true | |
# id: no-such-version | |
# with: | |
# path: tests/workflows/test-version/nosuchversion | |
# | |
# - name: Check failed to download no such version | |
# run: | | |
# if [[ "${{ steps.no-such-version.outcome }}" != "failure" ]]; then | |
# echo "Did not fail correctly" | |
# exit 1 | |
# fi | |
# | |
# - name: Test terraform-version | |
# uses: ./terraform-version | |
# id: terraform-version | |
# with: | |
# path: tests/workflows/test-version/tfswitch | |
# | |
# - name: Check the version | |
# run: | | |
# if [[ "$DETECTED_TERRAFORM_VERSION" != "1.1.0" ]]; then | |
# echo "::error:: Terraform version not set from .tfswitchrc" | |
# exit 1 | |
# fi | |
terraform_opentofu_version: | |
runs-on: ubuntu-24.04 | |
name: OPENTOFU_VERSION with terraform action | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version | |
env: | |
OPENTOFU_VERSION: "1.6.0" | |
with: | |
path: tests/workflows/test-version/empty | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version.outputs.terraform }} | |
DETECTED_TOFU_VERSION: ${{ steps.terraform-version.outputs.tofu }} | |
run: | | |
echo "The tofu version was $DETECTED_TOFU_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "1.6.0" ]]; then | |
echo "::error:: Terraform version not set from OPENTOFU_VERSION" | |
exit 1 | |
fi | |
if [[ "$DETECTED_TOFU_VERSION" != "1.6.0" ]]; then | |
echo "::error:: Terraform version not set from OPENTOFU_VERSION" | |
exit 1 | |
fi | |
opentofu_version: | |
runs-on: ubuntu-24.04 | |
name: OPENTOFU_VERSION with tofu action | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test terraform-version | |
uses: ./tofu-version | |
id: tofu-version | |
env: | |
OPENTOFU_VERSION: "1.6.0" | |
with: | |
path: tests/workflows/test-version/empty | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.tofu-version.outputs.terraform }} | |
DETECTED_TOFU_VERSION: ${{ steps.tofu-version.outputs.tofu }} | |
run: | | |
echo "The tofu version was $DETECTED_TOFU_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "1.6.0" ]]; then | |
echo "::error:: Terraform version not set from OPENTOFU_VERSION" | |
exit 1 | |
fi | |
if [[ "$DETECTED_TOFU_VERSION" != "1.6.0" ]]; then | |
echo "::error:: Terraform version not set from OPENTOFU_VERSION" | |
exit 1 | |
fi | |
opentofu_version_pre_release_nosig: | |
runs-on: ubuntu-24.04 | |
name: OPENTOFU_VERSION pre-release with tofu action | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test terraform-version | |
uses: ./tofu-version | |
id: tofu-version | |
env: | |
OPENTOFU_VERSION: "1.6.0-alpha3" | |
with: | |
path: tests/workflows/test-version/empty | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.tofu-version.outputs.terraform }} | |
DETECTED_TOFU_VERSION: ${{ steps.tofu-version.outputs.tofu }} | |
run: | | |
echo "The tofu version was $DETECTED_TOFU_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "1.6.0-alpha3" ]]; then | |
echo "::error:: Terraform version not set from OPENTOFU_VERSION" | |
exit 1 | |
fi | |
if [[ "$DETECTED_TOFU_VERSION" != "1.6.0-alpha3" ]]; then | |
echo "::error:: Terraform version not set from OPENTOFU_VERSION" | |
exit 1 | |
fi | |
opentofu_old_version: | |
runs-on: ubuntu-24.04 | |
name: Prefer OpenTofu, but only Terraform matches constraints | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test tofu-version | |
uses: ./tofu-version | |
id: tofu-version | |
env: | |
OPENTOFU_VERSION: "<1.6.0" | |
with: | |
path: tests/workflows/test-version/empty | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.tofu-version.outputs.terraform }} | |
DETECTED_TOFU_VERSION: ${{ steps.tofu-version.outputs.tofu }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != *"1.5"* ]]; then | |
echo "::error:: Terraform version not selected" | |
exit 1 | |
fi | |
hard_parse: | |
runs-on: ubuntu-24.04 | |
name: Get version constraint from hard to parse file | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Test terraform-version | |
uses: ./terraform-version | |
id: terraform-version | |
with: | |
path: tests/workflows/test-version/hard-parse | |
- name: Check the version | |
env: | |
DETECTED_TERRAFORM_VERSION: ${{ steps.tofu-version.outputs.terraform }} | |
run: | | |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION" | |
if [[ "$DETECTED_TERRAFORM_VERSION" != "1.10.4" ]]; then | |
echo "::error:: Terraform constraint not parsed correctly" | |
exit 1 | |
fi |