generated from amazon-archives/__template_Custom
-
Notifications
You must be signed in to change notification settings - Fork 252
feat(ci): Add pre-compiled test binaries for EC2 integration tests #2026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
the-mann
wants to merge
21
commits into
main
Choose a base branch
from
feat/go-build-cache-s3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b20af67
feat(ci): Add Go build cache warming for integration tests
the-mann 1c1d8cf
feat(ci): Add Go build cache warming to PR-test workflow
the-mann 37d97a2
fix(ci): Only pass cache_key to terraform when non-empty
the-mann 2cde20a
fix(ci): Check terraform config declares cache_key before passing it
the-mann 6333a71
feat(ci): Add pre-compiled test binary build and distribution (Phase 2)
the-mann c4baf26
fix(ci): Build test binaries for both amd64 and arm64
the-mann 9b7b015
Merge branch 'main' into feat/go-build-cache-s3
the-mann 49a8e7d
refactor(ci): Remove Go cache warming, keep only pre-compiled binaries
the-mann aeda280
feat: Upload test binaries to ITAR and CN S3 buckets
the-mann 0947704
fix: Use separate jobs with OIDC auth for ITAR/CN uploads
the-mann 1cc298c
feat: Pass test_func to terraform for per-function test execution
the-mann 307372c
feat: Parallelize test binary and Mac package builds
the-mann 1cbe231
fix: Skip matrix jobs when array is empty
the-mann 0a43483
fix: Use /tmp/ directly for MakeMacPkg since each arch runs on separa…
the-mann 9c15a56
fix: Use separate go caches for mac amd64/arm64
the-mann 556c92f
Merge branch 'main' into feat/go-build-cache-s3
the-mann d956795
fix: avoid 1MB job output limit by writing ec2_linux_matrix to file
the-mann 88210e6
fix: strip empty fields from test matrix to avoid 1MB output limit
the-mann 76312d4
Revert "fix: strip empty fields from test matrix to avoid 1MB output …
the-mann bc99e3f
fix: strip empty fields from matrix JSON to stay under 1MB limit
the-mann df53dc8
fix: use artifacts for ec2_linux matrices to avoid 1MB output limit
the-mann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,197 @@ | ||
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| name: Build Test Binaries | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| test_repo_name: | ||
| required: true | ||
| type: string | ||
| test_repo_branch: | ||
| required: true | ||
| type: string | ||
| s3_integration_bucket: | ||
| required: true | ||
| type: string | ||
| terraform_assume_role: | ||
| required: true | ||
| type: string | ||
| s3_integration_bucket_itar: | ||
| required: false | ||
| type: string | ||
| terraform_assume_role_itar: | ||
| required: false | ||
| type: string | ||
| s3_integration_bucket_cn: | ||
| required: false | ||
| type: string | ||
| terraform_assume_role_cn: | ||
| required: false | ||
| type: string | ||
| outputs: | ||
| test_binaries_prefix: | ||
| description: "S3 prefix for pre-compiled test binaries" | ||
| value: ${{ jobs.Complete.outputs.test_binaries_prefix }} | ||
|
|
||
| jobs: | ||
| BuildTestBinaries: | ||
| name: 'BuildTestBinaries-${{ matrix.arch }}' | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| arch: [amd64, arm64] | ||
| outputs: | ||
| test_binaries_prefix: ${{ steps.set-prefix.outputs.test_binaries_prefix }} | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| repository: ${{ inputs.test_repo_name }} | ||
| ref: ${{ inputs.test_repo_branch }} | ||
|
|
||
| - name: Set prefix | ||
| id: set-prefix | ||
| run: | | ||
| COMMIT_SHA=$(git rev-parse --short HEAD) | ||
| echo "test_binaries_prefix=integration-test/test-binaries/${COMMIT_SHA}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Set up Go 1.x | ||
| uses: actions/setup-go@v4 | ||
| with: | ||
| go-version: ~1.25 | ||
| cache: false | ||
|
|
||
| - name: Configure AWS Credentials | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| role-to-assume: ${{ inputs.terraform_assume_role }} | ||
| aws-region: us-west-2 | ||
|
|
||
| - name: Build and upload test binaries | ||
| env: | ||
| S3_BUCKET: ${{ inputs.s3_integration_bucket }} | ||
| GOARCH: ${{ matrix.arch }} | ||
| run: | | ||
| COMMIT_SHA=$(git rev-parse --short HEAD) | ||
| PREFIX="integration-test/test-binaries/${COMMIT_SHA}/linux/${GOARCH}" | ||
| mkdir -p "build/bin/${GOARCH}" | ||
|
|
||
| go mod download | ||
|
|
||
| echo "=== Building for linux/${GOARCH} ===" | ||
| for pkg in $(go list ./test/...); do | ||
| name=$(basename "$pkg") | ||
| if CGO_ENABLED=0 GOOS=linux GOARCH=$GOARCH go test -c -o "build/bin/${GOARCH}/${name}.test" "$pkg" 2>&1; then | ||
| echo " ✓ ${name}.test" | ||
| else | ||
| echo " ✗ ${name}.test (skipped)" | ||
| fi | ||
| done | ||
|
|
||
| BUILT=$(ls "build/bin/${GOARCH}/"*.test 2>/dev/null | wc -l) | ||
| echo "Built ${BUILT} binaries for linux/${GOARCH}" | ||
|
|
||
| aws s3 cp "build/bin/${GOARCH}/" "s3://${S3_BUCKET}/${PREFIX}/" --recursive --quiet | ||
| echo "Upload complete to commercial bucket" | ||
|
|
||
| - name: Upload binaries artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: test-binaries-${{ matrix.arch }} | ||
| path: build/bin/${{ matrix.arch }}/ | ||
| retention-days: 1 | ||
|
|
||
| UploadTestBinariesITAR: | ||
| name: 'UploadTestBinariesITAR' | ||
| needs: [BuildTestBinaries] | ||
| if: ${{ inputs.s3_integration_bucket_itar != '' && inputs.terraform_assume_role_itar != '' }} | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| steps: | ||
| - name: Download amd64 binaries | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: test-binaries-amd64 | ||
| path: build/bin/amd64/ | ||
|
|
||
| - name: Download arm64 binaries | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: test-binaries-arm64 | ||
| path: build/bin/arm64/ | ||
|
|
||
| - name: Configure AWS Credentials for ITAR | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| role-to-assume: ${{ inputs.terraform_assume_role_itar }} | ||
| aws-region: us-gov-east-1 | ||
|
|
||
| - name: Upload to ITAR bucket | ||
| env: | ||
| S3_BUCKET: ${{ inputs.s3_integration_bucket_itar }} | ||
| PREFIX: ${{ needs.BuildTestBinaries.outputs.test_binaries_prefix }} | ||
| run: | | ||
| for GOARCH in amd64 arm64; do | ||
| aws s3 cp "build/bin/${GOARCH}/" "s3://${S3_BUCKET}/${PREFIX}/linux/${GOARCH}/" --recursive --quiet | ||
| done | ||
| echo "Upload complete to ITAR bucket" | ||
|
|
||
| UploadTestBinariesCN: | ||
| name: 'UploadTestBinariesCN' | ||
| needs: [BuildTestBinaries] | ||
| if: ${{ inputs.s3_integration_bucket_cn != '' && inputs.terraform_assume_role_cn != '' }} | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| steps: | ||
| - name: Download amd64 binaries | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: test-binaries-amd64 | ||
| path: build/bin/amd64/ | ||
|
|
||
| - name: Download arm64 binaries | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: test-binaries-arm64 | ||
| path: build/bin/arm64/ | ||
|
|
||
| - name: Configure AWS Credentials for CN | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| role-to-assume: ${{ inputs.terraform_assume_role_cn }} | ||
| aws-region: cn-north-1 | ||
|
|
||
| - name: Upload to CN bucket | ||
| env: | ||
| S3_BUCKET: ${{ inputs.s3_integration_bucket_cn }} | ||
| PREFIX: ${{ needs.BuildTestBinaries.outputs.test_binaries_prefix }} | ||
| run: | | ||
| for GOARCH in amd64 arm64; do | ||
| aws s3 cp "build/bin/${GOARCH}/" "s3://${S3_BUCKET}/${PREFIX}/linux/${GOARCH}/" --recursive --quiet | ||
| done | ||
| echo "Upload complete to CN bucket" | ||
|
|
||
| Complete: | ||
| name: 'Complete' | ||
| needs: [BuildTestBinaries, UploadTestBinariesITAR, UploadTestBinariesCN] | ||
| if: ${{ always() }} | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| test_binaries_prefix: ${{ needs.BuildTestBinaries.outputs.test_binaries_prefix }} | ||
| steps: | ||
| - name: Check results | ||
| run: | | ||
| echo "BuildTestBinaries: ${{ needs.BuildTestBinaries.result }}" | ||
| echo "UploadTestBinariesITAR: ${{ needs.UploadTestBinariesITAR.result }}" | ||
| echo "UploadTestBinariesCN: ${{ needs.UploadTestBinariesCN.result }}" | ||
| if [[ "${{ needs.BuildTestBinaries.result }}" != "success" ]]; then | ||
| exit 1 | ||
| fi | ||
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI about 1 month ago
To fix the problem, we should explicitly define a
permissionsblock for theCompletejob so it no longer relies on repository/organization defaults. Since theCompletejob only echoes results and evaluates conditions without interacting with GitHub APIs or repository contents, it does not need any token permissions at all, so the least‑privilege configuration is to disable theGITHUB_TOKENfor this job usingpermissions: {}.Concretely, in
.github/workflows/build-test-binaries.yml, in theCompletejob definition starting at line 182, add apermissions: {}entry alongsideruns-onandoutputs. For example, immediately afterruns-on: ubuntu-latestinsert a linepermissions: {}with the same indentation asruns-on. No imports or additional methods are needed, as this is purely a YAML configuration change.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this warning still valid, or did you resolve it?