Skip to content

Conversation

joshuarli
Copy link
Member

@joshuarli joshuarli commented Aug 19, 2025

This introduces devenv, uv and pre-commit in accordance with these repo standards:
https://www.notion.so/sentry/Standard-Spec-devenv-2238b10e4b5d8072a992d8b67d94be22
https://www.notion.so/sentry/Standard-Spec-python-uv-2248b10e4b5d8045b8fff30f8b8b67ca
https://www.notion.so/sentry/Standard-Spec-pre-commit-2238b10e4b5d8019aa1fe1158e39c38e

The ability to run devenv sync and get a dev environment in any repo is the DX i'm aiming for,
and these standards provide a foundation from which later we can easily push updates to all repos.

You should be able to checkout this branch, run direnv allow and devenv sync (might be prompted to run ~/.local/share/sentry-devenv/bin/devenv update first), which will set up everything needed for development (other than cargo).

Thanks to uv and our internal pypi, setting up the venv is near instant now (excluding the rust build of py/ of course).


Originally I was going to split this into 2 PRs, where the latter would configure py/ for uv, but it's not very good DX since uv sync will erase it as it doesn't know about it.

@joshuarli joshuarli changed the title feat: devenv and pre-commit feat: devenv + uv + pre-commit Aug 20, 2025
# TODO: reactivate when fixed
# - id: check-github-workflows

- repo: local
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-commit now runs in ci and now runs black/flake8/mypy (locked+installed via uv) on python files!

@@ -87,33 +87,24 @@ doc-rust: setup-git ## generate API docs for Rust code

# Style checking

style: style-rust style-python ## check code style
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style and lint for python's moved into pre-commit

i decided to leave rust alone for now to keep things simple (will need some work as tools like rustfmt and clippy-driver are needed to accept individual file arguments)

$$RELAY_PYTHON_VERSION -m venv --copies .venv
.venv/bin/pip install -U pip wheel

.venv/python-requirements-stamp: requirements-dev.txt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rerunning make setup-venv will always make sure python stuff is up to date and reexecutes the build - all this complexity can be removed

# Make will re-run 'pip install' if the mtime on requirements-dev.txt is higher again.
touch .venv/python-requirements-stamp

.git/hooks/pre-commit:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has been rolled up into pre-commit install --install-hooks in devenv sync

@@ -1,14 +1,20 @@
#!/bin/bash
#!/not/executable/bash

# Our policy is that the .envrc is entirely optional, and a user
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

devenv/sync.py and .pre-commit-config.yaml are all using .venv/bin explicitly so this policy you have here is still being respected! although you will need a global install of devenv: https://github.com/getsentry/devenv/?tab=readme-ov-file#install

(chances are and i would hope relay devs already have devenv installed as it is required for sentry development)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually well it is needed to put .devenv/bin on path so you have access to devenv's uv at .devenv/bin/uv

@joshuarli joshuarli marked this pull request as ready for review August 21, 2025 23:36
@joshuarli joshuarli requested a review from a team as a code owner August 21, 2025 23:36
cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@loewenheim loewenheim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I would appreciate a second opinion

@@ -3,4 +3,30 @@ repos:
rev: 0.16.0
hooks:
- id: check-github-actions
- id: check-github-workflows
# TODO: reactivate when fixed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this referring to? What needs to be fixed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://gist.github.com/joshuarli/36587aeb18445bf18f36abcd4b82382e
(upgraded to 0.33.0 since in previous versions output is a lot less readable)

mostly complaining about 'uses' is a required property which... it is not? lol

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were you able to test this workflow? Any chance we will face surprises next time we want to release the library?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good catch, I'll run it and see!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup it's totally broken haha, will fix

README.md Outdated
# Install the release build, recommended:
pip install --editable ./py
uv pip install -v -e py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not too familiar with direnv but this command fails for me on a fresh relay clone. .devenv/bin/ux exists but .devenv/bin is not in my $PATH. I've tried calling direnv allow and direnv reload.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you checked out to this branch? devenv sync will install uv to .devenv/bin. .envrc does PATH_add "${PWD}/.devenv/bin".

cursor[bot]

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants