Skip to content

Commit cb0d7b6

Browse files
committed
ci: use uv pip install everywhere with auto torch backend
1 parent 954cd5a commit cb0d7b6

File tree

3 files changed

+148
-157
lines changed

3 files changed

+148
-157
lines changed

.github/workflows/documentation.yml

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,36 @@ name: Documentation
33
on:
44
workflow_dispatch:
55
push:
6-
branches: [master, dev]
6+
branches: [ master, dev, main ]
77

88
env:
9+
UV_TORCH_BACKEND: "auto"
10+
UV_SYSTEM_PYTHON: 1
911
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
10-
# UV_INDEX_STRATEGY: "unsafe-first-match"
11-
# UV_EXTRA_INDEX_URL: "https://download.pytorch.org/whl/cpu"
12-
PIP_EXTRA_INDEX_URL: "https://download.pytorch.org/whl/cpu"
1312

1413
jobs:
1514
Documentation:
1615
runs-on: ubuntu-latest
1716
steps:
18-
- uses: actions/checkout@v2
19-
20-
- uses: actions/setup-python@v4
21-
with:
22-
python-version: "3.11"
23-
cache: 'pip'
24-
25-
- run: echo WEEK=$(date +%V) >>$GITHUB_ENV
26-
shell: bash
27-
28-
# - uses: hynek/setup-cached-uv@v1
29-
# with:
30-
# cache-suffix: -docs-${{ matrix.python-version }}-${{ env.WEEK }}
31-
32-
- name: Install dependencies
33-
run: |
34-
pip install . --group docs
35-
# uv venv
36-
# uv pip install . --group docs
37-
38-
- name: Set up Git
39-
run: |
40-
git config user.name ${{ github.actor }}
41-
git config user.email ${{ github.actor }}@users.noreply.github.com
42-
43-
- name: Build documentation
44-
run: |
45-
git fetch origin gh-pages
46-
mike delete $BRANCH_NAME
47-
mike deploy --push $BRANCH_NAME
48-
# source .venv/bin/activate
17+
- uses: actions/checkout@v2
18+
19+
- uses: actions/setup-python@v4
20+
with:
21+
python-version: "3.11"
22+
23+
- name: Install the latest version of uv
24+
uses: astral-sh/setup-uv@v7
25+
26+
- name: Install dependencies
27+
run: uv pip install . --group docs
28+
29+
- name: Set up Git
30+
run: |
31+
git config user.name ${{ github.actor }}
32+
git config user.email ${{ github.actor }}@users.noreply.github.com
33+
34+
- name: Build documentation
35+
run: |
36+
git fetch origin gh-pages
37+
mike delete $BRANCH_NAME
38+
mike deploy --push $BRANCH_NAME

.github/workflows/release.yml

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,19 @@ name: Upload Python Package
1111
on:
1212
workflow_dispatch:
1313
release:
14-
types: [published]
14+
types: [ published ]
1515

1616
env:
17-
# UV_INDEX_STRATEGY: "unsafe-first-match"
18-
# UV_EXTRA_INDEX_URL: "https://download.pytorch.org/whl/cpu"
19-
PIP_EXTRA_INDEX_URL: "https://download.pytorch.org/whl/cpu"
17+
UV_TORCH_BACKEND: "auto"
18+
UV_SYSTEM_PYTHON: 1
2019

2120
jobs:
2221
build_wheels:
2322
name: Build wheels on ${{ matrix.os }}/${{ matrix.arch || '*' }}
2423
runs-on: ${{ matrix.os }}
2524
strategy:
2625
matrix:
27-
os: [ubuntu-latest, windows-latest, macos-latest]
26+
os: [ ubuntu-latest, windows-latest, macos-latest ]
2827

2928
steps:
3029
- uses: actions/checkout@v4
@@ -57,45 +56,46 @@ jobs:
5756
PyPI:
5857
name: Upload to PyPI
5958

60-
needs: [build_wheels, build_sdist]
59+
needs: [ build_wheels, build_sdist ]
6160
runs-on: ubuntu-latest
6261

