Skip to content

Commit 904b3ab

Browse files
ci(py): autodetect services dir; guard steps
1 parent 3b878d9 commit 904b3ab

1 file changed

Lines changed: 29 additions & 24 deletions

File tree

.github/workflows/python-services.yml

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,56 @@ concurrency:
88
jobs:
99
services:
1010
runs-on: ubuntu-latest
11-
defaults:
12-
run:
13-
working-directory: python-services # <- adjust if your folder name differs
1411
steps:
1512
- uses: actions/checkout@v4
16-
1713
- uses: actions/setup-python@v5
1814
with:
1915
python-version: "3.11"
2016

21-
- name: Cache pip
22-
uses: actions/cache@v4
23-
with:
24-
path: ~/.cache/pip
25-
key: ${{ runner.os }}-pip-${{ hashFiles('python-services/requirements.txt') }}
26-
27-
- name: Install deps
17+
- name: Detect Python dir
18+
shell: bash
19+
run: |
20+
set -e
21+
PY_DIR=""
22+
for C in services backend api server apps/* packages/* .; do
23+
if [ -f "$C/requirements.txt" ] || [ -f "$C/scripts/run_demo.py" ] || [ -f "$C/scripts/check_feedback.py" ]; then PY_DIR="$C"; break; fi
24+
done
25+
echo "py_dir=$PY_DIR" >> $GITHUB_ENV
26+
echo "Detected Python dir: '${PY_DIR:-<none>}'"
27+
if [ -z "$PY_DIR" ]; then mkdir -p artifacts && echo "## python-services\nNo Python dir found." > artifacts/summary.md; fi
28+
29+
- name: Install requirements (guarded)
30+
if: env.py_dir != ''
31+
working-directory: ${{ env.py_dir }}
2832
run: |
2933
python -m pip install -U pip
30-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
34+
if [ -f requirements.txt ]; then pip install -r requirements.txt; else echo "No requirements.txt; skip."; fi
3135
32-
- name: Lint/Test/Demo
36+
- name: Lint/Test/Demo (with fallbacks)
37+
if: env.py_dir != ''
38+
working-directory: ${{ env.py_dir }}
3339
run: |
3440
set -e
3541
if [ -f Makefile ] && grep -qE '(^|\n)ci:' Makefile; then
3642
make ci
3743
elif [ -f scripts/run_demo.py ] && [ -f seeds/prompts.jsonl ]; then
3844
mkdir -p artifacts
3945
python -m scripts.run_demo --seed seeds/prompts.jsonl --outdir artifacts
46+
elif [ -f scripts/check_feedback.py ]; then
47+
mkdir -p artifacts
48+
python -m scripts.check_feedback --outdir artifacts || python scripts/check_feedback.py
4049
else
41-
echo "No Makefile:ci or scripts/run_demo.py found. Add one to enforce gates."
42-
mkdir -p artifacts && echo "No demo run." > artifacts/summary.md
43-
fi
44-
45-
- name: Job Summary
46-
if: always()
47-
run: |
48-
if [ -f artifacts/summary.md ]; then
49-
echo "" >> $GITHUB_STEP_SUMMARY
50-
cat artifacts/summary.md >> $GITHUB_STEP_SUMMARY
50+
mkdir -p artifacts
51+
echo "## python-services" > artifacts/summary.md
52+
echo "No entrypoint found. Add Makefile:ci or scripts/run_demo.py." >> artifacts/summary.md
5153
fi
5254
5355
- name: Upload artifacts
5456
if: always()
5557
uses: actions/upload-artifact@v4
5658
with:
5759
name: python-services-artifacts
58-
path: artifacts/*
60+
path: |
61+
${{ env.py_dir }}/artifacts/*
62+
artifacts/*
63+
if-no-files-found: warn

0 commit comments

Comments
 (0)