8000 [dx] automatically detect version for migrations in installer.sh by kvaps · Pull Request #837 · cozystack/cozystack · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[dx] automatically detect version for migrations in installer.sh #837

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

Merged
merged 1 commit into from
Apr 22, 2025

Conversation

kvaps
Copy link
Member
@kvaps kvaps commented Apr 22, 2025

Signed-off-by: Andrei Kvapil kvapss@gmail.com

Summary by CodeRabbit

  • Chores
    • Updated migration versioning to automatically determine the next version based on existing migration scripts, removing the need for manual updates.

@kvaps kvaps requested a review from lllamnyp as a code owner April 22, 2025 09:59
Copy link
Contributor
coderabbitai bot commented Apr 22, 2025

Warning

Rate limit exceeded

@kvaps has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 56 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between e00532c and 172e660.

📒 Files selected for processing (1)
  • scripts/installer.sh (1 hunks)

Walkthrough

The change updates the way the VERSION variable is set in the scripts/installer.sh script. Instead of assigning a fixed value, the script now calculates the version dynamically by examining the filenames in the scripts/migrations directory, sorting them, and setting VERSION to one higher than the highest existing migration script number. This approach ties the version directly to the migration files present in the directory.

Changes

File(s) Change Summary
scripts/installer.sh Changed VERSION from a hardcoded value to a dynamically calculated value based on migration files

Poem

In the warren of scripts, a change takes the stage,
No more hard numbers—let filenames gauge!
Migrations now guide what the version will be,
Counting each hop, as clever as me.
Dynamic and nimble, this bunny approves,
For every new script, the version now moves! 🐇✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 generate docstrings to generate docstrings for this 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

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.

@kvaps kvaps changed the title [ci] Fix escaping for gen_versions_map.sh script [dx] automatically detect version for migrations in installer.sh Apr 22, 2025
Signed-off-by: Andrei Kvapil <kvapss@gmail.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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🧹 Nitpick comments (1)
scripts/installer.sh (1)

6-6: Robustly parse numeric prefixes from migration filenames
The current AWK expression ($NF+1) may misinterpret filenames that include extensions or non-numeric suffixes. To strictly extract and increment only the numeric prefix, split on the underscore or apply a regex. For instance:

-| find scripts/migrations -mindepth 1 -maxdepth 1 -type f | sort -V | awk -F/ 'END {print $NF+1}'
+| find scripts/migrations -mindepth 1 -maxdepth 1 -type f | sort -V \
+  | awk -F/ '{print $NF}' \
+  | sed -E 's/^([0-9]+).*/\1/' \
+  | awk 'END {print $1 + 1}'

This two-step extraction ensures only the leading digits are considered.

🛑 Comments failed to post (1)
scripts/installer.sh (1)

6-6: 🛠️ Refactor suggestion

Ensure fallback when no migration scripts exist
If scripts/migrations is empty, the pipeline find … | sort -V | awk … will yield an empty VERSION, which may cause the configmap creation or later loops to misbehave. Consider defaulting to version 1 when no migrations are found. For example:

+latest=$(find scripts/migrations -mindepth 1 -maxdepth 1 -type f | sort -V | tail -n1)
+if [ -z "$latest" ]; then
+  VERSION=1
+else
+  # Extract numeric prefix and increment
+  base=$(basename "$latest")
+  num=${base%%_*}
+  VERSION=$((num + 1))
+fi

@klinch0 klinch0 merged commit 53cf1c5 into main Apr 22, 2025
6 checks passed
@klinch0 klinch0 deleted the auto-version branch April 22, 2025 13:24
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
0