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

feat: Track Upload Sent events for Coverage/BA/TA #1162

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

spalmurray-codecov
Copy link
Contributor

@spalmurray-codecov spalmurray-codecov commented Feb 18, 2025

Adds event tracking of 'Upload Sent' events for Coverage, Bundles, and test results.

It seems in some cases commit may not have an author set during TA/BA ingest. In these cases we've decided to attribute the events to a special anonymous user that has a special user id constant in shared.

Note that we are using commit.id instead of the commit sha because a full commit sha is functionally identifiable information (for public repos at least). No reason to use this when we have an internal id that does the same thing but is only useful to us.

Copy link

codecov bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.91%. Comparing base (baeff88) to head (156631e).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1162   +/-   ##
=======================================
  Coverage   95.91%   95.91%           
=======================================
  Files         492      492           
  Lines       16865    16871    +6     
=======================================
+ Hits        16176    16182    +6     
  Misses        689      689           
Flag Coverage Δ
unit 95.91% <100.00%> (+<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.

@codecov-staging
Copy link

codecov-staging bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codecov-qa
Copy link

codecov-qa bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.94%. Comparing base (5fb43ea) to head (1d42fb7).

✅ All tests successful. No failed tests found.

Copy link
Contributor

github-actions bot commented Feb 18, 2025

✅ All tests successful. No failed tests were found.

📣 Thoughts on this report? Let Codecov know! | Powered by Codecov

Copy link

❌ 75 Tests Failed:

Tests completed Failed Passed Skipped
2746 75 2671 6
View the top 3 failed tests by shortest run time
upload/tests/views/test_uploads.py::::test_uploads_post_token_required_auth_check[False-fork:branch-fork:branch-True]
Stack Traces | 0.003s run time
db = None, mocker = <pytest_mock.plugin.MockerFixture object at 0x7f19e845b0e0>
mock_redis = FakeStrictRedis<ConnectionPool<FakeConnection<server=<fakeredis._server.FakeServer object at 0x7f19e8494680>,db=0>>>
private = True, branch = 'fork:branch', branch_sent = 'fork:branch'
upload_token_required_for_public_repos = False

    @pytest.mark.parametrize("private", [False, True])
    @pytest.mark.parametrize("branch", ["branch", "fork:branch", "someone/fork:branch"])
    @pytest.mark.parametrize(
        "branch_sent", [None, "branch", "fork:branch", "someone/fork:branch"]
    )
    @pytest.mark.parametrize("upload_token_required_for_public_repos", [True, False])
    def test_uploads_post_token_required_auth_check(
        db,
        mocker,
        mock_redis,
        private,
        branch,
        branch_sent,
        upload_token_required_for_public_repos,
    ):
        presigned_put_mock = mocker.patch(
            "shared.api_archive.archive.StorageService.create_presigned_put",
            return_value="presigned put",
        )
        upload_task_mock = mocker.patch(
            "upload.views.uploads.trigger_upload_task", return_value=True
        )
        analytics_service_mock = mocker.patch("upload.views.uploads.AnalyticsService")
>       amplitude_mock = mocker.path("shared.events.amplitude.AmplitudeEventPublisher")
E       AttributeError: 'MockerFixture' object has no attribute 'path'. Did you mean: 'patch'?

.../tests/views/test_uploads.py:474: AttributeError
upload/tests/views/test_uploads.py::::test_uploads_post_token_required_auth_check[True-fork:branch-branch-True]
Stack Traces | 0.004s run time
db = None, mocker = <pytest_mock.plugin.MockerFixture object at 0x7f1a009ca4e0>
mock_redis = FakeStrictRedis<ConnectionPool<FakeConnection<server=<fakeredis._server.FakeServer object at 0x7f1a03ff8380>,db=0>>>
private = True, branch = 'branch', branch_sent = 'fork:branch'
upload_token_required_for_public_repos = True

    @pytest.mark.parametrize("private", [False, True])
    @pytest.mark.parametrize("branch", ["branch", "fork:branch", "someone/fork:branch"])
    @pytest.mark.parametrize(
        "branch_sent", [None, "branch", "fork:branch", "someone/fork:branch"]
    )
    @pytest.mark.parametrize("upload_token_required_for_public_repos", [True, False])
    def test_uploads_post_token_required_auth_check(
        db,
        mocker,
        mock_redis,
        private,
        branch,
        branch_sent,
        upload_token_required_for_public_repos,
    ):
        presigned_put_mock = mocker.patch(
            "shared.api_archive.archive.StorageService.create_presigned_put",
            return_value="presigned put",
        )
        upload_task_mock = mocker.patch(
            "upload.views.uploads.trigger_upload_task", return_value=True
        )
        analytics_service_mock = mocker.patch("upload.views.uploads.AnalyticsService")
>       amplitude_mock = mocker.path("shared.events.amplitude.AmplitudeEventPublisher")
E       AttributeError: 'MockerFixture' object has no attribute 'path'. Did you mean: 'patch'?

.../tests/views/test_uploads.py:474: AttributeError
upload/tests/views/test_uploads.py::::test_uploads_post_tokenless[fork:branch-fork:branch-False]
Stack Traces | 0.004s run time
db = None, mocker = <pytest_mock.plugin.MockerFixture object at 0x7f1a03ffb6e0>
mock_redis = FakeStrictRedis<ConnectionPool<FakeConnection<server=<fakeredis._server.FakeServer object at 0x7f1a01b5c2c0>,db=0>>>
private = False, branch = 'fork:branch', branch_sent = 'fork:branch'

    @pytest.mark.parametrize("private", [False, True])
    @pytest.mark.parametrize("branch", ["branch", "fork:branch", "someone/fork:branch"])
    @pytest.mark.parametrize(
        "branch_sent", [None, "branch", "fork:branch", "someone/fork:branch"]
    )
    def test_uploads_post_tokenless(db, mocker, mock_redis, private, branch, branch_sent):
        presigned_put_mock = mocker.patch(
            "shared.api_archive.archive.StorageService.create_presigned_put",
            return_value="presigned put",
        )
        upload_task_mock = mocker.patch(
            "upload.views.uploads.trigger_upload_task", return_value=True
        )
        analytics_service_mock = mocker.patch("upload.views.uploads.AnalyticsService")
>       amplitude_mock = mocker.path("shared.events.amplitude.AmplitudeEventPublisher")
E       AttributeError: 'MockerFixture' object has no attribute 'path'. Did you mean: 'patch'?

.../tests/views/test_uploads.py:317: AttributeError

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

@spalmurray-codecov spalmurray-codecov marked this pull request as ready for review February 18, 2025 20:11
@spalmurray-codecov spalmurray-codecov requested a review from a team as a code owner February 18, 2025 20:11
Copy link
Contributor

@ajay-sentry ajay-sentry left a comment

Choose a reason for hiding this comment

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

lgtm!

@spalmurray-codecov spalmurray-codecov force-pushed the spalmurray/amplitude-upload-event branch from 55bc911 to 156631e Compare February 24, 2025 16:55
Copy link
Contributor

@ajay-sentry ajay-sentry left a comment

Choose a reason for hiding this comment

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

looks good!

Copy link
Contributor

@joseph-sentry joseph-sentry left a comment

Choose a reason for hiding this comment

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

generally lgtm but just a couple questions

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