@@ -76,87 +76,26 @@ jobs:
7676 # ---------------------------------------------------------------------------
7777 # Change detection — decides which downstream jobs actually run.
7878 # On push/workflow_dispatch every flag is true so all jobs execute.
79- # On pull_request we diff against the merge base (same approach as astral-sh/ruff) .
79+ # On pull_request we diff against the merge base.
8080 # ---------------------------------------------------------------------------
8181 determine-changes :
82- runs-on : ubuntu-latest
83- permissions :
84- contents : read
85- outputs :
86- unit_tests : ${{ github.event_name != 'pull_request' || steps.check.outputs.unit_tests == 'true' }}
87- type_check : ${{ github.event_name != 'pull_request' || steps.check.outputs.type_check == 'true' }}
88- e2e : ${{ github.event_name != 'pull_request' || steps.check.outputs.e2e == 'true' }}
89- e2e_js : ${{ github.event_name != 'pull_request' || steps.check.outputs.e2e_js == 'true' }}
90- e2e_java : ${{ github.event_name != 'pull_request' || steps.check.outputs.e2e_java == 'true' }}
91- steps :
92- - uses : actions/checkout@v6
93- if : github.event_name == 'pull_request'
94- with :
95- fetch-depth : 0
96-
97- - name : Determine merge base
98- if : github.event_name == 'pull_request'
99- id : merge_base
100- run : |
101- sha=$(git merge-base HEAD "origin/${{ github.event.pull_request.base.ref }}")
102- echo "sha=${sha}" >> "$GITHUB_OUTPUT"
103-
104- - name : Check changed paths
105- if : github.event_name == 'pull_request'
106- id : check
107- run : |
108- check_paths() {
109- local name="$1"; shift
110- if ! git diff --quiet "$MERGE_BASE...HEAD" -- "$@" 2>/dev/null; then
111- echo "${name}=true" >> "$GITHUB_OUTPUT"
112- else
113- echo "${name}=false" >> "$GITHUB_OUTPUT"
114- fi
115- }
116-
117- # Unit tests: code + test infra + packages + build config
118- check_paths unit_tests \
119- 'codeflash/' 'codeflash-benchmark/' \
120- 'tests/' 'packages/' 'pyproject.toml' 'uv.lock'
121-
122- # Type checking: code + build config + mypy config
123- check_paths type_check \
124- 'codeflash/' 'pyproject.toml' 'uv.lock' 'mypy_allowlist.txt'
125-
126- # E2E tests: Python pipeline + tests + build config (excludes java/ and javascript/)
127- check_paths e2e \
128- 'codeflash/*.py' \
129- 'codeflash/api/' 'codeflash/benchmarking/' 'codeflash/cli_cmds/' \
130- 'codeflash/code_utils/' 'codeflash/discovery/' 'codeflash/github/' \
131- 'codeflash/languages/python/' 'codeflash/languages/*.py' \
132- 'codeflash/lsp/' 'codeflash/models/' 'codeflash/optimization/' \
133- 'codeflash/picklepatch/' 'codeflash/result/' 'codeflash/setup/' \
134- 'codeflash/telemetry/' 'codeflash/tracing/' 'codeflash/verification/' \
135- 'tests/' 'pyproject.toml' 'uv.lock'
136-
137- # JS E2E tests: JS language support + shared pipeline + packages + test fixtures
138- check_paths e2e_js \
139- 'codeflash/languages/javascript/' 'codeflash/languages/base.py' \
140- 'codeflash/languages/registry.py' 'codeflash/optimization/' \
141- 'codeflash/verification/' 'packages/' \
142- 'code_to_optimize/js/' 'tests/scripts/end_to_end_test_js*'
143-
144- # Java E2E tests: Java language support + shared pipeline + runtime
145- check_paths e2e_java \
146- 'codeflash/languages/java/' 'codeflash/languages/base.py' \
147- 'codeflash/languages/registry.py' 'codeflash/optimization/' \
148- 'codeflash/verification/' 'codeflash-java-runtime/' \
149- 'code_to_optimize/java/' 'tests/scripts/end_to_end_test_java*' \
150- 'tests/test_languages/fixtures/java_tracer_e2e/'
151- env :
152- MERGE_BASE : ${{ steps.merge_base.outputs.sha }}
82+ uses : codeflash-ai/github-workflows/.github/workflows/determine-changes.yml@main
83+ with :
84+ path-filters : |
85+ {
86+ "unit_tests": ["codeflash/", "codeflash-benchmark/", "tests/", "packages/", "pyproject.toml", "uv.lock"],
87+ "type_check": ["codeflash/", "pyproject.toml", "uv.lock", "mypy_allowlist.txt"],
88+ "e2e": ["codeflash/*.py", "codeflash/api/", "codeflash/benchmarking/", "codeflash/cli_cmds/", "codeflash/code_utils/", "codeflash/discovery/", "codeflash/github/", "codeflash/languages/python/", "codeflash/languages/*.py", "codeflash/lsp/", "codeflash/models/", "codeflash/optimization/", "codeflash/picklepatch/", "codeflash/result/", "codeflash/setup/", "codeflash/telemetry/", "codeflash/tracing/", "codeflash/verification/", "tests/", "pyproject.toml", "uv.lock"],
89+ "e2e_js": ["codeflash/languages/javascript/", "codeflash/languages/base.py", "codeflash/languages/registry.py", "codeflash/optimization/", "codeflash/verification/", "packages/", "code_to_optimize/js/", "tests/scripts/end_to_end_test_js*"],
90+ "e2e_java": ["codeflash/languages/java/", "codeflash/languages/base.py", "codeflash/languages/registry.py", "codeflash/optimization/", "codeflash/verification/", "codeflash-java-runtime/", "code_to_optimize/java/", "tests/scripts/end_to_end_test_java*", "tests/test_languages/fixtures/java_tracer_e2e/"]
91+ }
15392
15493 # ---------------------------------------------------------------------------
15594 # Unit tests — 6 Linux + 1 Windows matrix
15695 # ---------------------------------------------------------------------------
15796 unit-tests :
15897 needs : determine-changes
159- if : needs.determine-changes.outputs.unit_tests == 'true'
98+ if : fromJSON( needs.determine-changes.outputs.flags) .unit_tests == 'true'
16099 strategy :
161100 fail-fast : false
162101 matrix :
@@ -207,7 +146,7 @@ jobs:
207146 # ---------------------------------------------------------------------------
208147 coverage :
209148 needs : determine-changes
210- if : needs.determine-changes.outputs.unit_tests == 'true'
149+ if : fromJSON( needs.determine-changes.outputs.flags) .unit_tests == 'true'
211150 runs-on : ubuntu-latest
212151 env :
213152 PYTHONIOENCODING : utf-8
@@ -245,7 +184,7 @@ jobs:
245184 # ---------------------------------------------------------------------------
246185 type-check :
247186 needs : determine-changes
248- if : needs.determine-changes.outputs.type_check == 'true'
187+ if : fromJSON( needs.determine-changes.outputs.flags) .type_check == 'true'
249188 runs-on : ubuntu-latest
250189 steps :
251190 - uses : actions/checkout@v6
@@ -271,39 +210,15 @@ jobs:
271210 needs : determine-changes
272211 if : >-
273212 github.event_name == 'pull_request'
274- && (needs.determine-changes.outputs.e2e == 'true'
275- || needs.determine-changes.outputs.e2e_js == 'true')
276- runs-on : ubuntu-latest
213+ && (fromJSON( needs.determine-changes.outputs.flags) .e2e == 'true'
214+ || fromJSON( needs.determine-changes.outputs.flags) .e2e_js == 'true')
215+ uses : codeflash-ai/github-workflows/.github/workflows/prek-lint.yml@main
277216 permissions :
278217 contents : write
279- steps :
280- - uses : actions/checkout@v6
281- with :
282- ref : ${{ github.head_ref }}
283- fetch-depth : 0
284- - uses : astral-sh/setup-uv@v8.0.0
285- with :
286- enable-cache : true
287-
288- - name : Auto-fix formatting
289- run : |
290- uv run ruff check --fix . || true
291- uv run ruff format .
292- # uv-dynamic-versioning rewrites version.py on every `uv run` — discard those changes
293- git checkout HEAD -- codeflash/version.py codeflash-benchmark/codeflash_benchmark/version.py 2>/dev/null || true
294-
295- - name : Commit and push fixes
296- run : |
297- git diff --quiet && exit 0
298- git config user.name "github-actions[bot]"
299- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
300- git add -u
301- git commit -m "style: auto-format with ruff"
302- git push
303-
304- - uses : j178/prek-action@v2
305- with :
306- extra-args : ' --from-ref origin/${{ github.base_ref }} --to-ref HEAD'
218+ with :
219+ auto-fix : true
220+ checkout-ref : ${{ github.head_ref }}
221+ restore-paths : " codeflash/version.py codeflash-benchmark/codeflash_benchmark/version.py"
307222
308223 # ---------------------------------------------------------------------------
309224 # E2E tests — only on pull_request and workflow_dispatch (not push to main)
@@ -313,7 +228,7 @@ jobs:
313228 e2e-python :
314229 needs : determine-changes
315230 if : >-
316- needs.determine-changes.outputs.e2e == 'true'
231+ fromJSON( needs.determine-changes.outputs.flags) .e2e == 'true'
317232 && github.event_name != 'push'
318233 strategy :
319234 fail-fast : false
@@ -416,7 +331,7 @@ jobs:
416331 e2e-js :
417332 needs : determine-changes
418333 if : >-
419- needs.determine-changes.outputs.e2e_js == 'true'
334+ fromJSON( needs.determine-changes.outputs.flags) .e2e_js == 'true'
420335 && github.event_name != 'push'
421336 strategy :
422337 fail-fast : false
@@ -497,7 +412,7 @@ jobs:
497412 e2e-java :
498413 needs : determine-changes
499414 if : >-
500- needs.determine-changes.outputs.e2e_java == 'true'
415+ fromJSON( needs.determine-changes.outputs.flags) .e2e_java == 'true'
501416 && github.event_name != 'push'
502417 strategy :
503418 fail-fast : false
@@ -605,13 +520,6 @@ jobs:
605520 - e2e-java
606521 runs-on : ubuntu-latest
607522 steps :
608- - name : Verify all required jobs passed
609- run : |
610- failing=$(echo "$NEEDS_JSON" | jq -r 'to_entries[] | select(.value.result != "success" and .value.result != "skipped") | "\(.key): \(.value.result)"')
611- if [ -n "$failing" ]; then
612- echo "Required jobs failed or were cancelled:"
613- echo "$failing"
614- exit 1
615- fi
616- env :
617- NEEDS_JSON : ${{ toJSON(needs) }}
523+ - uses : codeflash-ai/github-workflows/.github/actions/required-checks-gate@main
524+ with :
525+ needs-json : ${{ toJSON(needs) }}
0 commit comments