Skip to content

Commit 64c5fa3

Browse files
authored
feat: uv (#7368)
1 parent c8eca7b commit 64c5fa3

29 files changed

+2042
-385
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ snuba.egg-info/
1818
snuba/admin/dist/bundle.js*
1919
*/node_modules
2020
rust_snuba/target/
21+
/.devenv

.envrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ fi
2121
export VIRTUAL_ENV="${PWD}/.venv"
2222
PATH_add "${PWD}/.venv/bin"
2323

24+
PATH_add /opt/homebrew/opt/rustup/bin
25+
2426
. scripts/rust-envvars

.github/workflows/bump-version.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ jobs:
3232
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3333
with:
3434
token: ${{ secrets.GETSENTRY_BOT_REVERT_TOKEN }}
35+
- uses: astral-sh/setup-uv@884ad927a57e558e7a70b92f2bccf9198a4be546 # v6
36+
with:
37+
version: '0.8.2'
3538
- run: |
3639
set -euxo pipefail
3740
@@ -41,8 +44,9 @@ jobs:
4144
4245
git checkout -b "bot/bump-version/$PACKAGE/$VERSION"
4346
47+
python3 -S -m tools.bump_version "$PACKAGE" "$VERSION"
48+
4449
re="$(sed 's/[_-]/[_-]/g' <<< "$PACKAGE")"
45-
sed -i "s/^\($re\)==.*/\1==$VERSION/g" -- requirements*.txt
4650
4751
# Update Cargo.toml dependencies (format: package = "version")
4852
sed -i "s/^\($re\) = \"[^\"]*\"/\1 = \"$VERSION\"/g" -- rust_snuba/Cargo.toml

.github/workflows/ci.yml

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
linting:
2828
name: "pre-commit hooks" # (includes Python formatting + linting)
2929
runs-on: ubuntu-latest
30-
timeout-minutes: 5
30+
timeout-minutes: 10
3131
steps:
3232
- uses: actions/checkout@v4
3333
name: Checkout code
@@ -38,19 +38,28 @@ jobs:
3838
with:
3939
app_id: ${{ vars.SENTRY_INTERNAL_APP_ID }}
4040
private_key: ${{ secrets.SENTRY_INTERNAL_APP_PRIVATE_KEY }}
41-
- uses: actions/setup-python@v5
41+
42+
- uses: astral-sh/setup-uv@884ad927a57e558e7a70b92f2bccf9198a4be546 # v6
4243
with:
43-
python-version: '3.11'
44-
- uses: actions/cache@v4
44+
version: '0.8.2'
45+
# we just cache the venv-dir directly in action-setup-venv
46+
enable-cache: false
47+
48+
- uses: getsentry/action-setup-venv@3a832a9604b3e1a4202ae559248f26867b467cc7 # v2.1.1
49+
with:
50+
python-version: 3.11.11
51+
cache-dependency-path: uv.lock
52+
# NOTE: can't pass --only-dev yet since we're missing some mypy stub packages
53+
install-cmd: uv sync --frozen --active
54+
55+
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
4556
with:
4657
path: ~/.cache/pre-commit
47-
key: cache-epoch-1|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
48-
- name: Install dependencies
49-
run: |
50-
python -m pip install --upgrade pip
51-
python -m pip install -r requirements-test.txt
58+
key: cache-epoch-1|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml', 'uv.lock') }}
59+
5260
- name: Setup pre-commit
53-
run: make setup-git
61+
run: pre-commit install-hooks
62+
5463
- uses: getsentry/paths-filter@v2
5564
id: files
5665
with:
@@ -65,6 +74,7 @@ jobs:
6574
filters: |
6675
all:
6776
- added|modified: '**/*'
77+
6878
- name: Run pre-commit checks
6979
# Run pre-commit to lint and format check files that were changed (but not deleted) compared to master.
7080
# XXX: there is a very small chance that it'll expand to exceed Linux's limits
@@ -96,38 +106,26 @@ jobs:
96106
run: |
97107
make lint-rust format-rust-ci
98108
99-
typing:
100-
name: "mypy typing"
101-
runs-on: ubuntu-latest
102-
timeout-minutes: 5
103-
steps:
104-
- uses: actions/checkout@v4
105-
name: Checkout code
106-
- uses: actions/setup-python@v5
107-
with:
108-
python-version: '3.11'
109-
- name: Install dependencies
110-
run: |
111-
python -m pip install --upgrade pip
112-
make install-python-dependencies
113-
- name: Run mypy
114-
run: |
115-
make backend-typing
116-
117109
config-validation:
118110
name: "Dataset Config Validation"
119111
runs-on: ubuntu-latest
120112
timeout-minutes: 2
121113
steps:
122114
- uses: actions/checkout@v4
123115
name: Checkout code
124-
- uses: actions/setup-python@v5
116+
117+
- uses: astral-sh/setup-uv@884ad927a57e558e7a70b92f2bccf9198a4be546 # v6
125118
with:
126-
python-version: '3.11'
127-
- name: Install dependencies
128-
run: |
129-
python -m pip install --upgrade pip
130-
make install-python-dependencies
119+
version: '0.8.2'
120+
# we just cache the venv-dir directly in action-setup-venv
121+
enable-cache: false
122+
123+
- uses: getsentry/action-setup-venv@3a832a9604b3e1a4202ae559248f26867b467cc7 # v2.1.1
124+
with:
125+
python-version: 3.11.11
126+
cache-dependency-path: uv.lock
127+
install-cmd: uv sync --frozen --active
128+
131129
- name: Validate configs
132130
run: |
133131
make validate-configs
@@ -293,7 +291,6 @@ jobs:
293291
- name: Setup steps
294292
id: setup
295293
run: |
296-
pip install --upgrade pip wheel
297294
# We cannot execute actions that are not placed under .github of the main repo
298295
mkdir -p .github/actions
299296
cp -r sentry/.github/actions/* .github/actions
@@ -404,15 +401,23 @@ jobs:
404401
run: |
405402
curl -Os https://uploader.codecov.io/latest/linux/codecov && chmod +x codecov && ./codecov -t ${CODECOV_TOKEN}
406403
407-
408404
validate-devservices-config:
409405
runs-on: ubuntu-24.04
410406
needs: files-changed
411407
if: ${{ needs.files-changed.outputs.devservices_changes == 'true' }}
412408
steps:
413409
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
414410
name: Checkout repository
415-
- uses: getsentry/action-validate-devservices-config@02a078d1280293e6598cabfbd318a01609c12c83
411+
412+
- name: Get devservices version
413+
id: get-devservices-version
414+
run: |
415+
awk -F'"' '
416+
/name/ { pkg = $2 }
417+
/version/ { if (pkg == "devservices") print "version="$2 }
418+
' uv.lock >> $GITHUB_OUTPUT
419+
420+
- uses: getsentry/action-validate-devservices-config@711ae7221998ddf81211f25f5e3873ecffd22387
416421
name: Validate devservices config
417422
with:
418-
requirements-file-path: requirements-test.txt
423+
devservices-version: ${{ steps.get-devservices-version.outputs.version }}

.github/workflows/ddl-changes.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@ jobs:
2020
with:
2121
clean: false
2222
fetch-depth: 200
23-
- uses: actions/setup-python@v5
23+
24+
- uses: astral-sh/setup-uv@884ad927a57e558e7a70b92f2bccf9198a4be546 # v6
2425
with:
25-
python-version: '3.11'
26-
- name: Install dependencies
27-
run: |
28-
python -m pip install --upgrade pip
29-
make install-python-dependencies
26+
version: '0.8.2'
27+
# we just cache the venv-dir directly in action-setup-venv
28+
enable-cache: false
29+
30+
- uses: getsentry/action-setup-venv@3a832a9604b3e1a4202ae559248f26867b467cc7 # v2.1.1
31+
with:
32+
python-version: 3.11.11
33+
cache-dependency-path: uv.lock
34+
install-cmd: uv sync --frozen --active
35+
3036
- name: Run the migration script
3137
run: |
3238
SNUBA_SETTINGS=test_distributed python scripts/ddl-changes.py

.github/workflows/docs-pr.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,23 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
12-
- name: Setup Python
13-
uses: actions/setup-python@v5
12+
13+
- uses: astral-sh/setup-uv@884ad927a57e558e7a70b92f2bccf9198a4be546 # v6
14+
with:
15+
version: '0.8.2'
16+
# we just cache the venv-dir directly in action-setup-venv
17+
enable-cache: false
18+
19+
- uses: getsentry/action-setup-venv@3a832a9604b3e1a4202ae559248f26867b467cc7 # v2.1.1
1420
with:
15-
python-version: '3.8'
21+
python-version: 3.11.11
22+
cache-dependency-path: docs-requirements.txt
23+
install-cmd: echo
24+
1625
- name: Generate config schema docs
1726
run: |
18-
pip install virtualenv
1927
make generate-config-docs
28+
2029
- name: Build docs
2130
run: |
2231
make snubadocs

.github/workflows/docs.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,27 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
14-
- name: Setup Python
15-
uses: actions/setup-python@v5
14+
15+
- uses: astral-sh/setup-uv@884ad927a57e558e7a70b92f2bccf9198a4be546 # v6
16+
with:
17+
version: '0.8.2'
18+
# we just cache the venv-dir directly in action-setup-venv
19+
enable-cache: false
20+
21+
- uses: getsentry/action-setup-venv@3a832a9604b3e1a4202ae559248f26867b467cc7 # v2.1.1
1622
with:
17-
python-version: '3.8'
23+
python-version: 3.11.11
24+
cache-dependency-path: docs-requirements.txt
25+
install-cmd: echo
26+
1827
- name: Generate config schema docs
1928
run: |
20-
pip install virtualenv
2129
make generate-config-docs
30+
2231
- name: Build docs
2332
run: |
2433
make snubadocs
34+
2535
- uses: peaceiris/actions-gh-pages@v4.0.0
2636
name: Publish to GitHub Pages
2737
with:

.pre-commit-config.yaml

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,69 @@ exclude: >
66
)
77
88
repos:
9-
- repo: https://github.com/psf/black
10-
rev: 22.3.0
9+
- repo: local
1110
hooks:
11+
# Configuration for black exists in pyproject.toml,
12+
# but we let pre-commit take care of the file filtering.
1213
- id: black
13-
- repo: https://github.com/pre-commit/pre-commit-hooks
14-
rev: v4.2.0
15-
hooks:
16-
- id: check-case-conflict
17-
- id: check-merge-conflict
18-
- id: check-symlinks
19-
- id: check-xml
20-
- id: check-yaml
21-
- id: detect-private-key
22-
- id: end-of-file-fixer
23-
- id: trailing-whitespace
24-
- id: fix-encoding-pragma
25-
args: ["--remove"]
26-
- repo: https://github.com/pycqa/flake8
27-
rev: 4.0.1
28-
hooks:
29-
- id: flake8
30-
- repo: https://github.com/pycqa/isort
31-
rev: 5.12.0
32-
hooks:
14+
name: black
15+
entry: black
16+
language: system
17+
types_or: [python, pyi]
18+
require_serial: true
19+
# Configuration for isort exists in pyproject.toml,
20+
# but we let pre-commit take care of the file filtering.
3321
- id: isort
34-
name: isort (python)
35-
- repo: https://github.com/pre-commit/pre-commit-hooks
36-
rev: v4.2.0
37-
hooks:
38-
- id: no-commit-to-branch
39-
args: ['--branch', 'master']
40-
- repo: local
41-
hooks:
22+
name: isort
23+
entry: isort
24+
language: system
25+
types: [python]
26+
# Configuration for flake8 exists in setup.cfg,
27+
# but we let pre-commit take care of the file filtering.
28+
- id: flake8
29+
name: flake8
30+
entry: flake8
31+
language: system
32+
types: [python]
33+
require_serial: true
34+
35+
- id: mypy
36+
name: mypy
37+
entry: mypy
38+
language: system
39+
types: [python]
40+
require_serial: true
41+
4242
- id: validate-configs-syntax
4343
name: validate-configs-syntax
4444
entry: env SNUBA_SETTINGS=test python3 -m snuba.validate_configs
4545
language: python
4646
additional_dependencies: [ 'fastjsonschema', 'pyyaml', 'sentry_sdk' ]
4747
pass_filenames: false
4848
files: 'snuba/datasets/configuration/.*'
49-
- repo: local
50-
hooks:
5149
- id: cargo-fmt
5250
name: format rust code
5351
language: system
5452
# keep in sync with Cargo.toml. There is no way to run cargo fmt for specific files
5553
# https://github.com/rust-lang/rustfmt/issues/4485
5654
entry: rustfmt --edition 2021
5755
files: ^rust_snuba/.*\.rs$
58-
default_language_version:
59-
python: python3.11
56+
57+
- repo: https://github.com/pre-commit/pre-commit-hooks
58+
rev: v5.0.0
59+
hooks:
60+
- id: check-case-conflict
61+
- id: check-executables-have-shebangs
62+
- id: check-merge-conflict
63+
- id: check-symlinks
64+
- id: check-xml
65+
- id: check-yaml
66+
- id: detect-private-key
67+
- id: end-of-file-fixer
68+
- id: trailing-whitespace
69+
- id: fix-encoding-pragma
70+
args: ["--remove"]
71+
- id: no-commit-to-branch
72+
args: ['--branch', 'master']
73+
- id: check-added-large-files
74+
args: ['--maxkb=1024']

0 commit comments

Comments
 (0)