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

Cache feature flags on disk #1384

Merged
merged 4 commits into from
Nov 21, 2022
Merged

Cache feature flags on disk #1384

merged 4 commits into from
Nov 21, 2022

Conversation

aeisenberg
Copy link
Contributor

@aeisenberg aeisenberg commented Nov 21, 2022

This will allow feature flags to be shared across steps in the same job, avoiding an error we saw earlier where the init action had the flag enabled, but the analyze step had it disabled.

This uses the runner's temp folder to cache the flags file, which will stick around until the job completes.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

This will allow feature flags to be shared across steps in the same job,
avoiding an error we saw earlier where the init action had the flag
enabled, but the analyze step had it disabled.

This uses the runner's temp folder to cache the flags file, which will
stick around until the job completes.
@aeisenberg aeisenberg requested a review from a team as a code owner November 21, 2022 19:17
Comment on lines +325 to +328
fs.writeFileSync(
cachedFeatureFlags,
JSON.stringify(actualFeatureEnablement)
);

Check failure

Code scanning / CodeQL

Potential file system race condition

The file may have changed since it [was checked](1). The file may have changed since it [was checked](2).
Copy link
Contributor

Choose a reason for hiding this comment

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

Huh.. should we be checking files we write to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This does feel like an FP. I will contact the team.

angelapwen
angelapwen previously approved these changes Nov 21, 2022
Copy link
Contributor

@angelapwen angelapwen left a comment

Choose a reason for hiding this comment

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

Thanks!! Makes sense, just a couple of naming thoughts

Comment on lines +325 to +328
fs.writeFileSync(
cachedFeatureFlags,
JSON.stringify(actualFeatureEnablement)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Huh.. should we be checking files we write to?

src/feature-flags.ts Show resolved Hide resolved
@@ -55,6 +58,8 @@ export const featureConfig: Record<
*/
type GitHubFeatureFlagsApiResponse = Partial<Record<Feature, boolean>>;

export const FEATURE_FLAGS_FILE_NAME = "feature-flags.json";
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if this could be renamed to include local or cache somehow so it's easier to remember the difference between this file and the remote server-side flags 🤔

Copy link
Contributor

@angelapwen angelapwen left a comment

Choose a reason for hiding this comment

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

Thanks! Extra test looks 👍

@aeisenberg aeisenberg merged commit 26df9a9 into main Nov 21, 2022
@aeisenberg aeisenberg deleted the aeisenberg/feature-flags-disk branch November 21, 2022 23:25
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