-
Notifications
You must be signed in to change notification settings - Fork 1
[codex] Add Ruby Bundler cooldown conventions #4
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f8af63e
Add Ruby Bundler cooldown conventions
michaelmwu d599fc9
Fix Ruby stack port helper copy flow
michaelmwu 511c18d
Keep Ruby port fallback ADE neutral
michaelmwu bb36a6e
Make Ruby stack copy instructions robust
michaelmwu af13437
Address Ruby stack review fixes
michaelmwu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| source "https://rubygems.org", cooldown: 7 | ||
|
|
||
| ruby ">= 3.2" | ||
|
|
||
| group :development, :test do | ||
| gem "rspec", require: false | ||
| gem "rubocop", require: false | ||
| gem "rubocop-performance", require: false | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # Ruby Stack | ||
|
|
||
| Use this stack when the target project needs Ruby, Rails, Rack, or Ruby-first | ||
| service tooling. | ||
|
|
||
| ## Contains | ||
|
|
||
| - `Gemfile.example`: minimal Bundler policy with a public RubyGems cooldown. | ||
| - `scripts/{setup,dev,lint,test,check-all}.sh`: validation and local | ||
| development wrappers for a copied Ruby stack. | ||
|
|
||
| The root devkit keeps `scripts/worktree-ports.sh` as the canonical port helper | ||
| so projects are not forced to include Ruby just for port allocation. | ||
| If an ADE or workspace orchestrator has its own reserved port variable, map it | ||
| to `PORT` or `WORKTREE_PRIMARY_PORT` in that environment's wrapper script | ||
| instead of adding ADE-specific names to this stack. | ||
|
|
||
| ## Apply | ||
|
|
||
| Copy the relevant files into the target repo root: | ||
|
|
||
| ```bash | ||
| mkdir -p scripts | ||
| cp stacks/ruby/Gemfile.example Gemfile | ||
| cp scripts/worktree-ports.sh scripts/ | ||
| cp stacks/ruby/scripts/*.sh scripts/ | ||
| ``` | ||
|
|
||
| Then check the local Bundler version: | ||
|
|
||
| ```bash | ||
| bundle --version | ||
| ``` | ||
|
|
||
| Bundler cooldowns require Bundler `4.0.13` or newer. If the target repo has an | ||
| older Bundler, ask before upgrading. After upgrading, pin Bundler in the | ||
| lockfile: | ||
|
|
||
| ```bash | ||
| gem install bundler -v 4.0.13 | ||
| bundle install | ||
| bundle lock --bundler=4.0.13 | ||
| ``` | ||
|
|
||
| Then validate the copied stack: | ||
|
|
||
| ```bash | ||
| ./scripts/check-all.sh | ||
| ``` | ||
|
|
||
| ## Agent Notes | ||
|
|
||
| - Do not copy this stack just because a repo has scripts. Select it only when | ||
| Ruby is part of the target runtime or tooling. | ||
| - Keep `source "https://rubygems.org", cooldown: 7` on public RubyGems sources | ||
| when Bundler is `4.0.13` or newer. | ||
| - Use `cooldown: 0`, `bundle install --cooldown 0`, or `BUNDLE_COOLDOWN=0` | ||
| only for intentional exceptions such as urgent security fixes. | ||
| - Commit `Gemfile.lock` after applying the stack to a real target repo. | ||
| - Keep root port helpers shell-based unless the target repo intentionally wants | ||
| Ruby helper scripts. | ||
| - If the target repo already has its own port helper, adapt `scripts/dev.sh` | ||
| instead of overwriting that helper. | ||
| - If the target ADE exposes a product-specific port variable, map it to `PORT` | ||
| or `WORKTREE_PRIMARY_PORT` outside the reusable stack scripts. | ||
| - Update `.env.example` whenever settings fields change. | ||
| - Run `./scripts/check-all.sh` from the copied Ruby stack before handing off. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #!/usr/bin/env sh | ||
| set -eu | ||
|
|
||
| cd "$(dirname "$0")/.." | ||
|
|
||
| bundle check | ||
| ./scripts/lint.sh | ||
| ./scripts/test.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #!/usr/bin/env sh | ||
| set -eu | ||
|
|
||
| cd "$(dirname "$0")/.." | ||
|
|
||
| export WEB_HOST="${WEB_HOST:-127.0.0.1}" | ||
| export RACK_ENV="${RACK_ENV:-development}" | ||
| export RAILS_ENV="${RAILS_ENV:-development}" | ||
|
|
||
| if [ -x ./scripts/worktree-ports.sh ]; then | ||
| eval "$(./scripts/worktree-ports.sh export)" | ||
| export PORT="${PORT:-$WEB_PORT}" | ||
| else | ||
| export PORT="${PORT:-${WORKTREE_PRIMARY_PORT:-3000}}" | ||
| fi | ||
|
|
||
| echo "508 Devkit Ruby stack" | ||
| echo " Web: http://${WEB_HOST}:${PORT}" | ||
| if [ -n "${POSTGRES_HOST_PORT:-}" ]; then | ||
| echo " Postgres: 127.0.0.1:${POSTGRES_HOST_PORT}" | ||
| fi | ||
| if [ -n "${REDIS_HOST_PORT:-}" ]; then | ||
| echo " Redis: 127.0.0.1:${REDIS_HOST_PORT}" | ||
| fi | ||
| echo | ||
|
|
||
| if [ -x bin/dev ]; then | ||
| exec bin/dev | ||
| fi | ||
|
|
||
| if [ -x bin/rails ]; then | ||
| exec bundle exec rails server --binding "$WEB_HOST" --port "$PORT" | ||
| fi | ||
|
|
||
| if [ -f config.ru ]; then | ||
| exec bundle exec rackup --host "$WEB_HOST" --port "$PORT" | ||
| fi | ||
|
|
||
| echo "No Ruby dev entrypoint found. Add bin/dev, bin/rails, or config.ru." >&2 | ||
| exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/usr/bin/env sh | ||
| set -eu | ||
|
|
||
| cd "$(dirname "$0")/.." | ||
|
|
||
| bundle exec rubocop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/usr/bin/env sh | ||
| set -eu | ||
|
|
||
| cd "$(dirname "$0")/.." | ||
|
|
||
| if ! command -v bundle >/dev/null 2>&1; then | ||
| echo "Bundler is required. Install Bundler 4.0.13 or newer before setup." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| version="$(bundle --version | awk '{print $3}')" | ||
| if ! ruby -e 'exit(Gem::Version.new(ARGV[0]) >= Gem::Version.new("4.0.13") ? 0 : 1)' "$version"; then | ||
| echo "Bundler ${version} is too old for Gemfile cooldown syntax; install Bundler 4.0.13 or newer." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| bundle install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #!/usr/bin/env sh | ||
| set -eu | ||
|
|
||
| cd "$(dirname "$0")/.." | ||
|
|
||
| if [ -d spec ]; then | ||
| exec bundle exec rspec | ||
| fi | ||
|
|
||
| if [ -x bin/rails ]; then | ||
| exec bundle exec rails test | ||
| fi | ||
|
|
||
| if [ -d test ]; then | ||
| exec bundle exec ruby -Itest -e 'Dir["test/**/*_test.rb"].sort.each { |file| require "./#{file}" }' | ||
| fi | ||
|
michaelmwu marked this conversation as resolved.
|
||
|
|
||
| echo "No spec/ or test/ directory found." | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.