Skip to content

Commit

Permalink
Use matrix include.
Browse files Browse the repository at this point in the history
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..
  • Loading branch information
hmlanigan committed Dec 6, 2023
1 parent ec94489 commit 4fdf3e4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 232 deletions.
120 changes: 16 additions & 104 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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<<EOF" >> $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<<EOF" >> $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: |
Expand Down
136 changes: 16 additions & 120 deletions .github/workflows/test_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<<EOF" >> $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<<EOF" >> $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: |
Expand Down
26 changes: 18 additions & 8 deletions .github/workflows/test_new_candidates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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' }}
Expand Down

0 comments on commit 4fdf3e4

Please sign in to comment.