From 4fdf3e4b8177b39f10e682abcc8b7325d00a5897 Mon Sep 17 00:00:00 2001 From: Heather Lanigan Date: Wed, 6 Dec 2023 09:21:51 -0500 Subject: [PATCH] Use matrix include. This solves the problem in the matrix where the channel is only necessary for microk8s clouds and not lxd. It also allows for 1 test configuration rather than many.. --- .github/workflows/canary.yml | 120 +++---------------- .github/workflows/test_integration.yml | 136 +++------------------- .github/workflows/test_new_candidates.yml | 26 +++-- 3 files changed, 50 insertions(+), 232 deletions(-) diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml index 75116b62..a5aac295 100644 --- a/.github/workflows/canary.yml +++ b/.github/workflows/canary.yml @@ -25,7 +25,7 @@ jobs: - run: go build -v . # Run acceptance tests in a matrix with Terraform CLI versions - test29: + test: name: Terraform Provider Acceptance Tests needs: - build @@ -34,13 +34,21 @@ jobs: strategy: fail-fast: false matrix: - cloud: - - "lxd" - - "microk8s" terraform: - "1.6.*" - juju: - - "2.9/stable" + include: + - cloud: "lxd" + cloud-channel: "5.19/stable" + juju-channel: "2.9/stable" + - cloud: "microk8s" + cloud-channel: "1.28/stable" + juju-channel: "2.9/stable" + - cloud: "lxd" + cloud-channel: "5.19/stable" + juju-channel: "3.1/stable" + - cloud: "microk8s" + cloud-channel: "1.28-strict/stable" + juju-channel: "3.1/stable" steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v4 @@ -55,104 +63,8 @@ jobs: uses: charmed-kubernetes/actions-operator@main with: provider: ${{ matrix.cloud }} - juju-channel: ${{ matrix.juju }} - - name: "Set environment to configure provider" - # language=bash - run: | - CONTROLLER=$(juju whoami --format yaml | yq .controller) - - echo "JUJU_CONTROLLER_ADDRESSES=$(juju show-controller | yq .$CONTROLLER.details.api-endpoints | yq -r '. | join(",")')" >> $GITHUB_ENV - echo "JUJU_USERNAME=$(juju show-controller | yq .$CONTROLLER.account.user)" >> $GITHUB_ENV - echo "JUJU_PASSWORD=$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.password)" >> $GITHUB_ENV - echo "JUJU_CA_CERT<> $GITHUB_ENV - juju show-controller | yq .$CONTROLLER.details.ca-cert >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - - env: - TF_ACC: "1" - TEST_CLOUD: ${{ matrix.cloud }} - run: go test -timeout 40m -v -cover ./internal/provider/ - - # test-31-microk8s is different from test-31-lxd as the - # charmed-kubernetes/actions-operator does not have the ability - # to specify a microk8s specific channel. Channel is generic - # and the operator tried to use for lxd, which fails. Bug filed. - test-31-microk8s: - name: Terraform Provider Acceptance Tests - needs: - - build - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - cloud: - - "microk8s" - terraform: - - "1.6.*" - juju: - - "3.1/stable" - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 - with: - go-version-file: "go.mod" - cache: true - - uses: hashicorp/setup-terraform@v3 - with: - terraform_version: ${{ matrix.terraform }} - terraform_wrapper: false - - name: Setup operator environment - uses: charmed-kubernetes/actions-operator@main - with: - provider: ${{ matrix.cloud }} - juju-channel: ${{ matrix.juju }} - channel: "1.28-strict/stable" - - name: "Set environment to configure provider" - # language=bash - run: | - CONTROLLER=$(juju whoami --format yaml | yq .controller) - - echo "JUJU_CONTROLLER_ADDRESSES=$(juju show-controller | yq .$CONTROLLER.details.api-endpoints | yq -r '. | join(",")')" >> $GITHUB_ENV - echo "JUJU_USERNAME=$(juju show-controller | yq .$CONTROLLER.account.user)" >> $GITHUB_ENV - echo "JUJU_PASSWORD=$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.password)" >> $GITHUB_ENV - echo "JUJU_CA_CERT<> $GITHUB_ENV - juju show-controller | yq .$CONTROLLER.details.ca-cert >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - - env: - TF_ACC: "1" - TEST_CLOUD: ${{ matrix.cloud }} - run: go test -timeout 40m -v -cover ./internal/provider/ - - test-31-lxd: - name: Terraform Provider Acceptance Tests - needs: - - build - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - cloud: - - "lxd" - terraform: - - "1.6.*" - juju: - - "3.1/stable" - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 - with: - go-version-file: "go.mod" - cache: true - - uses: hashicorp/setup-terraform@v3 - with: - terraform_version: ${{ matrix.terraform }} - terraform_wrapper: false - - name: Setup operator environment - uses: charmed-kubernetes/actions-operator@main - with: - provider: ${{ matrix.cloud }} - juju-channel: ${{ matrix.juju }} + channel: ${{ matrix.cloud-channel }} + juju-channel: ${{ matrix.juju-channel }} - name: "Set environment to configure provider" # language=bash run: | diff --git a/.github/workflows/test_integration.yml b/.github/workflows/test_integration.yml index e68bb339..4276ef23 100644 --- a/.github/workflows/test_integration.yml +++ b/.github/workflows/test_integration.yml @@ -38,23 +38,30 @@ jobs: # Using juju 2.9/stable which requires a classic version # of the microk8s snap. This happens to be the default snap # today. - test-29: + test: name: Integration needs: build runs-on: ubuntu-latest strategy: fail-fast: false matrix: - # Different clouds - cloud: - - "lxd" - - "microk8s" terraform: - "1.4.*" - "1.5.*" - "1.6.*" - juju: - - "2.9/stable" + include: + - cloud: "lxd" + cloud-channel: "5.19/stable" + juju-channel: "2.9/stable" + - cloud: "microk8s" + cloud-channel: "1.28/stable" + juju-channel: "2.9/stable" + - cloud: "lxd" + cloud-channel: "5.19/stable" + juju-channel: "3.1/stable" + - cloud: "microk8s" + cloud-channel: "1.28-strict/stable" + juju-channel: "3.1/stable" timeout-minutes: 60 steps: - uses: actions/checkout@v4 @@ -70,119 +77,8 @@ jobs: uses: charmed-kubernetes/actions-operator@main with: provider: ${{ matrix.cloud }} - juju-channel: ${{ matrix.juju }} - - name: "Set environment to configure provider" - # language=bash - run: | - CONTROLLER=$(juju whoami --format yaml | yq .controller) - - echo "JUJU_CONTROLLER_ADDRESSES=$(juju show-controller | yq .$CONTROLLER.details.api-endpoints | yq -r '. | join(",")')" >> $GITHUB_ENV - echo "JUJU_USERNAME=$(juju show-controller | yq .$CONTROLLER.account.user)" >> $GITHUB_ENV - echo "JUJU_PASSWORD=$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.password)" >> $GITHUB_ENV - echo "JUJU_CA_CERT<> $GITHUB_ENV - juju show-controller | yq .$CONTROLLER.details.ca-cert >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - - run: go mod download - - env: - TF_ACC: "1" - TEST_CLOUD: ${{ matrix.cloud }} - run: go test -timeout 40m -v -cover ./internal/provider/ - timeout-minutes: 40 - - # Run acceptance tests in a matrix with Terraform CLI versions - # Using juju 3.1/stable which requires a strictly confined version - # of the microk8s snap. - # - # test-31-microk8s is different from test-31-lxd as the - # charmed-kubernetes/actions-operator does not have the ability - # to specify a microk8s specific channel. Channel is generic - # and the operator tried to use for lxd, which fails. Bug filed. - test-31-microk8s: - name: Integration - needs: build - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - # Different clouds - cloud: - - "microk8s" - terraform: - - "1.4.*" - - "1.5.*" - - "1.6.*" - juju: - - "3.1/stable" - timeout-minutes: 60 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 - with: - go-version-file: "go.mod" - cache: true - - uses: hashicorp/setup-terraform@v3 - with: - terraform_version: ${{ matrix.terraform }} - terraform_wrapper: false - - name: Setup operator environment - uses: charmed-kubernetes/actions-operator@main - with: - provider: ${{ matrix.cloud }} - juju-channel: ${{ matrix.juju }} - channel: "1.28-strict/stable" - - name: "Set environment to configure provider" - # language=bash - run: | - CONTROLLER=$(juju whoami --format yaml | yq .controller) - - echo "JUJU_CONTROLLER_ADDRESSES=$(juju show-controller | yq .$CONTROLLER.details.api-endpoints | yq -r '. | join(",")')" >> $GITHUB_ENV - echo "JUJU_USERNAME=$(juju show-controller | yq .$CONTROLLER.account.user)" >> $GITHUB_ENV - echo "JUJU_PASSWORD=$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.password)" >> $GITHUB_ENV - echo "JUJU_CA_CERT<> $GITHUB_ENV - juju show-controller | yq .$CONTROLLER.details.ca-cert >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - - run: go mod download - - env: - TF_ACC: "1" - TEST_CLOUD: ${{ matrix.cloud }} - run: go test -timeout 40m -v -cover ./internal/provider/ - timeout-minutes: 40 - - # Run acceptance tests in a matrix with Terraform CLI versions - # Using juju 3.1/stable which requires a strictly confined version - # of the microk8s snap. - test-31-lxd: - name: Integration - needs: build - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - # Different clouds - cloud: - - "lxd" - terraform: - - "1.4.*" - - "1.5.*" - - "1.6.*" - juju: - - "3.1/stable" - timeout-minutes: 60 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 - with: - go-version-file: "go.mod" - cache: true - - uses: hashicorp/setup-terraform@v3 - with: - terraform_version: ${{ matrix.terraform }} - terraform_wrapper: false - - name: Setup operator environment - uses: charmed-kubernetes/actions-operator@main - with: - provider: ${{ matrix.cloud }} - juju-channel: ${{ matrix.juju }} + channel: ${{ matrix.cloud-channel }} + juju-channel: ${{ matrix.juju-channel }} - name: "Set environment to configure provider" # language=bash run: | diff --git a/.github/workflows/test_new_candidates.yml b/.github/workflows/test_new_candidates.yml index c444f70f..98cf390f 100644 --- a/.github/workflows/test_new_candidates.yml +++ b/.github/workflows/test_new_candidates.yml @@ -18,28 +18,37 @@ jobs: fail-fast: false max-parallel: 4 matrix: - juju_track: - - "2.9" - - "3.1" - juju_risk: + juju-risk: - "edge" terraform: - - "1.5.*" - "1.6.*" + include: + - cloud: "lxd" + cloud-channel: "5.19/stable" + juju-track: "2.9" + - cloud: "microk8s" + cloud-channel: "1.28/stable" + juju-track: "2.9" + - cloud: "lxd" + cloud-channel: "5.19/stable" + juju-track: "3.1" + - cloud: "microk8s" + cloud-channel: "1.28-strict/stable" + juju-track: "3.1" steps: - name: Set channel and artifact id run: | - channel=$(echo ${{ matrix.juju_track }}/${{ matrix.juju_risk }}) + channel=$(echo ${{ matrix.juju-track }}/${{ matrix.juju-risk }}) echo "Target channel is $channel" echo "channel=$channel" >> $GITHUB_ENV terraform_version=$(echo ${{ matrix.terraform }} | awk -F'\.' '{print $1$2}') - id=$(echo ${{ github.sha }}-${{ matrix.juju_track }}-${{ matrix.juju_risk }}-$terraform_version) + id=$(echo ${{ github.sha }}-${{ matrix.juju-track }}-${{ matrix.juju-risk }}-$terraform_version) echo "Target id is $id" echo "id=$id" >> $GITHUB_ENV - name: Checkout branch uses: actions/checkout@v4 with: - ref: ${{ env.juju_track }} + ref: ${{ env.juju-track }} - name: Download artifact uses: dawidd6/action-download-artifact@v2 id: download_artifact @@ -87,6 +96,7 @@ jobs: uses: charmed-kubernetes/actions-operator@main with: provider: ${{ matrix.cloud }} + channel: ${{ matrix.cloud-channel }} juju-channel: ${{ env.channel }} - name: "Set environment to configure provider" if: ${{ env.next-test != 'NA' }}