Repository navigation
feat: implement issue #1364 — [Fleet Monitor] petry-projects/.github-private — .github/workflows/test.yml #1366
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f68f1e8
feat: implement issue #1364 — [Fleet Monitor] petry-projects/.github-…
don-petry 7ace117
chore: dev-lead update (review-changes) [skip ci-relay]
don-petry f93ece6
fix(bot): address bot feedback [skip ci-relay]
don-petry 1d82d6c
fix(reviews): address review comments [skip ci-relay]
don-petry 3d46dc7
chore: dev-lead update (review-changes) [skip ci-relay]
don-petry cd3b2a1
chore: dev-lead update (review-changes) [skip ci-relay]
don-petry e9f064f
Merge branch 'main' into dev-lead/issue-1364-20260723-0915
don-petry 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,84 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| # test_test_workflow_resilience.sh — regression guard for issue #1364. | ||
| # | ||
| # The Tests workflow (.github/workflows/test.yml) flaked at ~14.8% of runs. Its | ||
| # only non-deterministic step is "Install test dependencies", which fetches | ||
| # packages over the network: | ||
| # - pip install pyyaml | ||
| # - sudo apt-get update && sudo apt-get install -y yq | ||
| # Transient PyPI / apt-mirror failures (and pip falling back to a source build) | ||
| # failed the whole run even though every test itself is pure and local. This | ||
| # test asserts the install step is hardened so a single transient fetch failure | ||
| # no longer fails the workflow: | ||
| # 1. network installs are wrapped in a bounded retry, | ||
| # 2. pip is pinned and binary-only (no flaky source build). | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| WORKFLOW="${SCRIPT_DIR}/../.github/workflows/test.yml" | ||
| STEP_NAME="Install test dependencies" | ||
| fail=0 | ||
|
|
||
| if ! command -v yq >/dev/null 2>&1; then | ||
| echo "FAIL: yq is required to run this test" | ||
| exit 2 | ||
| fi | ||
|
|
||
| if [ ! -f "$WORKFLOW" ]; then | ||
| echo "FAIL: $WORKFLOW not found" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Bracket-index the hyphenated job key: under jq-based yq (kislyuk), `.jobs.unit-tests` | ||
| # parses as `.jobs.unit - tests` and fails with "tests/0 is not defined" (issue #1364). | ||
| run=$(yq '.jobs["unit-tests"].steps[] | select(.name == "'"$STEP_NAME"'") | .run' "$WORKFLOW") | ||
|
|
||
| if [ -z "$run" ] || [ "$run" = "null" ]; then | ||
| echo "FAIL: could not find the \"$STEP_NAME\" step in $WORKFLOW" | ||
|
don-petry marked this conversation as resolved.
Resolved
|
||
| exit 1 | ||
| fi | ||
|
|
||
|
don-petry marked this conversation as resolved.
Resolved
|
||
| # 1. A retry helper must be defined so transient fetch failures are absorbed. | ||
| if ! grep -Eq 'retry\s*\(\)' <<<"$run"; then | ||
| echo "FAIL: \"$STEP_NAME\" must define a retry() helper to absorb transient" | ||
| echo " network failures (apt mirror / PyPI) — issue #1364." | ||
| fail=1 | ||
| fi | ||
|
don-petry marked this conversation as resolved.
Resolved
|
||
|
|
||
| # 2. Every network fetch must go through retry (check all occurrences are wrapped). | ||
| while IFS= read -r cmd; do | ||
| if grep -Eq "$cmd" <<<"$run"; then | ||
| # Count total occurrences and retry-wrapped occurrences; they must match. | ||
| total=$(grep -Eo "(^|[^a-z])$cmd" <<<"$run" | wc -l) | ||
| wrapped=$(grep -Eo "retry.*$cmd" <<<"$run" | wc -l) | ||
| if [ "$total" -ne "$wrapped" ]; then | ||
| echo "FAIL: all occurrences of \"$cmd\" in \"$STEP_NAME\" must be wrapped in retry" | ||
| echo " (found $total, wrapped $wrapped) — issue #1364" | ||
| fail=1 | ||
| fi | ||
| fi | ||
| done <<'CMDS' | ||
| apt-get update | ||
| apt-get install | ||
| pip install | ||
| CMDS | ||
|
don-petry marked this conversation as resolved.
Resolved
|
||
|
|
||
| # 3. pip must be pinned and binary-only so it never falls back to a source build. | ||
| if grep -Eq 'pip install' <<<"$run"; then | ||
| pip_lines=$(grep -E 'pip install' <<<"$run") | ||
| if ! grep -F -- '--only-binary' <<<"$pip_lines" >/dev/null; then | ||
| echo "FAIL: the pip install in \"$STEP_NAME\" must use --only-binary to avoid" | ||
| echo " a flaky source build (issue #1364)." | ||
|
don-petry marked this conversation as resolved.
Resolved
|
||
| fail=1 | ||
| fi | ||
| if ! grep -E 'pyyaml==[0-9]+\.[0-9]+\.[0-9]+' <<<"$pip_lines" >/dev/null; then | ||
| echo "FAIL: the pip install in \"$STEP_NAME\" must pin pyyaml to a specific" | ||
| echo " version (pyyaml==X.Y.Z) for reproducible installs (issue #1364)." | ||
|
don-petry marked this conversation as resolved.
Resolved
|
||
| fail=1 | ||
|
don-petry marked this conversation as resolved.
Resolved
|
||
| fi | ||
| fi | ||
|
|
||
| if [ "$fail" -eq 0 ]; then | ||
| echo "PASS: $WORKFLOW dependency install is retry-hardened and pinned" | ||
| fi | ||
| exit "$fail" | ||
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.
Uh oh!
There was an error while loading. Please reload this page.