Test Artifacts #224
Workflow file for this run
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
| # 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: "sky333999/win" | |
| 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 }} | |
| CWA_COMMIT_DATE: ${{ steps.get-commit-date.outputs.commit_date }} | |
| 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: Checkout agent repository for commit date | |
| uses: actions/checkout@v3 | |
| with: | |
| repository: aws/amazon-cloudwatch-agent | |
| fetch-depth: 0 | |
| path: agent-repo | |
| - name: Get commit date | |
| id: get-commit-date | |
| run: | | |
| cd agent-repo # Navigate to agent repo checkout | |
| echo "Extracting commit date from agent repository..." | |
| # Get commit date as Unix timestamp, fallback to 0 for easier backfilling | |
| if [[ "${{ inputs.build_id }}" =~ ^[0-9a-f]{40}$ ]]; then | |
| # Full SHA - get date from git log | |
| echo "Full SHA detected: ${{ inputs.build_id }}" | |
| COMMIT_DATE=$(git log -1 --format=%ct ${{ inputs.build_id }} 2>/dev/null || echo "0") | |
| elif [[ "${{ inputs.build_id }}" =~ ^[0-9]+\.[0-9]+\.[0-9a-f]+$ ]]; then | |
| # Version format like 1.300057.1b1168 - extract SHA and get date | |
| SHA_PART=$(echo "${{ inputs.build_id }}" | sed 's/.*\.//') | |
| echo "Version format detected, extracted SHA: $SHA_PART" | |
| COMMIT_DATE=$(git log -1 --format=%ct --grep="$SHA_PART" 2>/dev/null || echo "0") | |
| else | |
| # Fallback to 0 for easier backfilling of historical data | |
| echo "Unknown format, using 0 for easier backfilling" | |
| COMMIT_DATE="0" | |
| fi | |
| echo "commit_date=${COMMIT_DATE}" >> $GITHUB_OUTPUT | |
| echo "Retrieved commit date: ${COMMIT_DATE} for build_id: ${{ inputs.build_id }}" | |
| if [[ "$COMMIT_DATE" != "0" ]]; then | |
| echo "SUCCESS: Found commit date ${COMMIT_DATE}" | |
| else | |
| echo "Using 0 - can be backfilled later with historical data" | |
| fi | |
| - 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 }}" | |
| echo "CWA_COMMIT_DATE: ${{ steps.get-commit-date.outputs.commit_date }}" | |
| - 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: | |
| eks_daemon_matrix: ${{ steps.set-matrix.outputs.eks_daemon_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 "eks_daemon_matrix=$(echo $(cat generator/resources/eks_daemon_complete_test_matrix.json))" >> "$GITHUB_OUTPUT" | |
| - name: Echo test plan matrix | |
| run: | | |
| echo "eks_daemon_matrix: ${{ steps.set-matrix.outputs.eks_daemon_matrix }}" | |
| EKSIntegrationTest: | |
| name: ${{matrix.arrays.testName}} | |
| runs-on: ubuntu-latest | |
| needs: [ GenerateTestMatrix, OutputEnvVariables ] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| arrays: ${{ fromJson(needs.GenerateTestMatrix.outputs.eks_daemon_matrix) }} | |
| permissions: | |
| id-token: write | |
| contents: read | |
| 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: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }} | |
| aws-region: us-west-2 | |
| role-duration-seconds: ${{ env.TERRAFORM_AWS_ASSUME_ROLE_DURATION }} | |
| - name: Login ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Install Terraform | |
| uses: hashicorp/setup-terraform@v3 | |
| with: | |
| terraform_version: 1.12.0 | |
| - name: Verify Terraform version | |
| run: terraform --version | |
| - name: Terraform apply | |
| uses: nick-fields/retry@v2 | |
| with: | |
| max_attempts: 1 | |
| timeout_minutes: 90 # EKS takes about 20 minutes to spin up a cluster and service on the cluster | |
| retry_wait_seconds: 5 | |
| command: | | |
| if [ "${{ matrix.arrays.terraform_dir }}" != "" ]; then | |
| cd "${{ matrix.arrays.terraform_dir }}" | |
| else | |
| cd terraform/eks/daemon | |
| fi | |
| terraform init | |
| terraform apply --auto-approve \ | |
| -var="test_dir=${{ matrix.arrays.test_dir }}"\ | |
| -var="cwagent_image_repo=${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_INTEGRATION_TEST_REPO }}" \ | |
| -var="cwagent_image_tag=${{ inputs.build_id }}" \ | |
| -var="ami_type=${{ matrix.arrays.ami }}" \ | |
| -var="instance_type=${{ matrix.arrays.instanceType }}" \ | |
| -var="k8s_version=${{ matrix.arrays.k8sVersion }}" |