From ad96cdbd8c5dab94c9fd5c5c01aabc5077b1a63f Mon Sep 17 00:00:00 2001 From: Daniel Flook Date: Thu, 13 Mar 2025 14:18:47 +0000 Subject: [PATCH 1/3] Reenable tests for arm64 --- .github/workflows/test.yaml | 56 ++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 662ff46f..47909a20 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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 From 5efb52505dc92dea07de075b4837e349a1d02793 Mon Sep 17 00:00:00 2001 From: Daniel Flook Date: Thu, 13 Mar 2025 14:26:27 +0000 Subject: [PATCH 2/3] Reenable tests for arm64 --- .github/workflows/test-plan.yaml | 38 ++++----- .github/workflows/test-version.yaml | 123 ++++++++++++++++------------ 2 files changed, 91 insertions(+), 70 deletions(-) diff --git a/.github/workflows/test-plan.yaml b/.github/workflows/test-plan.yaml index 91cc25ae..361b0e32 100644 --- a/.github/workflows/test-plan.yaml +++ b/.github/workflows/test-plan.yaml @@ -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 diff --git a/.github/workflows/test-version.yaml b/.github/workflows/test-version.yaml index c0ed1c9d..8fe1a2ae 100644 --- a/.github/workflows/test-version.yaml +++ b/.github/workflows/test-version.yaml @@ -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 From 9f93f1ea7c53f30290b28d037660c13925307062 Mon Sep 17 00:00:00 2001 From: Daniel Flook Date: Thu, 13 Mar 2025 17:03:06 +0000 Subject: [PATCH 3/3] Fix .opentofu-version Select from available versions, don't assume Terraform --- image/src/terraform_version/tfenv.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/image/src/terraform_version/tfenv.py b/image/src/terraform_version/tfenv.py index 4b2f11ef..c16771ba 100644 --- a/image/src/terraform_version/tfenv.py +++ b/image/src/terraform_version/tfenv.py @@ -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)