Skip to content

Commit 5b0063c

Browse files
authored
feat: devenv, uv, pre-commit (#1770)
1 parent 7a9144e commit 5b0063c

File tree

11 files changed

+636
-21
lines changed

11 files changed

+636
-21
lines changed

.envrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/not/executable/bash
2+
3+
if [[ -f "${PWD}/.env" ]]; then
4+
dotenv
5+
fi
6+
7+
PATH_add "${HOME}/.local/share/sentry-devenv/bin"
8+
9+
if ! command -v devenv >/dev/null; then
10+
echo "install devenv: https://github.com/getsentry/devenv#install"
11+
return 1
12+
fi
13+
14+
PATH_add "${PWD}/.devenv/bin"
15+
16+
export VIRTUAL_ENV="${PWD}/.venv"
17+
PATH_add "${PWD}/.venv/bin"

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ jobs:
149149
- name: Checkout sources
150150
uses: actions/checkout@v5
151151

152-
- name: Setup Python
153-
uses: actions/setup-python@v6
152+
- uses: astral-sh/setup-uv@884ad927a57e558e7a70b92f2bccf9198a4be546 # v6
153+
154+
- uses: getsentry/action-setup-venv@3a832a9604b3e1a4202ae559248f26867b467cc7 # v2.1.1
154155
with:
155156
python-version: 3.13.5
156-
157-
- name: Setup python dependencies
158-
run: pip install --upgrade mkdocs mkdocs-material pygments
157+
cache-dependency-path: uv.lock
158+
install-cmd: uv sync --frozen --only-dev --active
159159

160160
- name: Build Docs
161161
run: mkdocs build

.github/workflows/docs.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ jobs:
1414
- name: Checkout sources
1515
uses: actions/checkout@v5
1616

17-
- name: Setup Python
18-
uses: actions/setup-python@v6
17+
- uses: astral-sh/setup-uv@884ad927a57e558e7a70b92f2bccf9198a4be546 # v6
18+
19+
- uses: getsentry/action-setup-venv@3a832a9604b3e1a4202ae559248f26867b467cc7 # v2.1.1
1920
with:
2021
python-version: 3.13.5
21-
22-
- name: Setup python dependencies
23-
run: pip install --upgrade mkdocs mkdocs-material pygments
22+
cache-dependency-path: uv.lock
23+
install-cmd: uv sync --frozen --only-dev --active
2424

2525
- name: Build Docs
2626
run: |

.github/workflows/pre-commit.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: pre-commit
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
# Cancel in progress workflows on pull_requests.
10+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: true
14+
15+
defaults:
16+
run:
17+
# the default default is:
18+
# bash --noprofile --norc -eo pipefail {0}
19+
shell: bash --noprofile --norc -eo pipefail -ux {0}
20+
21+
jobs:
22+
pre-commit:
23+
name: pre-commit
24+
runs-on: ubuntu-24.04
25+
steps:
26+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27+
28+
- name: Get changed files
29+
id: changes
30+
uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd # v3.0.0
31+
with:
32+
list-files: json
33+
filters: |
34+
all:
35+
- added|modified: '**/*'
36+
37+
- uses: astral-sh/setup-uv@884ad927a57e558e7a70b92f2bccf9198a4be546 # v6
38+
with:
39+
version: '0.8.2'
40+
# we just cache the venv-dir directly in action-setup-venv
41+
enable-cache: false
42+
43+
- uses: getsentry/action-setup-venv@3a832a9604b3e1a4202ae559248f26867b467cc7 # v2.1.1
44+
with:
45+
python-version: 3.13.5
46+
cache-dependency-path: uv.lock
47+
install-cmd: uv sync --frozen --only-dev --active
48+
49+
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
50+
with:
51+
path: ~/.cache/pre-commit
52+
key: cache-epoch-1|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml', 'uv.lock') }}
53+
54+
- name: Install pre-commit
55+
run: pre-commit install-hooks
56+
57+
- name: Run pre-commit
58+
run: |
59+
jq '.[]' --raw-output <<< '${{steps.changes.outputs.all_files}}' |
60+
xargs pre-commit run --files

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: check-case-conflict
6+
- id: check-executables-have-shebangs
7+
- id: check-merge-conflict
8+
- id: check-symlinks
9+
- id: end-of-file-fixer
10+
exclude_types: [svg]
11+
- id: trailing-whitespace
12+
exclude_types: [svg]
13+
- id: check-added-large-files
14+
args: ['--maxkb=1024']

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13.5

Makefile

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
SHELL = /bin/bash
2-
export SYMBOLICATOR_PYTHON_VERSION := python3
32

43
all: check test
54
.PHONY: all
@@ -33,17 +32,19 @@ test:
3332

3433
# Documentation
3534

36-
docs: .venv/bin/python
37-
.venv/bin/pip install -U mkdocs mkdocs-material pygments
35+
docs: venv
3836
.venv/bin/mkdocs build
3937
touch site/.nojekyll
4038
.PHONY: docs
4139

42-
docserver: .venv/bin/python
43-
.venv/bin/pip install -U mkdocs mkdocs-material pygments
40+
docserver: venv
4441
.venv/bin/mkdocs serve
4542
.PHONY: doc
4643

44+
venv:
45+
devenv sync
46+
.PHONY: venv
47+
4748
# Style checking
4849

4950
style:
@@ -65,12 +66,6 @@ format:
6566
cargo +stable fmt
6667
.PHONY: format-rust
6768

68-
# Dependencies (currently needed for docs)
69-
70-
.venv/bin/python: Makefile
71-
rm -rf .venv
72-
$$SYMBOLICATOR_PYTHON_VERSION -m venv .venv
73-
7469
# Build GoCD pipelines
7570

7671
gocd:

devenv/config.ini

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[devenv]
2+
minimum_version = 1.22.1
3+
4+
[uv]
5+
darwin_arm64 = https://github.com/astral-sh/uv/releases/download/0.8.2/uv-aarch64-apple-darwin.tar.gz
6+
darwin_arm64_sha256 = 954d24634d5f37fa26c7af75eb79893d11623fc81b4de4b82d60d1ade4bfca22
7+
darwin_x86_64 = https://github.com/astral-sh/uv/releases/download/0.8.2/uv-x86_64-apple-darwin.tar.gz
8+
darwin_x86_64_sha256 = ae755df53c8c2c1f3dfbee6e3d2e00be0dfbc9c9b4bdffdb040b96f43678b7ce
9+
linux_arm64 = https://github.com/astral-sh/uv/releases/download/0.8.2/uv-aarch64-unknown-linux-gnu.tar.gz
10+
linux_arm64_sha256 = 27da35ef54e9131c2e305de67dd59a07c19257882c6b1f3cf4d8d5fbb8eaf4ca
11+
linux_x86_64 = https://github.com/astral-sh/uv/releases/download/0.8.2/uv-x86_64-unknown-linux-gnu.tar.gz
12+
linux_x86_64_sha256 = 6dcb28a541868a455aefb2e8d4a1283dd6bf888605a2db710f0530cec888b0ad
13+
# used for autoupdate
14+
version = 0.8.2

devenv/sync.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from devenv import constants
2+
from devenv.lib import config, proc, uv
3+
4+
5+
def main(context: dict[str, str]) -> int:
6+
reporoot = context["reporoot"]
7+
cfg = config.get_repo(reporoot)
8+
9+
uv.install(
10+
cfg["uv"]["version"],
11+
cfg["uv"][constants.SYSTEM_MACHINE],
12+
cfg["uv"][f"{constants.SYSTEM_MACHINE}_sha256"],
13+
reporoot,
14+
)
15+
16+
print("syncing .venv ...")
17+
proc.run(
18+
(f"{reporoot}/.devenv/bin/uv", "sync", "--frozen", "--quiet", "--active"),
19+
)
20+
21+
print("installing pre-commit hooks ...")
22+
proc.run((f"{reporoot}/.venv/bin/pre-commit", "install", "--install-hooks"))
23+
24+
return 0

pyproject.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[project]
2+
name = "symbolicator"
3+
# we only have this here to make uv happy
4+
# we use uv for dependency management, not packaging
5+
version = "0.0.0"
6+
7+
[dependency-groups]
8+
dev = [
9+
"devservices>=1.2.1",
10+
"mkdocs>=1.6.1",
11+
"mkdocs-material>=9.6.17",
12+
"pre-commit>=4.2.0",
13+
"pygments>=2.19.2",
14+
"sentry-devenv>=1.22.2",
15+
]
16+
17+
[tool.uv]
18+
environments = ["sys_platform == 'darwin' or sys_platform == 'linux'"]
19+
20+
[[tool.uv.index]]
21+
url = "https://pypi.devinfra.sentry.io/simple"
22+
default = true

0 commit comments

Comments
 (0)