Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit bd2fea7

Browse files
authored
dev: Migrate from pip-compile to uv (#1177)
1 parent 0ec7fe2 commit bd2fea7

File tree

17 files changed

+2417
-696
lines changed

17 files changed

+2417
-696
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,26 @@ permissions:
2121
jobs:
2222
lint:
2323
name: Run Lint
24-
uses: codecov/gha-workflows/.github/workflows/[email protected].26
24+
uses: codecov/gha-workflows/.github/workflows/[email protected].33
2525

2626
build:
2727
name: Build API
28-
uses: codecov/gha-workflows/.github/workflows/[email protected].26
28+
uses: codecov/gha-workflows/.github/workflows/[email protected].33
2929
secrets: inherit
3030
with:
3131
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-api' }}
32+
cache_file: "uv.lock"
3233

3334
codecovstartup:
3435
name: Codecov Startup
3536
needs: build
36-
uses: codecov/gha-workflows/.github/workflows/[email protected].26
37+
uses: codecov/gha-workflows/.github/workflows/[email protected].33
3738
secrets: inherit
3839

3940
test:
4041
name: Test
4142
needs: [build]
42-
uses: codecov/gha-workflows/.github/workflows/[email protected].30
43+
uses: codecov/gha-workflows/.github/workflows/[email protected].33
4344
secrets: inherit
4445
with:
4546
run_integration: false
@@ -48,16 +49,17 @@ jobs:
4849
build-self-hosted:
4950
name: Build Self Hosted API
5051
needs: [build, test]
51-
uses: codecov/gha-workflows/.github/workflows/[email protected].27
52+
uses: codecov/gha-workflows/.github/workflows/[email protected].33
5253
secrets: inherit
5354
with:
5455
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-api' }}
56+
cache_file: "uv.lock"
5557

5658
staging:
5759
name: Push Staging Image
5860
needs: [build, test]
5961
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/staging' && github.repository_owner == 'codecov' }}
60-
uses: codecov/gha-workflows/.github/workflows/[email protected].27
62+
uses: codecov/gha-workflows/.github/workflows/[email protected].33
6163
secrets: inherit
6264
with:
6365
environment: staging
@@ -67,7 +69,7 @@ jobs:
6769
name: Push Production Image
6870
needs: [build, test]
6971
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }}
70-
uses: codecov/gha-workflows/.github/workflows/[email protected].27
72+
uses: codecov/gha-workflows/.github/workflows/[email protected].33
7173
secrets: inherit
7274
with:
7375
environment: production
@@ -78,7 +80,8 @@ jobs:
7880
needs: [build-self-hosted, test]
7981
secrets: inherit
8082
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }}
81-
uses: codecov/gha-workflows/.github/workflows/[email protected].27
83+
uses: codecov/gha-workflows/.github/workflows/[email protected].33
8284
with:
8385
push_rolling: true
8486
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-api' }}
87+
cache_file: "uv.lock"

.github/workflows/mypy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ on:
1111
jobs:
1212
patch-typing-check:
1313
name: Run Patch Type Check
14-
uses: codecov/gha-workflows/.github/workflows/[email protected].21
14+
uses: codecov/gha-workflows/.github/workflows/[email protected].33

.github/workflows/self-hosted-release-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ on:
1010
jobs:
1111
create-release-pr:
1212
name: Create PR for Release ${{ github.event.inputs.versionName }}
13-
uses: codecov/gha-workflows/.github/workflows/[email protected].21
13+
uses: codecov/gha-workflows/.github/workflows/[email protected].33
1414
secrets: inherit

.github/workflows/self-hosted-release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@ jobs:
1414
create-release:
1515
name: Tag Release ${{ github.head_ref }} and Push Docker image to Docker Hub
1616
if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') && github.repository_owner == 'codecov' }}
17-
uses: codecov/gha-workflows/.github/workflows/[email protected].21
17+
uses: codecov/gha-workflows/.github/workflows/[email protected].33
1818
with:
1919
tag_to_prepend: self-hosted-
2020
secrets: inherit
2121

2222
push-image:
2323
needs: [create-release]
2424
if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') && github.repository_owner == 'codecov' }}
25-
uses: codecov/gha-workflows/.github/workflows/[email protected].21
25+
uses: codecov/gha-workflows/.github/workflows/[email protected].33
2626
secrets: inherit
2727
with:
2828
push_release: true
2929
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-api' }}
30+
cache_file: "uv.lock"

.pre-commit-config.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
repos:
2-
- repo: local
3-
hooks:
4-
- id: lint
5-
name: lint
6-
description: "Lint and sort"
7-
entry: make lint.run
8-
pass_filenames: false
9-
require_serial: true
10-
language: system
11-
- repo: https://github.com/pre-commit/mirrors-mypy
12-
rev: 'v1.10.0'
13-
hooks:
14-
- id: mypy
15-
verbose: true
16-
entry: bash -c 'mypy "$@" || true' --
2+
- repo: local
3+
hooks:
4+
- id: lint
5+
name: lint
6+
description: "Lint and sort"
7+
entry: make lint.local
8+
pass_filenames: false
9+
require_serial: true
10+
language: system
11+
- repo: https://github.com/pre-commit/mirrors-mypy
12+
rev: "v1.10.0"
13+
hooks:
14+
- id: mypy
15+
verbose: true
16+
entry: bash -c 'mypy "$@" || true' --

Makefile

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ branch = $(shell git branch | grep \* | cut -f2 -d' ')
77
epoch := $(shell date +"%s")
88
AR_REPO ?= codecov/api
99
DOCKERHUB_REPO ?= codecov/self-hosted-api
10-
REQUIREMENTS_TAG := requirements-v1-$(shell sha1sum requirements.txt | cut -d ' ' -f 1)-$(shell sha1sum docker/Dockerfile.requirements | cut -d ' ' -f 1)
10+
REQUIREMENTS_TAG := requirements-v1-$(shell sha1sum uv.lock | cut -d ' ' -f 1)-$(shell sha1sum docker/Dockerfile.requirements | cut -d ' ' -f 1)
1111
VERSION := release-${sha}
1212
CODECOV_UPLOAD_TOKEN ?= "notset"
1313
CODECOV_STATIC_TOKEN ?= "notset"
@@ -20,7 +20,7 @@ API_DOMAIN ?= api
2020
PROXY_NETWORK ?= api_default
2121

2222
# Codecov CLI version to use
23-
CODECOV_CLI_VERSION := 0.5.1
23+
CODECOV_CLI_VERSION := 9.0.4
2424

2525
build:
2626
make build.requirements
@@ -30,20 +30,20 @@ check-for-migration-conflicts:
3030
python manage.py check_for_migration_conflicts
3131

3232
test:
33-
COVERAGE_CORE=sysmon python -m pytest --cov=./ --junitxml=junit.xml -o junit_family=legacy
33+
COVERAGE_CORE=sysmon pytest --cov=./ --junitxml=junit.xml -o junit_family=legacy
3434

3535
test.unit:
3636
@if [ -n "$(GROUP)" ]; then \
37-
COVERAGE_CORE=sysmon python -m pytest --splits ${SPLIT} --group $(GROUP) --cov=./ -m "not integration" --cov-report=xml:unit.$(GROUP).coverage.xml --junitxml=unit.$(GROUP).junit.xml -o junit_family=legacy; \
37+
COVERAGE_CORE=sysmon pytest --splits ${SPLIT} --group $(GROUP) --cov=./ -m "not integration" --cov-report=xml:unit.$(GROUP).coverage.xml --junitxml=unit.$(GROUP).junit.xml -o junit_family=legacy; \
3838
else \
39-
COVERAGE_CORE=sysmon python -m pytest --cov=./ -m "not integration" --cov-report=xml:unit.coverage.xml --junitxml=unit.junit.xml -o junit_family=legacy; \
39+
COVERAGE_CORE=sysmon pytest --cov=./ -m "not integration" --cov-report=xml:unit.coverage.xml --junitxml=unit.junit.xml -o junit_family=legacy; \
4040
fi
4141