6362
steps:
64-
- uses: actions/download-artifact@v4
65-
with:
66-
pattern: cibw-*
67-
path: dist
68-
merge-multiple: true
69-
- name: Publish package
70-
uses: pypa/gh-action-pypi-publish@v1.5.0
71-
with:
72-
user: __token__
73-
password: ${{ secrets.PYPI_API_TOKEN }}
74-
75-
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
76-
# repository_url: https://test.pypi.org/legacy/
63+
- uses: actions/download-artifact@v4
64+
with:
65+
pattern: cibw-*
66+
path: dist
67+
merge-multiple: true
68+
- name: Publish package
69+
uses: pypa/gh-action-pypi-publish@v1.5.0
70+
with:
71+
user: __token__
72+
password: ${{ secrets.PYPI_API_TOKEN }}
73+
74+
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
75+
# repository_url: https://test.pypi.org/legacy/
7776

7877
Documentation:
7978
runs-on: ubuntu-latest
8079
steps:
81-
- uses: actions/checkout@v3
82-
83-
- uses: actions/setup-python@v4
84-
with:
85-
python-version: "3.11"
86-
cache: 'pip'
87-
88-
- name: Install dependencies
89-
run: |
90-
python -m pip install --upgrade pip
91-
pip install . --group docs
92-
93-
- name: Set up Git
94-
run: |
95-
git config user.name ${{ github.actor }}
96-
git config user.email ${{ github.actor }}@users.noreply.github.com
97-
98-
- name: Build documentation
99-
run: |
100-
git fetch origin gh-pages
101-
mike deploy --push --alias-type=copy --update-aliases $GITHUB_REF_NAME latest
80+
- uses: actions/checkout@v3
81+
82+
- uses: actions/setup-python@v4
83+
with:
84+
python-version: "3.11"
85+
cache: 'pip'
86+
87+
- name: Install the latest version of uv
88+
uses: astral-sh/setup-uv@v7
89+
90+
- name: Install dependencies
91+
run: uv pip install . --group docs
92+
93+
- name: Set up Git
94+
run: |
95+
git config user.name ${{ github.actor }}
96+
git config user.email ${{ github.actor }}@users.noreply.github.com
97+
98+
- name: Build documentation
99+
run: |
100+
git fetch origin gh-pages
101+
mike deploy --push --alias-type=copy --update-aliases $GITHUB_REF_NAME latest

.github/workflows/tests.yml

Lines changed: 83 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ on:
44
workflow_dispatch:
55
pull_request:
66
push:
7-
branches: [master]
7+
branches: [ master, main ]
88

99
env:
10-
UV_INDEX_STRATEGY: "unsafe-first-match"
11-
UV_EXTRA_INDEX_URL: "https://download.pytorch.org/whl/cpu"
12-
PIP_EXTRA_INDEX_URL: "https://download.pytorch.org/whl/cpu"
10+
UV_TORCH_BACKEND: "auto"
1311
UV_SYSTEM_PYTHON: 1
1412
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
1513

@@ -38,7 +36,7 @@ jobs:
3836
strategy:
3937
fail-fast: true
4038
matrix:
41-
python-version: ["3.10", "3.11", "3.12", "3.13"]
39+
python-version: [ "3.10", "3.11", "3.12", "3.13" ]
4240
steps:
4341
- uses: actions/checkout@v2
4442

@@ -58,19 +56,21 @@ jobs:
5856
uses: actions/setup-python@v5
5957
with:
6058
python-version: ${{ matrix.python-version }}
61-
cache: 'pip'
59+
60+
- name: Install the latest version of uv
61+
uses: astral-sh/setup-uv@v7
6262

6363
- name: Install dependencies
64-
run: pip install -e . --group dev
64+
run: uv pip install -e . --group dev
6565
if: matrix.python-version != '3.10' && matrix.python-version != '3.12' && matrix.python-version != '3.13' && matrix.python-version != '3.14'
6666

6767
- name: Install dependencies
68-
run: pip install -e . --group dev --group setup
68+
run: uv pip install -e . --group dev --group setup
6969
if: matrix.python-version == '3.10'
7070

