-
Notifications
You must be signed in to change notification settings - Fork 60
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: Various maintenance #16326
chore: Various maintenance #16326
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #16326 +/- ##
=======================================
Coverage 36.75% 36.75%
=======================================
Files 6804 6804
Lines 140903 140903
Branches 40137 40137
=======================================
Hits 51785 51785
Misses 89118 89118
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
|
Datadog ReportAll test runs ✅ 32 Total Test Services: 0 Failed, 32 Passed Test ServicesThis report shows up to 10 services
|
WalkthroughThe pull request introduces several modifications across multiple scripts. The Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 10
🧹 Outside diff range and nitpick comments (8)
scripts/generate-changelog.sh (4)
5-7
: Excellent addition for tool verification.The added verification step improves the script's robustness by ensuring 'generate-changelog' is installed. The echo statement enhances user feedback, which is great for usability.
Consider adding error handling for the case where 'generate-changelog' is not installed. For example:
if ! npx generate-changelog &>/dev/null; then echo "Error: 'generate-changelog' is not installed. Please install it and try again." exit 1 fi
22-23
: Improved error handling and script robustness.The expanded error message and the use of "tee" as a fallback option enhance the script's usability and robustness. This change allows the script to continue execution even when no clipboard tool is available.
For clarity, consider adding a comment explaining the fallback behavior:
# Fallback to 'tee' if no clipboard tool is available # This will print the changelog to stdout instead of copying to clipboard selected_tool="tee"
30-32
: Great addition of progress feedback.The introduction of a counter and real-time feedback on the number of branches found significantly improves the user experience. The use of 'echo -ne' with '\r' for dynamic updates is an efficient approach for terminal output.
For consistency with bash naming conventions, consider using uppercase for the constant maximum number of branches:
MAX_BRANCHES=2 n=0 while IFS= read -r line && [ "$n" -lt "$MAX_BRANCHES" ]; do echo -ne "Found $((++n)) branches\r" branches+=("$line") done < <(git for-each-ref --sort=-committerdate refs/heads/release/ --format='%(refname:short)')This change also ensures that we only process the required number of branches, improving efficiency.
35-36
: Improved user feedback and traceability.The addition of the total branch count provides a clear summary to the user, and including this information in the changelog generation command improves traceability. These changes enhance the overall user experience and maintainability of the script.
Consider adding a check to ensure that at least two branches were found before generating the changelog:
if [ "${#branches[@]}" -lt 2 ]; then echo "Error: Not enough release branches found. At least two are required." exit 1 fi echo "Found ${#branches[@]} branches in total" npx generate-changelog -t "${branches[1]}".."${branches[0]}" -a -f - | "$selected_tool"This addition would improve error handling and prevent potential issues if not enough branches are available.
infra/scripts/helm-diff.sh (1)
3-12
: Excellent enhancement for usability!The self-calling mechanism is a great addition that improves the script's ease of use. It automatically fetches the latest two release branches when no arguments are provided, which is very convenient.
A small suggestion for improvement:
Consider adding agit fetch
command beforegit branch -r
to ensure the list of remote branches is up-to-date. This would prevent potential issues if the local copy of remote branches is outdated.You could add the following line just before line 5:
git fetch --all --quietThis ensures that the list of remote branches is current before selecting the latest releases.
scripts/mkrelease.sh (2)
28-35
: Use consistent function definitions for color outputs.For better readability and consistency, it's recommended to define color functions before using them and to group related code together.
Consider moving the color function definitions directly after the color variables:
COLOR_GRAY="\e[90m" +red() { echo "${COLOR_RED}${*}${COLOR_RESET}"; } +blue() { echo "${COLOR_BLUE}${*}${COLOR_RESET}"; } +gray() { echo "${COLOR_GRAY}${*}${COLOR_RESET}"; } -echo -e "$(gray "$(echo -e "Environment debug:\n###\n$(set | grep '^RELEASE_')\n###")")\n"
37-37
: Avoid unnecessary nestedecho
commands.The
echo
command is nested unnecessarily, which might impact readability.Simplify the command by removing the redundant
echo -e
:-echo -e "$(gray "$(echo -e "Environment debug:\n###\n$(set | grep '^RELEASE_')\n###")")\n" +gray "Environment debug:\n###\n$(set | grep '^RELEASE_')\n###\n"scripts/_run-aws-eks-commands.js (1)
Line range hint
17-22
: Inconsistent error handling when container runtime is not foundWhen neither
podman
nordocker
is available, the code logs an error message but still returns'docker'
as thecontainerer
. This could lead to failures later sincedocker
is not installed on the system.Apply this diff to exit the process after logging the error:
} else if (commandExistsSync('docker')) { return 'docker' } console.error('Please install podman or docker') - return 'docker' + process.exit(1) })()This change ensures that the script halts execution when no valid container runtime is found, preventing unexpected errors downstream.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (4)
- infra/scripts/helm-diff.sh (2 hunks)
- scripts/_run-aws-eks-commands.js (1 hunks)
- scripts/generate-changelog.sh (2 hunks)
- scripts/mkrelease.sh (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
scripts/_run-aws-eks-commands.js (1)
Pattern
scripts/**/*
: "Confirm that the code adheres to the following:
- Script efficiency, readability, and maintainability.
- Usage of environmental variables and configuration files for flexibility.
- Integration with NX workspace utilities and commands."
scripts/generate-changelog.sh (1)
Pattern
scripts/**/*
: "Confirm that the code adheres to the following:
- Script efficiency, readability, and maintainability.
- Usage of environmental variables and configuration files for flexibility.
- Integration with NX workspace utilities and commands."
scripts/mkrelease.sh (1)
Pattern
scripts/**/*
: "Confirm that the code adheres to the following:
- Script efficiency, readability, and maintainability.
- Usage of environmental variables and configuration files for flexibility.
- Integration with NX workspace utilities and commands."
🔇 Additional comments (2)
infra/scripts/helm-diff.sh (1)
Line range hint
1-40
: Overall, excellent improvements to the script!The changes made to
helm-diff.sh
significantly enhance its functionality and ease of use. The addition of the self-calling mechanism with automatic retrieval of release branches aligns perfectly with the PR objective of simplifying the script's usage. The switch to dynamic temporary files improves the script's robustness and security.These modifications make the script more user-friendly and less error-prone, which should lead to a smoother workflow for your team.
To further polish the script, consider implementing the suggestions provided in the previous comments:
- Add a
git fetch
before retrieving release branches to ensure up-to-date information.- Implement a cleanup mechanism for the temporary files using a trap.
These minor adjustments will make the script even more robust and maintainable.
scripts/mkrelease.sh (1)
146-163
: GITHUB_TOKEN is not set: Authentication issues confirmed.The
GITHUB_TOKEN
environment variable is not set, which could lead to authentication failures when dispatching events.
- File:
scripts/mkrelease.sh
- Function:
dispatch-event
[issues_found]
🔗 Analysis chain
Handle GitHub token absence gracefully.
In the
dispatch-event
function, theAuthorization
header includes${GITHUB_TOKEN}
. IfGITHUB_TOKEN
is unset, it could lead to authentication issues.Ensure that the
GITHUB_TOKEN
is set before making the API call, or adjust the script to handle its absence.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify if GITHUB_TOKEN is set # Test: Check if GITHUB_TOKEN is set if [ -z "${GITHUB_TOKEN}" ]; then echo "GITHUB_TOKEN is not set. Please export GITHUB_TOKEN before running this script." else echo "GITHUB_TOKEN is set." fiLength of output: 184
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGMT (see comments)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
scripts/mkrelease.sh (2)
39-66
: Well-implementedrun()
function with comprehensive error handling.The
run()
function is well-designed, handling both dry runs and actual command execution. It effectively captures command output and exit codes, providing robust error handling. Consider either removing or uncommenting the debug lines (54-56) based on your debugging needs.If the debug lines are no longer needed, consider removing them to improve code cleanliness:
- # echo -e "$(gray "$(echo -e "[CMD] Command: ${CMD[1]}")")" - # for arg in "${CMD[@]}"; do - # echo -e "$(gray "$(echo -e "[CMD] -> Argument: '${arg}'")")" - # done
103-123
: Consider adding comments to clarify therename-branch()
function logic.The
rename-branch()
function handles both local and remote branch renaming effectively. However, the logic is somewhat complex and could benefit from additional inline comments explaining each step of the process. This would improve maintainability and make it easier for other developers to understand the function's workflow.Consider adding comments to explain the logic, especially for the conditional checks:
rename-branch() { local OLD_BRANCH="${1}" NEW_BRANCH="${2}" + # Handle local branch renaming ## Local # Don't rename if already renamed if ! git branch --list | grep -q "^${NEW_BRANCH}$" && ! git branch --list | grep -q "^${OLD_BRANCH}\$"; then run git branch -m "${OLD_BRANCH}" "${NEW_BRANCH}" fi run git fetch origin + # Handle remote branch renaming ## Remote if ! git branch -r | grep -q "origin/${NEW_BRANCH}"; then # Don't push new branch if it already exists run git push origin "${NEW_BRANCH}" fi run git branch -u "origin/${NEW_BRANCH}" "${NEW_BRANCH}" run git remote set-head origin -a run git fetch origin + # Clean up old remote branch if it exists if git branch -r | grep -q "origin/${OLD_BRANCH}"; then run git push origin --delete "${OLD_BRANCH}" fi }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (2)
- scripts/_run-aws-eks-commands.js (1 hunks)
- scripts/mkrelease.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- scripts/_run-aws-eks-commands.js
🧰 Additional context used
📓 Path-based instructions (1)
scripts/mkrelease.sh (1)
Pattern
scripts/**/*
: "Confirm that the code adheres to the following:
- Script efficiency, readability, and maintainability.
- Usage of environmental variables and configuration files for flexibility.
- Integration with NX workspace utilities and commands."
📓 Learnings (1)
scripts/mkrelease.sh (2)
Learnt from: AndesKrrrrrrrrrrr PR: island-is/island.is#16326 File: scripts/mkrelease.sh:149-150 Timestamp: 2024-10-11T14:02:50.332Z Learning: In the `scripts/` directory, `jq` is already a required dependency, so it's acceptable to use `jq` in scripts.
Learnt from: AndesKrrrrrrrrrrr PR: island-is/island.is#16326 File: scripts/mkrelease.sh:53-54 Timestamp: 2024-10-11T14:00:37.118Z Learning: In scripts with `set -e`, when capturing the exit code of a command that may fail, it's necessary to use `|| true` to prevent the script from exiting immediately.
🔇 Additional comments (6)
scripts/mkrelease.sh (6)
3-3
: Good use of error handling.The
set -euo pipefail
command is a best practice in bash scripting. It ensures that the script exits immediately if any command fails, treats unset variables as an error, and prevents errors in a pipeline from being masked.
12-15
: Improved portability by avoidingrealpath
.Good decision to avoid using
realpath
for path resolution. This improves the script's portability, especially for macOS systems whererealpath
might not be available by default.
28-35
: Effective use of color definitions for output formatting.The color definitions and associated functions (
red()
,blue()
,gray()
) are well-implemented. This approach enhances the readability of the script's output and makes it easier to distinguish between different types of messages.
153-172
: Effective implementation ofdispatch-event()
function.The
dispatch-event()
function is well-implemented, usingjq
for URI encoding as per the project's requirements. The use of an array for thecurl
command improves readability and maintainability. The function effectively dispatches GitHub Actions workflow events.
183-218
: Well-structured and comprehensive main execution flow.The main execution flow is logically organized, covering pre-release, staging, and production deployments. It effectively utilizes the helper functions defined earlier, making the process clear and maintainable. The inclusion of monitoring steps and user prompts ensures proper oversight during the release process.
219-219
:⚠️ Potential issueFix typo in the final message.
There's a minor typo in the final celebratory message.
Apply this diff to correct the spelling:
-echo -e "\n>\n> 🚀 Realease complete! 🚀\n>\n" +echo -e "\n>\n> 🚀 Release complete! 🚀\n>\n"Likely invalid or redundant comment.
--load
to export Docker layer (started failing for me)helm-diff.sh
usage (doesn't require arguments)Summary by CodeRabbit
New Features
podman
and included a new--load
option.Bug Fixes
Documentation