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

Rework project side configuration #64

Merged
merged 26 commits into from
Oct 26, 2024
Merged

Conversation

MGREMY
Copy link
Collaborator

@MGREMY MGREMY commented Oct 24, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a pre-installation script to enforce the use of pnpm as the package manager.
    • Updated workspace configuration to include all subdirectories under apps and libs.
    • Added new GitHub Actions workflows for CI checks, cache cleanup, and release automation.
    • Implemented a new target for semantic release in the flowbite-angular library.
  • Bug Fixes

    • Adjusted various documentation to reflect changes in package management from npm to pnpm.
  • Documentation

    • Updated contributor guidelines and technical documents to replace npm commands with pnpm equivalents.
  • Chores

    • Modified CI workflow and other configuration files to transition from npm to pnpm.
    • Removed environment variables from the Vercel configuration.
    • Introduced a new composite action for installing dependencies using pnpm.

Copy link

vercel bot commented Oct 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
flowbite-angular ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 26, 2024 1:10pm

Copy link
Contributor

coderabbitai bot commented Oct 24, 2024

Walkthrough

The pull request introduces a transition from npm to pnpm as the package manager across various configuration files and scripts in the project. Key changes include the removal of the CI workflow configuration in .github/workflows/ci-checks.yaml, updates to pre-commit hooks, documentation, and configuration files to reflect the new package management commands. The .prettierignore file is updated to exclude specific files, while the pnpm-workspace.yaml file now includes directories for workspace management. A new preinstall script is added to enforce the use of pnpm. Overall, the changes standardize the use of pnpm throughout the project.

Changes

File Path Change Summary
.github/workflows/ci-checks.yaml Entire CI checks workflow configuration removed.
.husky/pre-commit Changed linting command from npm run all:lint to pnpm all:lint.
.prettierignore Added entries /.nx/workspace-data and pnpm-lock.yaml to ignore list.
apps/docs/project.json No modifications; configuration structure intact.
docs/files/contributors.md Updated installation commands from npm to pnpm.
docs/files/technical-information/workflow-process/base/doc/build & test.md Updated build, unit testing, and E2E testing commands from npm to pnpm.
docs/files/technical-information/workflow-process/base/lib/build & test.md Updated BUILD_COMMAND and UT_COMMAND from npm to pnpm.
nx.json Changed packageManager from "npm" to "pnpm"; removed nxCloudAccessToken.
package.json Added a "preinstall" script to enforce pnpm; added a "lib:release" script.
pnpm-workspace.yaml Added packages section to include paths apps/** and libs/**.
vercel.json Updated buildCommand and installCommand from npm to pnpm; removed environment variable.
.github/actions/setup/action.yml New composite action for installing dependencies with pnpm added.
.github/workflows/cache_cleanup.yml New workflow for cache cleanup on closed pull requests added.
.github/workflows/ci.yml New CI workflow with jobs for linting, testing, and building added.
.github/workflows/release.yml New release workflow added to automate the release process.
.nxreleaserc.json New configuration file for release metadata created.
libs/flowbite-angular/project.json New target for semantic release added.

Possibly related PRs

🐰 In the meadow, where the bunnies play,
We’ve switched our tools, hip-hip-hooray!
From npm's grasp, we take a leap,
With pnpm now, our code runs deep.
Hopping through scripts, all fresh and bright,
Building our dreams, oh what a sight! 🌼✨


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>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 testing code 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (4)
.github/workflows/ci-checks.yaml (2)

Line range hint 24-29: Update cache configuration for pnpm.

The cache configuration is still using package-lock.json for key generation, but this file won't exist in a pnpm project. Update it to use pnpm-lock.yaml instead.

Apply this diff to fix the cache configuration:

      - name: Setup Cache 🗂
        uses: actions/cache@v3
        with:
          path: '**/node_modules'
-         key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
+         key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
          restore-keys: |
            ${{ runner.os }}-modules-

37-37: Consider adding pnpm version setup.

For better reproducibility, consider adding pnpm installation and version pinning before the install step.

Add these steps before the install command:

      - uses: pnpm/action-setup@v2
        with:
          version: 8
