-
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?
Changes from all commits
fc348b4
a70f01c
5d556eb
5f8b910
b16ecd7
73fb625
8c99e1f
047f166
8d5db14
cfbc3ec
1dc7bb6
bb87254
6388fec
8ffdff4
320b3f8
67826ad
74ff9cd
be53798
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
#!/bin/bash | ||
#!/not/executable/bash | ||
|
||
# Our policy is that the .envrc is entirely optional, and a user | ||
# without direnv should not really have a worse dev experience in any way. | ||
|
||
# 'make' is in charge of creating and managing virtualenvs, and things like | ||
# pytest can still be directly invoked using .venv/bin/pytest | ||
if [[ -f "${PWD}/.env" ]]; then | ||
dotenv | ||
fi | ||
|
||
PATH_add "${HOME}/.local/share/sentry-devenv/bin" | ||
|
||
if ! source .venv/bin/activate; then | ||
echo "!!! you have no virtualenv, run 'make setup' to fix that." | ||
# XXX: ideally, direnv is able to export PS1 as modified by sourcing venvs | ||
# but we'd have to patch direnv, and ".venv" isn't descriptive anyways | ||
unset PS1 | ||
if ! command -v devenv >/dev/null; then | ||
echo "install devenv: https://github.com/getsentry/devenv#install" | ||
return 1 | ||
fi | ||
|
||
PATH_add "${PWD}/.devenv/bin" | ||
|
||
export VIRTUAL_ENV="${PWD}/.venv" | ||
PATH_add "${PWD}/.venv/bin" | ||
|
||
PATH_add /opt/homebrew/opt/rustup/bin |
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. yup it's totally broken haha, will fix |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,16 +39,21 @@ jobs: | |
with: | ||
submodules: recursive | ||
|
||
- name: Get changed files | ||
id: changes | ||
uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd # v3.0.0 | ||
with: | ||
list-files: json | ||
filters: | | ||
all: | ||
- added|modified: '**/*' | ||
|
||
- name: Setup SSH agent | ||
if: env.SSH_PRIVATE_KEY != '' | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }} | ||
|
||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.11" | ||
|
||
- name: Install Rust Toolchain | ||
run: | | ||
rustup toolchain install stable --profile minimal --no-self-update | ||
|
@@ -58,6 +63,32 @@ jobs: | |
with: | ||
key: ${{ github.job }} | ||
|
||
- uses: astral-sh/setup-uv@884ad927a57e558e7a70b92f2bccf9198a4be546 # v6 | ||
with: | ||
version: '0.8.2' | ||
# we just cache the venv-dir directly in action-setup-venv | ||
enable-cache: false | ||
|
||
- uses: getsentry/action-setup-venv@3a832a9604b3e1a4202ae559248f26867b467cc7 # v2.1.1 | ||
with: | ||
python-version: 3.11.9 | ||
cache-dependency-path: uv.lock | ||
install-cmd: uv sync --frozen --only-dev --active | ||
|
||
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 | ||
with: | ||
path: ~/.cache/pre-commit | ||
key: cache-epoch-1|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml', 'uv.lock') }} | ||
|
||
- name: Setup pre-commit | ||
run: pre-commit install-hooks | ||
|
||
- name: Run pre-commit | ||
run: | | ||
jq '.[]' --raw-output <<< '${{steps.changes.outputs.all_files}}' | | ||
# Run pre-commit to lint and format check files that were changed (but not deleted) | ||
xargs pre-commit run --files | ||
|
||
- run: make style lint | ||
|
||
- name: Check Docs | ||
|
@@ -214,19 +245,24 @@ jobs: | |
- name: Install Rust Toolchain | ||
run: rustup toolchain install stable --profile minimal --no-self-update | ||
|
||
- uses: actions/setup-python@v5 | ||
- uses: swatinem/rust-cache@v2 | ||
with: | ||
python-version: "3.10" | ||
key: ${{ github.job }} | ||
|
||
- name: Install Dependencies | ||
run: pip install -U pytest | ||
- uses: astral-sh/setup-uv@884ad927a57e558e7a70b92f2bccf9198a4be546 # v6 | ||
with: | ||
version: '0.8.2' | ||
# we just cache the venv-dir directly in action-setup-venv | ||
enable-cache: false | ||
|
||
- uses: swatinem/rust-cache@v2 | ||
- uses: getsentry/action-setup-venv@3a832a9604b3e1a4202ae559248f26867b467cc7 # v2.1.1 | ||
with: | ||
key: ${{ github.job }} | ||
python-version: 3.11.9 | ||
cache-dependency-path: uv.lock | ||
install-cmd: uv sync --frozen --only-dev --active | ||
|
||
- name: Build and Install Library | ||
run: pip install -v --editable py | ||
run: uv sync --frozen --verbose --active | ||
env: | ||
RELAY_DEBUG: 1 | ||
|
||
|
@@ -749,9 +785,17 @@ jobs: | |
with: | ||
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }} | ||
|
||
- uses: actions/setup-python@v5 | ||
- uses: astral-sh/setup-uv@884ad927a57e558e7a70b92f2bccf9198a4be546 # v6 | ||
with: | ||
python-version: "3.11" | ||
version: '0.8.2' | ||
# we just cache the venv-dir directly in action-setup-venv | ||
enable-cache: false | ||
|
||
- uses: getsentry/action-setup-venv@3a832a9604b3e1a4202ae559248f26867b467cc7 # v2.1.1 | ||
with: | ||
python-version: 3.11.9 | ||
cache-dependency-path: uv.lock | ||
install-cmd: uv sync --frozen --only-dev --active | ||
|
||
- run: make test-integration | ||
env: | ||
|
@@ -838,13 +882,22 @@ jobs: | |
docker compose logs | ||
|
||
validate-devservices-config: | ||
runs-on: ubuntu-24.04 | ||
needs: devservices-files-changed | ||
if: needs.devservices-files-changed.outputs.devservices-files-changed == 'true' | ||
steps: | ||
- uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v4.1.7 | ||
name: Checkout repository | ||
- uses: getsentry/action-validate-devservices-config@02a078d1280293e6598cabfbd318a01609c12c83 | ||
name: Validate devservices config | ||
with: | ||
requirements-file-path: requirements-dev.txt | ||
runs-on: ubuntu-24.04 | ||
needs: devservices-files-changed | ||
if: needs.devservices-files-changed.outputs.devservices-files-changed == 'true' | ||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
name: Checkout repository | ||
|
||
- name: Get devservices version | ||
id: get-devservices-version | ||
run: | | ||
awk -F'"' ' | ||
/name/ { pkg = $2 } | ||
/version/ { if (pkg == "devservices") print "version="$2 } | ||
' uv.lock >> $GITHUB_OUTPUT | ||
|
||
- uses: getsentry/action-validate-devservices-config@711ae7221998ddf81211f25f5e3873ecffd22387 | ||
name: Validate devservices config | ||
with: | ||
devservices-version: ${{ steps.get-devservices-version.outputs.version }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,39 @@ 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. https://gist.github.com/joshuarli/36587aeb18445bf18f36abcd4b82382e mostly complaining about |
||
# - id: check-github-workflows | ||
|
||
- repo: local | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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! |
||
hooks: | ||
# Configuration for black exists in pyproject.toml, | ||
# but we let pre-commit take care of the file filtering. | ||
- id: black | ||
name: black | ||
entry: .venv/bin/black | ||
language: system | ||
types_or: [python, pyi] | ||
require_serial: true | ||
# Configuration for flake8 exists in setup.cfg, | ||
# but we let pre-commit take care of the file filtering. | ||
- id: flake8 | ||
name: flake8 | ||
entry: .venv/bin/flake8 | ||
language: system | ||
types: [python] | ||
require_serial: true | ||
- id: mypy | ||
name: mypy | ||
entry: .venv/bin/mypy | ||
language: system | ||
types: [python] | ||
require_serial: true | ||
- id: rustfmt | ||
name: format rust code | ||
language: system | ||
types: [rust] | ||
# keep edition in sync with Cargo.toml | ||
# There is no way to run cargo fmt for specific files, | ||
# rustfmt can do it but doesn't read Cargo.toml. | ||
# https://github.com/rust-lang/rustfmt/issues/4485 | ||
entry: rustfmt --edition=2024 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
brew 'librdkafka' | ||
|
||
brew 'rustup' |
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