7171
- name: Install dependencies
7272
# skip ML tests for 3.12 and 3.13
73-
run: pip install -e . --group dev
73+
run: uv pip install -e . --group dev
7474
if: matrix.python-version == '3.12' || matrix.python-version == '3.13' || matrix.python-version == '3.14'
7575

7676
- name: Test with Pytest on Python ${{ matrix.python-version }}
@@ -110,94 +110,95 @@ jobs:
110110
# Main docs are built in another workflow, we don't have to test them outside of PR
111111
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
112112
steps:
113-
- uses: actions/checkout@v2
114-
115-
- uses: actions/setup-python@v5
116-
with:
117-
python-version: "3.11"
118-
cache: 'pip'
119-
120-
- name: Install dependencies
121-
run: pip install -e . --group docs
122-
123-
- name: Set up Git
124-
run: |
125-
git config user.name ${{ github.actor }}
126-
git config user.email ${{ github.actor }}@users.noreply.github.com
127-
echo Current branch: $BRANCH_NAME
128-
129-
- name: Build documentation
130-
run: |
131-
mike deploy --alias-type=copy --update-aliases $BRANCH_NAME latest
132-
mike set-default $BRANCH_NAME
133-
134-
- name: Put content of gh-pages to public folder
135-
run: rm -rf public && mkdir public && git archive gh-pages | tar -x -C ./public/
136-
137-
- name: Set up Vercel
138-
run: npm install --global vercel@latest
139-
140-
- name: Pull Vercel environment
141-
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
142-
143-
- name: Create new vercel project linked to this branch
144-
run: vercel project add edsnlp-$BRANCH_NAME --token=${{ secrets.VERCEL_TOKEN }}
145-
146-
- name: Link public folder to the (maybe) new vercel project
147-
run: vercel link --cwd public --project edsnlp-$BRANCH_NAME --yes --token=${{ secrets.VERCEL_TOKEN }}
148-
149-
- name: Deploy to Vercel
150-
run: vercel deploy public/ --yes --token=${{ secrets.VERCEL_TOKEN }} --archive=tgz --prod > deployment-url.txt
151-
152-
- name: Post the documentation link
153-
env:
154-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155-
run: |
156-
slugify () {
157-
echo "$1" | iconv -c -t ascii//TRANSLIT | sed -E 's/[^a-zA-Z0-9-]+//g' | tr A-Z a-z
158-
}
159-
RAW_PROJECT_NAME="edsnlp-$BRANCH_NAME"
160-
URL=https://$(slugify "$RAW_PROJECT_NAME").vercel.app/
161-
COMMENT_BODY="## Docs preview URL\n\n$URL\n\n"
162-
HEADER="Authorization: token $GITHUB_TOKEN"
163-
PR_COMMENTS_URL="https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
164-
165-
# Fetch existing comments to find if one from this workflow already exists
166-
COMMENTS=$(curl -s -H "$HEADER" "$PR_COMMENTS_URL")
167-
COMMENT_ID=$(echo "$COMMENTS" | jq -r '.[] | select(.user.login == "github-actions[bot]" and (.body | startswith("## Docs preview URL"))) | .id')
168-
169-
# Check if we have a comment ID, if so, update it, otherwise create a new one
170-
if [[ "$COMMENT_ID" ]]; then
171-
# Update existing comment
172-
curl -s -X PATCH -H "$HEADER" -H "Content-Type: application/json" -d "{\"body\": \"$COMMENT_BODY\"}" "https://api.github.com/repos/${{ github.repository }}/issues/comments/$COMMENT_ID"
173-
else
174-
# Post new comment
175-
curl -s -X POST -H "$HEADER" -H "Content-Type: application/json" -d "{\"body\": \"$COMMENT_BODY\"}" "$PR_COMMENTS_URL"
176-
fi
177-
178-
if [ $status -ne 0 ]; then
179-
exit $status
180-
fi
113+
- uses: actions/checkout@v2
114+
115+
- uses: actions/setup-python@v5
116+
with:
117+
python-version: "3.11"
118+
119+
- name: Install the latest version of uv
120+
uses: astral-sh/setup-uv@v7
121+
122+
- name: Install dependencies
123+
run: uv pip install -e . --group docs
124+
125+
- name: Set up Git
126+
run: |
127+
git config user.name ${{ github.actor }}
128+
git config user.email ${{ github.actor }}@users.noreply.github.com
129+
echo Current branch: $BRANCH_NAME
130+
131+
- name: Build documentation
132+
run: |
133+
mike deploy --alias-type=copy --update-aliases $BRANCH_NAME latest
134+
mike set-default $BRANCH_NAME
135+
136+
- name: Put content of gh-pages to public folder
137+
run: rm -rf public && mkdir public && git archive gh-pages | tar -x -C ./public/
138+
139+
- name: Set up Vercel
140+
run: npm install --global vercel@latest
141+
142+
- name: Pull Vercel environment
143+
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
144+
145+
- name: Create new vercel project linked to this branch
146+
run: vercel project add edsnlp-$BRANCH_NAME --token=${{ secrets.VERCEL_TOKEN }}
147+
148+
- name: Link public folder to the (maybe) new vercel project
149+
run: vercel link --cwd public --project edsnlp-$BRANCH_NAME --yes --token=${{ secrets.VERCEL_TOKEN }}
150+
151+
- name: Deploy to Vercel
152+
run: vercel deploy public/ --yes --token=${{ secrets.VERCEL_TOKEN }} --archive=tgz --prod > deployment-url.txt
153+
154+
- name: Post the documentation link
155+
env:
156+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157+
run: |
158+
slugify () {
159+
echo "$1" | iconv -c -t ascii//TRANSLIT | sed -E 's/[^a-zA-Z0-9-]+//g' | tr A-Z a-z
160+
}
161+
RAW_PROJECT_NAME="edsnlp-$BRANCH_NAME"
162+
URL=https://$(slugify "$RAW_PROJECT_NAME").vercel.app/
163+
COMMENT_BODY="## Docs preview URL\n\n$URL\n\n"
164+
HEADER="Authorization: token $GITHUB_TOKEN"
165+
PR_COMMENTS_URL="https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
166+
167+
# Fetch existing comments to find if one from this workflow already exists
168+
COMMENTS=$(curl -s -H "$HEADER" "$PR_COMMENTS_URL")
169+
COMMENT_ID=$(echo "$COMMENTS" | jq -r '.[] | select(.user.login == "github-actions[bot]" and (.body | startswith("## Docs preview URL"))) | .id')
170+
171+
# Check if we have a comment ID, if so, update it, otherwise create a new one
172+
if [[ "$COMMENT_ID" ]]; then
173+
# Update existing comment
174+
curl -s -X PATCH -H "$HEADER" -H "Content-Type: application/json" -d "{\"body\": \"$COMMENT_BODY\"}" "https://api.github.com/repos/${{ github.repository }}/issues/comments/$COMMENT_ID"
175+
else
176+
# Post new comment
177+
curl -s -X POST -H "$HEADER" -H "Content-Type: application/json" -d "{\"body\": \"$COMMENT_BODY\"}" "$PR_COMMENTS_URL"
178+
fi
179+
180+
if [ $status -ne 0 ]; then
181+
exit $status
182+
fi
181183
182184
simple-installation:
183185
name: Simple installation
184186
runs-on: ubuntu-latest
185187
strategy:
186188
fail-fast: true
187189
matrix:
188-
python-version: ["3.10", "3.11", "3.12", "3.13"]
190+
python-version: [ "3.10", "3.11", "3.12", "3.13" ]
189191
steps:
190192
- uses: actions/checkout@v2
191193

192194
- uses: actions/setup-python@v5
193195
with:
194196
python-version: ${{ matrix.python-version }}
195-
cache: 'pip'
196197

197-
- run: echo WEEK=$(date +%V) >>$GITHUB_ENV
198-
shell: bash
198+
- name: Install the latest version of uv
199+
uses: astral-sh/setup-uv@v7
199200

200201
- name: Install library
201202
run: |
202-
pip install ".[ml]" pytest
203+
uv pip install ".[ml]" pytest
203204
pytest tests/pipelines/test_pipelines.py

0 commit comments

Comments
 (0)