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

Switch [OpenCollective] badges to use GraphQL and auth #9387

Merged
merged 5 commits into from Aug 20, 2023

Conversation

chris48s
Copy link
Member

@chris48s chris48s commented Jul 15, 2023

Closes #9345
Refs #9345 (comment)
Refs #9346 (comment)

This PR takes the code changes from #9346 and makes them viable for production traffic by adding auth and increasing the cache.

I've already reviewed c1a2593 in #9345 so it is only really the 3 additional commits that need a look here.

As things stand, we're currently using a more than 100 reqs/minute at busy times, but also we only cache these badges for 2 mins at the moment. Lets bump that up to 15 mins. That should keep us in line.
Potentially we could exceed this in future if OpenCollective badges become more popular. However I feel like if we need it, OpenCollective is a bit more of a human-scale organisation to ask for an increase than Youtube or DockerHub, for example.

I've made an OpenCollective account attached to the team AT shields.io email that has access to nothing and generated an API token with no scopes that we can use in production
I think for tests, review apps and staging, the anonymous rate limit will be OK

TODO: Before deploying this, add the token to the production env vars and shared credentials store

xxchan and others added 4 commits July 15, 2023 17:24
* update opencollective to api v2

* fix tests

* fix: do not filter by accountType for opencollective/all

* remove 404

* remove required in schema

* cnt -> count

* keep by-tier code as-is

---------

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
@chris48s chris48s added the service-badge Accepted and actionable changes, features, and bugs label Jul 15, 2023
@@ -218,7 +218,7 @@ installation access to private npm packages

[npm token]: https://docs.npmjs.com/getting-started/working_with_tokens

## Open Build Service
### Open Build Service
Copy link
Member Author

Choose a reason for hiding this comment

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

This isn't really related to this PR. I just noticed this heading level was wrong while I was editing the file.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 15, 2023

Warnings
⚠️ This PR modified the server but none of its tests.
That's okay so long as it's refactoring existing code.
Messages
📖 ✨ Thanks for your contribution to Shields, @chris48s!
📖

Thanks for contributing to our documentation. We ❤️ our documentarians!

Generated by 🚫 dangerJS against e3b4f91

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, one somewhat tangential inline thought below

Comment on lines +6 to +16
class DummyOpencollectiveService extends OpencollectiveBase {
static route = this.buildRoute('dummy')

async handle({ collective }) {
const data = await this.fetchCollectiveInfo({
collective,
accountType: [],
})
return this.constructor.render(this.getCount(data))
}
}
Copy link
Member

Choose a reason for hiding this comment

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

No concerns with using a dummy child class, though it does remind of a scenario we ran into with some of the GitLab classes a ways back where we forgot to wire up the auth for one or two of them. As a thought/potential future exercise, I wonder if there's a clean way we could consistently test "does every class that's supposed to use the auth" without having to write all the boilerplate for every single class 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it is a fair point, but the pattern here is not not unique to this service or PR. We use the same approach in other places e.g: https://github.com/badges/shields/blob/master/services/stackexchange/stackexchange-base.spec.js

I've raised #9493 as I agree it is worth improving

@chris48s
Copy link
Member Author

chris48s commented Aug 19, 2023

I'm going to hold off merging this just yet as I don't think I've set the OpenCollective token env vars in staging/prod yet. Will sort that out and get a deploy done soon though.

@chris48s chris48s added this pull request to the merge queue Aug 20, 2023
Merged via the queue into badges:master with commit 8f76982 Aug 20, 2023
20 checks passed
@chris48s chris48s deleted the 9345-oc-auth branch August 20, 2023 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge Accepted and actionable changes, features, and bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

opencollective members counts are imprecise
3 participants