Repository navigation
feat: implement issue #512 — [Fleet Monitor] petry-projects/.github-private — test-dev-lead.yml #529
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
feat: implement issue #512 — [Fleet Monitor] petry-projects/.github-private — test-dev-lead.yml #529
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f87a2a2
feat: implement issue #512 — [Fleet Monitor] petry-projects/.github-p…
4134392
fix(reviews): address review comments [skip ci-relay]
donpetry-bot 4e1bc4e
Merge branch 'main' into dev-lead/issue-512-20260609-2133
don-petry 1d6c064
fix(reviews): address review comments [skip ci-relay]
donpetry-bot 9f10d5a
Merge branch 'main' into dev-lead/issue-512-20260609-2133
don-petry fd2bca8
Merge branch 'main' into dev-lead/issue-512-20260609-2133
don-petry 6b3675b
Merge branch 'main' into dev-lead/issue-512-20260609-2133
don-petry ae8e251
Merge branch 'main' into dev-lead/issue-512-20260609-2133
don-petry c575caf
Merge branch 'main' into dev-lead/issue-512-20260609-2133
donpetry-bot 869a5df
Merge branch 'main' into dev-lead/issue-512-20260609-2133
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,167 @@ | ||
| #!/usr/bin/env bats | ||
| # Unit tests for tests/dev-lead/integration/test_concurrency_config.sh | ||
| # | ||
| # Regression guard for the silent-exit bug: when a workflow file has no | ||
| # concurrency block, grep -v '^\s*#' on empty input exits 1. With | ||
| # set -euo pipefail active, bash triggers set -e on the block=$(...|grep) | ||
| # assignment in non-interactive (script) mode, causing test_concurrency_config.sh | ||
| # to exit silently (no FAIL messages, no diagnostic output) — making failures | ||
| # look like infra noise rather than real test failures. | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/../../.." && pwd)" | ||
| readonly SCRIPT_DIR | ||
| CONCURRENCY_TEST="$SCRIPT_DIR/tests/dev-lead/integration/test_concurrency_config.sh" | ||
| readonly CONCURRENCY_TEST | ||
|
|
||
| setup() { | ||
| WORK_DIR="$(mktemp -d)" || { | ||
| echo "ERROR: Failed to create temporary directory" >&2 | ||
| exit 1 | ||
| } | ||
| mkdir -p "$WORK_DIR/.github/workflows" | ||
| # Run the script from WORK_DIR so its relative .github/workflows/ paths resolve | ||
| pushd "$WORK_DIR" > /dev/null || { | ||
| echo "ERROR: Failed to change to test directory" >&2 | ||
| exit 1 | ||
| } | ||
| } | ||
|
|
||
| teardown() { | ||
| popd > /dev/null 2>&1 || true | ||
| if [ -n "${WORK_DIR:-}" ]; then | ||
| rm -rf "$WORK_DIR" | ||
| fi | ||
| } | ||
|
don-petry marked this conversation as resolved.
|
||
|
|
||
| _write_proper_reusable() { | ||
| cat > "$WORK_DIR/.github/workflows/dev-lead-reusable.yml" << 'YAML' | ||
| name: Dev-Lead Agent (Reusable) | ||
| on: | ||
| workflow_call: {} | ||
| permissions: {} | ||
| concurrency: | ||
| group: >- | ||
| ${{ | ||
| (github.event_name == 'check_run' && format('dev-lead-ci-relay-{0}', github.event.check_run.head_sha)) | ||
| || (github.event.pull_request.number && format('dev-lead-pr-{0}', github.event.pull_request.number)) | ||
| || (github.event.issue.pull_request && format('dev-lead-pr-{0}', github.event.issue.number)) | ||
| || (github.event.issue.number && format('dev-lead-issue-{0}', github.event.issue.number)) | ||
| || (github.event.client_payload.pr_number && format('dev-lead-pr-{0}', github.event.client_payload.pr_number)) | ||
| || format('dev-lead-run-{0}', github.run_id) | ||
| }} | ||
| cancel-in-progress: false | ||
| jobs: | ||
| dispatch: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - run: echo ok | ||
| YAML | ||
| } | ||
|
|
||
| _write_proper_inline() { | ||
| cat > "$WORK_DIR/.github/workflows/dev-lead.yml" << 'YAML' | ||
| name: Dev-Lead Agent | ||
| on: | ||
| issues: | ||
| types: [labeled] | ||
| permissions: | ||
| contents: write | ||
| concurrency: | ||
| group: >- | ||
| ${{ | ||
| (github.event_name == 'check_run' && format('dev-lead-ci-relay-{0}', github.event.check_run.head_sha)) | ||
| || (github.event.pull_request.number && format('dev-lead-pr-{0}', github.event.pull_request.number)) | ||
| || (github.event.issue.pull_request && format('dev-lead-pr-{0}', github.event.issue.number)) | ||
| || (github.event.issue.number && format('dev-lead-issue-{0}', github.event.issue.number)) | ||
| || (github.event.client_payload.pr_number && format('dev-lead-pr-{0}', github.event.client_payload.pr_number)) | ||
| || format('dev-lead-run-{0}', github.run_id) | ||
| }} | ||
| cancel-in-progress: false | ||
| jobs: | ||
| dispatch: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - run: echo ok | ||
| YAML | ||
| } | ||
|
|
||
| # ── silent-exit regression tests ───────────────────────────────────────────── | ||
|
|
||
| @test "concurrency-config: exit 1 with FAIL output when dev-lead.yml has no concurrency block" { | ||
| # Stub caller — intentionally no concurrency block at all | ||
| cat > "$WORK_DIR/.github/workflows/dev-lead.yml" << 'YAML' | ||
| name: Dev-Lead Agent | ||
| on: | ||
| issues: | ||
| types: [labeled] | ||
| permissions: {} | ||
| jobs: | ||
| dev-lead: | ||
| uses: petry-projects/.github-private/.github/workflows/dev-lead-reusable.yml@main | ||
| secrets: inherit | ||
| YAML | ||
| _write_proper_reusable | ||
|
|
||
| run bash "$CONCURRENCY_TEST" | ||
|
|
||
| [ "$status" -eq 1 ] | ||
| # Must produce FAIL output — not a silent exit | ||
| [[ "$output" =~ "FAIL" ]] | ||
| } | ||
|
|
||
| @test "concurrency-config: exit 1 with FAIL output when dev-lead.yml concurrency block is comments-only" { | ||
| # Concurrency section exists but all content lines are comments — effectively empty | ||
| cat > "$WORK_DIR/.github/workflows/dev-lead.yml" << 'YAML' | ||
| name: Dev-Lead Agent | ||
| on: | ||
| issues: | ||
| types: [labeled] | ||
| concurrency: | ||
| # This comment-only block should not satisfy any assertion | ||
| # group: intentionally omitted | ||
| # cancel-in-progress: intentionally omitted | ||
| jobs: | ||
| dispatch: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - run: echo ok | ||
| YAML | ||
| _write_proper_reusable | ||
|
|
||
| run bash "$CONCURRENCY_TEST" | ||
|
|
||
| [ "$status" -eq 1 ] | ||
| [[ "$output" =~ "FAIL" ]] | ||
| } | ||
|
|
||
| @test "concurrency-config: exit 1 with FAIL output when dev-lead-reusable.yml has no concurrency block" { | ||
| _write_proper_inline | ||
| cat > "$WORK_DIR/.github/workflows/dev-lead-reusable.yml" << 'YAML' | ||
| name: Dev-Lead Agent (Reusable) | ||
| on: | ||
| workflow_call: {} | ||
| permissions: {} | ||
| jobs: | ||
| dispatch: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - run: echo ok | ||
| YAML | ||
|
|
||
| run bash "$CONCURRENCY_TEST" | ||
|
|
||
| [ "$status" -eq 1 ] | ||
| [[ "$output" =~ "FAIL" ]] | ||
| } | ||
|
|
||
| # ── passing baseline ────────────────────────────────────────────────────────── | ||
|
|
||
| @test "concurrency-config: passes when both files have correct concurrency config" { | ||
| _write_proper_inline | ||
| _write_proper_reusable | ||
|
|
||
| run bash "$CONCURRENCY_TEST" | ||
|
|
||
| [ "$status" -eq 0 ] | ||
| [[ "$output" =~ "All concurrency config checks passed." ]] | ||
| } | ||
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.