4242
test.integration:
4343
@if [ -n "$(GROUP)" ]; then \
44-
COVERAGE_CORE=sysmon python -m pytest --splits ${SPLIT} --group $(GROUP) --cov=./ -m "integration" --cov-report=xml:integration.$(GROUP).coverage.xml --junitxml=integration.$(GROUP).junit.xml -o junit_family=legacy; \
44+
COVERAGE_CORE=sysmon pytest --splits ${SPLIT} --group $(GROUP) --cov=./ -m "integration" --cov-report=xml:integration.$(GROUP).coverage.xml --junitxml=integration.$(GROUP).junit.xml -o junit_family=legacy; \
4545
else \
46-
COVERAGE_CORE=sysmon python -m pytest --cov=./ -m "integration" --cov-report=xml:integration.coverage.xml --junitxml=integration.junit.xml -o junit_family=legacy; \
46+
COVERAGE_CORE=sysmon pytest --cov=./ -m "integration" --cov-report=xml:integration.coverage.xml --junitxml=integration.junit.xml -o junit_family=legacy; \
4747
fi
4848

4949
lint:
@@ -54,6 +54,14 @@ lint.install:
5454
echo "Installing..."
5555
pip install -Iv ruff
5656

57+
lint.local:
58+
make lint.install.local
59+
make lint.run
60+
61+
lint.install.local:
62+
echo "Installing..."
63+
uv add --dev ruff
64+
5765
lint.run:
5866
ruff check
5967
ruff format
@@ -186,17 +194,17 @@ push.self-hosted-rolling:
186194
docker push ${DOCKERHUB_REPO}:rolling
187195

188196
shell:
189-
docker-compose exec api bash
197+
docker compose exec api bash
190198

191199
test_env.up:
192200
env | grep GITHUB > .testenv; true
193201
docker-compose up -d
194202

195203
test_env.prepare:
196-
docker-compose exec api make test_env.container_prepare
204+
docker compose exec api make test_env.container_prepare
197205

198206
test_env.check_db:
199-
docker-compose exec api make test_env.container_check_db
207+
docker compose exec api make test_env.container_check_db
200208
make test_env.check-for-migration-conflicts
201209

202210
test_env.install_cli:
@@ -212,21 +220,21 @@ test_env.container_check_db:
212220

213221
test_env.run_unit:
214222
@if [ -n "$(GROUP)" ]; then \
215-
docker-compose exec api make test.unit SPLIT=${SPLIT} GROUP=${GROUP}; \
223+
docker compose exec api make test.unit SPLIT=${SPLIT} GROUP=${GROUP}; \
216224
else \
217-
docker-compose exec api make test.unit; \
225+
docker compose exec api make test.unit; \
218226
fi
219227

220228
test_env.run_integration:
221229
# @if [ -n "$(GROUP)" ]; then \
222-
# docker-compose exec api make test.integration SPLIT=${SPLIT} GROUP=${GROUP}; \
230+
# docker compose exec api make test.integration SPLIT=${SPLIT} GROUP=${GROUP}; \
223231
# else \
224-
# docker-compose exec api make test.integration; \
232+
# docker compose exec api make test.integration; \
225233
# fi
226234
echo "Skipping. No Tests"
227235

228236
test_env.check-for-migration-conflicts:
229-
docker-compose exec api python manage.py check_for_migration_conflicts
237+
docker compose exec api python manage.py check_for_migration_conflicts
230238

231239
test_env:
232240
make test_env.up

README.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
Codecov API
2-
-----------
1+
## Codecov API
32

43
> We believe that everyone should have access to quality software (like Sentry), that’s why we have always offered Codecov for free to open source maintainers.
54
>
65
> By making our code public, we’re not only joining the community that’s supported us from the start — but also want to make sure that every developer can contribute to and build on the Codecov experience.
76
8-
A private Django REST Framework API intended to serve Codecov's front end.
7+
A private Django REST Framework API intended to serve Codecov's front end.
98

109
## Getting Started
1110

@@ -21,7 +20,7 @@ Note, you'll need to install Rust to build `ribs` which is a dependency of `shar
2120

2221
### Running Standalone
2322

24-
This project contains a `docker-compose.yml` file that is intended to run the api standalone. In this configuration it **does not** share codecov.io's development database; so don't expect parity there.
23+
This project contains a `docker-compose.yml` file that is intended to run the api standalone. In this configuration it **does not** share codecov.io's development database; so don't expect parity there.
2524

2625
To start the service, do
2726

@@ -33,7 +32,7 @@ Once running, the api will be available at `http://localhost:5100`
3332

3433
### Running with codecov.io
3534

36-
This service will startup when you run codecov.io normally. It is under that `api` block of codecov.io's `docker-compose.yml` file.
35+
This service will startup when you run codecov.io normally. It is under that `api` block of codecov.io's `docker-compose.yml` file.
3736

3837
### Testing
3938

@@ -48,7 +47,7 @@ If you would like to use pytest directly (Either through an IDE like PyCharm or
4847

4948
RUN_ENV=TESTING DJANGO_SETTINGS_MODULE=codecov.settings_test pytest
5049

51-
Make sure to have all the requirements from `requirements.txt` installed.
50+
Make sure to have all the latest dependencies installed via `uv sync`.
5251

5352
### Deploying
5453

@@ -69,23 +68,18 @@ Steps 2 and 3 are important to limit interaction between features not yet merged
6968
This project should store no secrets or credentials in its source. If you need to add to / modify / setup secrets for this project, contact Eli and he'll get you started..
7069

7170
### Adding dependencies
72-
This repository uses `pip-tools` to manage dependencies, so make sure you've installed it with `pip install pip-tools`. To add or update dependencies, change `requirements.in`, Then run
7371

74-
```
75-
pip-compile requirements.in
76-
```
77-
78-
Do not change `requirements.txt` directly.
72+
This repository uses `uv` to manage dependencies, so make sure you've installed it with `pip install uv`. To add or update dependencies, simply run `uv add __package_name__` or `uv sync`.
7973

8074
### Formatting
8175

82-
This project uses `ruff` for formatting.
83-
You can run the linter using the command `make lint`.
76+
This project uses `ruff` for formatting.
77+
You can run the linter using the command `make lint_local`.
8478

8579
### Migrations
8680

8781
We leverage Django's migration system to keep the state of our models in sync with the state of our database. You can read more about how we work with migrations at https://codecovio.atlassian.net/wiki/spaces/ENG/pages/1696530442/Migrations
8882

8983
## Contributing
9084

91-
This repository, like all of Codecov's repositories, strives to follow our general [Contributing guidlines](https://github.com/codecov/contributing). If you're considering making a contribution to this repository, we encourage review of our Contributing guidelines first.
85+
This repository, like all of Codecov's repositories, strives to follow our general [Contributing guidlines](https://github.com/codecov/contributing). If you're considering making a contribution to this repository, we encourage review of our Contributing guidelines first.

dev.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ _start_gunicorn() {
2323
python manage.py insert_data_to_db_from_csv core/management/commands/codecovPlans-Jan25.csv --model plans
2424
fi
2525
if [[ "$DEBUGPY" ]]; then
26-
pip install debugpy
26+
uv add debugpy
27+
uv sync
2728
python -m debugpy --listen 0.0.0.0:12345 -m gunicorn codecov.wsgi:application --reload --bind 0.0.0.0:8000 --access-logfile '-' --timeout "${GUNICORN_TIMEOUT:-600}" $suffix
2829
fi
2930
gunicorn codecov.wsgi:application --reload --bind 0.0.0.0:8000 --access-logfile '-' --timeout "${GUNICORN_TIMEOUT:-600}" $suffix

docker/Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ ARG BERGLAS_VERSION=2.0.6
66
FROM us-docker.pkg.dev/berglas/berglas/berglas:$BERGLAS_VERSION as berglas
77

88
FROM $REQUIREMENTS_IMAGE as app
9-
COPY . /app/apps/codecov-api
9+
1010
WORKDIR /app/apps/codecov-api
11-
RUN pip install setuptools==71.1.0
12-
RUN python manage.py collectstatic --no-input
11+
ADD . /app/apps/codecov-api
12+
1313

1414
FROM app as local
1515

@@ -20,7 +20,6 @@ COPY --chmod=755 --from=berglas /bin/berglas /usr/local/bin/berglas
2020

2121
FROM app as self-hosted
2222

23-
RUN pip uninstall -y typing
2423
# set settings module
2524
ENV DJANGO_SETTINGS_MODULE="codecov.settings_enterprise"
2625
# Remove the settings dev and enterprise files.

0 commit comments

Comments
 (0)