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

Allow user to supply an arbitrary filter param to [GithubTag] and [GithubRelease] badges #9193

Merged
merged 3 commits into from
Jul 3, 2023

Conversation

chris48s
Copy link
Member

@chris48s chris48s commented May 22, 2023

This PR implements the solution discussed in #9173 and applies it to the GitHub Tag and GitHub Release badges, although we could apply the same approach to others in future.

We've talked through the reasons and use-cases for this, but this provides a fairly flexible solution which enables users to do things like /github/v/tag/badges/shields?filter=%21server-%2A in monorepos and other situations where repos contain a mix of different tags/releases.

Closes #6253
Closes #6275
Closes #8205
Closes #9076
Closes #9080
Closes #9173

@calebcartwright - Although it would be nice to get this merged, if you've got time to review stuff, I am more keen to get #9014 over the line tbh.

@chris48s chris48s added the service-badge New or updated service badge label May 22, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 22, 2023

Messages
📖 ✨ Thanks for your contribution to Shields, @chris48s!

Generated by 🚫 dangerJS against 483a1d3

Comment on lines +73 to +74
given({ tags, filter: 'server-*' }).expect(['server-2022-01-01'])
given({ tags, filter: '!server-*' }).expect(['v1.1.0', 'v1.2.0'])
Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't really gone to town on testing different filters here. matcher has its own test suite.

I also haven't added any additional tests at the service layer. Just unit tests.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with the approach, we don't need to re-test the internals of a 3rd party library, just a couple of integration-like tests that give us confidence we're using that lib correctly.

Think you've fully cleared that threshold here 👍

@@ -32,7 +32,7 @@ t.create('Release (No releases)')

t.create('Prerelease (No releases)')
.get('/v/release/badges/daily-tests.json?include_prereleases')
.expectBadge({ label: 'release', message: 'no releases' })
.expectBadge({ label: 'release', message: 'no releases found' })
Copy link
Member Author

Choose a reason for hiding this comment

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

I've taken the opportunity here to align with the tag error message.

sort: 'date',
isPrerelease: false,
}),
documentation: documentation + filterDocs,
Copy link
Member Author

Choose a reason for hiding this comment

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

The move to OpenAPI in #9014 and follow-on PRs is going to make it way easier to document services that have lots of optional query params and provide documentation relevant to individual parameters.

if (!filter) {
return releases
}
if (displayName === 'tag') {
Copy link
Member Author

Choose a reason for hiding this comment

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

Here we apply the filter to either the release names or tag names depending on which is going to get displayed on the badge

@socket-security
Copy link

socket-security bot commented May 22, 2023

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

@chris48s
Copy link
Member Author

The socket.dev issues are false positive. Turns out there are a lot of similarly named packages called lodash.something :)

Copy link
Member

@calebcartwright calebcartwright left a comment

Choose a reason for hiding this comment

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

lgtm, will defer to you on when to merge as I know there's some other PRs that you may want to juggle (e.g. ones touching the lockfile, ones implementing similar end results, etc.)

@socket-security
Copy link

New dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
matcher 5.0.0 None +1 15.5 kB sindresorhus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge New or updated service badge
Projects
None yet
2 participants