docs/files/contributors.md (1)

11-11: LGTM! Consider adding pnpm installation instructions.

The commands have been correctly updated to use pnpm instead of npm, which aligns with the project's transition to pnpm as the package manager.

Consider adding a prerequisite step about installing pnpm globally. For example:

 1. Make sure you have `Node.js > v20` installed
+1a. Install pnpm globally: `npm install -g pnpm`
 2. Run `git clone https://github.com/themesberg/flowbite-angular.git`

Also applies to: 14-14

package.json (1)

Line range hint 1-137: Consider adding pnpm-specific configurations.

Since you're transitioning to pnpm, consider adding these configurations for better pnpm integration:

  • packageManager field to specify the pnpm version
  • .npmrc file reference for consistent configuration

Apply this diff to add pnpm-specific configurations:

{
  "name": "flowbite-angular",
  "version": "0.0.3",
+ "packageManager": "[email protected]",
  "private": false,
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8eaf281 and 5ce8e41.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (11)
  • .github/workflows/ci-checks.yaml (1 hunks)
  • .husky/pre-commit (1 hunks)
  • .prettierignore (1 hunks)
  • apps/docs/project.json (0 hunks)
  • docs/files/contributors.md (1 hunks)
  • docs/files/technical-information/workflow-process/base/doc/build & test.md (1 hunks)
  • docs/files/technical-information/workflow-process/base/lib/build & test.md (1 hunks)
  • nx.json (1 hunks)
  • package.json (1 hunks)
  • pnpm-workspace.yaml (1 hunks)
  • vercel.json (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/docs/project.json
✅ Files skipped from review due to trivial changes (5)
  • .husky/pre-commit
  • .prettierignore
  • docs/files/technical-information/workflow-process/base/doc/build & test.md
  • docs/files/technical-information/workflow-process/base/lib/build & test.md
  • pnpm-workspace.yaml
🔇 Additional comments (4)
vercel.json (1)

6-6: LGTM!

The build command has been correctly updated to use pnpm while maintaining the same build script target.

.github/workflows/ci-checks.yaml (1)

37-49: Verify script commands exist in package.json.

The command changes from npm to pnpm look correct. Let's verify that all the required scripts exist in the package.json file.

✅ Verification successful

Let me fix the regex syntax error and try again to verify the scripts in package.json.


All required scripts are present in package.json

The verification confirms that all the scripts used in the CI workflow exist in the root package.json:

  • "all:lint": "nx run-many --target lint --all"
  • "prettier": "nx format:check --base=HEAD"
  • "all:test": "nx run-many --target test --all"
  • "all:build": "nx run-many --target build --all"
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all required scripts exist in package.json
# Expected: Should find all script names used in the workflow

echo "Checking for required scripts in package.json files..."
rg -l '"scripts":\s*{[^}]*"all:lint"' --type json
rg -l '"scripts":\s*{[^}]*"prettier"' --type json
rg -l '"scripts":\s*{[^}]*"all:test"' --type json
rg -l '"scripts":\s*{[^}]*"all:build"' --type json

Length of output: 832


Script:

#!/bin/bash
# Description: Verify that all required scripts exist in package.json
# Expected: Should find all script names used in the workflow

echo "Checking for required scripts in package.json files..."
# First locate the package.json files
echo "Package.json files found:"
fd "package.json$"

echo -e "\nChecking scripts in package.json files:"
# Use simpler regex patterns with proper escaping
rg '"all:lint"' --type json
rg '"prettier"' --type json
rg '"all:test"' --type json
rg '"all:build"' --type json

Length of output: 929

nx.json (1)

3-3: LGTM! Package manager configuration updated correctly.

The change from npm to pnpm in the Nx configuration aligns with the PR objective of transitioning to pnpm as the project's package manager.

package.json (1)

22-22: Verify the preinstall script's impact on existing workflows.

The addition of only-allow pnpm enforces pnpm usage, which is good for consistency. However, ensure all team members and CI/CD pipelines are updated accordingly.

✅ Verification successful

Let me try a different approach to verify the CI/CD configurations and workflow files.

This script will:

  1. List all workflow files
  2. Show their contents to verify package manager usage
  3. Check for package manager lock files
  4. Check nx configuration for package manager settings

This will give us a comprehensive view of the package manager configuration across the project.


Based on the workflow file contents, I can now generate the final response:

The preinstall script is properly aligned with the project's CI/CD configuration

The CI workflow (ci-checks.yaml) already uses pnpm commands for all operations:

  • Package installation: pnpm i
  • Linting: pnpm all:lint
  • Formatting: pnpm prettier
  • Testing: pnpm all:test
  • Building: pnpm all:build

The preinstall script's addition of only-allow pnpm complements the existing setup by ensuring consistent package manager usage across both local development and CI environments.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if CI/CD configurations have been updated to use pnpm

# Test: Search for any remaining npm commands in workflow files
echo "Checking for npm commands in workflow files..."
rg 'npm (install|run|ci|test|build)' .github/

Length of output: 150


Script:

#!/bin/bash
# Check for workflow files and their content
echo "=== Listing workflow files ==="
fd . .github/workflows/ -e yml -e yaml

echo -e "\n=== Checking workflow contents ==="
fd . .github/workflows/ -e yml -e yaml -x cat {}

echo -e "\n=== Checking for package manager related files ==="
fd -g 'pnpm*' -g 'package-lock.json' -g 'yarn.lock'

echo -e "\n=== Checking nx configuration ==="
fd . -g 'nx.json' -x cat {}

Length of output: 1870

vercel.json Outdated Show resolved Hide resolved
nx.json Show resolved Hide resolved
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.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
.github/workflows/ci-checks.yaml (1)

Line range hint 1-48: Consider adding caching for the pnpm store.

While you've configured node_modules caching via setup-node, adding explicit pnpm store caching could further improve CI performance.

Add this step before the package installation:

      - name: Get pnpm store directory
        id: pnpm-cache
        run: |
          echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

      - uses: actions/cache@v4
        name: Setup pnpm cache
        with:
          path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
          key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
          restore-keys: |
            ${{ runner.os }}-pnpm-store-
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 104e68c and 89ee983.

📒 Files selected for processing (1)
  • .github/workflows/ci-checks.yaml (1 hunks)
🔇 Additional comments (2)
.github/workflows/ci-checks.yaml (2)

16-16: LGTM: Good practice to use the latest stable version.

The upgrade to actions/checkout@v4 brings performance improvements and bug fixes.


20-30: Verify pnpm version compatibility with the project.

The pnpm setup looks correct, but we should ensure version 9 is compatible with all project dependencies.

Comment on lines 36 to 48
run: pnpm i --frozen-lockfile

- name: Lint the code 🕵
run: npm run all:lint
run: pnpm all:lint

- name: Run Prettier 💅
run: npm run prettier
run: pnpm prettier

- name: Run unit tests 🔬
run: npm run all:test
run: pnpm all:test

- name: Build code 🛠
run: npm run all:build
run: pnpm all:build
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider adding explicit error handling for pnpm commands.

While the migration to pnpm commands is correct, consider adding error handling flags for better CI feedback:

-        run: pnpm i --frozen-lockfile
+        run: pnpm i --frozen-lockfile --strict-peer-dependencies

-        run: pnpm all:lint
+        run: pnpm all:lint || exit 1

-        run: pnpm all:test
+        run: pnpm all:test -- --ci --verbose

This will:

  • Ensure strict peer dependency checks during installation
  • Fail fast on lint errors
  • Provide more detailed test output in CI
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
run: pnpm i --frozen-lockfile
- name: Lint the code 🕵
run: npm run all:lint
run: pnpm all:lint
- name: Run Prettier 💅
run: npm run prettier
run: pnpm prettier
- name: Run unit tests 🔬
run: npm run all:test
run: pnpm all:test
- name: Build code 🛠
run: npm run all:build
run: pnpm all:build
run: pnpm i --frozen-lockfile --strict-peer-dependencies
- name: Lint the code 🕵
run: pnpm all:lint || exit 1
- name: Run Prettier 💅
run: pnpm prettier
- name: Run unit tests 🔬
run: pnpm all:test -- --ci --verbose
- name: Build code 🛠
run: pnpm all:build

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.

Actionable comments posted: 9

🧹 Outside diff range and nitpick comments (4)
.github/workflows/release.yml (1)

36-36: Document the release command flags.

The release command uses several flags (--ci, --verbose, --skip-nx-cache). Consider adding inline comments or documentation explaining their purpose and when they might need to be modified.

-        run: pnpm lib:release -- --ci --verbose --skip-nx-cache
+        # --ci: Ensures CI mode (no interactive prompts)
+        # --verbose: Detailed logging for debugging
+        # --skip-nx-cache: Forces fresh execution
+        run: pnpm lib:release -- --ci --verbose --skip-nx-cache
.github/actions/setup/action.yml (3)

1-23: Update documentation to match implementation details

There are a few inconsistencies in the documentation:

  1. The header mentions "pnpm 7/8+" but the action uses "latest-9"
  2. The usage example shows ./.github/actions/pnpm-install but the actual path would be ./.github/actions/setup

Apply this diff to fix the documentation:

-# "pnpm install" composite action for pnpm 7/8+                                        #
+# "pnpm install" composite action for pnpm 9+                                          #
 #--------------------------------------------------------------------------------------#
 # Requirement: @setup/node should be run before                                        #
 #                                                                                      #
 # Usage in workflows steps:                                                            #
 #                                                                                      #
 #      - name: 📥 Monorepo install                                                     #
-#        uses: ./.github/actions/pnpm-install                                          #
+#        uses: ./.github/actions/setup                                                 #

73-79: Remove commented code about store pruning

The commented section about store pruning adds noise to the codebase. If this is a future consideration, it should be tracked in an issue instead.

Remove these commented lines and create a GitHub issue to track the future implementation of store pruning if needed.


88-89: Document Nx integration purpose

The Nx SHA derivation step lacks context about its purpose and when it's needed.

Add a comment explaining why this step is necessary and when it should be used:

 - name: Derive appropriate SHAs for base and head for `nx affected` commands
+  # Required for determining which projects have been affected by changes when using Nx
+  # This step helps optimize the CI pipeline by only running tasks on affected projects
   uses: nrwl/nx-set-shas@v2
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 89ee983 and 3e1affc.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • .github/actions/setup/action.yml (1 hunks)
  • .github/workflows/cache_cleanup.yml (1 hunks)
  • .github/workflows/ci-checks.yaml (0 hunks)
  • .github/workflows/ci.yml (1 hunks)
  • .github/workflows/release.yml (1 hunks)
  • .nxreleaserc.json (1 hunks)
  • libs/flowbite-angular/project.json (1 hunks)
  • nx.json (1 hunks)
  • package.json (3 hunks)
💤 Files with no reviewable changes (1)
  • .github/workflows/ci-checks.yaml
✅ Files skipped from review due to trivial changes (1)
  • .nxreleaserc.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • nx.json
  • package.json
🧰 Additional context used
🪛 actionlint
.github/workflows/cache_cleanup.yml

18-18: shellcheck reported issue in this script: SC2086:info:14:29: Double quote to prevent globbing and word splitting

(shellcheck)

🪛 yamllint
.github/workflows/cache_cleanup.yml

[error] 27-27: trailing spaces

(trailing-spaces)

🔇 Additional comments (9)
.github/workflows/release.yml (3)

17-20: LGTM! Appropriate permissions are set.

The workflow follows the principle of least privilege by explicitly declaring only the required permissions:

  • contents: write for creating releases
  • issues: write for linking issues
  • pull-requests: write for linking PRs

35-39: Consider adding environment protection rules for secrets.

The workflow uses sensitive secrets (GITHUB_TOKEN and NPM_TOKEN). Consider adding environment protection rules to restrict which branches can access these secrets.

#!/bin/bash
# Check if environments are configured with protection rules
gh api repos/:owner/:repo/environments 2>/dev/null || echo "Warning: No environment protection rules found"

Additionally, consider these security enhancements:

  1. Add NODE_ENV=production to prevent development dependencies
  2. Consider adding checksum verification for the release artifacts

32-34: Verify the custom setup action implementation.

The workflow uses a local custom action ./.github/actions/setup. Ensure this action is properly implemented and maintained.

#!/bin/bash
# Check if the setup action exists and contains the necessary files
if [ -f ".github/actions/setup/action.yml" ]; then
    echo "Setup action found. Checking contents..."
    cat ".github/actions/setup/action.yml"
else
    echo "Warning: Setup action not found at .github/actions/setup/action.yml"
fi
.github/workflows/cache_cleanup.yml (2)

1-9: LGTM! Well-structured workflow configuration.

The workflow triggers and metadata are appropriately configured for cache cleanup purposes.


10-16: LGTM! Job configuration is correct.

The job uses the latest Ubuntu runner and checkout action version.

.github/workflows/ci.yml (1)

10-29: 🛠️ Refactor suggestion

Optimize lint job configuration

The lint job configuration can be improved in several ways:

  1. Remove unnecessary git history fetch
  2. Add caching for faster workflow execution
  3. Verify the custom setup action implementation
   lint:
     name: Lint the code 🕵
     runs-on: ubuntu-latest
     steps:
       - name: Check out the code 🗄
         uses: actions/checkout@v4
-        with:
-          fetch-depth: 0

       - name: Setup NodeJS 💿
         uses: actions/setup-node@v4
         with:
           node-version: 20
+          cache: 'pnpm'

       - name: Monorepo install
         uses: ./.github/actions/setup

Let's verify the custom setup action implementation:

libs/flowbite-angular/project.json (3)

56-58: Ensure build output path is consistent.

The outputPath matches the build target's output directory, which is good. However, let's verify that this path is consistently used across the workspace configuration.

#!/bin/bash
# Description: Verify consistency of output paths across workspace

# Test: Search for any references to the dist directory
rg "dist/libs/flowbite-angular" -g "*.{json,js,ts,yml,yaml}" -l

58-59: Review tag format for version consistency.

The tag format flowbite-angular@v${version} follows a good convention. However, let's verify this aligns with existing tags in the repository.

#!/bin/bash
# Description: Check existing tag format

# Test: List existing tags matching the flowbite-angular pattern
git tag | grep -E "flowbite-angular@v[0-9]"

36-60: Verify semantic-release configuration completeness.

The semantic-release configuration looks well-structured, but there are a few considerations:

  1. The configuration includes both GitHub and npm publishing, but we should verify the presence of required authentication tokens in the CI environment.
  2. The branch configuration follows semantic-release best practices with support for maintenance, pre-release, and alpha/beta releases.
✅ Verification successful

Semantic-release configuration is properly set up and integrated

The verification confirms that the semantic-release configuration is complete and well-integrated:

  • Required dependency @theunderscorer/nx-semantic-release is present in package.json
  • GitHub Actions workflow "Release" is configured with:
    • Correct branch triggers matching the semantic-release config
    • Required GH_TOKEN and NPM_TOKEN secrets
    • Proper execution command pnpm lib:release
  • Build target exists and is correctly referenced in semantic-release config
  • No conflicting release configurations found in the repository
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the presence of required semantic-release dependencies and configurations

# Test 1: Check if @theunderscorer/nx-semantic-release is in dependencies
rg -l "@theunderscorer/nx-semantic-release" "package.json"

# Test 2: Check for semantic-release config file that might override these settings
fd -g "*release*config*.{js,json,yaml,yml}"

# Test 3: Check for GitHub Actions workflow using this target
fd -g "*.{yml,yaml}" .github/workflows/ -x rg -l "flowbite-angular:semantic-release"

Length of output: 529


Script:

#!/bin/bash
# Let's try a different approach to verify the configuration

# Check package.json for semantic-release related dependencies
echo "=== Checking package.json for dependencies ==="
cat package.json | grep -A 5 -B 5 "semantic-release"

# Check for GitHub workflow files
echo -e "\n=== Checking GitHub workflow files ==="
fd -g "*.yml" .github/workflows/ -x cat {}

# Check for any existing semantic-release configuration
echo -e "\n=== Checking for release configuration files ==="
find . -type f -name ".releaserc*"
find . -type f -name "release.config.*"

# Check if the build target exists
echo -e "\n=== Checking build target configuration ==="
cat libs/flowbite-angular/project.json | grep -A 10 '"build":'

Length of output: 5203

Comment on lines +1 to +12
name: Release

on:
workflow_dispatch:
push:
branches:
- main
- next
- next-major
- alpha
- beta

Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Enable branch protection rules for release branches

The verification confirms that none of the branches, including the release-targeted branches (main, next, next-major, etc.), have protection rules enabled. This poses a security risk for the release workflow as:

  • The default branch (main) is unprotected
  • All branches can be directly pushed to without reviews
  • Squash and merge commits are allowed, but without required reviews

To prevent unauthorized releases, you should:

  • Enable branch protection rules for all release branches
  • Require pull request reviews before merging
  • Enable status checks to pass before merging
  • Consider restricting who can push to release branches
🔗 Analysis chain

Consider adding branch protection rules.

The workflow triggers on pushes to sensitive branches (main, next, next-major, etc.). To prevent unauthorized releases, ensure these branches have appropriate protection rules.


Let me gather more information about the repository's branch protection settings.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if branch protection rules exist for release branches
gh api repos/:owner/:repo/branches/main/protection 2>/dev/null || echo "Warning: main branch is not protected"
gh api repos/:owner/:repo/branches/next/protection 2>/dev/null || echo "Warning: next branch is not protected"

Length of output: 4076


Script:

#!/bin/bash
# Check repository settings and branch protection patterns
gh api repos/:owner/:repo | jq -r '.default_branch, .allow_squash_merge, .allow_merge_commit, .allow_rebase_merge'

# List all branch protection rules
gh api repos/:owner/:repo/branches | jq -r '.[].protected'

# Check workflow permissions
gh api repos/:owner/:repo/actions/permissions | jq -r '.default_workflow_permissions'

Length of output: 367

Comment on lines +17 to +36
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache

REPO=${{ github.repository }}
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"

echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 | grep pnpm)

## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Several improvements needed in the cleanup script.

While the basic functionality is correct, there are some improvements that could make the script more robust:

  1. Quote variables to prevent word splitting
  2. Add error handling for grep
  3. Improve logging of deleted cache keys
  4. Remove trailing whitespace
  5. Add existence check for caches

Here's the improved version:

      - name: Cleanup
        run: |
          gh extension install actions/gh-actions-cache

-         REPO=${{ github.repository }}
-         BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
+         REPO="${{ github.repository }}"
+         BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"

          echo "Fetching list of cache key"
-         cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 | grep pnpm)
+         cacheKeysForPR=$(gh actions-cache list -R "$REPO" -B "$BRANCH" | cut -f 1 | grep -F "pnpm" || true)

