Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions .github/workflows/test-plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1059,25 +1059,25 @@ jobs:
path: tests/workflows/test-plan/plan
label: test-plan test_plan_1_4

# arm64:
# runs-on: buildjet-2vcpu-ubuntu-2204-arm
# name: Test on arm64
# permissions:
# contents: read
# pull-requests: write
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# persist-credentials: false
#
# - name: Plan
# uses: ./terraform-plan
# with:
# path: tests/workflows/test-plan/plan
# label: arm64
arm64:
runs-on: ubuntu-24.04-arm
name: Test on arm64
permissions:
contents: read
pull-requests: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Plan
uses: ./terraform-plan
with:
path: tests/workflows/test-plan/plan
label: arm64

always_new:
runs-on: ubuntu-24.04
Expand Down
123 changes: 72 additions & 51 deletions .github/workflows/test-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -721,57 +721,78 @@ jobs:
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
arm64:
runs-on: ubuntu-24.04-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
env:
OUTCOME: ${{ steps.arm-unsupported.outcome }}
run: |
if [[ "$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
env:
OUTCOME: ${{ steps.no-such-version.outcome }}
run: |
if [[ "$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
env:
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version.outputs.terraform }}
run: |
if [[ "$DETECTED_TERRAFORM_VERSION" != "1.1.0" ]]; then
echo "::error:: Terraform version not set from .tfswitchrc"
exit 1
fi

- name: Test tofu-version
uses: ./tofu-version
id: tofu-version
with:
path: tests/workflows/test-version/tofuenv

- name: Check the version
env:
DETECTED_TOFU_VERSION: ${{ steps.tofu-version.outputs.tofu }}
run: |
if [[ "$DETECTED_TOFU_VERSION" != "1.8.5" ]]; then
echo "::error:: Terraform version not set from .tfswitchrc"
exit 1
fi

terraform_opentofu_version:
runs-on: ubuntu-24.04
Expand Down
56 changes: 30 additions & 26 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,36 @@ jobs:
run: |
GNUPGHOME=$HOME/.gnupg PYTHONPATH=image/tools:image/src pytest tests

# buildjet doesn't start the job most of the time
# pytest_arm64:
# runs-on: buildjet-2vcpu-ubuntu-2204-arm
# name: pytest arm64
# needs: pytest_amd64
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# persist-credentials: false
#
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install -r tests/requirements.txt
#
# gpg --recv-keys C874011F0AB405110D02105534365D9472D7468F \
# && echo "C874011F0AB405110D02105534365D9472D7468F:6:" | gpg --import-ownertrust
#
# - name: Run tests
# env:
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# TERRAFORM_ACTIONS_GITHUB_TOKEN: No
# run: |
# GNUPGHOME=$HOME/.gnupg PYTHONPATH=image/tools:image/src pytest tests
pytest_arm64:
runs-on: ubuntu-24.04-arm
name: pytest arm64
needs: pytest_amd64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements.txt

gpg --recv-keys C874011F0AB405110D02105534365D9472D7468F \
&& echo "C874011F0AB405110D02105534365D9472D7468F:6:" | gpg --import-ownertrust

- name: Run tests
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TERRAFORM_ACTIONS_GITHUB_TOKEN: No
run: |
GNUPGHOME=$HOME/.gnupg PYTHONPATH=image/tools:image/src pytest tests

docs:
runs-on: ubuntu-24.04
Expand Down
4 changes: 4 additions & 0 deletions image/src/terraform_version/tfenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def parse_tfenv(terraform_version_file: str, versions: Iterable[Version]) -> Ver

return latest_version(matched)

for v in sorted(versions, reverse=True):
if str(v) == version:
return v

return Version(version)


Expand Down
Loading