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

chore: change sbom generation to happen on prepublishOnly #268

Merged
merged 1 commit into from
Jul 13, 2023

Conversation

lance
Copy link
Member

@lance lance commented Jul 13, 2023

By having the sbom generated during the postinstall step, we have inadvertently made the package impossible to install as a dependency. This is because when installing this as a dependency in a project, npm install is run under the hood. Subsequently, npm run postinstall happens, but the published package does not contain a package-lock.json file and the sbom generation fails, therefore failing the installation of the module altogether.

This commit modifies the npm scripts so that the sbom generation happens only when publishing, and the publish will fail if there are any modified files in the repo, i.e. if the sbom was updated. This means it is incumbent on maintainers of this package to keep the sbom up to date by periodically running npm run sbom when modifying dependencies. If in the course of making changes on this module, the package.json or package-lock.json files are modified, the developer MUST run the command npm run sbom.

By having the sbom generated during the `postinstall` step, we have
inadvertently made the package impossible to install as a dependency.
This is because when installing this as a dependency in a project,
`npm install` is run under the hood. Subsequently, `npm run postinstall`
happens, but the published package does not contain a package-lock.json
file and the sbom generation fails, therefore failing the installation
of the module altogether.

This commit modifies the npm scripts so that the sbom generation happens
only when publishing, and the publish will fail if there are any
modified files in the repo, i.e. if the sbom was updated. This means it
is incumbent on maintainers of this package to keep the sbom up to date
by periodically running `npm run sbom` when modifying dependencies. If
in the course of making changes on this module, the package.json or
package-lock.json files are modified, the developer MUST run the command
`npm run sbom`.

Signed-off-by: Lance Ball <lball@redhat.com>
@lance lance requested a review from lholmquist July 13, 2023 21:10
@lance
Copy link
Member Author

lance commented Jul 13, 2023

@lholmquist ptal when you get a chance. I am not 100% sure this will work as expected in our github publish action.

@codecov-commenter
Copy link

codecov-commenter commented Jul 13, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (f0d8415) 90.54% compared to head (bf306cb) 90.54%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #268   +/-   ##
=======================================
  Coverage   90.54%   90.54%           
=======================================
  Files           9        9           
  Lines         296      296           
=======================================
  Hits          268      268           
  Misses         28       28           

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

Copy link
Member

@lholmquist lholmquist left a comment

Choose a reason for hiding this comment

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

lets try it

@lholmquist lholmquist merged commit 9fdef57 into nodeshift:main Jul 13, 2023
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.

3 participants