Skip to content

Commit 8c178b2

Browse files
committed
Merge remote-tracking branch 'origin/main' into ultraserver-tupperware
2 parents e16bbc5 + 2707e5f commit 8c178b2

394 files changed

Lines changed: 34613 additions & 5512 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/pull_request_template.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ By submitting this pull request, I confirm that you can use, modify, copy, and r
1111
_Describe what tests you have done._
1212

1313
# Requirements
14-
_Before commit the code, please do the following steps._
14+
_Before commiting your code, please do the following steps._
1515
1. Run `make fmt` and `make fmt-sh`
1616
2. Run `make lint`
1717

18+
-------
19+
### Integration Tests
20+
To run integration tests against this PR, add the `ready for testing` label.
1821

1922

2023

.github/workflows/PR-build.yml

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ name: PR Build
55
on:
66
workflow_dispatch:
77
pull_request:
8-
branches:
8+
branches:
99
- main*
1010
- feature*
11-
types:
11+
types:
1212
- opened
1313
- synchronize
1414
- reopened
@@ -78,7 +78,7 @@ jobs:
7878
strategy:
7979
fail-fast: false
8080
matrix:
81-
os: [ubuntu-latest, windows-2019, windows-latest, macos-13]
81+
os: [ubuntu-latest, windows-2022, windows-latest, macos-13]
8282
include:
8383
- os: ubuntu-latest
8484
family: linux
@@ -90,7 +90,7 @@ jobs:
9090
cache-path: |
9191
~/Library/Caches/go-build
9292
~/go/pkg/mod
93-
- os: windows-2019
93+
- os: windows-2022
9494
family: windows
9595
cache-path: |
9696
~\AppData\Local\go-build
@@ -158,3 +158,39 @@ jobs:
158158
- name: Test data race
159159
if: needs.changes.outputs.build == 'true'
160160
run: make test-data-race
161+
162+
verify-all:
163+
name: Verify All PR Build Jobs
164+
needs: [ changes, lint, build, test-data-race ]
165+
runs-on: ubuntu-latest
166+
if: always()
167+
steps:
168+
- name: Check Job Status
169+
run: |
170+
# Convert needs context to JSON and process with jq
171+
needs_json='${{ toJSON(needs) }}'
172+
173+
failed_jobs=()
174+
successful_jobs=()
175+
176+
# Loop through all jobs in needs context
177+
for job in $(echo "$needs_json" | jq -r 'keys[]'); do
178+
result=$(echo "$needs_json" | jq -r ".[\"$job\"].result")
179+
180+
if [[ "$result" == "failure" ]]; then
181+
failed_jobs+=("$job")
182+
elif [[ "$result" == "success" ]]; then
183+
successful_jobs+=("$job")
184+
fi
185+
done
186+
187+
echo "Successfully validated jobs:"
188+
printf '%s\n' "${successful_jobs[@]}"
189+
190+
if [ ${#failed_jobs[@]} -ne 0 ]; then
191+
echo -e "\nFailed jobs:"
192+
printf '%s\n' "${failed_jobs[@]}"
193+
exit 1
194+
fi
195+
196+
echo -e "\nAll required jobs completed without failures!"

.github/workflows/PR-test.yml

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: MIT
3+
4+
name: PR Test
5+
env:
6+
TERRAFORM_AWS_ASSUME_ROLE: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }}
7+
TERRAFORM_AWS_ASSUME_ROLE_DURATION: 14400 # 4 hours
8+
CWA_GITHUB_TEST_REPO_NAME: "aws/amazon-cloudwatch-agent-test"
9+
CWA_GITHUB_TEST_REPO_URL: "https://github.com/aws/amazon-cloudwatch-agent-test.git"
10+
CWA_GITHUB_TEST_REPO_BRANCH: "main"
11+
KEY_NAME: ${{ secrets.KEY_NAME }}
12+
PRIVATE_KEY: ${{ secrets.AWS_PRIVATE_KEY }}
13+
S3_INTEGRATION_BUCKET: ${{ vars.S3_INTEGRATION_BUCKET }}
14+
15+
on:
16+
workflow_dispatch:
17+
pull_request:
18+
branches:
19+
- main*
20+
- feature*
21+
types:
22+
- opened
23+
- synchronize
24+
- reopened
25+
- ready_for_review
26+
- labeled
27+
- unlabeled
28+
29+
concurrency:
30+
group: ${{ github.workflow }}-${{ github.ref_name }}
31+
cancel-in-progress: true
32+
33+
jobs:
34+
CheckLabel:
35+
runs-on: ubuntu-latest
36+
outputs:
37+
should_run: ${{ steps.check.outputs.has_label }}
38+
steps:
39+
- id: check
40+
run: |
41+
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'ready for testing') }}" == "true" ]]; then
42+
echo "has_label=true" >> $GITHUB_OUTPUT
43+
else
44+
echo "has_label=false" >> $GITHUB_OUTPUT
45+
fi
46+
47+
BuildAndUpload:
48+
needs: [ CheckLabel ]
49+
if: needs.CheckLabel.outputs.should_run == 'true'
50+
uses: ./.github/workflows/test-build.yml
51+
secrets: inherit
52+
permissions:
53+
id-token: write
54+
contents: read
55+
with:
56+
BucketKey: "integration-test/binary/${{ github.sha }}"
57+
PackageBucketKey: "integration-test/packaging/${{ github.sha }}"
58+
TerraformAWSAssumeRole: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }}
59+
Bucket: ${{ vars.S3_INTEGRATION_BUCKET }}
60+
61+
OutputEnvVariables:
62+
name: 'OutputEnvVariables'
63+
needs: [ CheckLabel ]
64+
if: needs.CheckLabel.outputs.should_run == 'true'
65+
runs-on: ubuntu-latest
66+
outputs:
67+
CWA_GITHUB_TEST_REPO_NAME: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_NAME }}
68+
CWA_GITHUB_TEST_REPO_URL: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_URL }}
69+
CWA_GITHUB_TEST_REPO_BRANCH: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
70+
steps:
71+
- name: SetOutputs
72+
id: set-outputs
73+
run: |
74+
CWA_GITHUB_TEST_REPO_BRANCH=${{ env.CWA_GITHUB_TEST_REPO_BRANCH }}
75+
76+
echo "CWA_GITHUB_TEST_REPO_NAME=${{ env.CWA_GITHUB_TEST_REPO_NAME }}" >> "$GITHUB_OUTPUT"
77+
echo "CWA_GITHUB_TEST_REPO_URL=${{ env.CWA_GITHUB_TEST_REPO_URL }}" >> "$GITHUB_OUTPUT"
78+
echo "CWA_GITHUB_TEST_REPO_BRANCH=${CWA_GITHUB_TEST_REPO_BRANCH:-${{ env.CWA_GITHUB_TEST_REPO_BRANCH }}}" >> "$GITHUB_OUTPUT"
79+
80+
- name: Echo test variables
81+
run: |
82+
echo "build_id: ${{ github.sha }}"
83+
echo "CWA_GITHUB_TEST_REPO_NAME: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_NAME }}"
84+
echo "CWA_GITHUB_TEST_REPO_URL: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_URL }}"
85+
echo "CWA_GITHUB_TEST_REPO_BRANCH: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}"
86+
87+
- uses: actions/checkout@v3
88+
with:
89+
repository: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_NAME }}
90+
ref: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
91+
92+
- name: Set up Go 1.x
93+
uses: actions/setup-go@v4
94+
with:
95+
go-version: ~1.22.2
96+
97+
StartLocalStack:
98+
name: 'StartLocalStack'
99+
needs: [ CheckLabel, OutputEnvVariables ]
100+
if: needs.CheckLabel.outputs.should_run == 'true'
101+
uses: ./.github/workflows/start-localstack.yml
102+
secrets: inherit
103+
permissions:
104+
id-token: write
105+
contents: read
106+
with:
107+
region: us-west-2
108+
test_repo_name: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }}
109+
test_repo_branch: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
110+
terraform_assume_role: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }}
111+
test_repo_url: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_URL }}
112+
github_sha: ${{ github.sha }}
113+
s3_integration_bucket: ${{ vars.S3_INTEGRATION_BUCKET }}
114+
115+
GenerateTestMatrix:
116+
name: 'GenerateTestMatrix'
117+
needs: [ CheckLabel, OutputEnvVariables ]
118+
if: needs.CheckLabel.outputs.should_run == 'true'
119+
runs-on: ubuntu-latest
120+
outputs:
121+
ec2_linux_matrix: ${{ steps.set-matrix.outputs.ec2_linux_matrix }}
122+
ec2_selinux_matrix: ${{ steps.set-matrix.outputs.ec2_selinux_matrix }}
123+
124+
steps:
125+
- uses: actions/checkout@v3
126+
with:
127+
repository: ${{env.CWA_GITHUB_TEST_REPO_NAME}}
128+
ref: ${{env.CWA_GITHUB_TEST_REPO_BRANCH}}
129+
130+
- name: Set up Go 1.x
131+
uses: actions/setup-go@v4
132+
with:
133+
go-version: ~1.22.2
134+
135+
- name: Install jq
136+
run: sudo apt-get install -y jq
137+
138+
- name: Generate matrix
139+
id: set-matrix
140+
run: |
141+
go run --tags=generator generator/test_case_generator.go
142+
# Convert the output to valid JSON and filter out metric_value_benchmark tests
143+
jq -c '[.[] | select(.test_dir != "./test/metric_value_benchmark")]' generator/resources/ec2_linux_complete_test_matrix.json > filtered_matrix.json
144+
# Escape the JSON for GitHub Actions
145+
MATRIX=$(jq -c -r '@json' filtered_matrix.json)
146+
echo "ec2_linux_matrix=$MATRIX" >> $GITHUB_OUTPUT
147+
jq -c '[.[] | select(.test_dir != "./test/metric_value_benchmark")]' generator/resources/ec2_selinux_complete_test_matrix.json > filtered_matrix_selinux.json
148+
# Escape the JSON for GitHub Actions
149+
MATRIX=$(jq -c -r '@json' filtered_matrix_selinux.json)
150+
echo "ec2_selinux_matrix=$MATRIX" >> $GITHUB_OUTPUT
151+
152+
153+
- name: Echo test plan matrix
154+
run: |
155+
echo "ec2_linux_matrix: ${{ steps.set-matrix.outputs.ec2_linux_matrix }}"
156+
echo "ec2_selinux_matrix: ${{ steps.set-matrix.outputs.ec2_selinux_matrix }}"
157+
158+
159+
EC2LinuxIntegrationTest:
160+
name: 'EC2LinuxTests'
161+
needs: [ CheckLabel, GenerateTestMatrix, OutputEnvVariables, StartLocalStack, BuildAndUpload ]
162+
if: needs.CheckLabel.outputs.should_run == 'true'
163+
uses: ./.github/workflows/ec2-integration-test.yml
164+
with:
165+
build_id: ${{ github.sha }}
166+
test_dir: terraform/ec2/linux
167+
job_id: ec2-linux-integration-test
168+
test_props: ${{ needs.GenerateTestMatrix.outputs.ec2_linux_matrix }}
169+
test_repo_name: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }}
170+
test_repo_url: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_URL }}
171+
test_repo_branch: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
172+
localstack_host: ${{ needs.StartLocalStack.outputs.local_stack_host_name }}
173+
region: us-west-2
174+
terraform_assume_role: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }}
175+
s3_integration_bucket: ${{ vars.S3_INTEGRATION_BUCKET }}
176+
is_selinux_test: false
177+
secrets: inherit
178+
179+
EC2SELinuxIntegrationTest:
180+
name: 'EC2SELinuxTests'
181+
needs: [ CheckLabel, GenerateTestMatrix, OutputEnvVariables, StartLocalStack, BuildAndUpload ]
182+
if: needs.CheckLabel.outputs.should_run == 'true'
183+
uses: ./.github/workflows/ec2-integration-test.yml
184+
with:
185+
build_id: ${{ github.sha }}
186+
test_dir: terraform/ec2/linux
187+
job_id: ec2-linux-integration-test
188+
test_props: ${{ needs.GenerateTestMatrix.outputs.ec2_selinux_matrix }}
189+
test_repo_name: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }}
190+
test_repo_url: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_URL }}
191+
test_repo_branch: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
192+
localstack_host: ${{ needs.StartLocalStack.outputs.local_stack_host_name }}
193+
region: us-west-2
194+
terraform_assume_role: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }}
195+
s3_integration_bucket: ${{ vars.S3_INTEGRATION_BUCKET }}
196+
is_selinux_test: true
197+
secrets: inherit
198+
199+
StopLocalStack:
200+
name: 'StopLocalStack'
201+
needs: [ CheckLabel, StartLocalStack, EC2LinuxIntegrationTest, OutputEnvVariables ]
202+
if: ${{ always() && needs.StartLocalStack.result == 'success' && needs.CheckLabel.outputs.should_run == 'true'}}
203+
uses: ./.github/workflows/stop-localstack.yml
204+
secrets: inherit
205+
permissions:
206+
id-token: write
207+
contents: read
208+
with:
209+
region: us-west-2
210+
test_repo_name: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }}
211+
test_repo_branch: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}
212+
terraform_assume_role: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }}
213+
github_sha: ${{ github.sha }}
214+
s3_integration_bucket: ${{ vars.S3_INTEGRATION_BUCKET }}
215+
216+
verify-all:
217+
name: Verify All PR Test Jobs
218+
needs: [CheckLabel, BuildAndUpload, OutputEnvVariables, StartLocalStack,
219+
GenerateTestMatrix, EC2LinuxIntegrationTest, EC2SELinuxIntegrationTest,
220+
StopLocalStack]
221+
runs-on: ubuntu-latest
222+
if: always()
223+
steps:
224+
- name: Check Job Status
225+
run: |
226+
# Convert needs context to JSON and process with jq
227+
needs_json='${{ toJSON(needs) }}'
228+
229+
failed_jobs=()
230+
successful_jobs=()
231+
232+
# Loop through all jobs in needs context
233+
for job in $(echo "$needs_json" | jq -r 'keys[]'); do
234+
result=$(echo "$needs_json" | jq -r ".[\"$job\"].result")
235+
236+
if [[ "$result" == "failure" ]]; then
237+
failed_jobs+=("$job")
238+
elif [[ "$result" == "success" ]]; then
239+
successful_jobs+=("$job")
240+
fi
241+
done
242+
243+
echo "Successfully validated jobs:"
244+
printf '%s\n' "${successful_jobs[@]}"
245+
246+
if [ ${#failed_jobs[@]} -ne 0 ]; then
247+
echo -e "\nFailed jobs:"
248+
printf '%s\n' "${failed_jobs[@]}"
249+
exit 1
250+
fi
251+
252+
echo -e "\nAll required jobs completed without failures!"

.github/workflows/application-signals-e2e-test.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,6 @@ jobs:
190190
caller-workflow-name: 'main-build'
191191
dotnet-version: '8.0'
192192

193-
dotnet-ec2-default-v6-e2e-test:
194-
needs: [ CheckBuildTestArtifacts ]
195-
uses: aws-observability/aws-application-signals-test-framework/.github/workflows/dotnet-ec2-default-test.yml@main
196-
secrets: inherit
197-
with:
198-
aws-region: us-east-1
199-
caller-workflow-name: 'main-build'
200-
dotnet-version: '6.0'
201-
202193
dotnet-ec2-windows-e2e-test:
203194
needs: [ CheckBuildTestArtifacts ]
204195
uses: aws-observability/aws-application-signals-test-framework/.github/workflows/dotnet-ec2-windows-test.yml@main
@@ -222,4 +213,22 @@ jobs:
222213
secrets: inherit
223214
with:
224215
aws-region: us-east-1
225-
caller-workflow-name: 'main-build'
216+
caller-workflow-name: 'main-build'
217+
218+
# This validation is to ensure that all test workflows relevant to this repo are actually
219+
# being used in this repo, which is referring to all the other jobs in this file.
220+
#
221+
# If this starts failing, then it most likely means that new e2e test workflow was
222+
# added to `aws-observability/aws-application-signals-test-framework`, but was not
223+
# added to this file. It could also mean that a test in this file has been removed.
224+
#
225+
# If a particular test file is intended to not be tested in this repo and should not
226+
# be failing this particular validation, then choose one of the following options:
227+
# - Add the test file to the exclusions input (CSV format) to the workflow
228+
# (see: https://github.com/aws-observability/aws-application-signals-test-framework/blob/main/.github/workflows/validate-e2e-tests-are-accounted-for.yml#L1)
229+
# - Update the `validate-e2e-tests-are-accounted-for` job to change which "workflow files are expected to be used by this repo"
230+
# (see: https://github.com/aws-observability/aws-application-signals-test-framework/blob/main/.github/workflows/validate-e2e-tests-are-accounted-for.yml)
231+
validate-all-tests-are-accounted-for:
232+
uses: aws-observability/aws-application-signals-test-framework/.github/workflows/validate-e2e-tests-are-accounted-for.yml@main
233+
with:
234+
exclusions: dotnet-ec2-nuget-test.yml,dotnet-ec2-asg-test.yml,dotnet-eks-windows-test.yml,java-ec2-ubuntu-test.yml

.github/workflows/build-test-artifacts.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ on:
1515
- '!.github/workflows/build-test-artifacts.yml'
1616
- '!.github/workflows/integration-test.yml'
1717
- '!.github/workflows/application-signals-e2e-test.yml'
18+
schedule:
19+
- cron: '0 11 * * 1,2,3,4,5' # Every day at 11:00 UTC on Monday to Friday
1820
workflow_dispatch:
1921
inputs:
2022
test-image-before-upload:
@@ -108,7 +110,7 @@ jobs:
108110
StartApplicationSignalsE2ETests:
109111
needs: [ BuildAndUploadPackages, BuildAndUploadITAR, BuildAndUploadCN, BuildDocker ]
110112
# Workflow only runs against main
111-
if: ${{ contains(github.ref_name, 'main') && (github.event_name == 'push' || inputs.test-image-before-upload) }}
113+
if: ${{ github.event_name == 'push' || inputs.test-image-before-upload }}
112114
runs-on: ubuntu-latest
113115
steps:
114116
- run: gh workflow run application-signals-e2e-test.yml --ref ${{ github.ref_name }} --repo $GITHUB_REPOSITORY -f build_run_id=${{ github.run_id }} -f build_sha=${{ github.sha }}

0 commit comments

Comments
 (0)