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 coin gecko pro API usage for the governor #4025

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

Conversation

mdulin2
Copy link
Contributor

@mdulin2 mdulin2 commented Jul 18, 2024

In case the Guardians want to use API keys for Coin Gecko, support for the API keys has been added. This changes code in the Guardian and adds a command line flag.

Testing this is difficult because we don't want to include a key in here. Prior to this, I don't think we had tests for the query success from CoinGecko anyway. So, I added tests that make requests to coin gecko using the standard and pro APIs. If the API key isn't specified in the test file, the test is just skipped. If there's a better way to do this or relying on external APIs for builds to succeed is bad practice, then please say something and I'm happy to make changes accordingly.

@mdulin2
Copy link
Contributor Author

mdulin2 commented Jul 18, 2024

Failing tests have been fixed. I'm unsure why tilt is failing though.

@mdulin2
Copy link
Contributor Author

mdulin2 commented Jul 18, 2024

Once John's changes for cancel flow are approved at #4016 I'll have to fix a few locations since it touches similar code.

Copy link
Collaborator

@djb15 djb15 left a comment

Choose a reason for hiding this comment

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

Not sure if this is the best way to do it, but for the Pro API test we could load a string from an environment variable? That way we could add a key as a secret in GitHub and load it in the Action

node/cmd/guardiand/node.go Outdated Show resolved Hide resolved
node/pkg/governor/governor.go Outdated Show resolved Hide resolved
bruce-riley
bruce-riley previously approved these changes Jul 19, 2024
node/pkg/governor/governor_prices.go Outdated Show resolved Hide resolved
node/pkg/governor/governor_test.go Outdated Show resolved Hide resolved
node/pkg/governor/governor_test.go Outdated Show resolved Hide resolved
@mdulin2
Copy link
Contributor Author

mdulin2 commented Jul 19, 2024

Not sure if this is the best way to do it, but for the Pro API test we could load a string from an environment variable? That way we could add a key as a secret in GitHub and load it in the Action

Good thought! I wasn't sure if testing this small feature was worth the pain of doing something like that. What do you think?

Also, it depends on whether we can even connect to the Internet during our tests.

node/pkg/governor/governor_prices.go Outdated Show resolved Hide resolved
node/pkg/node/options.go Show resolved Hide resolved
@evan-gray
Copy link
Contributor

Not sure if this is the best way to do it, but for the Pro API test we could load a string from an environment variable? That way we could add a key as a secret in GitHub and load it in the Action

@djb15 - I saw this comment and wanted to note that I don’t believe secrets for this repo would be available to PRs from forks, so I would not rely on that approach. https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#using-secrets-in-a-workflow

It may be better to simply give reviewers a “hack” script or the like to prove the updated fetching logic does indeed work with and without an API key and have the unit tests ensure that URL is formatted appropriately.

@djb15
Copy link
Collaborator

djb15 commented Jul 30, 2024

@djb15 - I saw this comment and wanted to note that I don’t believe secrets for this repo would be available to PRs from forks, so I would not rely on that approach. https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#using-secrets-in-a-workflow

It may be better to simply give reviewers a “hack” script or the like to prove the updated fetching logic does indeed work with and without an API key and have the unit tests ensure that URL is formatted appropriately.

Ah thanks, yeah that's not an option then. Anyhow I think the approach we're going for with this now is to avoid adding an internet dependency here in these unit tests: #4025 (comment)

@evan-gray evan-gray marked this pull request as draft July 30, 2024 18:04
@evan-gray
Copy link
Contributor

converting to draft while this has conflicts

@mdulin2 mdulin2 marked this pull request as ready for review August 2, 2024 18:04
@mdulin2
Copy link
Contributor Author

mdulin2 commented Aug 2, 2024

I accidentally added a test CoinGecko API key in the last commit. I deleted the key from the PR and revoked the key from my coin gecko account.

djb15
djb15 previously approved these changes Aug 6, 2024
node/pkg/governor/governor_prices.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@SEJeff SEJeff left a comment

Choose a reason for hiding this comment

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

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants