Skip to content

Test Artifacts

Test Artifacts #156

# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT
name: Test Artifacts
env:
PRIVATE_KEY: ${{ secrets.AWS_PRIVATE_KEY }}
TERRAFORM_AWS_ASSUME_ROLE: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }}
TERRAFORM_AWS_ASSUME_ROLE_DURATION: 14400 # 4 hours
S3_INTEGRATION_BUCKET: ${{ vars.S3_INTEGRATION_BUCKET }}
KEY_NAME: ${{ secrets.KEY_NAME }}
CF_IAM_ROLE: ${{ secrets.CF_IAM_ROLE }}
CF_KEY_NAME: ${{ secrets.CF_KEY_NAME }}
ECR_INTEGRATION_TEST_REPO: "cwagent-integration-test"
CWA_GITHUB_TEST_REPO_NAME: "aws/amazon-cloudwatch-agent-test"
CWA_GITHUB_TEST_REPO_URL: "https://github.com/aws/amazon-cloudwatch-agent-test.git"
CWA_GITHUB_TEST_REPO_BRANCH: "main"
TERRAFORM_AWS_ASSUME_ROLE_ITAR: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE_ITAR }}
S3_INTEGRATION_BUCKET_ITAR: ${{ vars.S3_INTEGRATION_BUCKET_ITAR }}
TERRAFORM_AWS_ASSUME_ROLE_CN: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE_CN }}
S3_INTEGRATION_BUCKET_CN: ${{ vars.S3_INTEGRATION_BUCKET_CN }}
on:
workflow_dispatch:
inputs:
build_id:
description: 'The build ID (release candidate build number or GitHub commit SHA)'
type: string
required: true
test_repo_branch:
description: 'Override for the GitHub test repository branch to use (default is main)'
type: string
workflow_call:
inputs:
build_id:
description: 'The build ID (release candidate build number or GitHub commit SHA)'
type: string
required: true
test_repo_branch:
description: 'Override for the GitHub test repository branch to use (default is main)'
type: string
concurrency:
group: ${{ github.workflow }}-${{ inputs.build_id }}
cancel-in-progress: true
jobs:
id:
name: Workflow ID Provider
runs-on: ubuntu-latest
steps:
- name: ${{ github.event.inputs.build_id }}
run: echo run identifier ${{ inputs.build_id }}
OutputEnvVariables:
name: 'OutputEnvVariables'
runs-on: ubuntu-latest
outputs:
CWA_GITHUB_TEST_REPO_NAME: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_NAME }}
CWA_GITHUB_TEST_REPO_URL: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_URL }}
CWA_GITHUB_TEST_REPO_BRANCH: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
steps:
- name: SetOutputs
id: set-outputs
run: |
CWA_GITHUB_TEST_REPO_BRANCH=${{ inputs.test_repo_branch }}
echo "CWA_GITHUB_TEST_REPO_NAME=${{ env.CWA_GITHUB_TEST_REPO_NAME }}" >> "$GITHUB_OUTPUT"
echo "CWA_GITHUB_TEST_REPO_URL=${{ env.CWA_GITHUB_TEST_REPO_URL }}" >> "$GITHUB_OUTPUT"
echo "CWA_GITHUB_TEST_REPO_BRANCH=${CWA_GITHUB_TEST_REPO_BRANCH:-${{ env.CWA_GITHUB_TEST_REPO_BRANCH }}}" >> "$GITHUB_OUTPUT"
- name: Echo test variables
run: |
echo "build_id: ${{ inputs.build_id }}"
echo "CWA_GITHUB_TEST_REPO_NAME: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_NAME }}"
echo "CWA_GITHUB_TEST_REPO_URL: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_URL }}"
echo "CWA_GITHUB_TEST_REPO_BRANCH: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}"
- uses: actions/checkout@v3
with:
repository: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_NAME }}
ref: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: ~1.22.2
GenerateTestMatrix:
name: 'GenerateTestMatrix'
needs: [OutputEnvVariables]
runs-on: ubuntu-latest
outputs:
ec2_linux_matrix: ${{ steps.set-matrix.outputs.ec2_linux_matrix }}
steps:
- uses: actions/checkout@v3
with:
repository: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }}
ref: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: ~1.22.2
- name: Generate matrix
id: set-matrix
run: |
go run --tags=generator generator/test_case_generator.go
echo "ec2_linux_matrix=$(echo $(cat generator/resources/ec2_linux_complete_test_matrix.json))" >> "$GITHUB_OUTPUT"
- name: Echo test plan matrix
run: |
echo "ec2_linux_matrix: ${{ steps.set-matrix.outputs.ec2_linux_matrix }}"
StartLocalStack:
name: 'StartLocalStack'
needs: [OutputEnvVariables]
uses: ./.github/workflows/start-localstack.yml
secrets: inherit
permissions:
id-token: write
contents: read
with:
region: us-west-2
test_repo_name: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }}
test_repo_branch: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
terraform_assume_role: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }}
test_repo_url: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_URL }}
github_sha: ${{ inputs.build_id }}
s3_integration_bucket: ${{ vars.S3_INTEGRATION_BUCKET }}
EC2LinuxIntegrationTest:
needs: [ StartLocalStack, GenerateTestMatrix, OutputEnvVariables ]
name: 'EC2Linux'
uses: ./.github/workflows/ec2-integration-test.yml
with:
build_id: ${{ inputs.build_id }}
test_dir: terraform/ec2/linux
job_id: ec2-linux-integration-test
test_props: ${{ needs.GenerateTestMatrix.outputs.ec2_linux_matrix }}
test_repo_name: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }}
test_repo_url: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_URL }}
test_repo_branch: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
localstack_host: ${{ needs.StartLocalStack.outputs.local_stack_host_name }}
region: us-west-2
terraform_assume_role: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }}
s3_integration_bucket: ${{ vars.S3_INTEGRATION_BUCKET }}
is_selinux_test: false
secrets: inherit
StopLocalStack:
name: 'StopLocalStack'
if: ${{ always() && needs.StartLocalStack.result == 'success' }}
needs: [ StartLocalStack, EC2LinuxIntegrationTest, OutputEnvVariables ]
uses: ./.github/workflows/stop-localstack.yml
secrets: inherit
permissions:
id-token: write
contents: read
with:
region: us-west-2
test_repo_name: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }}
test_repo_branch: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
terraform_assume_role: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }}
github_sha: ${{inputs.build_id}}
s3_integration_bucket: ${{ vars.S3_INTEGRATION_BUCKET }}