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

Artifact creation and validation #2540

Merged
merged 37 commits into from
Sep 9, 2024

Conversation

d3caf
Copy link
Contributor

@d3caf d3caf commented Aug 29, 2024

This is based on #2538 and adds a script to create the release artifact and validate it.

Todo

  • Validate artifact with JSON schema
  • Verify that artifact is properly created
  • Save artifact to filesystem (or in a way that can be published easily by the next step in the process)
  • Set up GH action to run script

@d3caf
Copy link
Contributor Author

d3caf commented Sep 3, 2024

Status

I have the validations running properly and outputting the errors to the console. Next steps would be:

  • Fix existing quickstarts that are failing validations (they're actually invalid, we just never validated them super closely)
  • Code cleanup/refactor
  • Evaluate whether we want to use json-schema-to-ts to generate the TS interface for the artifact (may be unnecessary)
  • Save the artifact in a way that GH actions can use it (will be handled in future tickets)
  • Set up GH action (will be handled in future tickets)

Base automatically changed from zstix/NR-268433_qs_json_schema to release September 4, 2024 15:48
@CLAassistant
Copy link

CLAassistant commented Sep 5, 2024

CLA assistant check
All committers have signed the CLA.

zstix and others added 2 commits September 5, 2024 10:31
Co-authored-by: Zack Stickles <[email protected]>
Co-authored-by: Sarah Kitten <[email protected]>
Co-authored-by: Andrew Anguiano <[email protected]>
@mickeyryan42 mickeyryan42 force-pushed the campfire/NR-268461-build-validate-artifact branch from 0294b60 to 5338b6b Compare September 5, 2024 19:16
@d3caf d3caf marked this pull request as ready for review September 5, 2024 21:08
@d3caf d3caf requested review from a team and josephgregoryii and removed request for a team September 5, 2024 21:08
@d3caf d3caf force-pushed the campfire/NR-268461-build-validate-artifact branch from f2782f4 to a54677a Compare September 6, 2024 15:43
return alertPaths.map(alertPath => {
// The identifier for alerts is the folder and the file name
// e.g. `node-js/HighCpuUtilization.yml`
const identifier = path.join(...alertPath.split('/').slice(-2, -1));
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it's not likely, but I always get a little anxious seeing slice (or pop) on arrays since those can technically return [] (and undefined for pop).

Typescript doesn't seem to be angry at this here, but I know that we're using a ! in the Quickstart file to get around this. We might want to consider some additional error checking (or tests) to ensure we for sure have an identifier.

Copy link
Contributor

Choose a reason for hiding this comment

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

Note: I wouldn't block the PR on this!

zstix
zstix previously requested changes Sep 6, 2024
Copy link
Contributor

@zstix zstix left a comment

Choose a reason for hiding this comment

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

I found at least one (potential) bug and a few places where we might want to refactor. Additionally, we don't have any tests for this work (something called out in the acceptance criteria).

I'll probably jump in to make these adjustments since this is blocking other work.

utils/build-validate-quickstart-artifact.ts Outdated Show resolved Hide resolved
utils/build-validate-quickstart-artifact.ts Outdated Show resolved Hide resolved
utils/build-validate-quickstart-artifact.ts Outdated Show resolved Hide resolved
utils/build-validate-quickstart-artifact.ts Outdated Show resolved Hide resolved
utils/build-validate-quickstart-artifact.ts Outdated Show resolved Hide resolved
utils/build-validate-quickstart-artifact.ts Outdated Show resolved Hide resolved
utils/build-validate-quickstart-artifact.ts Outdated Show resolved Hide resolved
utils/build-validate-quickstart-artifact.ts Outdated Show resolved Hide resolved
@zstix zstix dismissed their stale review September 6, 2024 22:44

I have addressed my own feedback. This is going to need someone else to review now.

sarahkitten
sarahkitten previously approved these changes Sep 6, 2024
Copy link
Contributor

@sarahkitten sarahkitten left a comment

Choose a reason for hiding this comment

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

This is easy to read and passes when run with the current config changes PR. Small suggestion for the tests but not blocking.

.fn()
.mockReturnValueOnce([{ config: 'test-dataSource-1' }]);

Alert.getAll = jest.fn().mockReturnValueOnce([]);
Copy link
Contributor

Choose a reason for hiding this comment

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

we might want to test each of these with non-empty values here since we had problems with the getAll returning nothing before!


const value = get(artifact, invalidValuePath);

// Get the specific "component" (e.g. the alert or dashboard) that contains
Copy link
Contributor

Choose a reason for hiding this comment

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

I appreciate this refactoring and comments!

Copy link
Contributor Author

@d3caf d3caf left a comment

Choose a reason for hiding this comment

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

As the author, I can't approve, but this looks good to me and functions well. I was originally hesitant to bring in lodash for a single use-case, but it does clean it up a bit and using the modularized version is nice 👍 ✅

@mickeyryan42 mickeyryan42 merged commit c616b1d into release Sep 9, 2024
17 checks passed
@mickeyryan42 mickeyryan42 deleted the campfire/NR-268461-build-validate-artifact branch September 9, 2024 14:06
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.

5 participants