-
-
Notifications
You must be signed in to change notification settings - Fork 50
213 lines (186 loc) · 6.32 KB
/
extralit.yml
File metadata and controls
213 lines (186 loc) · 6.32 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: Build Extralit Package & Publish
concurrency:
group: ${{ github.workflow }}-${{ github.sha }}
cancel-in-progress: true
on:
workflow_dispatch:
push:
branches:
- main
- develop
- releases/**
paths:
- "extralit/**"
- ".github/workflows/extralit.yml"
pull_request:
paths:
- "extralit/**"
- ".github/workflows/extralit.yml"
permissions:
id-token: write
contents: write
jobs:
build:
if: github.event.pull_request.draft == false
services:
extralit-container:
image: extralitdev/extralit-hf-space:latest
ports:
- 6900:6900
env:
HF_HUB_DISABLE_TELEMETRY: 1
# Set credentials
USERNAME: extralit
PASSWORD: 12345678
API_KEY: extralit.apikey
runs-on: ubuntu-22.04
defaults:
run:
working-directory: extralit
strategy:
fail-fast: true
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
pyproject-file: "extralit/pyproject.toml"
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-local-path: ~/.cache/uv
ignore-nothing-to-cache: true
cache-dependency-glob: "extralit/pdm.lock"
- name: Install PDM
run: uv tool install pdm
- name: Install dependencies
env:
PDM_IGNORE_ACTIVE_VENV: 1
run: |
pdm config use_uv true
pdm config python.install_root "$(uv python dir)"
pdm install
uv cache prune --ci
- name: Wait for extralit-container to start
timeout-minutes: 3
run: |
echo "Waiting for services to start..."
# Start streaming logs in background
docker logs -f ${{ job.services.extralit-container.id }} &
LOGS_PID=$!
# Wait for the service to be ready
while ! curl -s -o /dev/null -XGET http://localhost:6900/api/v1/status; do sleep 10; done
echo "✅ Services are ready!"
# Stop log streaming
kill $LOGS_PID || true
- name: Set huggingface hub credentials
run: |
echo "HF_TOKEN_EXTRALIT_INTERNAL_TESTING=${{ secrets.HF_TOKEN_EXTRALIT_INTERNAL_TESTING }}" >> "$GITHUB_ENV"
echo "Enable HF access token"
- name: Run unit tests
id: tests-unit
continue-on-error: true
run: |
pdm run test-cov tests/unit
- name: Check test status
if: steps.tests-unit.outcome == 'failure'
run: exit 1
- name: Run integration tests
id: tests-integration
continue-on-error: true
run: |
pdm run test-cov tests/integration
- name: Generate coverage report
if: always()
continue-on-error: true
run: |
pdm run coverage xml -o coverage.xml
pdm run coverage report
- name: Upload test coverage
if: always()
uses: codecov/codecov-action@v5.4.3
with:
files: coverage.xml
flags: extralit
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
- name: Check test status
if: steps.tests-integration.outcome == 'failure'
run: exit 1
- name: Build package
run: |
pdm build
- name: Upload artifact
uses: actions/upload-artifact@v4
# Upload the package to be used in the next jobs only once
if: ${{ matrix.python-version == '3.9' }}
with:
name: extralit
path: extralit/dist
# This job will publish extralit package into PyPI repository
publish_release:
name: Publish Release
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' }}
permissions:
# This permission is needed for private repositories.
# contents: read
# IMPORTANT: this permission is mandatory for trusted publishing on PyPI
id-token: write
needs:
- build
defaults:
run:
shell: bash -l {0}
working-directory: extralit
steps:
- name: Checkout Code 🛎
uses: actions/checkout@v4
- name: Update repo visualizer
uses: githubocto/repo-visualizer@0.7.1
with:
root_path: "extralit/"
excluded_paths: "dist,build,node_modules,docs,tests,.swm,assets,.github,package-lock.json,pdm.lock"
excluded_globs: "*.spec.js;**/*.{png,jpg,svg,md};**/!(*.module).ts,**/__pycache__/,**/__mocks__/,LICENSE*,**/.gitignore,**/*.egg-info/,**/.*/"
output_file: "repo-visualizer.svg"
should_push: false
- name: Upload repo visualizer diagram as artifact
uses: actions/upload-artifact@v4
with:
name: repo-visualizer
path: repo-visualizer.svg
retention-days: 10
- name: Download python package
uses: actions/download-artifact@v4
with:
name: extralit
path: extralit/dist
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
pyproject-file: "extralit/pyproject.toml"
python-version: "3.9"
enable-cache: true
cache-local-path: ~/.cache/uv
ignore-nothing-to-cache: true
cache-dependency-glob: "extralit/pdm.lock"
- name: Install PDM
run: uv tool install pdm
- name: Read package info
run: |
PACKAGE_VERSION=$(pdm show --version)
PACKAGE_NAME=$(pdm show --name)
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV
echo "$PACKAGE_NAME==$PACKAGE_VERSION"
- name: Publish Package to PyPI test environment 🥪
run: pdm publish --no-build --repository testpypi --username __token__ --password ${{ secrets.AR_TEST_PYPI_API_TOKEN }}
continue-on-error: true
- name: Test Installing 🍿
continue-on-error: true
run: |
pip3 install --index-url https://test.pypi.org/simple --no-deps $PACKAGE_NAME==$PACKAGE_VERSION
- name: Publish Package to PyPI 🥩
if: github.ref == 'refs/heads/main'
run: pdm publish --no-build --username __token__ --password ${{ secrets.AR_PYPI_API_TOKEN }}