-
Notifications
You must be signed in to change notification settings - Fork 12
174 lines (152 loc) 路 6.21 KB
/
Copy pathci.yml
File metadata and controls
174 lines (152 loc) 路 6.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: PaperFlow CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with ruff
run: |
pip install ruff
# Hard gate on real defects: undefined names, redefinitions, unused
# imports/variables, bare excepts, mutable default arguments.
# B008 is deliberately excluded -- typer.Option()/Argument() in argument
# defaults is Typer's documented idiom, not a bug.
# pyproject configures ruff (line-length, target-version, select), so
# this stays in sync with what developers run locally.
ruff check . --select=E9,F,B006,E722 --output-format=concise
# Style and modernization findings are advisory for now; the backlog is
# large and mostly auto-fixable, so surface it without blocking.
ruff check . --exit-zero --statistics
- name: Test with pytest
run: |
pip install pytest pytest-cov
python -m pytest tests/ -v --cov=. --cov-report=xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
fail_ci_if_error: false
# Installs the built wheel into a clean venv and drives the CLI from an
# unrelated working directory. This is the only job that can catch packaging
# regressions: `pip install -e .` puts the repo root on sys.path, so an
# editable install masks missing package data entirely. A previous release
# shipped a wheel whose very first command failed with "init script not
# found" because agents/, skills/, deployments/ and scripts/ were excluded
# from the distribution while the CLI shells out to them at runtime.
wheel-install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Build wheel
run: |
python -m pip install --upgrade pip build
python -m build --wheel --outdir dist/
- name: Install the wheel into a clean environment
run: |
python -m venv /tmp/pf-venv
/tmp/pf-venv/bin/pip install --upgrade pip
/tmp/pf-venv/bin/pip install dist/*.whl
- name: Runtime files must be present in the installed package
run: |
# Resolve from /tmp, not the repo root: the checkout contains an
# importable `paperflow` package, and cwd precedes site-packages on
# sys.path, so running this here would inspect the source tree and pass
# regardless of what the wheel actually shipped.
SP="$(cd /tmp && /tmp/pf-venv/bin/python -c 'import paperflow,pathlib;print(pathlib.Path(paperflow.__file__).parent.parent)')"
echo "site-packages: $SP"
case "$SP" in
*"site-packages") ;;
*) echo "Expected a site-packages path, got: $SP"; exit 1 ;;
esac
for path in \
scripts/init_db.py \
scripts/doctor.py \
agents/coldstart-agent/main.py \
agents/reading-agent/main.py \
deployments/desktop/server.py \
deployments/desktop/static/index.html \
deployments/feishu/daily-push-agent/main.py \
skills/storage-helper/scripts/db_ops.py \
config/scoring_weights.yaml
do
test -f "$SP/$path" || { echo "MISSING from wheel: $path"; exit 1; }
done
echo "All runtime files present"
- name: CLI must work from an unrelated working directory
run: |
cd /tmp
export HOME=/tmp/pf-home
export PAPERFLOW_LLM_PROVIDER=mock
export PAPERFLOW_EMBED_PROVIDER=hash
/tmp/pf-venv/bin/paperflow init
/tmp/pf-venv/bin/paperflow demo
/tmp/pf-venv/bin/paperflow profile --user-id ci_user \
--natural-language "LLM agents for scientific discovery"
- name: Mutable state must not be written into site-packages
run: |
# Same cwd caveat as above: resolved from the repo root this returned the
# checkout and then flagged the repository's own committed data/.gitkeep
# as leaked runtime state.
SP="$(cd /tmp && /tmp/pf-venv/bin/python -c 'import paperflow,pathlib;print(pathlib.Path(paperflow.__file__).parent.parent)')"
echo "site-packages: $SP"
case "$SP" in
*"site-packages") ;;
*) echo "Expected a site-packages path, got: $SP"; exit 1 ;;
esac
if [ -e "$SP/data" ]; then
echo "Runtime state leaked into the install directory:"
find "$SP/data" | head -20
exit 1
fi
test -f /tmp/pf-home/.paperflow/data/paperflow.db || {
echo "Database was not created under the runtime home"; exit 1; }
echo "Runtime state correctly isolated from the install directory"
build:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Check project structure
run: |
echo "Checking required files..."
test -f README.md || exit 1
test -f requirements.txt || exit 1
test -f .env.example || exit 1
echo "All required files present"
- name: Validate configuration files
run: |
python -c "import yaml; yaml.safe_load(open('config/conferences.yaml'))"
python -c "import yaml; yaml.safe_load(open('config/journals.yaml'))"
python -c "import yaml; yaml.safe_load(open('config/scoring_weights.yaml'))"
python -c "import json; json.load(open('config/user-profile-template.json'))"
echo "All configuration files are valid"