-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
91f9895
commit 215b3b8
Showing
6 changed files
with
333 additions
and
53 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: MIT | ||
|
||
name: Run Integration Tests In ITAR | ||
env: | ||
PRIVATE_KEY: ${{ secrets.AWS_PRIVATE_KEY_ITAR }} | ||
TERRAFORM_AWS_ASSUME_ROLE: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE_ITAR }} | ||
TERRAFORM_AWS_ASSUME_ROLE_DURATION: 14400 # 4 hours | ||
S3_INTEGRATION_BUCKET: ${{ vars.S3_INTEGRATION_BUCKET_ITAR }} | ||
KEY_NAME: ${{ vars.KEY_NAME_ITAR }} | ||
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" | ||
|
||
on: | ||
push: | ||
branches: | ||
- main* | ||
paths-ignore: | ||
- '**/*.md' | ||
- 'NOTICE' | ||
- 'RELEASE_NOTES' | ||
- 'THIRD-PARTY' | ||
- 'LICENSE' | ||
- '.github/**' | ||
- '!.github/workflows/integration-test.yml' | ||
workflow_dispatch: | ||
inputs: | ||
plugins: | ||
description: 'Comma delimited list of plugins to test. Default is empty, and tests everything' | ||
required: false | ||
default: '' | ||
type: string | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref_name }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
BuildAndUpload: | ||
uses: ./.github/workflows/test-build.yml | ||
secrets: inherit | ||
permissions: | ||
id-token: write | ||
contents: read | ||
with: | ||
BucketKey: "integration-test/binary/${{ github.sha }}" | ||
PackageBucketKey: "integration-test/packaging/${{ github.sha }}" | ||
|
||
GenerateTestMatrix: | ||
name: 'GenerateTestMatrix' | ||
runs-on: ubuntu-latest | ||
outputs: | ||
ec2_linux_matrix: ${{ steps.set-matrix.outputs.ec2_linux_matrix }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
repository: ${{env.CWA_GITHUB_TEST_REPO_NAME}} | ||
ref: ${{env.CWA_GITHUB_TEST_REPO_BRANCH}} | ||
|
||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ~1.21.1 | ||
|
||
- name: Generate matrix | ||
id: set-matrix | ||
run: | | ||
go run --tags=generator generator/test_case_generator.go | ||
echo "::set-output name=ec2_linux_matrix::$(echo $(cat generator/resources/ec2_linux_complete_test_matrix.json))" | ||
- name: Echo test plan matrix | ||
run: | | ||
echo "ec2_linux_matrix: ${{ steps.set-matrix.outputs.ec2_linux_matrix }}" | ||
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: | ||
- uses: actions/checkout@v3 | ||
with: | ||
repository: ${{env.CWA_GITHUB_TEST_REPO_NAME}} | ||
ref: ${{env.CWA_GITHUB_TEST_REPO_BRANCH}} | ||
|
||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ~1.21.1 | ||
|
||
- name: SetOutputs | ||
id: set-outputs | ||
run: | | ||
echo "::set-output name=CWA_GITHUB_TEST_REPO_NAME::${{ env.CWA_GITHUB_TEST_REPO_NAME }}" | ||
echo "::set-output name=CWA_GITHUB_TEST_REPO_URL::${{ env.CWA_GITHUB_TEST_REPO_URL }}" | ||
echo "::set-output name=CWA_GITHUB_TEST_REPO_BRANCH::${{ env.CWA_GITHUB_TEST_REPO_BRANCH }}" | ||
- name: Echo test variables | ||
run: | | ||
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 }}" | ||
StartLocalStack: | ||
name: 'StartLocalStack' | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: terraform/ec2/localstack | ||
outputs: | ||
local_stack_host_name: ${{ steps.localstack.outputs.local_stack_host_name }} | ||
permissions: | ||
id-token: write | ||
contents: read | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
repository: ${{env.CWA_GITHUB_TEST_REPO_NAME}} | ||
ref: ${{env.CWA_GITHUB_TEST_REPO_BRANCH}} | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }} | ||
aws-region: us-west-2 | ||
role-duration-seconds: ${{ env.TERRAFORM_AWS_ASSUME_ROLE_DURATION }} | ||
|
||
- name: Verify Terraform version | ||
run: terraform --version | ||
|
||
- name: Terraform init | ||
run: terraform init | ||
|
||
- name: Terraform apply | ||
id: localstack | ||
run: > | ||
echo run terraform and execute test code && | ||
terraform apply --auto-approve | ||
-var="ssh_key_value=${PRIVATE_KEY}" | ||
-var="github_test_repo=${{env.CWA_GITHUB_TEST_REPO_URL}}" | ||
-var="github_test_repo_branch=${{env.CWA_GITHUB_TEST_REPO_BRANCH}}" | ||
-var="cwa_github_sha=${GITHUB_SHA}" | ||
-var="s3_bucket=${S3_INTEGRATION_BUCKET}" | ||
-var="ssh_key_name=${KEY_NAME}" && | ||
LOCAL_STACK_HOST_NAME=$(terraform output -raw public_dns) && | ||
echo $LOCAL_STACK_HOST_NAME && | ||
echo "::set-output name=local_stack_host_name::$LOCAL_STACK_HOST_NAME" && | ||
aws s3 cp terraform.tfstate s3://${S3_INTEGRATION_BUCKET}/integration-test/local-stack-terraform-state/${GITHUB_SHA}/terraform.tfstate | ||
EC2LinuxIntegrationTest: | ||
needs: [ BuildAndUpload, StartLocalStack, GenerateTestMatrix, OutputEnvVariables ] | ||
name: 'EC2Linux' | ||
uses: ./.github/workflows/ec2-integration-test.yml | ||
with: | ||
github_sha: ${{github.sha}} | ||
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}} | ||
secrets: inherit | ||
|
||
StopLocalStack: | ||
name: 'StopLocalStack' | ||
runs-on: ubuntu-latest | ||
if: ${{ always() }} | ||
needs: [ StartLocalStack, EC2LinuxIntegrationTest, LinuxOnPremIntegrationTest ] | ||
defaults: | ||
run: | ||
working-directory: terraform/ec2/localstack | ||
permissions: | ||
id-token: write | ||
contents: read | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
repository: ${{env.CWA_GITHUB_TEST_REPO_NAME}} | ||
ref: ${{env.CWA_GITHUB_TEST_REPO_BRANCH}} | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }} | ||
aws-region: us-west-2 | ||
role-duration-seconds: ${{ env.TERRAFORM_AWS_ASSUME_ROLE_DURATION }} | ||
|
||
- name: Copy state | ||
run: aws s3 cp s3://${S3_INTEGRATION_BUCKET}/integration-test/local-stack-terraform-state/${GITHUB_SHA}/terraform.tfstate . | ||
|
||
- name: Verify Terraform version | ||
run: terraform --version | ||
|
||
- name: Terraform init | ||
run: terraform init | ||
|
||
- name: Terraform destroy | ||
run: terraform destroy --auto-approve |
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
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
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
Oops, something went wrong.