Skip to content

Azure integration test #62

Azure integration test

Azure integration test #62

name: Azure integration test
on:
workflow_dispatch:
schedule:
- cron: "0 22 * * 0" # every sunday at 10pm
pull_request:
branches:
- "main"
paths:
- "acme_dns_azure/**"
- "!acme_dns_azure/___init___.py"
- "tests/integration/**"
- ".github/workflows/integration_test.yml"
workflow_call:
concurrency:
group: "integration-test"
cancel-in-progress: false
defaults:
run:
working-directory: ./tests/integration
jobs:
integration_test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
run: [1, 2]
environment:
name: cicd
steps:
- name: Install and configure Poetry
uses: snok/install-poetry@v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
working-directory: ./
run: |
poetry install --all-extras
- name: Install Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_wrapper: false
- name: Azure login
uses: azure/login@v1
with:
creds: "${{ secrets.AZURE_CREDENTIALS }}"
- name: Terraform Init
run: terraform -chdir="infra" init
- name: Terraform Apply
run: |
echo "${{ vars.TFVARS }}" | base64 --decode | jq > "infra/tfvars.json"
terraform -chdir="infra" apply -auto-approve -var="resource_group_name=ci-${{ github.run_id }}${{ matrix.run }}-acme" -var="key_vault_name=ci${{ github.run_id }}${{ matrix.run }}" -var-file=tfvars.json
- name: Happy path
run: |
params=$(terraform -chdir="infra" output -json | jq -r .integration_test_params.value)
source ./../../.venv/bin/activate
pytest happy_path.py $params --resource-prefix ci-${{ github.run_number }}${{ matrix.run }} --log-cli-level='WARNING' --log-file='happy.log' --log-file-level='INFO'
- uses: actions/upload-artifact@v4
with:
name: ci-${{ github.run_number }}${{ matrix.run }}-happy.log
path: |
./tests/integration/happy.log
- name: Unhappy path
run: |
params=$(terraform -chdir="infra" output -json | jq -r .integration_test_params.value)
source ./../../.venv/bin/activate
pytest unhappy_path.py $params --resource-prefix ci-${{ github.run_number }}${{ matrix.run }} --log-cli-level='WARNING' --log-file='unhappy.log' --log-file-level='INFO'
- uses: actions/upload-artifact@v4
with:
name: ci-${{ matrix.run }}${{ github.run_number }}-unhappy.log
path: |
./tests/integration/unhappy.log
- name: Terraform Destroy
if: always()
run: terraform -chdir="infra" destroy -auto-approve -var="resource_group_name=ci-${{ github.run_id }}${{ matrix.run }}-acme" -var="key_vault_name=ci${{ github.run_id }}${{ matrix.run }}" -var-file=tfvars.json