-
Notifications
You must be signed in to change notification settings - Fork 104
feat: devenv + uv + pre-commit #5070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
# TODO: reactivate when fixed | ||
# - id: check-github-workflows | ||
|
||
- repo: local |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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"
.
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.