Skip to content
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

... :O Port Some API Models to Shared #139

Merged
merged 46 commits into from
Apr 8, 2024

Conversation

adrian-codecov
Copy link
Contributor

@adrian-codecov adrian-codecov commented Mar 1, 2024

TLDR, we want to move all django API models to shared so they're shared amongst different codebases. This is a stab at it, first taking a look at Core, Codecov_authand Reports apps.

Specifically,

  • I've moved all models inside those apps
  • There are some fields I didn't move as those would require a substantially higher effort. I'm abstaining from that and following this approach instead
  • I moved all migrations for all those apps
  • All the makemigrations commands had noop
  • Moved some helper files that made sense for this transition. Didn't explicitly test those fns as they're tested through other functions in API

Files to take a special look at

  • docker-compose.yml
  • setup.py
  • duimmy_settings.py
  • migrate.py (mostly copy paste but slight change from original file)

The rest of the files are mostly copy-paste models + migrations

Note

I had to adjust some imports in migrations independently, for example, they used to be from core.models import DateTimeWithouTZField to from shared.django_apps.core.models import DateTimeWithouTZField`

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Copy link

codecov bot commented Mar 1, 2024

Codecov Report

Attention: Patch coverage is 82.70364% with 499 lines in your changes are missing coverage. Please review.

Project coverage is 89.30%. Comparing base (db61cbc) to head (b73c978).
Report is 1 commits behind head on main.

Files Patch % Lines
shared/reports/api_report_service.py 0.00% 119 Missing ⚠️
shared/django_apps/core/managers.py 28.76% 52 Missing ⚠️
shared/api_archive/archive.py 55.55% 48 Missing ⚠️
shared/django_apps/codecov_auth/models.py 91.26% 29 Missing and 7 partials ⚠️
..._migrations/migrations/legacy_sql/upgrades/v440.py 34.09% 29 Missing ⚠️
shared/django_apps/core/models.py 91.60% 22 Missing and 1 partial ⚠️
shared/plan/service.py 82.94% 18 Missing and 4 partials ⚠️
shared/django_apps/core/tests/factories.py 78.94% 14 Missing and 6 partials ⚠️
shared/api_archive/storage.py 34.48% 19 Missing ⚠️
shared/django_apps/codecov_auth/helpers.py 34.48% 19 Missing ⚠️
... and 27 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #139      +/-   ##
==========================================
- Coverage   91.97%   89.30%   -2.68%     
==========================================
  Files         117      314     +197     
  Lines        7187    10104    +2917     
  Branches     1644     1802     +158     
==========================================
+ Hits         6610     9023    +2413     
- Misses        545     1014     +469     
- Partials       32       67      +35     
Flag Coverage Δ
shared-docker-uploader ?
smart-labels 89.30% <82.70%> (-2.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -31,6 +33,10 @@ services:
tmpfs:
size: 1024M

redis:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed to run migrations tests

@thomasrockhu-codecov
Copy link
Contributor

this is a monster of a change, good luck to the reviewers

Copy link
Contributor

@matt-codecov matt-codecov left a comment

Choose a reason for hiding this comment

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

looks like there are a lot of totally untested files in this PR. could you check if any of them have tests in API you can steal?

  • api_archive/archive.py
  • api_archive/storage.py
  • django_apps/codecov_auth/helpers.py
  • django_apps/codecov_auth/managers.py
  • django_apps/core/managers.py
  • anything in django_apps/utils
  • reports/api_report_service.py

doesn't necessarily have to be in this PR, but would be good not to lose coverage. i guess when some of this code is deleted from API we'll be able to find tests that cover them

also i think there is a ton of code here we can dedup beyond models lol

codecov.yml Outdated
Comment on lines 14 to 25
services:
minio:
hash_key: 12345bf3f7d947f2a0681b2154067890
verify_ssl: false
host: "minio"
port: 9000
# bucket: <bucket-name>
# region: <bucket-region>
access_key_id: codecov-default-key
secret_access_key: codecov-default-secret
client_uploads: true

Copy link
Contributor

Choose a reason for hiding this comment

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

this section looks like it is meant to be in an "installation yaml" but this is a repo configuration yaml. also is that hash_key value a real secret or

Copy link
Contributor

Choose a reason for hiding this comment

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

i know there is some mock config stuff set up in https://github.com/codecov/shared/blob/main/tests/conftest.py but i don't actually know if/where there is a yml for the docker-compose setup. it may be that nobody needed one. if we need one now, put it in the docker folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hash_key is fake, I manually used prepend/append 12345 67890 to make it fake

Its late so not fully following the rest of the ask here, should I move this to a docker folder?

Copy link
Contributor

Choose a reason for hiding this comment

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

i think this codecov.yml is the one that defines our flags and stuff for our CI uploads, not the codecov.yml that defines the service config inside docker-compose. i don't think this will be read by anything. if you just delete it, does everything still work?

setup.py Outdated Show resolved Hide resolved
shared/api_archive/archive.py Show resolved Hide resolved
shared/django_apps/dummy_settings.py Outdated Show resolved Hide resolved
shared/django_apps/dummy_settings.py Outdated Show resolved Hide resolved
shared/django_apps/dummy_settings.py Outdated Show resolved Hide resolved
shared/django_apps/dummy_settings.py Outdated Show resolved Hide resolved
@adrian-codecov adrian-codecov merged commit 3cb5d67 into main Apr 8, 2024
7 of 10 checks passed
@adrian-codecov adrian-codecov deleted the 1256-move-api-models-to-shared branch April 8, 2024 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants