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

#68: proper ci cd for npm package publishing #1012

Merged

Conversation

TGTGamer
Copy link
Contributor

@TGTGamer TGTGamer commented Feb 19, 2024

Caution

Intentionally targetting V2 branch:
If accepting this PR, please ensure that you either REBASE the commits or follow the below steps for first release

CLOSES: #68

  • New Features

    • Automated dependency updates with Dependabot for improved package management.
    • Automated release management setup for streamlined versioning and deployment.
    • Enhanced workflow execution triggers for better CI/CD pipeline control.
    • Security enhancements including CodeQL analysis, Microsoft Defender for DevOps integration, dependency review for vulnerabilities, open-source static analysis (OSSAR), and supply-chain security checks.
  • Chores

    • Configuration for automated dependency updates, release management, and security workflows.
  • Documentation

    • Added configuration files and workflows for dependency management, release automation, and security analysis.

Examples

How should I write my commits?

Release Please assumes you are using Conventional Commit messages.
The most important prefixes you should have in mind are:

  • fix: which represents bug fixes, and correlates to a SemVer
    patch.
  • feat: which represents a new feature, and correlates to a SemVer minor.
  • feat!:, or fix!:, refactor!:, etc., which represent a breaking change
    (indicated by the !) and will result in a SemVer major.

Linear git commit history (use squash-merge)

We highly recommend that you use squash-merges when merging pull requests.

Further info found here: https://github.com/googleapis/release-please

I am ready to release V2.

Amazing, we are all looking forward to it. To start using release-please all you need to do is REBASE this PR onto the v2 branch. This will ensure that the "chore: release 2.0.0" commit is the last commit on your branch.

If you then plan on merging V2 into Main you should follow one of these below steps:

REBASE - Keeps the commit at the top, ensuring that release-please knows to release at V2.
SQUASH - Name the PR "chore: release 2.0.0" and include "Release-As: 2.0.0" within the message.
POST-PR COMMIT - Make a new commit post PR merge to main to link to V2.
git commit --allow-empty -m "chore: release 2.0.0" -m "Release-As: 2.0.0"


I try to follow the OpenSSF Best Practices Gold Level. Files I create automatically generate a License Statement. Please feel free to remove these if you desire - or ask me to :)

Summary by CodeRabbit

  • New Features
    • Introduced automated security workflows:
      • CodeQL analysis for code scanning.
      • Microsoft Security DevOps integration for static analysis.
      • Dependency review to block vulnerable package merges.
      • Open source static analysis tools integration.
      • Supply-chain security checks with Scorecard tool.
  • Documentation
    • Added workflows for security and compliance.
  • Chores
    • Scheduled security scans for ongoing project health.

…ily updates for npm packages in various directories
… 2.0.0-alpha.1

feat(release): define package names and components in release main config file
feat(release): set up configuration for automated versioning and release process
…pull request,

and schedule events targeting main, develop, and release/* branches. Set
permissions for job execution and analysis. Include steps to harden runner,
checkout repository, initialize CodeQL, autobuild, and perform CodeQL analysis
for javascript and typescript languages.
feat(workflows): configure release workflow to trigger on push to main, dev, and release branches
feat(workflows): set permissions for contents to read and write in release job
feat(workflows): add steps to harden runner for runtime security in release job
feat(workflows): add release-please-action for automated releases in release job
feat(workflows): add actions/checkout and actions/setup-node for release job setup
feat(workflows): add pnpm installation and publishing steps in release job
…or Microsoft Defender For DevOps security checks
…workflow to scan and block PRs with known-vulnerable packages
…sing OSSAR

feat(security-ossar.yml): integrate open source static analysis tools with GitHub code scanning
feat(security-ossar.yml): schedule security scans on main, develop, and release branches
…y scorecard

analysis to enhance supply-chain security monitoring and compliance with
best practices
filtering for push and pull_request events to align with project requirements
…cores instead of spaces for consistency and readability.
…n to use underscore instead of space for consistency across components
Release-As: 2.0.0
@ymc9
Copy link
Member

ymc9 commented Feb 19, 2024

Thanks for working on this @TGTGamer ! I've wanted to have such a nice workflow for a long time.

I'm new to release-please and still checking documentation, but it looks very neat. Let me dig into your change and ask questions in the review.

.github/dependabot.yml Outdated Show resolved Hide resolved
.github/release/release-main-config.json Show resolved Hide resolved
.github/workflows/build-test.yml Outdated Show resolved Hide resolved
.github/workflows/codeql.yml Show resolved Hide resolved
.github/workflows/management-changelog.yml Show resolved Hide resolved
.github/workflows/management-changelog.yml Outdated Show resolved Hide resolved
.github/workflows/management-changelog.yml Show resolved Hide resolved
@ymc9
Copy link
Member

ymc9 commented Feb 19, 2024

Thanks for working on this @TGTGamer ! I've wanted to have such a nice workflow for a long time.

I'm new to release-please and still checking documentation, but it looks very neat. Let me dig into your change and ask questions in the review.

I've added a bunch of comments (questions more precisely 😄). You're definitely at an expert level with properly configuring an OSS project. I'm learning a lot from this PR!

.github/dependabot.yml Outdated Show resolved Hide resolved
.github/workflows/codeql.yml Outdated Show resolved Hide resolved
.github/workflows/management-changelog.yml Outdated Show resolved Hide resolved
.github/workflows/security-defender-for-devops.yml Outdated Show resolved Hide resolved
.github/workflows/security-dependency-review.yml Outdated Show resolved Hide resolved
.github/workflows/security-ossar.yml Outdated Show resolved Hide resolved
.github/workflows/security-scorecard.yml Outdated Show resolved Hide resolved
Copy link
Member

@ymc9 ymc9 left a comment

Choose a reason for hiding this comment

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

I don't know why but I can't find the option to commit the suggested changes. Could you check if you can do it from your side? They all look good to me.

.github/workflows/security-ossar.yml Outdated Show resolved Hide resolved
.github/workflows/security-ossar.yml Outdated Show resolved Hide resolved
.github/workflows/security-scorecard.yml Outdated Show resolved Hide resolved
.github/workflows/security-defender-for-devops.yml Outdated Show resolved Hide resolved
.github/workflows/security-defender-for-devops.yml Outdated Show resolved Hide resolved
.github/workflows/codeql.yml Outdated Show resolved Hide resolved
.github/workflows/codeql.yml Outdated Show resolved Hide resolved
.github/workflows/build-test.yml Outdated Show resolved Hide resolved
Copy link
Contributor

coderabbitai bot commented Feb 20, 2024

Walkthrough

Walkthrough

The updates introduce a suite of GitHub Actions workflows and configurations to automate dependency management, security analysis, static code analysis, and the release process. These changes enhance the project's CI/CD pipeline by ensuring up-to-date dependencies, secure codebase, compliance, and streamlined release automation. The project now includes automated testing and deployment configurations, addressing key objectives for improving npm package publishing workflows.

Changes

File Path Change Summary
.github/dependabot.yml Configures automated dependency updates for npm packages and GitHub Actions.
.github/release/... Introduces files for specifying versions and configurations for the release process.
.github/workflows/build-test.yml Updates the build and test workflow to trigger on specific branches and events.
.github/workflows/codeql.yml Adds a workflow for running CodeQL security analysis.
.github/workflows/security-... Introduces workflows focused on security analysis, compliance, and dependency review.

Related issues

  • zenstackhq/zenstack#68: The changes in this PR address the objectives of implementing a CI/CD pipeline for npm package testing, deployment, and security concerns by introducing automated workflows for dependency management, security analysis, and the release process.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@TGTGamer
Copy link
Contributor Author

I don't know why but I can't find the option to commit the suggested changes. Could you check if you can do it from your side? They all look good to me.

Probably because it's on a fork. Bet once it merged over it would sort itself out :)

@TGTGamer TGTGamer requested a review from ymc9 February 20, 2024 19:54
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 6

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 7b453f7 and 238bb2f.
Files selected for processing (10)
  • .github/dependabot.yml (1 hunks)
  • .github/release/.release-manifest.json (1 hunks)
  • .github/release/release-main-config.json (1 hunks)
  • .github/workflows/build-test.yml (1 hunks)
  • .github/workflows/codeql.yml (1 hunks)
  • .github/workflows/management-changelog.yml (1 hunks)
  • .github/workflows/security-defender-for-devops.yml (1 hunks)
  • .github/workflows/security-dependency-review.yml (1 hunks)
  • .github/workflows/security-ossar.yml (1 hunks)
  • .github/workflows/security-scorecard.yml (1 hunks)
Files skipped from review due to trivial changes (2)
  • .github/dependabot.yml
  • .github/release/.release-manifest.json
Additional comments: 19
.github/workflows/security-dependency-review.yml (2)
  • 11-13: The trigger event merge_group is specified but not standard in GitHub Actions. Verify if this is a custom event or a typo. Standard events include push, pull_request, etc.
  • 31-31: The use of a conditional operator to choose between secrets.BOT_TOKEN and github.token is a good practice for flexibility. However, ensure that BOT_TOKEN has the necessary permissions for the actions being performed.
.github/release/release-main-config.json (2)
  • 1-59: The configuration file is well-structured and follows best practices for managing releases in a monorepo setup. The use of "separate-pull-requests": true allows for granular control over package releases, which is beneficial in a monorepo environment.
  • 56-56: Given the previous discussion between ymc9 and TGTGamer regarding the separate-pull-requests setting, it's good to see the decision documented and implemented in the configuration. This decision should be revisited periodically to ensure it continues to meet the project's needs.
.github/workflows/management-changelog.yml (2)
  • 46-46: The use of google-github-actions/release-please-action with a specific configuration file is a good practice for automating release management. Ensure that the .github/release/release-main-config.json and .github/release/.release-manifest.json files are correctly set up and maintained.
  • 61-61: The decision to use pnpm publish-all for publishing indicates a streamlined process for handling package releases. However, ensure that this script is well-documented and that its implications on the release process are fully understood by all contributors.
.github/workflows/security-defender-for-devops.yml (3)
  • 11-12: The note about MSDO currently being in beta and running on windows-latest with upcoming ubuntu-latest support is important for future planning. Keep an eye on updates to expand support and improve the workflow's compatibility.
  • 16-18: The trigger events are well-defined, covering push and pull_request for relevant branches, and a scheduled run. This ensures regular security checks alongside development activities.
  • 59-59: The use of actions/setup-dotnet to install multiple versions of .NET is a good practice for ensuring compatibility across different versions. Ensure that all projects within the repository are compatible with these versions.
.github/workflows/security-ossar.yml (2)
  • 12-14: The trigger events are well-defined, covering both direct code changes (push, pull_request) and a scheduled run. This ensures that the codebase is regularly scanned for vulnerabilities.
  • 72-72: Uploading OSSAR results to the Security tab is a good practice for visibility and tracking of security issues. Ensure that the SARIF file path is correctly specified and that the security-events permission is appropriately set.
.github/workflows/codeql.yml (2)
  • 4-6: The trigger events are well-defined, covering both direct code changes (push, pull_request) and a scheduled run. This ensures that the codebase is regularly scanned for vulnerabilities.
  • 74-74: The final step of performing CodeQL analysis is crucial for identifying vulnerabilities. Ensure that the analysis covers all relevant languages and that the results are reviewed and acted upon.
.github/workflows/build-test.yml (4)
  • 11-13: The trigger events are well-defined, covering both direct code changes (push, pull_request) and a custom merge_group. Verify if merge_group is a custom event or a typo. Standard events include push, pull_request, etc.
  • 25-25: Setting permissions to read-only for contents is a good security practice, minimizing the risk of unauthorized modifications during the CI process.
  • 27-27: The build-test job is configured to run on a specific runner (buildjet-8vcpu-ubuntu-2204). Ensure that this runner has the necessary resources and is available for the project.
  • 8-29: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [61-61]

The use of pnpm publish-all for publishing indicates a streamlined process for handling package releases. However, ensure that this script is well-documented and that its implications on the release process are fully understood by all contributors.

.github/workflows/security-scorecard.yml (2)
  • 8-10: The workflow is named appropriately and focuses on supply-chain security, which is crucial for modern software development. The trigger events include a schedule and branch-specific triggers, ensuring regular and relevant analysis.
  • 77-77: Uploading the results to GitHub's code scanning dashboard is a good practice for visibility and tracking of security issues. Ensure that the SARIF file path is correctly specified and that the security-events permission is appropriately set.

.github/workflows/management-changelog.yml Show resolved Hide resolved
.github/workflows/security-defender-for-devops.yml Outdated Show resolved Hide resolved
.github/workflows/security-ossar.yml Outdated Show resolved Hide resolved
.github/workflows/codeql.yml Outdated Show resolved Hide resolved
.github/workflows/security-scorecard.yml Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 238bb2f and 0dc41f9.
Files selected for processing (5)
  • .github/workflows/codeql.yml (1 hunks)
  • .github/workflows/security-defender-for-devops.yml (1 hunks)
  • .github/workflows/security-dependency-review.yml (1 hunks)
  • .github/workflows/security-ossar.yml (1 hunks)
  • .github/workflows/security-scorecard.yml (1 hunks)
Files skipped from review as they are similar to previous changes (5)
  • .github/workflows/codeql.yml
  • .github/workflows/security-defender-for-devops.yml
  • .github/workflows/security-dependency-review.yml
  • .github/workflows/security-ossar.yml
  • .github/workflows/security-scorecard.yml

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@ymc9 ymc9 merged commit d296e5f into zenstackhq:v2 Feb 21, 2024
10 of 11 checks passed
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