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

Factor out a function to load app config #519

Merged
merged 3 commits into from
Jul 11, 2023

Conversation

chadwhitacre
Copy link
Member

@chadwhitacre chadwhitacre commented Jul 11, 2023

Part of #482.

Since we're going to have somewhat complex logic to parse envvars into app config, we should test as we go. Factoring out a function gives us something to test.

@chadwhitacre chadwhitacre mentioned this pull request Jul 10, 2023
43 tasks
src/api/github/appAuthStrategyOptions.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,14 @@
import { AppAuthStrategyOptions } from '@api/github/appAuthStrategyOptions';

export function loadGitHubApps(env) {
Copy link
Member

Choose a reason for hiding this comment

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

does this function need to pass in environment variables as env? Can we just use process.env here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It makes testing much easier.

Copy link
Member

@hubertdeng123 hubertdeng123 Jul 11, 2023

Choose a reason for hiding this comment

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

In that case, can we just pass in GH_APP_IDENTIFIER and GH_APP_SECRET_KEY instead? feels a bit weird to me to pass all the env variables just to use two of them

Copy link
Member Author

Choose a reason for hiding this comment

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

Filtering out unused envvars is part of the logic we want to test, no? Does da690d2 help? It changes the function name to loadGitHubAppsFromEnvironment and adds a few more tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also keep in mind that the next PR is going to add multi-org support, for which we're going to need to iterate over the whole process.env to pull out the vars we want.

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha, I think this is a pretty small thing and don't want to block you further. Thanks for making it more clear

@codecov
Copy link

codecov bot commented Jul 11, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.03 ⚠️

Comparison is base (22559ea) 84.50% compared to head (da690d2) 84.48%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #519      +/-   ##
==========================================
- Coverage   84.50%   84.48%   -0.03%     
==========================================
  Files          96       97       +1     
  Lines        2479     2475       -4     
  Branches      481      473       -8     
==========================================
- Hits         2095     2091       -4     
  Misses        377      377              
  Partials        7        7              
Impacted Files Coverage Δ
src/api/github/getClient.ts 86.66% <100.00%> (ø)
src/config/index.ts 98.00% <100.00%> (-0.06%) ⬇️
src/config/loadGitHubAppsFromEnvironment.ts 100.00% <100.00%> (ø)

... and 6 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@chadwhitacre chadwhitacre merged commit ff05eeb into main Jul 11, 2023
@chadwhitacre chadwhitacre deleted the cwlw/factor-out-app-config-loader branch July 11, 2023 17:37
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.

2 participants