Skip to content

Conversation

@matt-codecov
Copy link
Contributor

depends on:

also hacks the absorb script to include these PRs for worker/api:

commands:

$ git checkout -b matt/absorb-dry-run-clean

$ ./tools/absorb-repo/absorb-repo.sh shared git@github.com:codecov/shared.git libs/shared

$ ./tools/absorb-repo/absorb-repo.sh worker git@github.com:codecov/worker.git apps/worker
$ cd apps/worker
$ sed -i '' 's/shared = { git.*/shared = { path = "..\/..\/libs\/shared" }/' pyproject.toml
$ uv sync
$ cd -
$ git add .
$ git commit -m 'use local shared for worker'

$ ./tools/absorb-repo/absorb-repo.sh codecov-api git@github.com:codecov/codecov-api.git apps/codecov-api
$ cd apps/codecov-api
$ sed -i '' 's/shared = { git.*/shared = { path = "..\/..\/libs\/shared" }/' pyproject.toml
$ uv sync
$ cd -
$ git add .
$ git commit -m 'use local shared for api'

local validation:

$ make devenv

$ make devenv.test.worker

$ make devenv.test.api

$ make devenv.test.shared

note that you need the umbrella conf file from our 1PW vault for all tests to pass locally.

ajay-sentry and others added 30 commits February 21, 2025 19:48
* Consolidate implementation of `_process_totals`

In particular, this unifies the duplicated implementations of these methods across `Filtered/ReportFile`.

The new method also spells out a "very concise, but also unreadable" implementation that sums up the cyclomatic complexity (something I would like to remove completely eventually).
This is now more readable and understandable, but more importantly, it only iterates over the `lines` *once*, instead of twice as the previous implementation did.
Along with avoiding a bunch of intermediate list allocations that the `FilteredReportFile` implementation did, this should yield quite a good speedup.

* rename imports
There is the `old` substring match behavior, and the new exact match one.
We do get logs for mismatches, but usage of the old behavior depends on a config flag which we are not logging yet.
* Remove unused `ReadOnlyReport.append`

This method seemed to have been intended to warn about wrong usage of `ReadOnlyReport`.

I checked both in production logs, as well as scanning through the code, and it looks like we are not misusing the this report class in such a way. So it is safe to remove this warning.

* rm test
The base `Report` and `ReportFile` classes had some code related to filtering which was never actually used, as filtering works using the `FilteredReport` class.
the goal of the storage service was to wrap the old minio storage
service with 2 methods for creating and getting presigned urls. it did
this by accessing the inner minio client of that service.

i don't think we need this, we can instead have the minio storage
and new minio storage services implement the same functionality and
have that interface encoded as a new ABC.

so this commit removes the storage service, creates a new ABC,
inherits that ABC in the minio storage services, then has the archive
service to use the minio storage services directly
* Consolidate implementation of `calculate_diff`

This cleans up the duplicated implementations of `Filtered/Report.calculate_diff` and moves it to a new well typed file.

* improve typing and docs
In particular, this better highlights the difference between a shallow and a full parse of the Report.

It also focuses the `totals` code a bit more, making the different operations more obvious.
The filtering has also been slightly updated.

As a driveby fix, this fixes the `Report.get(bind)` code, which was completely broken (because noone was using it?)
* Micro-optimize `_line` parser

The `ReportLine` `__post_init__` method already converts `LineSession`s to proper objects. No need to do that in `_line` as well.

* fix more imports
* Port `change_sessionid` from `worker`

This is a first step moving that function, before further work in `shared` can happen to merge the `EditableReport` back into the main `Report` class.

* fix test
The recent change to the `api_archive.ArchiveService` meant that all the mocks that target `get_appropriate_storage_service` within `worker` stopped working.

This fixes the mocking within `worker` by making sure that we always go through `get_appropriate_storage_service`.
This was a recent regression from consolidating the diff calculation.
Downstream code expects/asserts the `complexity/_total` to be `None` when no lines have been touched by the diff.
* Add amplitude unsafe_publish method, making publish safe by default

* Lint

* Add prometheus metric

* Lint

* Use separate counters for total calls and failures

* Lint

* Add error name and event type to error log
joseph-sentry and others added 23 commits April 3, 2025 14:55
This extends GitHub request caching to the `list_files` and `get_source` functions.

While both can take an arbitrary "mutable" ref, like a branch name, we only call those with an immutable commit sha, which makes these good calls to cache.
@codecov
Copy link

codecov bot commented Apr 8, 2025

Codecov Report

Attention: Patch coverage is 98.41675% with 93 lines in your changes missing coverage. Please review.

Project coverage is 96.50%. Comparing base (dd90d42) to head (d1f03fc).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
apps/codecov-api/api/internal/tests/test_charts.py 88.58% 42 Missing ⚠️
...cov-api/api/internal/tests/views/test_repo_view.py 97.08% 11 Missing ⚠️
apps/codecov-api/api/internal/chart/views.py 86.36% 6 Missing ⚠️
apps/codecov-api/api/internal/repo/filter.py 84.61% 4 Missing ⚠️
apps/codecov-api/api/internal/tests/test_utils.py 78.94% 4 Missing ⚠️
...i/api/internal/tests/views/test_account_viewset.py 99.40% 4 Missing ⚠️
apps/codecov-api/api/internal/chart/helpers.py 96.80% 3 Missing ⚠️
apps/codecov-api/api/gen_ai/views.py 95.34% 2 Missing ⚠️
apps/codecov-api/api/internal/feature/views.py 96.61% 2 Missing ⚠️
apps/codecov-api/api/internal/owner/serializers.py 99.12% 2 Missing ⚠️
... and 10 more
Additional details and impacted files
@@           Coverage Diff            @@
##             main      #31    +/-   ##
========================================
  Coverage   96.49%   96.50%            
========================================
  Files        1654     1643    -11     
  Lines       93104    92959   -145     
  Branches     1464     1458     -6     
========================================
- Hits        89843    89707   -136     
+ Misses       2956     2947     -9     
  Partials      305      305            
Flag Coverage Δ
apiunit 98.02% <98.41%> (+0.01%) ⬆️
shared-docker-uploader 87.99% <ø> (-0.06%) ⬇️
workerintegration 42.82% <ø> (-0.03%) ⬇️
workerunit 90.49% <ø> (-0.01%) ⬇️

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.

@codspeed-hq
Copy link

codspeed-hq bot commented Apr 8, 2025

CodSpeed Performance Report

Merging #31 will create unknown performance changes

Comparing matt/absorb-dry-run-clean (d1f03fc) with main (dd90d42)

Summary

🆕 9 new benchmarks
⁉️ 9 dropped benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 test_parse_full N/A 535.6 ms N/A
🆕 test_parse_shallow N/A 9.5 ms N/A
🆕 test_process_totals N/A 640 ms N/A
🆕 test_report_carryforward N/A 2.7 ms N/A
🆕 test_report_diff_calculation[FilteredReport] N/A 3.1 ms N/A
🆕 test_report_diff_calculation[Report] N/A 1.9 ms N/A
🆕 test_report_filtering N/A 2.6 s N/A
🆕 test_report_merge N/A 2.7 s N/A
🆕 test_report_serialize N/A 5.8 ms N/A
⁉️ test_parse_full 534.9 ms N/A N/A
⁉️ test_parse_shallow 9.5 ms N/A N/A
⁉️ test_process_totals 640.7 ms N/A N/A
⁉️ test_report_carryforward 2.7 ms N/A N/A
⁉️ test_report_diff_calculation[FilteredReport] 3.1 ms N/A N/A
⁉️ test_report_diff_calculation[Report] 2 ms N/A N/A
⁉️ test_report_filtering 2.6 s N/A N/A
⁉️ test_report_merge 2.7 s N/A N/A
⁉️ test_report_serialize 5.8 ms N/A N/A

@matt-codecov
Copy link
Contributor Author

CI passed, closing

@matt-codecov matt-codecov deleted the matt/absorb-dry-run-clean branch April 30, 2025 19:41
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.