Skip to content

chore(deps): update all non-major dependencies #157

chore(deps): update all non-major dependencies

chore(deps): update all non-major dependencies #157

# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
name: Terraform module tests
on:
pull_request:
permissions:
contents: read
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
terraform: ${{ steps.filter.outputs.terraform }}
steps:
- uses: actions/checkout@v6.0.2
- uses: dorny/paths-filter@v4
id: filter
with:
filters: |
terraform:
- "**/terraform/**"
validate:
needs: detect-changes
if: needs.detect-changes.outputs.terraform == 'true'
name: Validate terraform configuration files
runs-on: ubuntu-latest
env:
WORKING_DIR: "terraform/charm"
steps:
- name: Check out code
uses: actions/checkout@v6.0.2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v4.0.0
- name: Run terraform fmt
run: terraform fmt -check -recursive
working-directory: ${{env.WORKING_DIR}}
- name: Setup Tflint
uses: terraform-linters/setup-tflint@v6.2.2
with:
tflint_wrapper_enabled: true
- name: Run tflint
run: |
tflint --version
tflint --init
tflint -f compact --recursive
working-directory: ${{env.WORKING_DIR}}
terraform-lint-status-check:
runs-on: ubuntu-latest
needs: [detect-changes, validate]
if: always()
steps:
- name: Check terraform lint results
run: |
# If linting was skipped because no changes, that's success
if [ "${{ needs.detect-changes.outputs.terraform }}" != "true" ]; then
echo "No terraform changes detected, skipping lint is expected"
exit 0
fi
# If lint ran, check its results
validate_result="${{ needs.validate.result }}"
echo "Terraform lint result: $validate_result"
# Fail if lint that ran actually failed (not skipped)
if [ "$validate_result" = "failure" ]; then
echo "Terraform lint failed"
exit 1
fi
echo "Terraform lint passed or was skipped appropriately"
exit 0
test-terraform:
needs: detect-changes
if: needs.detect-changes.outputs.terraform == 'true'
name: Test Terraform with Juju
runs-on: self-hosted-linux-amd64-noble-edge
env:
WORKING_DIR: "terraform/charm/tests"
steps:
- uses: actions/checkout@v6.0.2
- uses: charmed-kubernetes/actions-operator@main
with:
provider: "microk8s"
channel: 1.34-strict/stable
juju-channel: 3.6/stable
- name: Prepare juju tf provider environment
run: |
set -e
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"
- run: juju add-model test-deploy-image-builder
- uses: hashicorp/setup-terraform@v4.0.0
- run: terraform init
working-directory: ${{env.WORKING_DIR}}
- run: terraform validate
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: terraform test
working-directory: ${{env.WORKING_DIR}}
terraform-status-check:
runs-on: ubuntu-latest
needs: [detect-changes, test-terraform]
if: always()
steps:
- name: Check terraform test results
run: |
# If tests were skipped because no changes, that's success
if [ "${{ needs.detect-changes.outputs.terraform }}" != "true" ]; then
echo "No terraform changes detected, skipping tests is expected"
exit 0
fi
# If tests ran, check their results
test_result="${{ needs.test-terraform.result }}"
echo "Terraform test result: $test_result"
# Fail if test that ran actually failed (not skipped)
if [ "$test_result" = "failure" ]; then
echo "Terraform tests failed"
exit 1
fi
echo "Terraform tests passed or were skipped appropriately"
exit 0