Run Terraform Tests on CI #5
This file contains hidden or 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
name: Run Terraform Tests on CI | |
on: | |
push: | |
paths-ignore: | |
- 'README.md' | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
schedule: | |
# “At 00:00 on Sunday.” | |
- cron: "0 0 * * 0" | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
terraform: | |
name: Deploy infrastructure using Terraform | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: "1.9.8" | |
- name: Set up Python 3.10 | |
id: setup-python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.10" | |
- name: Start LocalStack | |
env: | |
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} | |
run: | | |
pip install localstack awscli-local[ver1] | |
pip install terraform-local | |
docker pull localstack/localstack-pro | |
# Start LocalStack in the background | |
localstack start -d | |
# Wait 30 seconds for the LocalStack container to become ready before timing out | |
echo "Waiting for LocalStack startup..." | |
localstack wait -t 15 | |
echo "Startup complete" | |
- name: Run Terraform tests | |
run: | | |
tflocal init | |
tflocal test | |
- name: Check LocalStack logs | |
run: | | |
localstack logs |