chore(deps): bump aws-sdk-waf and train-aws #26
Workflow file for this run
This file contains 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 AWS Spec Tests | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
workflow_call: | |
inputs: | |
test_type: | |
description: 'Type of test: terraform or cloudformation' | |
required: true | |
type: 'string' | |
code_sha: | |
description: 'SHA of the terraform or cloudformation code to checkout' | |
required: true | |
type: 'string' | |
secrets: | |
OBSERVE_CUSTOMER: | |
required: true | |
OBSERVE_TOKEN: | |
required: true | |
OBSERVE_DOMAIN: | |
required: false | |
AWS_ACCESS_KEY_ID: | |
required: true | |
AWS_SECRET_ACCESS_KEY: | |
required: true | |
AWS_SESSION_TOKEN: | |
required: false | |
AWS_REGION: | |
required: false | |
env: | |
USER: gha-${{ github.run_id }} | |
AWS_TEST_KITCHEN_REPO: aws-test-kitchen | |
jobs: | |
permission_check: | |
runs-on: ubuntu-latest | |
outputs: | |
can-write: ${{ steps.check.outputs.can-write }} | |
env: | |
OBSERVE_CUSTOMER: ${{ secrets.OBSERVE_CUSTOMER }} | |
steps: | |
- id: check | |
run: | | |
# If the OBSERVE_CUSTOMER secret is MIA we can't run tests | |
if [[ -z "$OBSERVE_CUSTOMER" ]]; then | |
echo "can-write=false" >> $GITHUB_OUTPUT | |
else | |
echo "can-write=true" >> $GITHUB_OUTPUT | |
fi | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
image_name: ${{ steps.set_output_image_name.outputs.image_name }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ github.repository_owner }}/${{ env.AWS_TEST_KITCHEN_REPO }} | |
submodules: true | |
- name: Login to GitHub Container Registry | |
if: ${{ inputs.test_type == '' }} | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
if: ${{ inputs.test_type == '' }} | |
uses: docker/setup-buildx-action@v2 | |
- name: Metadata for Docker Image | |
id: docker_metadata | |
uses: docker/metadata-action@v4 | |
with: | |
images: ghcr.io/${{ github.repository_owner }}/${{ env.AWS_TEST_KITCHEN_REPO }} | |
tags: | | |
type=sha | |
type=ref,event=branch,priority=1001 | |
type=raw,value=latest,enable={{is_default_branch}} | |
- name: Set IMAGE_NAME environment variable | |
id: set_output_image_name | |
run: | | |
if [[ "${{ inputs.test_type }}" != "" ]]; then | |
IMAGE_NAME="ghcr.io/${{ github.repository_owner }}/${{ env.AWS_TEST_KITCHEN_REPO }}:main" | |
else | |
IMAGE_NAME=$(echo "${DOCKER_METADATA_OUTPUT_TAGS}" | head -n 1) | |
fi | |
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV | |
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_OUTPUT | |
- name: Build docker image | |
if: ${{ inputs.test_type == '' }} | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
load: false | |
push: false | |
tags: ${{ steps.docker_metadata.outputs.tags }} | |
labels: ${{ steps.docker_metadata.outputs.labels }} | |
cache-from: | | |
type=gha | |
ghcr.io/${{ github.repository_owner }}/${{ env.AWS_TEST_KITCHEN_REPO }}:latest | |
ghcr.io/${{ github.repository_owner }}/${{ env.AWS_TEST_KITCHEN_REPO }}:main | |
ghcr.io/${{ github.repository_owner }}/${{ env.AWS_TEST_KITCHEN_REPO }}:${{ github.ref_name }} | |
cache-to: type=gha,mode=max | |
determine-provider: | |
runs-on: ubuntu-latest | |
outputs: | |
providers: ${{steps.set-providers.outputs.providers}} | |
steps: | |
- id: set-providers | |
run: | | |
if [[ "${{ github.event_name }}" == "pull_request" || "${{ github.event_name }}" == "push" ]]; then | |
echo "providers=[\"cloudformation\", \"terraform\"]" >> $GITHUB_ENV | |
echo "providers=[\"cloudformation\", \"terraform\"]" >> $GITHUB_OUTPUT | |
else | |
echo "providers=[\"${{ github.event.inputs.test_type }}\"]" >> $GITHUB_ENV | |
echo "providers=[\"${{ github.event.inputs.test_type }}\"]" >> $GITHUB_OUTPUT | |
fi | |
test: | |
runs-on: ubuntu-latest | |
needs: [permission_check, build, determine-provider] | |
if: needs.permission_check.outputs.can-write == 'true' | |
name: test ${{ matrix.provider }} | |
env: | |
OBSERVE_CUSTOMER: ${{ secrets.OBSERVE_CUSTOMER }} | |
OBSERVE_TOKEN: ${{ secrets.OBSERVE_TOKEN }} | |
OBSERVE_DOMAIN: ${{ secrets.OBSERVE_DOMAIN }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
IMAGE_NAME: ${{ needs.build.outputs.image_name }} | |
strategy: | |
matrix: | |
provider: ${{fromJson(needs.determine-provider.outputs.providers)}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ github.repository_owner }}/${{ env.AWS_TEST_KITCHEN_REPO }} | |
submodules: true | |
- name: Checkout Terraform SHA | |
if: matrix.provider == 'terraform' && github.event.inputs.terraform_sha != '' | |
run: | | |
cd terraform-aws-collection | |
git checkout ${{ github.event.inputs.terraform_sha }} | |
- name: Checkout CloudFormation SHA | |
if: matrix.provider == 'cloudformation' && github.event.inputs.cloudformation_sha != '' | |
run: | | |
cd cloudformation-aws-collection | |
git checkout ${{ github.event.inputs.cloudformation_sha }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Metadata for Docker Image | |
id: docker_metadata | |
if: ${{ inputs.test_type == '' }} | |
uses: docker/metadata-action@v4 | |
with: | |
images: ghcr.io/${{ github.repository_owner }}/${{ env.AWS_TEST_KITCHEN_REPO }} | |
tags: | | |
type=sha | |
type=ref,event=branch,priority=1001 | |
type=raw,value=latest,enable={{is_default_branch}} | |
- name: Build docker image (from cache) | |
if: ${{ inputs.test_type == '' }} | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
load: true | |
push: false | |
tags: ${{ steps.docker_metadata.outputs.tags }} | |
labels: ${{ steps.docker_metadata.outputs.labels }} | |
cache-from: | | |
type=gha | |
ghcr.io/${{ github.repository_owner }}/${{ env.AWS_TEST_KITCHEN_REPO }}:latest | |
ghcr.io/${{ github.repository_owner }}/${{ env.AWS_TEST_KITCHEN_REPO }}:main | |
ghcr.io/${{ github.repository_owner }}/${{ env.AWS_TEST_KITCHEN_REPO }}:${{ github.ref_name }} | |
cache-to: type=gha,mode=max | |
- name: Pull Docker image | |
if: ${{ inputs.test_type != '' }} | |
run: docker pull $IMAGE_NAME | |
- name: Check AWS Quota | |
run: | | |
attempts=0 | |
until make check_aws_quota; do | |
if [ $attempts -ge 10 ]; then | |
echo "Exceeded maximum retries for quota check." | |
exit 1 | |
fi | |
echo "Failed to meet quota. Retrying in 2 minutes..." | |
sleep 120 | |
attempts=$((attempts + 1)) | |
done | |
- name: Setup Infra and Run spec tests | |
run: make docker/test | |
env: | |
PROVIDER: ${{ matrix.provider }} | |
- name: Teardown test infrastructure | |
if: always() | |
continue-on-error: true | |
run: make docker/clean | |
env: | |
PROVIDER: ${{ matrix.provider }} | |
push: | |
runs-on: ubuntu-latest | |
needs: [permission_check, build, test] | |
if: ${{ inputs.test_type == '' }} && needs.permission_check.outputs.can-write == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ github.repository_owner }}/${{ env.AWS_TEST_KITCHEN_REPO }} | |
submodules: true | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Metadata for Docker Image | |
id: docker_metadata | |
uses: docker/metadata-action@v4 | |
with: | |
images: ghcr.io/${{ github.repository_owner }}/${{ env.AWS_TEST_KITCHEN_REPO }} | |
tags: | | |
type=sha | |
type=ref,event=branch,priority=1001 | |
type=raw,value=latest,enable={{is_default_branch}} | |
- name: Push Docker images | |
if: success() | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.docker_metadata.outputs.tags }} | |
labels: ${{ steps.docker_metadata.outputs.labels }} | |
cache-from: | | |
type=gha | |
ghcr.io/${{ github.repository_owner }}/${{ env.AWS_TEST_KITCHEN_REPO }}:latest | |
ghcr.io/${{ github.repository_owner }}/${{ env.AWS_TEST_KITCHEN_REPO }}:main | |
ghcr.io/${{ github.repository_owner }}/${{ env.AWS_TEST_KITCHEN_REPO }}:${{ github.ref_name }} | |
cache-to: type=gha,mode=max |