Add the stable/squid-jammy branch #50
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2025 Canonical Ltd. | |
# See LICENSE file for licensing details. | |
name: Plan Terraform tests | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
plan-terraform: | |
name: Plan Terraform with Juju | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
test: | |
- name: default | |
yaml: ../tests/terraform/default.yaml | |
env: | |
TF_VAR_model: test | |
TF_VAR_manifest_yaml: ${{ matrix.test.yaml }} | |
WORKING_DIR: 'terraform' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- uses: charmed-kubernetes/actions-operator@main | |
with: | |
provider: lxd | |
channel: latest/stable | |
- name: Prepare juju tf provider environment | |
run: | | |
CONTROLLER=$(juju whoami | yq .Controller) | |
JUJU_CONTROLLER_ADDRESSES="$(juju show-controller | yq '.[$CONTROLLER]'.details.\"api-endpoints\" | tr -d "[]' "|tr -d '"'|tr -d '\n')" | |
JUJU_USERNAME="$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.user|tr -d '"')" | |
JUJU_PASSWORD="$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.password|tr -d '"')" | |
echo "JUJU_CONTROLLER_ADDRESSES=$JUJU_CONTROLLER_ADDRESSES" >> "$GITHUB_ENV" | |
echo "JUJU_USERNAME=$JUJU_USERNAME" >> "$GITHUB_ENV" | |
echo "JUJU_PASSWORD=$JUJU_PASSWORD" >> "$GITHUB_ENV" | |
{ | |
echo 'JUJU_CA_CERT<<EOF' | |
juju show-controller $(echo $CONTROLLER|tr -d '"') | yq '.[$CONTROLLER]'.details.\"ca-cert\"|tr -d '"' | |
echo EOF | |
} >> "$GITHUB_ENV" | |
- uses: hashicorp/setup-terraform@v3 | |
- run: terraform init | |
working-directory: ${{env.WORKING_DIR}} | |
- run: terraform plan -out=tfplan | |
working-directory: ${{env.WORKING_DIR}} | |
- run: terraform show tfplan | |
working-directory: ${{env.WORKING_DIR}} | |
- run: | | |
juju add-model test | |
set -e # Exit on error | |
# Apply Terraform changes | |
terraform apply -auto-approve || { echo "Terraform apply failed"; exit 1; } | |
# Wait for Juju applications to become active | |
MAX_RETRIES=30 | |
for i in $(seq 1 $MAX_RETRIES); do | |
echo "Checking Juju application statuses... Attempt $i/$MAX_RETRIES" | |
# Fetch status JSON once and store it | |
STATUS_JSON=$(juju status --format=json) | |
# Check if all applications are active | |
if echo "$STATUS_JSON" | jq -e '.applications | all(.["application-status"].current == "active")' > /dev/null; then | |
echo "✅ All applications are active" | |
exit 0 | |
fi | |
echo "⏳ Waiting for applications to become active..." | |
sleep 10 | |
done | |
echo "❌ Timeout waiting for applications to become active" | |
exit 1 | |
working-directory: ${{env.WORKING_DIR}} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{matrix.test.name}}-terraform-plan | |
path: ${{env.WORKING_DIR}}/tfplan |