41c3377b96
--- ci--- project: acdl phase: 67b milestone: v1.12 status: execute --- /ci--- The modules-lifecycle pipeline now defaults to plan-only (fast, no AWS mutation, no credentials, no cost) so it runs on every PR. A CI variable ACDL_LIFECYCLE_MODE (workflow_dispatch input 'lifecycle_mode', default 'plan') overrides to 'full' for the real apply->modify->destroy against live AWS. Scripts: run_lifecycle_test.sh / run_lifecycle_destroy.sh / run_l2_lifecycle_test.sh / run_l2_lifecycle_destroy.sh read the flag and dispatch to --plan-only (plan mode) or --apply/--destroy (full mode). Destroy is a no-op exit 0 in plan mode (nothing was applied). VPC-output injection is gated on full mode. Workflows: both .github + .gitea (byte-identical) expose lifecycle_mode as a workflow_dispatch input (choice: plan/full), pass it via env: ACDL_LIFECYCLE_MODE to every lifecycle step, skip ci-vpc-apply + ci-vpc-destroy + Read-CI-VPC-outputs in plan mode, and run the lifecycle + l2-lifecycle jobs with if: always() so they execute (plan-only) even when ci-vpc-apply is skipped. Contract + schema: pipelines/modules-lifecycle.yml gains default_mode: plan; the schema accepts default_mode (enum plan|full) and a richer workflow_dispatch inputs shape. Tests: 14 new tests in test_lifecycle_mode_flag.py (script dispatch) + 10 new tests in TestModulesLifecyclePipeline (workflow flag wiring, byte-identity, plan-mode skips). Updated test_platform_vpc_destroy to reflect the plan-mode skip. 516 tests pass; smoke-tested plan mode on the s3 module (--plan-only green, no AWS apply).
207 lines
9.4 KiB
YAML
207 lines
9.4 KiB
YAML
# ACDL Modules Lifecycle Pipeline — Gitea Actions (dev environment)
|
|
#
|
|
# Matrix-runs each L1 module's examples/{simple,complex}.yml contracts through
|
|
# apply→modify→destroy against live AWS. No per-module Python. The "test" =
|
|
# the pipeline cell going green.
|
|
#
|
|
# Also matrix-runs L2 composition modules (static-assets, microservice) through
|
|
# the same apply→modify→destroy lifecycle. L2 = composition only (no L2
|
|
# terraform files); the composition must be deterministic.
|
|
#
|
|
# This workflow implements pipelines/modules-lifecycle.yml (byte-identical
|
|
# in .gitea/workflows/ and .github/workflows/).
|
|
#
|
|
# Lifecycle mode (REQ-134, v1.12): the `lifecycle_mode` input defaults to
|
|
# "plan" — the lifecycle scripts run `run_platform.sh --plan-only` (fast,
|
|
# no AWS mutation, validates the contract->resolver->adapter->plan chain
|
|
# for every module on every PR, with no AWS credentials or cost). Set to
|
|
# "full" via workflow_dispatch (or the ACDL_LIFECYCLE_MODE repo variable)
|
|
# to run the real apply→modify→destroy against live AWS. In plan mode the
|
|
# short-lived CI VPC apply/destroy jobs are skipped (nothing is applied).
|
|
#
|
|
# A short-lived CI VPC (terraform/ci-vpc/) is created before testing VPC-dependent
|
|
# modules (alb, ecs-service, rds, uptime, and L2 microservice) and destroyed
|
|
# after all tests complete. The CI VPC is separate from the long-lived platform
|
|
# VPC. Outputs are read from the S3 state by each lifecycle job (no artifact
|
|
# passing needed).
|
|
name: acdl-modules-lifecycle
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
inputs:
|
|
lifecycle_mode:
|
|
description: "Lifecycle mode: 'plan' (default, fast, no AWS mutation) or 'full' (real apply→modify→destroy against live AWS)"
|
|
required: false
|
|
default: "plan"
|
|
type: choice
|
|
options:
|
|
- plan
|
|
- full
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
# Prerequisite: apply the short-lived CI VPC (needed by VPC-dependent L1s + L2 microservice)
|
|
# Skipped in plan mode (no resources are applied, so no VPC is needed).
|
|
ci-vpc-apply:
|
|
name: CI VPC apply
|
|
runs-on: ubuntu-latest
|
|
if: ${{ github.event.inputs.lifecycle_mode != 'plan' && vars.ACDL_LIFECYCLE_MODE != 'plan' }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install Terraform 1.9.*
|
|
run: |
|
|
wget -qO- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp.gpg
|
|
echo "deb [signed-by=/usr/share/keyrings/hashicorp.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
|
|
sudo apt-get update && sudo apt-get install -y terraform=1.9.*
|
|
- name: Apply CI VPC
|
|
working-directory: terraform/ci-vpc
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.ACDL_AWS_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.ACDL_AWS_SECRET_ACCESS_KEY }}
|
|
AWS_DEFAULT_REGION: us-east-1
|
|
run: |
|
|
terraform init -input=false -lock=false
|
|
terraform apply -auto-approve -lock=false
|
|
|
|
# L1 lifecycle matrix: apply simple → apply complex (modify) → destroy
|
|
lifecycle:
|
|
name: L1 lifecycle (${{ matrix.module }})
|
|
needs: ci-vpc-apply
|
|
if: always()
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
module: [s3, kms-key, ecr, ecs-cluster, iam-role, cloudfront, waf, vpc, alb, ecs-service, rds, uptime]
|
|
env:
|
|
ACDL_LIFECYCLE_MODE: ${{ github.event.inputs.lifecycle_mode || vars.ACDL_LIFECYCLE_MODE || 'plan' }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Free disk space
|
|
run: |
|
|
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /usr/local/share/boost
|
|
sudo apt-get clean
|
|
df -h /
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
- name: Install dependencies
|
|
run: pip install jsonschema pyyaml boto3
|
|
- name: Install Terraform 1.9.*
|
|
run: |
|
|
wget -qO- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp.gpg
|
|
echo "deb [signed-by=/usr/share/keyrings/hashicorp.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
|
|
sudo apt-get update && sudo apt-get install -y terraform=1.9.*
|
|
- name: Read CI VPC outputs
|
|
if: ${{ env.ACDL_LIFECYCLE_MODE == 'full' }}
|
|
working-directory: terraform/ci-vpc
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.ACDL_AWS_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.ACDL_AWS_SECRET_ACCESS_KEY }}
|
|
AWS_DEFAULT_REGION: us-east-1
|
|
run: |
|
|
terraform init -input=false -lock=false
|
|
terraform output -json > /tmp/ci-vpc-outputs.json
|
|
- name: Apply (simple)
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.ACDL_AWS_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.ACDL_AWS_SECRET_ACCESS_KEY }}
|
|
AWS_DEFAULT_REGION: us-east-1
|
|
run: bash scripts/run_lifecycle_test.sh ${{ matrix.module }} simple /tmp/ci-vpc-outputs.json
|
|
- name: Modify (complex)
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.ACDL_AWS_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.ACDL_AWS_SECRET_ACCESS_KEY }}
|
|
AWS_DEFAULT_REGION: us-east-1
|
|
run: bash scripts/run_lifecycle_test.sh ${{ matrix.module }} complex /tmp/ci-vpc-outputs.json
|
|
- name: Destroy
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.ACDL_AWS_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.ACDL_AWS_SECRET_ACCESS_KEY }}
|
|
AWS_DEFAULT_REGION: us-east-1
|
|
run: bash scripts/run_lifecycle_destroy.sh ${{ matrix.module }} /tmp/ci-vpc-outputs.json
|
|
|
|
# L2 lifecycle matrix: apply simple → apply complex (modify) → destroy
|
|
l2-lifecycle:
|
|
name: L2 lifecycle (${{ matrix.module }})
|
|
needs: ci-vpc-apply
|
|
if: always()
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
module: [static-assets, microservice]
|
|
env:
|
|
ACDL_LIFECYCLE_MODE: ${{ github.event.inputs.lifecycle_mode || vars.ACDL_LIFECYCLE_MODE || 'plan' }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Free disk space
|
|
run: |
|
|
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /usr/local/share/boost
|
|
sudo apt-get clean
|
|
df -h /
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
- name: Install dependencies
|
|
run: pip install jsonschema pyyaml boto3
|
|
- name: Install Terraform 1.9.*
|
|
run: |
|
|
wget -qO- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp.gpg
|
|
echo "deb [signed-by=/usr/share/keyrings/hashicorp.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
|
|
sudo apt-get update && sudo apt-get install -y terraform=1.9.*
|
|
- name: Read CI VPC outputs
|
|
if: ${{ env.ACDL_LIFECYCLE_MODE == 'full' }}
|
|
working-directory: terraform/ci-vpc
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.ACDL_AWS_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.ACDL_AWS_SECRET_ACCESS_KEY }}
|
|
AWS_DEFAULT_REGION: us-east-1
|
|
run: |
|
|
terraform init -input=false -lock=false
|
|
terraform output -json > /tmp/ci-vpc-outputs.json
|
|
- name: Apply (simple)
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.ACDL_AWS_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.ACDL_AWS_SECRET_ACCESS_KEY }}
|
|
AWS_DEFAULT_REGION: us-east-1
|
|
run: bash scripts/run_l2_lifecycle_test.sh ${{ matrix.module }} simple /tmp/ci-vpc-outputs.json
|
|
- name: Modify (complex)
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.ACDL_AWS_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.ACDL_AWS_SECRET_ACCESS_KEY }}
|
|
AWS_DEFAULT_REGION: us-east-1
|
|
run: bash scripts/run_l2_lifecycle_test.sh ${{ matrix.module }} complex /tmp/ci-vpc-outputs.json
|
|
- name: Destroy
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.ACDL_AWS_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.ACDL_AWS_SECRET_ACCESS_KEY }}
|
|
AWS_DEFAULT_REGION: us-east-1
|
|
run: bash scripts/run_l2_lifecycle_destroy.sh ${{ matrix.module }} /tmp/ci-vpc-outputs.json
|
|
|
|
# Cleanup: destroy the CI VPC (always runs in full mode, even if lifecycle fails)
|
|
ci-vpc-destroy:
|
|
name: CI VPC destroy
|
|
needs: [lifecycle, l2-lifecycle]
|
|
runs-on: ubuntu-latest
|
|
if: ${{ always() && github.event.inputs.lifecycle_mode != 'plan' && vars.ACDL_LIFECYCLE_MODE != 'plan' }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install Terraform 1.9.*
|
|
run: |
|
|
wget -qO- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp.gpg
|
|
echo "deb [signed-by=/usr/share/keyrings/hashicorp.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
|
|
sudo apt-get update && sudo apt-get install -y terraform=1.9.*
|
|
- name: Destroy CI VPC
|
|
working-directory: terraform/ci-vpc
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.ACDL_AWS_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.ACDL_AWS_SECRET_ACCESS_KEY }}
|
|
AWS_DEFAULT_REGION: us-east-1
|
|
run: |
|
|
terraform init -input=false -lock=false
|
|
terraform destroy -auto-approve -lock=false |