Skip to content

Commit

Permalink
Add terraform provider for juju smoke workflow.
Browse files Browse the repository at this point in the history
Ensure that we test apiserver changes for 2.9 and 3.x against the
lastest terraform provider for juju release.
  • Loading branch information
hmlanigan committed Jan 17, 2024
1 parent 5741ba3 commit 56fd117
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/terraform-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: "Terraform Smoke"
on:
push:
branches: [2.9, 3.1, 3.2, 3.3]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'apiserver/**.go'
- 'go.mod'
- '.github/workflows/terraform-tests.yml'
branches-ignore:
- 'main'

workflow_dispatch:

permissions:
contents: read

jobs:

smoke:
name: Terraform Smoke
runs-on: [self-hosted, linux, x64, aws, xlarge]
if: github.event.pull_request.draft == false
steps:

- name: Install Dependencies
shell: bash
run: |
set -euxo pipefail
echo "/snap/bin" >> $GITHUB_PATH
sudo DEBIAN_FRONTEND=noninteractive apt install -y expect
- name: Checkout juju
uses: actions/checkout@v3

- name: Setup LXD
uses: canonical/setup-lxd@4e959f8e0d9c5feb27d44c5e4d9a330a782edee0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true

- name: setup env
shell: bash
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Install local Juju
shell: bash
run: |
make go-install
- name: Bootstrap Juju - localhost
shell: bash
run: |
set -euxo pipefail
juju bootstrap localhost c \
--constraints "arch=$(go env GOARCH)"
juju version
- name: Checkout terraform provider for juju latest release
uses: actions/checkout@v3
with:
repository: 'github.com/juju/terraform-provider-juju'
ref: ''
#path: terraform-provider-juju
fetch-depth: 0
run: |
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $LATEST_TAG
- name: Set environment to configure provider for test
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
- name: Run terraform provider for juju ACC tests
shell: bash
env:
TF_ACC: "1"
TEST_CLOUD: lxd
run: |
go mod download
go test -timeout 40m -v -cover ./internal/provider/

0 comments on commit 56fd117

Please sign in to comment.