Skip to content

Commit 30f73c9

Browse files
authored
Simplify required PR checks (#155)
## Summary\n- add a single Required CI workflow for PR-time focused tests\n- move legacy unit/parse/integration suites to develop push/manual runs\n- include diagnose in the CLI smoke script\n\n## Verification\n- uv run pytest -n auto --timeout 15 tests/unit/cli/commands tests/unit/sdk/codebase/test_rust_backend.py tests/unit/sdk/codebase/test_rust_rewrite_readiness.py -q\n- rust-rewrite/tools/check_cli_smoke.sh\n- uv run python YAML parse check for changed workflows
1 parent 51cc3c1 commit 30f73c9

4 files changed

Lines changed: 53 additions & 173 deletions

File tree

.github/workflows/required-ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Required CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "develop"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ${{ github.workflow_ref }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
required-checks:
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 8
20+
steps:
21+
- name: Check out repository
22+
uses: actions/checkout@v4
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v5.4
26+
with:
27+
enable-cache: true
28+
prune-cache: false
29+
python-version: "3.13"
30+
version: "0.9.1"
31+
cache-suffix: required-ci
32+
33+
- name: Install Python dependencies
34+
run: uv sync --frozen
35+
36+
- name: Run required checks
37+
run: |
38+
uv run pytest \
39+
-n auto \
40+
--timeout 15 \
41+
tests/unit/cli/commands \
42+
tests/unit/sdk/codebase/test_rust_backend.py \
43+
tests/unit/sdk/codebase/test_rust_rewrite_readiness.py \
44+
-q

.github/workflows/test.yml

Lines changed: 4 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,29 @@
1-
name: Tests
1+
name: Legacy Tests
22

33
on:
44
push:
55
branches:
66
- "develop"
7-
pull_request_target:
8-
types: [opened, synchronize, reopened, labeled]
9-
branches:
10-
- "develop"
117
workflow_dispatch:
128

13-
jobs:
14-
access-check:
15-
runs-on: ubuntu-latest
16-
steps:
17-
- name: Check if bot account
18-
id: bot-check
19-
run: |
20-
actor="${{ github.triggering_actor }}"
21-
echo "Checking actor: $actor"
22-
if [[ "$actor" == *"[bot]" ]] || [[ "$actor" == "renovate" ]] || [[ "$actor" == "dependabot" ]]; then
23-
echo "is_bot=true" >> $GITHUB_OUTPUT
24-
echo "Detected bot account: $actor - skipping permission check"
25-
exit 0
26-
else
27-
echo "is_bot=false" >> $GITHUB_OUTPUT
28-
echo "Detected human account: $actor"
29-
fi
30-
- name: Check user permissions
31-
if: steps.bot-check.outputs.is_bot == 'false'
32-
uses: actions-cool/check-user-permission@v2
33-
with:
34-
require: write
35-
username: ${{ github.triggering_actor }}
36-
error-if-missing: true
37-
38-
legacy-test-scope:
39-
needs: access-check
40-
runs-on: ubuntu-latest
41-
outputs:
42-
run_legacy_tests: ${{ steps.scope.outputs.run_legacy_tests }}
43-
steps:
44-
- name: Detect changes requiring legacy tests
45-
id: scope
46-
env:
47-
GH_TOKEN: ${{ github.token }}
48-
GH_EVENT_NAME: ${{ github.event_name }}
49-
PR_NUMBER: ${{ github.event.pull_request.number }}
50-
REPOSITORY: ${{ github.repository }}
51-
run: |
52-
if [[ "$GH_EVENT_NAME" != "pull_request_target" ]]; then
53-
echo "run_legacy_tests=true" >> "$GITHUB_OUTPUT"
54-
exit 0
55-
fi
56-
57-
run_legacy_tests=false
58-
while IFS= read -r file; do
59-
case "$file" in
60-
.codegen/*|.github/actions/*|.github/workflows/test.yml|Cargo.lock|Cargo.toml|Dockerfile|hatch.toml|mypy.ini|pyproject.toml|ruff.toml|uv.lock|crates/*|examples/*|rust-rewrite/tools/*|scripts/*|src/*|tests/*)
61-
run_legacy_tests=true
62-
;;
63-
esac
64-
done < <(gh api --paginate "repos/$REPOSITORY/pulls/$PR_NUMBER/files" --jq '.[].filename')
65-
66-
echo "run_legacy_tests=$run_legacy_tests" >> "$GITHUB_OUTPUT"
67-
if [[ "$run_legacy_tests" == "true" ]]; then
68-
echo "Code, package, test, or workflow files changed; running legacy tests."
69-
else
70-
echo "Only docs/site/planning files changed; skipping expensive legacy tests."
71-
fi
9+
permissions:
10+
contents: read
7211

12+
jobs:
7313
unit-tests:
74-
needs: [access-check, legacy-test-scope]
7514
runs-on: ubuntu-latest
7615
strategy:
7716
matrix:
7817
group: [1, 2, 3, 4, 5, 6, 7, 8]
79-
8018
steps:
81-
- name: Skip legacy unit tests
82-
if: ${{ needs.legacy-test-scope.outputs.run_legacy_tests != 'true' }}
83-
run: echo "Only docs/site/planning files changed; skipping legacy unit test shard ${{ matrix.group }}."
84-
8519
- uses: actions/checkout@v4
86-
if: ${{ needs.legacy-test-scope.outputs.run_legacy_tests == 'true' }}
8720
with:
8821
fetch-depth: 0
89-
ref: ${{ github.event.pull_request.head.sha }}
9022

9123
- name: Setup environment
92-
if: ${{ needs.legacy-test-scope.outputs.run_legacy_tests == 'true' }}
9324
uses: ./.github/actions/setup-environment
9425

9526
- name: Test with pytest
96-
if: ${{ needs.legacy-test-scope.outputs.run_legacy_tests == 'true' }}
9727
timeout-minutes: 5
9828
run: |
9929
uv run pytest \
@@ -105,61 +35,14 @@ jobs:
10535
tests/unit
10636
10737
- uses: ./.github/actions/report
108-
if: ${{ needs.legacy-test-scope.outputs.run_legacy_tests == 'true' }}
10938
with:
11039
flag: unit-tests
11140
codecov_token: ${{ secrets.CODECOV_TOKEN }}
11241

113-
codemod-tests:
114-
needs: access-check
115-
# TODO: re-enable when this check is a develop required check
116-
if: false
117-
runs-on: ubuntu-latest
118-
strategy:
119-
matrix:
120-
sync_graph: [true, false]
121-
size: [small, large]
122-
exclude:
123-
# Exclude large codemod tests when not needed
124-
- size: ${{(contains(github.event.pull_request.labels.*.name, 'big-codemod-tests') || github.event_name == 'push' || github.event_name == 'workflow_dispatch') && 'kevin' || 'large'}}
125-
- size: large
126-
sync_graph: true
127-
concurrency:
128-
group: ${{ github.workflow }}-${{github.ref}}-${{matrix.sync_graph}}-${{matrix.size}}-${{github.event_name == 'push'&& github.sha}}
129-
cancel-in-progress: true
130-
name: "Codemod tests ${{matrix.size}}: Sync Graph=${{matrix.sync_graph}}"
131-
steps:
132-
- uses: actions/checkout@v4
133-
with:
134-
ref: ${{ github.event.pull_request.head.sha }}
135-
136-
- name: Setup environment
137-
uses: ./.github/actions/setup-environment
138-
139-
- name: Cache oss-repos
140-
uses: ./.github/actions/setup-oss-repos
141-
142-
- name: Run ATS and Tests
143-
uses: ./.github/actions/run-ats
144-
timeout-minutes: 15
145-
with:
146-
default_tests: "tests/integration/codemod/test_codemods.py"
147-
codecov_static_token: ${{ secrets.CODECOV_STATIC_TOKEN }}
148-
codecov_token: ${{ secrets.CODECOV_TOKEN }}
149-
collect_args: "--size=${{matrix.size}} --sync-graph=${{matrix.sync_graph}}"
150-
ats_collect_args: "--size=${{matrix.size}},--sync-graph=${{matrix.sync_graph}},"
151-
codecov_flags: codemod-tests-${{matrix.size}}-${{matrix.sync_graph}}
152-
env:
153-
GITHUB_WORKSPACE: $GITHUB_WORKSPACE
154-
15542
parse-tests:
156-
needs: access-check
157-
if: contains(github.event.pull_request.labels.*.name, 'parse-tests') || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
15843
runs-on: ubuntu-latest
15944
steps:
16045
- uses: actions/checkout@v4
161-
with:
162-
ref: ${{ github.event.pull_request.head.sha }}
16346

16447
- name: Setup environment
16548
uses: ./.github/actions/setup-environment
@@ -187,65 +70,15 @@ jobs:
18770
flag: no-flag
18871
codecov_token: ${{ secrets.CODECOV_TOKEN }}
18972

190-
- name: Notify parse tests failure
191-
uses: slackapi/slack-github-action@v2.1.1
192-
if: failure() && github.event_name == 'push' && false
193-
with:
194-
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
195-
webhook-type: incoming-webhook
196-
payload: |
197-
{
198-
"blocks": [
199-
{
200-
"type": "header",
201-
"text": {
202-
"type": "plain_text",
203-
"text": "❌ Parse Tests Failed",
204-
"emoji": true
205-
}
206-
},
207-
{
208-
"type": "section",
209-
"text": {
210-
"type": "mrkdwn",
211-
"text": "*Branch:* ${{ github.ref_name }}\n*Triggered by:* <${{ github.server_url }}/${{ github.actor }}|@${{ github.actor }}>\n\n*Details:*\n• <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View workflow run>"
212-
}
213-
},
214-
{
215-
"type": "context",
216-
"elements": [
217-
{
218-
"type": "mrkdwn",
219-
"text": "Failed at <!date^${{ github.event.head_commit.timestamp }}^{date_num} {time}|just now>"
220-
}
221-
]
222-
}
223-
]
224-
}
225-
22673
integration-tests:
227-
needs: [access-check, legacy-test-scope]
228-
# The rust-rewrite baseline PR keeps protected checks focused on local unit,
229-
# Rust, wheel, docs, and large-repo proof. These legacy integration tests push
230-
# branches to an external fixture repo and require a writable PAT.
231-
if: ${{ github.event_name != 'pull_request_target' || github.event.pull_request.head.ref != 'rust-rewrite' }}
23274
runs-on: ubuntu-latest
23375
steps:
234-
- name: Skip legacy integration tests
235-
if: ${{ needs.legacy-test-scope.outputs.run_legacy_tests != 'true' }}
236-
run: echo "Only docs/site/planning files changed; skipping legacy integration tests."
237-
23876
- uses: actions/checkout@v4
239-
if: ${{ needs.legacy-test-scope.outputs.run_legacy_tests == 'true' }}
240-
with:
241-
ref: ${{ github.event.pull_request.head.sha }}
24277

24378
- name: Setup environment
244-
if: ${{ needs.legacy-test-scope.outputs.run_legacy_tests == 'true' }}
24579
uses: ./.github/actions/setup-environment
24680

24781
- name: Test with pytest
248-
if: ${{ needs.legacy-test-scope.outputs.run_legacy_tests == 'true' }}
24982
timeout-minutes: 5
25083
env:
25184
GITHUB_WORKSPACE: $GITHUB_WORKSPACE
@@ -257,7 +90,6 @@ jobs:
25790
tests/integration/codegen
25891
25992
- uses: ./.github/actions/report
260-
if: ${{ needs.legacy-test-scope.outputs.run_legacy_tests == 'true' }}
26193
with:
26294
flag: integration-tests
26395
codecov_token: ${{ secrets.CODECOV_TOKEN }}

rust-rewrite/tools/check_cli_smoke.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ cd "$ROOT"
66

77
CLI_FILES=(
88
src/graph_sitter/cli/cli.py
9+
src/graph_sitter/cli/commands/diagnose/main.py
910
src/graph_sitter/cli/commands/doctor/main.py
1011
src/graph_sitter/cli/commands/parse/main.py
1112
src/graph_sitter/cli/commands/run/main.py
1213
src/graph_sitter/cli/commands/run/run_local.py
1314
src/graph_sitter/cli/commands/transform/main.py
15+
tests/unit/cli/commands/diagnose/test_diagnose.py
1416
tests/unit/cli/commands/parse/test_parse.py
1517
tests/unit/cli/commands/run/test_run.py
1618
tests/unit/cli/commands/transform/test_transform.py
@@ -20,13 +22,15 @@ uv run ruff check "${CLI_FILES[@]}"
2022
uv run python -m py_compile "${CLI_FILES[@]}"
2123

2224
uv run graph-sitter --help >/dev/null
25+
uv run graph-sitter diagnose --help >/dev/null
2326
uv run graph-sitter doctor --help >/dev/null
2427
uv run graph-sitter doctor --json >/dev/null
2528
uv run graph-sitter parse --help >/dev/null
2629
uv run graph-sitter run --help >/dev/null
2730
uv run graph-sitter transform --help >/dev/null
2831

2932
uv run pytest \
33+
tests/unit/cli/commands/diagnose/test_diagnose.py \
3034
tests/unit/cli/commands/parse/test_parse.py \
3135
tests/unit/cli/commands/run/test_run.py \
3236
tests/unit/cli/commands/transform/test_transform.py \

src/graph_sitter/cli/commands/diagnose/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def _memory_payload(samples: list[dict[str, float | str]]) -> dict[str, float |
4848
start_rss = float(samples[0]["rss_mb"])
4949
after_parse_rss = float(samples[1]["rss_mb"])
5050
after_stats_rss = float(samples[-1]["rss_mb"])
51-
peak_rss = max(float(sample["max_rss_mb"]) for sample in samples)
51+
peak_rss = max(max(float(sample["rss_mb"]), float(sample["max_rss_mb"])) for sample in samples)
5252
return {
5353
"rss_start_mb": round(start_rss, 3),
5454
"rss_after_parse_mb": round(after_parse_rss, 3),

0 commit comments

Comments
 (0)