Skip to content

Add type SponsorshipEvent - #3258

Merged
gmlewis merged 8 commits into
google:masterfrom
DiegoDev2:add-sponsorship-event-type
Sep 10, 2024
Merged

Add type SponsorshipEvent#3258
gmlewis merged 8 commits into
google:masterfrom
DiegoDev2:add-sponsorship-event-type

Conversation

@DiegoDev2

Copy link
Copy Markdown
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

@gmlewisgmlewis changed the title [Add Type] Add type SponsorshipEventAdd type SponsorshipEventSep 8, 2024
@codecov

codecovBot commented Sep 8, 2024

Copy link
Copy Markdown

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.

@gmlewisgmlewis left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
ContributorAuthor

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

@gmlewis

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
ContributorAuthor

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

@gmlewis

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
ContributorAuthor

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

@gmlewis

Copy link
Copy Markdown
Collaborator

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

@gmlewis

Copy link
Copy Markdown
Collaborator

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

@DiegoDev2

Copy link
Copy Markdown
ContributorAuthor

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

@DiegoDev2

Copy link
Copy Markdown
ContributorAuthor

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

@gmlewis

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Collaborator

For example:

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

Signed-off-by: CodeDiego15 <andrebermudezdiego@gmail.com>
@DiegoDev2

Copy link
Copy Markdown
ContributorAuthor

I already did👍🏻

@DiegoDev2

Copy link
Copy Markdown
ContributorAuthor

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

@gmlewisgmlewis left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
ContributorAuthor

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

Comment threadgithub/messages_test.go Outdated
@gmlewis

Copy link
Copy Markdown
Collaborator

Still not sorted. Please try again.

@DiegoDev2

Copy link
Copy Markdown
ContributorAuthor

AAAA

@DiegoDev2

Copy link
Copy Markdown
ContributorAuthor

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

@gmlewis

Copy link
Copy Markdown
Collaborator

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

@gmlewis

gmlewis commented Sep 10, 2024

Copy link
Copy Markdown
Collaborator

@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.

@gmlewisgmlewis left a comment

Copy link
Copy Markdown
Collaborator

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:masterSep 10, 2024
@DiegoDev2

Copy link
Copy Markdown
ContributorAuthor

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

Sign up for freeto 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

@DiegoDev2@gmlewis