+         if [ -z "$cacheKeysForPR" ]; then
+           echo "No caches found for this PR"
+           exit 0
+         fi

-         ## Setting this to not fail the workflow while deleting cache keys. 
+         # Setting this to not fail the workflow while deleting cache keys
          set +e
          echo "Deleting caches..."
-         for cacheKey in $cacheKeysForPR
+         for cacheKey in $cacheKeysForPR
          do
-             gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
+             echo "Deleting cache key: $cacheKey"
+             gh actions-cache delete "$cacheKey" -R "$REPO" -B "$BRANCH" --confirm
          done
          echo "Done"

The improvements:

  • Added quotes around variables to prevent word splitting
  • Added -F to grep for literal string matching
  • Added || true to prevent grep from failing when no matches found
  • Added check for empty cache list
  • Improved logging to show which cache keys are being deleted
  • Fixed trailing whitespace in comment
  • Made comment style consistent

Consider adding a timeout to the job to prevent long-running cleanups:

jobs:
  cleanup:
    runs-on: ubuntu-latest
    timeout-minutes: 10
🧰 Tools
🪛 actionlint

18-18: shellcheck reported issue in this script: SC2086:info:14:29: Double quote to prevent globbing and word splitting

(shellcheck)

🪛 yamllint

[error] 27-27: trailing spaces

(trailing-spaces)

Comment on lines +3 to +7
on:
workflow_dispatch:
pull_request:

concurrency: ${{ github.ref }}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance workflow trigger configuration and permissions

Consider the following improvements for better workflow control:

  1. Add branch filters to the pull_request trigger to limit unnecessary workflow runs
  2. Add cancel-in-progress: true to the concurrency setting
  3. Explicitly declare required permissions

Apply these changes to improve the workflow configuration:

 on:
   workflow_dispatch:
   pull_request:
+    branches:
+      - main
+      - develop
+
+permissions:
+  contents: read
+  pull-requests: read

-concurrency: ${{ github.ref }}
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
on:
workflow_dispatch:
pull_request:
concurrency: ${{ github.ref }}
on:
workflow_dispatch:
pull_request:
branches:
- main
- develop
permissions:
contents: read
pull-requests: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

Comment on lines +50 to +68
build:
name: Build code 🛠
runs-on: ubuntu-latest
steps:
- name: Check out the code 🗄
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup NodeJS 💿
uses: actions/setup-node@v4
with:
node-version: 20

- name: Monorepo install
uses: ./.github/actions/setup

- name: Build code 🛠
run: pnpm all:build
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Optimize build job configuration and add dependencies

The build job should:

  1. Depend on successful lint and test jobs
  2. Upload build artifacts
  3. Use dependency caching

