-
Notifications
You must be signed in to change notification settings - Fork 0
chore: add cache to the build stage #57
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
base: go-integration-tests
Are you sure you want to change the base?
Changes from all commits
0837bee
204037c
c9d0d0e
7d81079
33f8e47
68592f4
1470827
e4149f3
7f8d799
804a3f3
d5e9042
b970c83
f34aa60
b3ec3e9
6a2e215
b7b6410
d548467
0f79ecb
31a8770
423eb2b
50e5aae
96594cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -26,6 +26,11 @@ on: | |||||||||
| description: "The duration before tests are stopped" | ||||||||||
| type: string | ||||||||||
| default: "10m" | ||||||||||
| DOCKER_CACHE_IMAGES: | ||||||||||
| description: "Comma-separated list of Docker images to pre-pull and cache for integration tests" | ||||||||||
| type: string | ||||||||||
| required: false | ||||||||||
| default: "" | ||||||||||
| secrets: | ||||||||||
| GH_CI_PAT: | ||||||||||
| description: 'Token password for GitHub auth' | ||||||||||
|
|
@@ -130,7 +135,22 @@ jobs: | |||||||||
| # Install go-junit-report to format test results. | ||||||||||
| - name: Install go-junit-report | ||||||||||
| run: go install github.com/jstemmer/go-junit-report/v2@v2.1.0 | ||||||||||
| # Run unit test for evet Go module. | ||||||||||
| # Free up disk space before integration tests (removes ~25GB of unused tools) | ||||||||||
| - name: Free disk space | ||||||||||
| if: ${{ inputs.GO_TEST_INTEGRATION_ENABLED }} | ||||||||||
| run: | | ||||||||||
| echo "Disk space before cleanup:" | ||||||||||
| df -h | ||||||||||
|
|
||||||||||
| # Remove unnecessary tools and SDKs (preserve Go and Docker) | ||||||||||
| sudo rm -rf /usr/share/dotnet | ||||||||||
| sudo rm -rf /usr/local/lib/android | ||||||||||
| sudo rm -rf /opt/ghc | ||||||||||
| sudo rm -rf /opt/hostedtoolcache/CodeQL | ||||||||||
|
|
||||||||||
| echo "Disk space after cleanup:" | ||||||||||
| df -h | ||||||||||
| # Run unit test for every Go module. | ||||||||||
| - name: build coverage output directories | ||||||||||
| run: | | ||||||||||
| mkdir -p coverage/unit | ||||||||||
|
|
@@ -156,8 +176,126 @@ jobs: | |||||||||
| files: ./junit_report.xml | ||||||||||
| name: junit-report | ||||||||||
| token: ${{ secrets.CODECOV_TOKEN }} | ||||||||||
| # Get the digest of the latest integrations-testsuite image | ||||||||||
| - name: Get integrations-testsuite image digest | ||||||||||
| if: ${{ inputs.GO_TEST_INTEGRATION_ENABLED }} | ||||||||||
| id: image-digest | ||||||||||
| env: | ||||||||||
| ARTIFACT_REGISTRY: ${{ secrets.ARTIFACT_REGISTRY }} | ||||||||||
| run: | | ||||||||||
| IMAGE="${ARTIFACT_REGISTRY}/kochava/integrations-testsuite:latest" | ||||||||||
| # Get digest without pulling the full image (only manifest) | ||||||||||
| # Extract the actual image digest from the manifest | ||||||||||
| DIGEST=$(docker manifest inspect ${IMAGE} | jq -r '.manifests[0].digest // .config.digest' | sed 's/sha256://') | ||||||||||
|
||||||||||
| DIGEST=$(docker manifest inspect ${IMAGE} | jq -r '.manifests[0].digest // .config.digest' | sed 's/sha256://') | |
| DIGEST=$(docker buildx imagetools inspect --raw ${IMAGE} | grep -m1 '^Digest:' | awk '{print $2}' | sed 's/sha256://') |
Copilot
AI
Dec 4, 2025
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.
The docker manifest inspect command requires authentication when used with private registries, but this step runs before the Login to Artifact Registry step (lines 112-120) has authenticated. This will cause the command to fail with authentication errors for private images.
The authentication step should be moved before this step, or this step should be moved after the authentication step to ensure docker manifest inspect can access the private registry.
Copilot
AI
Dec 4, 2025
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.
The cache key rotation strategy using github.run_number will not work correctly across different branches. Run numbers are global to the repository, not per-branch, which means cache keys will invalidate unpredictably when PRs from different branches are running.
Consider using a time-based rotation (e.g., ${{ github.run_number / 20 }} rounded down) or a date-based approach like $(date +%Y%m%d) to ensure more predictable cache behavior across branches.
| # Calculate cache slot (invalidate every 20 runs) | |
| CACHE_SLOT=$(( ${{ github.run_number }} - (${{ github.run_number }} % 20) )) | |
| # Calculate cache slot (invalidate daily) | |
| CACHE_SLOT=$(date +%Y%m%d) |
cri0ll0 marked this conversation as resolved.
Show resolved
Hide resolved
cri0ll0 marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Dec 4, 2025
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.
The filename sanitization using tr '/:' '_' is insufficient and could lead to collisions or filesystem issues. It doesn't handle other problematic characters like spaces, special characters, or very long names.
Consider using a more robust approach:
filename=$(echo "$image" | sed 's/[^a-zA-Z0-9._-]/_/g' | cut -c1-200)Or use a hash-based approach for guaranteed uniqueness:
filename=$(echo "$image" | sha256sum | cut -d' ' -f1)| filename=$(echo "$image" | tr '/:' '_') | |
| filename=$(echo "$image" | sha256sum | cut -d' ' -f1) |
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.
The
docker manifest inspectcommand output is piped tojqandsedwithout error checking. If the manifest inspection fails (e.g., due to network issues or authentication problems), the pipeline might produce an empty or invalid digest, which would be written toGITHUB_OUTPUT. This could cause cache key issues or failures in subsequent steps.Add error checking after the pipeline: