Skip to content

Commit d97f372

Browse files
committed
ci: narrow paths, extract validate-pr, remove continue-on-error
- Remove codeflash-java-runtime/ from unit_tests change detection - Narrow e2e flag from codeflash/ to explicit Python subdirs (excludes java/, javascript/) - Narrow tests/ in e2e_java/e2e_js to specific test scripts - Extract duplicated Validate PR step into composite action - Use fetch-depth: 1 for unit-tests and type-check (no git history needed) - Remove continue-on-error: true from unit-tests (was masking real failures) - Change git add -A to git add -u in prek auto-fix (won't stage untracked files)
1 parent 82249ef commit d97f372

2 files changed

Lines changed: 70 additions & 55 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Validate PR
2+
description: Ensure only authorized users can modify workflow files in PRs
3+
inputs:
4+
base_sha:
5+
description: Base commit SHA of the pull request
6+
required: true
7+
head_sha:
8+
description: Head commit SHA of the pull request
9+
required: true
10+
author:
11+
description: Login of the PR author
12+
required: true
13+
pr_state:
14+
description: State of the pull request (open/closed)
15+
required: true
16+
runs:
17+
using: composite
18+
steps:
19+
- name: Check workflow file changes
20+
shell: bash
21+
run: |
22+
if git diff --name-only "${{ inputs.base_sha }}" "${{ inputs.head_sha }}" | grep -q "^.github/workflows/"; then
23+
echo "Workflow changes detected."
24+
AUTHOR="${{ inputs.author }}"
25+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
26+
echo "Authorized user ($AUTHOR). Proceeding."
27+
elif [[ "${{ inputs.pr_state }}" == "open" ]]; then
28+
echo "PR is open. Protection rules in place. Proceeding."
29+
else
30+
echo "Unauthorized user ($AUTHOR). Exiting."
31+
exit 1
32+
fi
33+
else
34+
echo "No workflow file changes. Proceeding."
35+
fi

.github/workflows/ci.yaml

Lines changed: 35 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -61,31 +61,39 @@ jobs:
6161
fi
6262
}
6363
64-
# Unit tests: code + test infra + java + packages + build config
64+
# Unit tests: code + test infra + packages + build config
6565
check_paths unit_tests \
66-
'codeflash/' 'codeflash-benchmark/' 'codeflash-java-runtime/' \
66+
'codeflash/' 'codeflash-benchmark/' \
6767
'tests/' 'packages/' 'pyproject.toml' 'uv.lock'
6868
6969
# Type checking: code + build config + mypy config
7070
check_paths type_check \
7171
'codeflash/' 'pyproject.toml' 'uv.lock' 'mypy_allowlist.txt'
7272
73-
# E2E tests: code + tests + build config
73+
# E2E tests: Python pipeline + tests + build config (excludes java/ and javascript/)
7474
check_paths e2e \
75-
'codeflash/' 'tests/' 'pyproject.toml' 'uv.lock'
75+
'codeflash/*.py' \
76+
'codeflash/api/' 'codeflash/benchmarking/' 'codeflash/cli_cmds/' \
77+
'codeflash/code_utils/' 'codeflash/discovery/' 'codeflash/github/' \
78+
'codeflash/languages/python/' 'codeflash/languages/*.py' \
79+
'codeflash/lsp/' 'codeflash/models/' 'codeflash/optimization/' \
80+
'codeflash/picklepatch/' 'codeflash/result/' 'codeflash/setup/' \
81+
'codeflash/telemetry/' 'codeflash/tracing/' 'codeflash/verification/' \
82+
'tests/' 'pyproject.toml' 'uv.lock'
7683
7784
# JS E2E tests: JS language support + shared pipeline + packages
7885
check_paths e2e_js \
7986
'codeflash/languages/javascript/' 'codeflash/languages/base.py' \
8087
'codeflash/languages/registry.py' 'codeflash/optimization/' \
81-
'codeflash/verification/' 'packages/' 'tests/'
88+
'codeflash/verification/' 'packages/' \
89+
'tests/scripts/end_to_end_test_js*'
8290
8391
# Java E2E tests: Java language support + shared pipeline + runtime
8492
check_paths e2e_java \
8593
'codeflash/languages/java/' 'codeflash/languages/base.py' \
8694
'codeflash/languages/registry.py' 'codeflash/optimization/' \
8795
'codeflash/verification/' 'codeflash-java-runtime/' \
88-
'code_to_optimize/java/' 'tests/'
96+
'code_to_optimize/java/' 'tests/scripts/end_to_end_test_java*'
8997
env:
9098
MERGE_BASE: ${{ steps.merge_base.outputs.sha }}
9199

@@ -113,14 +121,13 @@ jobs:
113121
python-version: "3.14"
114122
- os: windows-latest
115123
python-version: "3.13"
116-
continue-on-error: true
117124
runs-on: ${{ matrix.os }}
118125
env:
119126
PYTHONIOENCODING: utf-8
120127
steps:
121128
- uses: actions/checkout@v4
122129
with:
123-
fetch-depth: 0
130+
fetch-depth: 1
124131
token: ${{ secrets.GITHUB_TOKEN }}
125132

126133
- name: Install uv
@@ -148,7 +155,7 @@ jobs:
148155
steps:
149156
- uses: actions/checkout@v4
150157
with:
151-
fetch-depth: 0
158+
fetch-depth: 1
152159
token: ${{ secrets.GITHUB_TOKEN }}
153160

154161
- name: Install uv
@@ -191,7 +198,7 @@ jobs:
191198
git diff --quiet && exit 0
192199
git config user.name "github-actions[bot]"
193200
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
194-
git add -A
201+
git add -u
195202
git commit -m "style: auto-format with ruff"
196203
git push
197204
@@ -260,21 +267,12 @@ jobs:
260267

261268
- name: Validate PR
262269
if: github.event_name == 'pull_request'
263-
run: |
264-
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then
265-
echo "Workflow changes detected."
266-
AUTHOR="${{ github.event.pull_request.user.login }}"
267-
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
268-
echo "Authorized user ($AUTHOR). Proceeding."
269-
elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then
270-
echo "PR is open. Protection rules in place. Proceeding."
271-
else
272-
echo "Unauthorized user ($AUTHOR). Exiting."
273-
exit 1
274-
fi
275-
else
276-
echo "No workflow file changes. Proceeding."
277-
fi
270+
uses: ./.github/actions/validate-pr
271+
with:
272+
base_sha: ${{ github.event.pull_request.base.sha }}
273+
head_sha: ${{ github.event.pull_request.head.sha }}
274+
author: ${{ github.event.pull_request.user.login }}
275+
pr_state: ${{ github.event.pull_request.state }}
278276

279277
- name: Install uv
280278
uses: astral-sh/setup-uv@v8.0.0
@@ -357,21 +355,12 @@ jobs:
357355

358356
- name: Validate PR
359357
if: github.event_name == 'pull_request'
360-
run: |
361-
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then
362-
echo "Workflow changes detected."
363-
AUTHOR="${{ github.event.pull_request.user.login }}"
364-
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
365-
echo "Authorized user ($AUTHOR). Proceeding."
366-
elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then
367-
echo "PR is open. Protection rules in place. Proceeding."
368-
else
369-
echo "Unauthorized user ($AUTHOR). Exiting."
370-
exit 1
371-
fi
372-
else
373-
echo "No workflow file changes. Proceeding."
374-
fi
358+
uses: ./.github/actions/validate-pr
359+
with:
360+
base_sha: ${{ github.event.pull_request.base.sha }}
361+
head_sha: ${{ github.event.pull_request.head.sha }}
362+
author: ${{ github.event.pull_request.user.login }}
363+
pr_state: ${{ github.event.pull_request.state }}
375364

376365
- name: Set up Node.js
377366
uses: actions/setup-node@v4
@@ -441,21 +430,12 @@ jobs:
441430

442431
- name: Validate PR
443432
if: github.event_name == 'pull_request'
444-
run: |
445-
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then
446-
echo "Workflow changes detected."
447-
AUTHOR="${{ github.event.pull_request.user.login }}"
448-
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
449-
echo "Authorized user ($AUTHOR). Proceeding."
450-
elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then
451-
echo "PR is open. Protection rules in place. Proceeding."
452-
else
453-
echo "Unauthorized user ($AUTHOR). Exiting."
454-
exit 1
455-
fi
456-
else
457-
echo "No workflow file changes. Proceeding."
458-
fi
433+
uses: ./.github/actions/validate-pr
434+
with:
435+
base_sha: ${{ github.event.pull_request.base.sha }}
436+
head_sha: ${{ github.event.pull_request.head.sha }}
437+
author: ${{ github.event.pull_request.user.login }}
438+
pr_state: ${{ github.event.pull_request.state }}
459439

460440
- name: Set up JDK 11
461441
uses: actions/setup-java@v4

0 commit comments

Comments
 (0)