Repository navigation
170 lines (147 loc) · 5.68 KB
/
Copy pathpython-package.yml
File metadata and controls
170 lines (147 loc) · 5.68 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
name: Tests
on:
workflow_dispatch:
#push:
# branches: ["main"]
#pull_request:
# branches: ["main"]
env:
MODEL_NAME: qwen3:1.7b # Must match the one test_config.json "Ollama Small"
jobs:
test:
runs-on: ubuntu-latest
environment: pytest
steps:
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo docker image prune --all --force
df -h
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version
- name: Cache Python virtual environment
id: venv-cache
uses: actions/cache@v3
with:
path: .venv
key: ${{ runner.os }}-venv-${{ hashFiles('.python-version') }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt') }}
restore-keys: |
${{ runner.os }}-venv-${{ hashFiles('.python-version') }}-
- name: Create and activate virtual environment
if: steps.venv-cache.outputs.cache-hit != 'true'
run: |
python -m venv .venv
echo "$PWD/.venv/bin" >> $GITHUB_PATH
- name: Install Python dependencies
if: steps.venv-cache.outputs.cache-hit != 'true'
run: |
source .venv/bin/activate
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
pip install flake8 pytest pytest-bdd pytest-playwright
- name: Force save Python venv cache
if: always() && steps.venv-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: .venv
key: ${{ runner.os }}-venv-${{ hashFiles('.python-version') }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt') }}
- name: Activate virtual environment for subsequent steps
run: |
echo "$PWD/.venv/bin" >> $GITHUB_PATH
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('requirements.txt', 'requirements-dev.txt') }}
restore-keys: |
${{ runner.os }}-playwright-
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: |
playwright install --with-deps chromium
- name: Force save Playwright cache
if: always() && steps.playwright-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('requirements.txt', 'requirements-dev.txt') }}
# - name: Cache Ollama installation and models
# id: ollama-cache
# uses: actions/cache@v3
# with:
# path: |
# /usr/local/bin/ollama
# ~/.ollama
# key: ollama-${{ runner.os }}-${{ env.MODEL_NAME }}-${{ hashFiles('**/ollama-version.txt') }}
# restore-keys: |
# ollama-${{ runner.os }}-${{ env.MODEL_NAME }}-
# - name: Install Ollama
# if: steps.ollama-cache.outputs.cache-hit != 'true'
# run: |
# curl -fsSL https://ollama.com/install.sh | sh
# # Create a version file for cache invalidation if needed
# echo "ollama-$(date +%Y%m%d)" > ollama-version.txt
# - name: Start Ollama server
# run: |
# ollama serve &
# # Wait for server to be ready
# for i in {1..30}; do
# if curl -s http://localhost:11434/api/tags > /dev/null; then
# echo "Ollama server is ready"
# break
# fi
# echo "Waiting for Ollama server... ($i/30)"
# sleep 2
# done
# - name: Pull Ollama model
# if: steps.ollama-cache.outputs.cache-hit != 'true'
# run: |
# ollama pull ${{ env.MODEL_NAME }}
# - name: Force save Ollama cache
# if: always() && steps.ollama-cache.outputs.cache-hit != 'true'
# uses: actions/cache/save@v3
# with:
# path: |
# /usr/local/bin/ollama
# ~/.ollama
# key: ${{ env.MODEL_CACHE_KEY }}-${{ hashFiles('**/ollama-version.txt') }}
# - name: Verify model is available
# run: |
# ollama list
# curl -X POST http://localhost:11434/api/generate -d '{
# "model": "${{ env.MODEL_NAME }}",
# "prompt": "Hello. /no_think",
# "stream": false
# }'
- name: Lint with flake8
run: |
source .venv/bin/activate
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
id: tests
continue-on-error: true
run: |
source .venv/bin/activate
FORCE_LOG=DEBUG pytest -v
env:
OLLAMA_HOST: http://localhost:11434
OLLAMA_MODEL: ${{ env.MODEL_NAME }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
OLLAMA_API_KEY: ${{ secrets.OLLAMA_API_KEY }}
FORCE_LLM: ${{ vars.FORCE_LLM}}
- name: Check test results
if: steps.tests.outcome != 'success'
run: |
echo "Tests failed but caches were saved for next run!"
exit 1