Apply these changes to improve the build job:

   build:
     name: Build code 🛠
+    needs: [lint, test]
     runs-on: ubuntu-latest
     steps:
       - name: Check out the code 🗄
         uses: actions/checkout@v4
-        with:
-          fetch-depth: 0

       - name: Setup NodeJS 💿
         uses: actions/setup-node@v4
         with:
           node-version: 20
+          cache: 'pnpm'

       - name: Monorepo install
         uses: ./.github/actions/setup

       - name: Build code 🛠
         run: pnpm all:build
+
+      - name: Upload build artifacts
+        uses: actions/upload-artifact@v3
+        with:
+          name: build-artifacts
+          path: dist/

Committable suggestion was skipped due to low confidence.

Comment on lines +30 to +49
test:
name: Run unit tests 🔬
runs-on: ubuntu-latest
steps:
- name: Check out the code 🗄
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup NodeJS 💿
uses: actions/setup-node@v4
with:
node-version: 20

- name: Monorepo install
uses: ./.github/actions/setup

- name: Run unit tests 🔬
run: pnpm all:test -- --ci --verbose

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance test job with artifacts and coverage reporting

Consider improving the test job configuration:

  1. Add test results and coverage artifacts
  2. Remove unnecessary git history fetch
  3. Add caching for dependencies

