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

Add type SponsorshipEvent #3258

Merged
merged 8 commits into from
Sep 10, 2024
Merged

Conversation

DiegoDev2
Copy link
Contributor

Description

This pull request adds support for the SponsorshipEvent to the go-github library, addressing the issue described in #2982.

Details

According to GitHub documentation (SponsorshipEvent), the SponsorshipEvent is triggered when sponsorship changes occur, such as creation, cancellation, or tier changes.

This PR introduces the following changes:

  • New SponsorshipEvent struct: Captures the key properties of a sponsorship event, including:

    • Action: The type of action performed (e.g., created, tier_changed, cancelled, etc.).
    • EffectiveDate: The date when the event or change becomes effective, applicable for events like pending_cancellation and pending_tier_change.
    • Changes: An optional field that captures details about changes, such as adjustments in sponsorship tier or privacy. This is represented by an embedded struct called SponsorshipChanges.
    • Standard fields like Repository, Organization, Sender, and Installation are also included to maintain consistency with other GitHub event types.
  • New SponsorshipChanges struct: This struct provides additional details when the tier or privacy_level of a sponsorship is modified.

    • The Tier field captures tier changes using an embedded SponsorshipTier struct, which contains a From field representing the previous tier.
    • The PrivacyLevel field tracks any changes to the sponsorship’s privacy settings.

This new event type will allow go-github users to programmatically handle sponsorship-related events triggered on GitHub, improving support for GitHub Sponsors workflows.

Testing

  • Unit tests have been added to verify the correct deserialization of the SponsorshipEvent struct from JSON payloads.
  • The tests cover various event scenarios, including tier changes, privacy level changes, and sponsorship creation.

Issue Link

Resolves #2982

@gmlewis gmlewis changed the title [Add Type] Add type SponsorshipEvent Add type SponsorshipEvent Sep 8, 2024
Copy link

codecov bot commented Sep 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.94%. Comparing base (2b8c7fa) to head (b5df93c).
Report is 108 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3258      +/-   ##
==========================================
- Coverage   97.72%   92.94%   -4.78%     
==========================================
  Files         153      171      +18     
  Lines       13390    11663    -1727     
==========================================
- Hits        13085    10840    -2245     
- Misses        215      729     +514     
- Partials       90       94       +4     

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

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

Thank you, @CodeDiego15 !
Please read step 4 of CONTRIBUTING.md and push (not force-push) the resulting changes to this PR.

@DiegoDev2
Copy link
Contributor Author

Force the push? Oh sorry I didn't notice.

@gmlewis
Copy link
Collaborator

gmlewis commented Sep 8, 2024

Force the push? Oh sorry I didn't notice.

No. Please push the results. (Not a big deal, but please do NOT use force push in this repo, as explained in CONTRIBUTING.md, as we always use squash and merge in this repo.)

@DiegoDev2
Copy link
Contributor Author

I did a normal git push, I don't know what happened, I'm sorry

@gmlewis
Copy link
Collaborator

gmlewis commented Sep 8, 2024

Please read step 4 of CONTRIBUTING.md

Once again, please read step 4 of CONTRIBUTING.md.

Specifically,

  1. Run script/fmt.sh, script/test.sh and script/lint.sh to format your code and
    check that it passes all tests and linters. script/lint.sh may also tell you
    that generated files need to be updated. If so, run script/generate.sh to
    update them.

@DiegoDev2
Copy link
Contributor Author

That's what I'm trying right now, but when I do I get this: ./script/fmt.sh
usage: dirname path

@gmlewis
Copy link
Collaborator

gmlewis commented Sep 8, 2024

OK, then just try ./script/generate.sh

@gmlewis
Copy link
Collaborator

gmlewis commented Sep 8, 2024

And if that fails, then please try go generate ./...

@DiegoDev2
Copy link
Contributor Author

That's it, some dependencies were downloaded, After that and excuse me. First time I contribute to the

@DiegoDev2
Copy link
Contributor Author

Excuse me for bothering you so much, is there something missing to solve it?

@gmlewis
Copy link
Collaborator

gmlewis commented Sep 8, 2024

Once you run go generate ./... then some auto-generated files should be updated.

Then, you can commit the changes, push to this PR, and the tests should all pass.

@gmlewis
Copy link
Collaborator

gmlewis commented Sep 8, 2024

For example:

go generate ./...
git commit -sam 'run step 4'
git push origin add-sponsorship-event-type

@DiegoDev2
Copy link
Contributor Author

I already did👍🏻

@DiegoDev2
Copy link
Contributor Author

Was it done again as Git Push --forze? Because I did a normal git push?

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

Please update messages.go by adding this somewhere around line 104:

		"security_and_analysis":          &SecurityAndAnalysisEvent{},
		"sponsorship":                    &SponsorshipEvent{},
		"star":                           &StarEvent{},

and also update messages_test.go respectively. Thanks.

@DiegoDev2
Copy link
Contributor Author

Hello good evening, an apology I had to leave. I'm already working on it

github/messages_test.go Outdated Show resolved Hide resolved
@gmlewis
Copy link
Collaborator

gmlewis commented Sep 9, 2024

Still not sorted. Please try again.

@DiegoDev2
Copy link
Contributor Author

AAAA

@DiegoDev2
Copy link
Contributor Author

I'm sorry, I don't know what to do anymore.

@gmlewis
Copy link
Collaborator

gmlewis commented Sep 10, 2024

No problem. I'll take over from here. Thanks.

@gmlewis
Copy link
Collaborator

gmlewis commented Sep 10, 2024

@CodeDiego15 -

Here's what you had before I made changes:

before-2024-09-09_20-41-58

Here's what I changed it to:

after-2024-09-09_20-45-11

See the difference?

It always helps to take a look at the changes directly in the GitHub user interface so that you can see exactly what is being changed.

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

Thank you, @CodeDiego15 !
LGTM.
Merging.

@gmlewis gmlewis merged commit 662da6f into google:master Sep 10, 2024
6 of 7 checks passed
@DiegoDev2
Copy link
Contributor Author

Thank you very much for accepting the PR will probably contribute to more issues.

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.

Missing SponsorshipEvent in events types
2 participants