Skip to content

Commit 79af378

Browse files
authored
Merge pull request #375 from dflook/arm
Reenable tests for ARM
2 parents ae04bd7 + 9f93f1e commit 79af378

File tree

4 files changed

+125
-96
lines changed

4 files changed

+125
-96
lines changed

.github/workflows/test-plan.yaml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,25 +1059,25 @@ jobs:
10591059
path: tests/workflows/test-plan/plan
10601060
label: test-plan test_plan_1_4
10611061

1062-
# arm64:
1063-
# runs-on: buildjet-2vcpu-ubuntu-2204-arm
1064-
# name: Test on arm64
1065-
# permissions:
1066-
# contents: read
1067-
# pull-requests: write
1068-
# env:
1069-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1070-
# steps:
1071-
# - name: Checkout
1072-
# uses: actions/checkout@v4
1073-
# with:
1074-
# persist-credentials: false
1075-
#
1076-
# - name: Plan
1077-
# uses: ./terraform-plan
1078-
# with:
1079-
# path: tests/workflows/test-plan/plan
1080-
# label: arm64
1062+
arm64:
1063+
runs-on: ubuntu-24.04-arm
1064+
name: Test on arm64
1065+
permissions:
1066+
contents: read
1067+
pull-requests: write
1068+
env:
1069+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1070+
steps:
1071+
- name: Checkout
1072+
uses: actions/checkout@v4
1073+
with:
1074+
persist-credentials: false
1075+
1076+
- name: Plan
1077+
uses: ./terraform-plan
1078+
with:
1079+
path: tests/workflows/test-plan/plan
1080+
label: arm64
10811081

10821082
always_new:
10831083
runs-on: ubuntu-24.04

.github/workflows/test-version.yaml

Lines changed: 72 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -721,57 +721,78 @@ jobs:
721721
exit 1
722722
fi
723723
724-
# arm64:
725-
# runs-on: buildjet-2vcpu-ubuntu-2204-arm
726-
# name: Version detection on arm
727-
# steps:
728-
# - name: Checkout
729-
# uses: actions/checkout@v4
730-
# with:
731-
# persist-credentials: false
732-
#
733-
# - name: Version unsupported on arm
734-
# uses: ./terraform-version
735-
# continue-on-error: true
736-
# id: arm-unsupported
737-
# env:
738-
# TERRAFORM_VERSION: 0.12.0
739-
# with:
740-
# path: tests/workflows/test-version/empty
741-
#
742-
# - name: Check failed to download unsupported platform
743-
# run: |
744-
# if [[ "${{ steps.arm-unsupported.outcome }}" != "failure" ]]; then
745-
# echo "Did not fail correctly"
746-
# exit 1
747-
# fi
748-
#
749-
# - name: Version doesn't exist
750-
# uses: ./terraform-version
751-
# continue-on-error: true
752-
# id: no-such-version
753-
# with:
754-
# path: tests/workflows/test-version/nosuchversion
755-
#
756-
# - name: Check failed to download no such version
757-
# run: |
758-
# if [[ "${{ steps.no-such-version.outcome }}" != "failure" ]]; then
759-
# echo "Did not fail correctly"
760-
# exit 1
761-
# fi
762-
#
763-
# - name: Test terraform-version
764-
# uses: ./terraform-version
765-
# id: terraform-version
766-
# with:
767-
# path: tests/workflows/test-version/tfswitch
768-
#
769-
# - name: Check the version
770-
# run: |
771-
# if [[ "$DETECTED_TERRAFORM_VERSION" != "1.1.0" ]]; then
772-
# echo "::error:: Terraform version not set from .tfswitchrc"
773-
# exit 1
774-
# fi
724+
arm64:
725+
runs-on: ubuntu-24.04-arm
726+
name: Version detection on arm
727+
steps:
728+
- name: Checkout
729+
uses: actions/checkout@v4
730+
with:
731+
persist-credentials: false
732+
733+
- name: Version unsupported on arm
734+
uses: ./terraform-version
735+
continue-on-error: true
736+
id: arm-unsupported
737+
env:
738+
TERRAFORM_VERSION: 0.12.0
739+
with:
740+
path: tests/workflows/test-version/empty
741+
742+
- name: Check failed to download unsupported platform
743+
env:
744+
OUTCOME: ${{ steps.arm-unsupported.outcome }}
745+
run: |
746+
if [[ "$OUTCOME" != "failure" ]]; then
747+
echo "Did not fail correctly"
748+
exit 1
749+
fi
750+
751+
- name: Version doesn't exist
752+
uses: ./terraform-version
753+
continue-on-error: true
754+
id: no-such-version
755+
with:
756+
path: tests/workflows/test-version/nosuchversion
757+
758+
- name: Check failed to download no such version
759+
env:
760+
OUTCOME: ${{ steps.no-such-version.outcome }}
761+
run: |
762+
if [[ "$OUTCOME" != "failure" ]]; then
763+
echo "Did not fail correctly"
764+
exit 1
765+
fi
766+
767+
- name: Test terraform-version
768+
uses: ./terraform-version
769+
id: terraform-version
770+
with:
771+
path: tests/workflows/test-version/tfswitch
772+
773+
- name: Check the version
774+
env:
775+
DETECTED_TERRAFORM_VERSION: ${{ steps.terraform-version.outputs.terraform }}
776+
run: |
777+
if [[ "$DETECTED_TERRAFORM_VERSION" != "1.1.0" ]]; then
778+
echo "::error:: Terraform version not set from .tfswitchrc"
779+
exit 1
780+
fi
781+
782+
- name: Test tofu-version
783+
uses: ./tofu-version
784+
id: tofu-version
785+
with:
786+
path: tests/workflows/test-version/tofuenv
787+
788+
- name: Check the version
789+
env:
790+
DETECTED_TOFU_VERSION: ${{ steps.tofu-version.outputs.tofu }}
791+
run: |
792+
if [[ "$DETECTED_TOFU_VERSION" != "1.8.5" ]]; then
793+
echo "::error:: Terraform version not set from .tfswitchrc"
794+
exit 1
795+
fi
775796
776797
terraform_opentofu_version:
777798
runs-on: ubuntu-24.04