Apply these changes to enhance the test job:

   test:
     name: Run unit tests 🔬
     runs-on: ubuntu-latest
     steps:
       - name: Check out the code 🗄
         uses: actions/checkout@v4
-        with:
-          fetch-depth: 0

       - name: Setup NodeJS 💿
         uses: actions/setup-node@v4
         with:
           node-version: 20
+          cache: 'pnpm'

       - name: Monorepo install
         uses: ./.github/actions/setup

       - name: Run unit tests 🔬
-        run: pnpm all:test -- --ci --verbose
+        run: pnpm all:test -- --ci --verbose --coverage

+      - name: Upload test results
+        if: always()
+        uses: actions/upload-artifact@v3
+        with:
+          name: test-results
+          path: |
+            coverage/
+            test-results/

Committable suggestion was skipped due to low confidence.

Comment on lines +39 to +41
"github": true,
"npm": true,
"changelog": true,
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider adding additional semantic-release plugins.

While the basic configuration with GitHub, npm, and changelog is good, consider adding these commonly used plugins for a more robust release process:

  • @semantic-release/commit-analyzer: For conventional commits parsing
  • @semantic-release/release-notes-generator: For structured release notes
  • @semantic-release/git: For version bumping in package.json
    "options": {
      "github": true,
      "npm": true,
      "changelog": true,
+     "plugins": [
+       "@semantic-release/commit-analyzer",
+       "@semantic-release/release-notes-generator",
+       "@semantic-release/npm",
+       "@semantic-release/github",
+       "@semantic-release/git"
+     ],

Committable suggestion was skipped due to low confidence.

Comment on lines +24 to +32
inputs:
enable-corepack:
description: 'Enable corepack'
required: false
default: 'false'
cwd:
description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()"
required: false
default: '.'
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance input parameters documentation and validation

Consider the following improvements:

  1. Clarify whether cwd accepts absolute paths or must be relative to the workspace
  2. Add input validation for the enable-corepack boolean value

Apply this diff to enhance the input parameters:

 inputs:
   enable-corepack:
     description: 'Enable corepack'
     required: false
     default: 'false'
+    type: boolean
   cwd:
-    description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()"
+    description: "Project directory relative to workspace root. Default: '.'"
     required: false
     default: '.'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
inputs:
enable-corepack:
description: 'Enable corepack'
required: false
default: 'false'
cwd:
description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()"
required: false
default: '.'
inputs:
enable-corepack:
description: 'Enable corepack'
required: false
default: 'false'
type: boolean
cwd:
description: "Project directory relative to workspace root. Default: '.'"
required: false
default: '.'

Comment on lines +80 to +87
- name: Install dependencies
shell: bash
working-directory: ${{ inputs.cwd }}
run: pnpm install --frozen-lockfile --prefer-offline
env:
# Other environment variables
HUSKY: '0' # By default do not run HUSKY install

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance error handling and environment variables documentation

The installation step could benefit from:

  1. Better error handling with continue-on-error or explicit error messages
  2. Clear documentation for all environment variables (currently only HUSKY is documented)

Apply this diff to improve the installation step:

 - name: Install dependencies
   shell: bash
   working-directory: ${{ inputs.cwd }}
-  run: pnpm install --frozen-lockfile --prefer-offline
+  run: |
+    echo "Installing dependencies in ${{ inputs.cwd }}..."
+    if ! pnpm install --frozen-lockfile --prefer-offline; then
+      echo "::error::Failed to install dependencies. Check the lockfile and try again."
+      exit 1
+    fi
   env:
-    # Other environment variables
+    # Prevent Husky installation during CI
     HUSKY: '0' # By default do not run HUSKY install
+    # Add other environment variables here with clear documentation
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Install dependencies
shell: bash
working-directory: ${{ inputs.cwd }}
run: pnpm install --frozen-lockfile --prefer-offline
env:
# Other environment variables
HUSKY: '0' # By default do not run HUSKY install
- name: Install dependencies
shell: bash
working-directory: ${{ inputs.cwd }}
run: |
echo "Installing dependencies in ${{ inputs.cwd }}..."
if ! pnpm install --frozen-lockfile --prefer-offline; then
echo "::error::Failed to install dependencies. Check the lockfile and try again."
exit 1
fi
env:
# Prevent Husky installation during CI
HUSKY: '0' # By default do not run HUSKY install
# Add other environment variables here with clear documentation

Comment on lines +65 to +72
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-config.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve cache key strategy

The current cache key strategy might lead to cache misses when dependencies haven't changed. Consider including the Node.js version in the cache key to prevent issues with different Node.js versions.

Apply this diff to enhance cache keys:

 - uses: actions/cache@v4
   name: Setup pnpm cache
   with:
     path: ${{ steps.pnpm-config.outputs.STORE_PATH }}
-    key: ${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-${{ hashFiles('**/pnpm-lock.yaml') }}
+    key: ${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-node-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
     restore-keys: |
-      ${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-
+      ${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-node-${{ matrix.node-version }}-

Committable suggestion was skipped due to low confidence.

@MGREMY MGREMY changed the base branch from beta to alpha October 26, 2024 13:10
@MGREMY MGREMY marked this pull request as ready for review October 26, 2024 13:19
@MGREMY MGREMY merged commit 3e681ff into alpha Oct 26, 2024
4 of 5 checks passed
@MGREMY MGREMY deleted the rework_project_side_configuration branch October 26, 2024 13:21
@MGREMY
Copy link
Collaborator Author

MGREMY commented Nov 4, 2024

🎉 This PR is included in version 1.0.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@MGREMY
Copy link
Collaborator Author

MGREMY commented Nov 11, 2024

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants