Skip to content

add kv to terraform sample of aci sample app #209

add kv to terraform sample of aci sample app

add kv to terraform sample of aci sample app #209

Workflow file for this run

name: Samples CI
# Tests Azure samples against the LocalStack emulator.
# Each test runs in its own job. Set DEFAULT_RUN_MODE to 'changed' to only run affected tests.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
run_mode:
description: "Test mode: 'all' runs every test, 'changed' runs only tests with modified files"
required: false
type: choice
options:
- all
- changed
default: changed
# Default run mode for pull_request events (change to 'changed' to only run affected tests)
env:
DEFAULT_RUN_MODE: changed
jobs:
# Lightweight job that builds the dynamic test matrix for the main test jobs
setup:
name: "Build Test Matrix"
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.build-matrix.outputs.matrix }}
has_tests: ${{ steps.build-matrix.outputs.has_tests }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history needed for git diff in "changed" mode
- name: Build dynamic matrix
id: build-matrix
run: |
# Pick run mode: manual dispatch uses the dropdown, PRs use the env default
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
RUN_MODE="${{ github.event.inputs.run_mode }}"
else
RUN_MODE="${{ env.DEFAULT_RUN_MODE }}"
fi
# In "changed" mode, determine the base commit to diff against
BASE_SHA=""
if [[ "$RUN_MODE" == "changed" ]]; then
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
else
BASE_SHA=$(git rev-parse origin/main 2>/dev/null || git rev-parse HEAD~1)
fi
fi
.github/scripts/build-matrix.sh "$RUN_MODE" "$BASE_SHA"
# Each test runs in its own job — one matrix entry per test from the setup job
scripts:
name: "Test: ${{ matrix.name }}"
needs: setup
if: needs.setup.outputs.has_tests == 'true' # Skip entirely when no tests match
environment: AZURE
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
runs-on: github-ubuntu2204-amd64-4
env:
IMAGE_NAME: localstack/localstack-azure-alpha
DEFAULT_TAG: latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up environment
run: echo "AZURE_CONFIG_DIR=${{ runner.temp }}/azure-cli" >> $GITHUB_ENV
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0'
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '25'
- name: Install System Dependencies
# Essential tools for script execution, app packaging, and database connectivity.
# jq: for parsing JSON responses from Azure CLI.
# zip: for packaging function/web apps.
# unixodbc-dev & libsnappy-dev: required for Python database drivers (pyodbc, pymongo).
run: |
sudo apt-get update
sudo apt-get install -y jq zip unixodbc-dev libsnappy-dev
find . -name "*.sh" -exec chmod +x {} +
- name: Install Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.5.0"
terraform_wrapper: false
- name: Install test dependencies
# Mirroring the localstack-pro approach: install all Python dependencies
# (including the localstack CLI) into a virtual environment to avoid system-level conflicts.
run: make install
- name: Login to Docker Hub
# Mandatory login to Docker Hub to benefit from higher rate limits for authenticated pulls.
# This prevents '429 Too Many Requests' errors during the pull of large emulator images.
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_PULL_USERNAME }}
password: ${{ secrets.DOCKERHUB_PULL_TOKEN }}
- name: Free up disk space
# Azure emulator images are large. Pruning unused Docker objects ensures enough
# disk space is available on the GitHub runner for image pulls and sidecar containers.
run: |
docker system prune -af --volumes
docker builder prune -af
- name: Pull LocalStack Azure Image
# Explicitly pull the image before starting. This mirrors the "Build Docker Image"
# step in localstack-pro and ensures the pull logic is separated from the start logic.
run: docker pull ${{ env.IMAGE_NAME }}:${{ env.DEFAULT_TAG }}
- name: Start LocalStack
# Run the emulator in detached mode using the virtual environment.
run: |
source .venv/bin/activate
python -m localstack_cli.cli.main start -d
python -m localstack_cli.cli.main wait -t 120
env:
IMAGE_NAME: ${{ env.IMAGE_NAME }}:${{ env.DEFAULT_TAG }}
LOCALSTACK_AUTH_TOKEN: ${{ secrets.TEST_LOCALSTACK_AUTH_TOKEN }}
DOCKER_FLAGS: "-e MSSQL_ACCEPT_EULA=Y"
LS_LOG: "DEBUG"
DISABLE_EVENTS: "1"
ACTIVATE_PRO: "1"
DNS_ADDRESS: "0"
- name: Install Azure Functions Core Tools
# Required for publishing function app samples to the emulator.
run: npm install -g azure-functions-core-tools@4 --unsafe-perm true
- name: Install MSSQL ODBC and Tools
# Required for the 'web-app-sql-database' sample which uses 'sqlcmd' to
# initialize and verify the database schema in the local emulator.
run: |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18
echo "/opt/mssql-tools18/bin" >> $GITHUB_PATH
- name: "Run: ${{ matrix.name }}"
# Each job runs exactly one test. SPLITS equals the total test count, and SHARD
# is the 1-based index of this specific test, so run-samples.sh executes only it.
run: make test SHARD=${{ matrix.shard }} SPLITS=${{ matrix.splits }}
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.TEST_LOCALSTACK_AUTH_TOKEN }}
- name: Get LocalStack Logs
# Captured on failure or success to provide a detailed audit trail of the emulator's activity.
if: always()
run: make logs