.github/workflows/test.yaml

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,36 @@ jobs:
3737
run: |
3838
GNUPGHOME=$HOME/.gnupg PYTHONPATH=image/tools:image/src pytest tests
3939
40-
# buildjet doesn't start the job most of the time
41-
# pytest_arm64:
42-
# runs-on: buildjet-2vcpu-ubuntu-2204-arm
43-
# name: pytest arm64
44-
# needs: pytest_amd64
45-
# steps:
46-
# - name: Checkout
47-
# uses: actions/checkout@v4
48-
# with:
49-
# persist-credentials: false
50-
#
51-
# - name: Install dependencies
52-
# run: |
53-
# python -m pip install --upgrade pip
54-
# pip install -r tests/requirements.txt
55-
#
56-
# gpg --recv-keys C874011F0AB405110D02105534365D9472D7468F \
57-
# && echo "C874011F0AB405110D02105534365D9472D7468F:6:" | gpg --import-ownertrust
58-
#
59-
# - name: Run tests
60-
# env:
61-
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
62-
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
63-
# TERRAFORM_ACTIONS_GITHUB_TOKEN: No
64-
# run: |
65-
# GNUPGHOME=$HOME/.gnupg PYTHONPATH=image/tools:image/src pytest tests
40+
pytest_arm64:
41+
runs-on: ubuntu-24.04-arm
42+
name: pytest arm64
43+
needs: pytest_amd64
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v4
47+
with:
48+
persist-credentials: false
49+
50+
- name: Set up Python
51+
uses: actions/setup-python@v4
52+
with:
53+
python-version: 3.9
54+
55+
- name: Install dependencies
56+
run: |
57+
python -m pip install --upgrade pip
58+
pip install -r tests/requirements.txt
59+
60+
gpg --recv-keys C874011F0AB405110D02105534365D9472D7468F \
61+
&& echo "C874011F0AB405110D02105534365D9472D7468F:6:" | gpg --import-ownertrust
62+
63+
- name: Run tests
64+
env:
65+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
66+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
67+
TERRAFORM_ACTIONS_GITHUB_TOKEN: No
68+
run: |
69+
GNUPGHOME=$HOME/.gnupg PYTHONPATH=image/tools:image/src pytest tests
6670
6771
docs:
6872
runs-on: ubuntu-24.04

image/src/terraform_version/tfenv.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ def parse_tfenv(terraform_version_file: str, versions: Iterable[Version]) -> Ver
3535

3636
return latest_version(matched)
3737

38+
for v in sorted(versions, reverse=True):
39+
if str(v) == version:
40+
return v
41+
3842
return Version(version)
3943

4044

0 commit comments

Comments
 (0)