-
-
Notifications
You must be signed in to change notification settings - Fork 535
refa(devcontainer): rework to use mise for fast switching #2948
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
base: master
Are you sure you want to change the base?
Changes from all commits
43b4e70
7df491c
d6cd2e6
ced5fca
c157829
2cd8c42
fcca3ee
d4888c1
4ba7828
a184ffb
3f0330c
9929d92
5406008
b6e5dbd
d4b3958
7b423cd
7b6ef3a
c5e368a
f1827bc
8d20a8c
26662b2
9c27785
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| "features": { | ||
| "ghcr.io/devcontainers-extra/features/npm-packages:latest": { | ||
| "version": "1.0.1", | ||
| "resolved": "ghcr.io/devcontainers-extra/features/npm-packages@sha256:0851cc312204f4044f22230986134026409565f9e632d8ab2b8c639e81cedd7c", | ||
| "integrity": "sha256:0851cc312204f4044f22230986134026409565f9e632d8ab2b8c639e81cedd7c" | ||
| }, | ||
| "ghcr.io/devcontainers/features/github-cli:latest": { | ||
| "version": "1.1.0", | ||
| "resolved": "ghcr.io/devcontainers/features/github-cli@sha256:d22f50b70ed75339b4eed1ba9ecde3a1791f90e88d37936517e3bace0bbad671", | ||
| "integrity": "sha256:d22f50b70ed75339b4eed1ba9ecde3a1791f90e88d37936517e3bace0bbad671" | ||
| }, | ||
| "ghcr.io/devcontainers/features/node:latest": { | ||
| "version": "2.0.0", | ||
| "resolved": "ghcr.io/devcontainers/features/node@sha256:fedd4c11f7adfb64283b578dddc7da906728daa25fa293351c9d913231acf12f", | ||
| "integrity": "sha256:fedd4c11f7adfb64283b578dddc7da906728daa25fa293351c9d913231acf12f" | ||
| }, | ||
| "ghcr.io/nils-geistmann/devcontainers-features/zsh:latest": { | ||
| "version": "0.0.8", | ||
| "resolved": "ghcr.io/nils-geistmann/devcontainers-features/zsh@sha256:fd57a61a5187480b5e73f8041be5b67005be48f06503736df6cfdd8d0f38f3c4", | ||
| "integrity": "sha256:fd57a61a5187480b5e73f8041be5b67005be48f06503736df6cfdd8d0f38f3c4" | ||
| }, | ||
| "ghcr.io/rocker-org/devcontainer-features/apt-packages:latest": { | ||
| "version": "1.0.2", | ||
| "resolved": "ghcr.io/rocker-org/devcontainer-features/apt-packages@sha256:87a4d7750a596a5db034ba8508782f31aebdc2ffe955c66aaecb33d9de2ecdae", | ||
| "integrity": "sha256:87a4d7750a596a5db034ba8508782f31aebdc2ffe955c66aaecb33d9de2ecdae" | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,92 +1,58 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
| # | ||
| # Container entrypoint. | ||
| # | ||
| # Order of operations: | ||
| # 1. Set up mise (the Ruby version manager) for this shell. | ||
| # 2. Ensure the desired Ruby is installed (precompiled, no source build). | ||
| # 3. Hand off to whatever docker-compose passes as `command`. | ||
| # | ||
| set -euo pipefail | ||
|
|
||
| cd /workspace/sentry | ||
|
|
||
| sudo mkdir -p vendor/gems | ||
| sudo chown -R sentry:sentry vendor/gems | ||
|
|
||
| # git config --global --replace-all safe.directory /workspace/sentry | ||
| # git config --global --replace-all safe.directory /workspace/sentry/vendor/gems/* | ||
|
|
||
| sudo chown -R sentry:sentry . | ||
|
|
||
| run_service_setup() { | ||
| local service="$1" | ||
| # In CI the workspace is checked out by the runner user (e.g. UID 1001) and | ||
| # then bind-mounted into the container where we run as sentry (UID 1000). | ||
| # Fix ownership once here so bundler, git, etc. can write freely. | ||
| sudo chown -R sentry:sentry /workspace/sentry 2>/dev/null || true | ||
| MISE_BIN="/home/sentry/.local/bin/mise" | ||
|
|
||
| echo "🚀 Running setup for service: $service" | ||
| # Git also refuses to operate in directories owned by a different user. | ||
| git config --global --add safe.directory /workspace/sentry 2>/dev/null || true | ||
|
|
||
| case "$service" in | ||
| "dev") | ||
| if ! .devcontainer/setup --with-foreman --only-bundle; then | ||
| echo "❌ Setup failed for service: $service" | ||
| exit 1 | ||
| fi | ||
| ;; | ||
| "test") | ||
| if ! .devcontainer/setup --with-foreman --only .,spec/apps/rails-mini; then | ||
| echo "❌ Setup failed for service: $service" | ||
| exit 1 | ||
| fi | ||
| ;; | ||
| *) | ||
| echo "❌ Unknown service: $service" | ||
| echo "Available services: dev, test" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| # ---- 1. mise setup ----------------------------------------------------------- | ||
|
|
||
| echo "✅ Setup completed for service: $service" | ||
| } | ||
|
|
||
| # Function to start services in background | ||
| start_services_if_needed() { | ||
| # Check if we're running tests (bundle exec rake) | ||
| if [[ "$*" == *"bundle exec rake"* ]]; then | ||
| echo "🚀 Starting e2e services in background for test execution..." | ||
| if [[ ! -x "$MISE_BIN" ]]; then | ||
| echo "❌ mise not found at $MISE_BIN (it should be installed by the Dockerfile)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Start foreman in background | ||
| foreman start & | ||
| FOREMAN_PID=$! | ||
| # Activate mise for this shell so PATH/shims are resolved correctly. | ||
| eval "$("$MISE_BIN" activate bash)" | ||
|
|
||
| # Wait for services to be ready | ||
| echo "⏳ Waiting for services to start..." | ||
| for i in {1..30}; do | ||
| if curl -f http://localhost:4000/health >/dev/null 2>&1 && \ | ||
| curl -f http://localhost:4001/health >/dev/null 2>&1; then | ||
| echo "✅ Services are ready!" | ||
| break | ||
| fi | ||
| # Trust the workspace config so mise will use it without prompting. | ||
| "$MISE_BIN" trust /workspace/sentry >/dev/null | ||
|
|
||
| if [ $i -eq 30 ]; then | ||
| echo "❌ Services failed to start within timeout" | ||
| kill $FOREMAN_PID 2>/dev/null || true | ||
| exit 1 | ||
| fi | ||
| # ---- 2. Install Ruby (precompiled) ------------------------------------------- | ||
|
|
||
| sleep 2 | ||
| done | ||
| # Default to the latest Ruby unless the caller pins a specific version. | ||
| RUBY_VERSION="${RUBY_VERSION:-latest}" | ||
|
|
||
| # Set up cleanup trap | ||
| trap "echo '🧹 Stopping services...'; kill $FOREMAN_PID 2>/dev/null || true; wait $FOREMAN_PID 2>/dev/null || true" EXIT | ||
| fi | ||
| } | ||
| # Skip installation when the version is already present in the image (e.g. CI | ||
| # images built with the RUBY_VERSION build arg in the Dockerfile). | ||
| if "$MISE_BIN" list ruby 2>/dev/null | grep -qF "${RUBY_VERSION}"; then | ||
| echo "✅ ruby@${RUBY_VERSION} already installed, skipping download." | ||
| else | ||
| echo "📦 Installing ruby@${RUBY_VERSION} (precompiled)..." | ||
| "$MISE_BIN" install "ruby@${RUBY_VERSION}" | ||
|
Comment on lines
+43
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The check for an existing Ruby installation using Suggested FixResolve the Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
| fi | ||
|
|
||
| # Parse arguments | ||
| if [ "$1" = "--service" ] && [ -n "$2" ]; then | ||
| service="$2" | ||
| shift 2 | ||
| "$MISE_BIN" use --global "ruby@${RUBY_VERSION}" | ||
|
|
||
| run_service_setup "$service" | ||
| # ---- 3. Hand off ------------------------------------------------------------- | ||
|
|
||
| if [ $# -gt 0 ]; then | ||
| start_services_if_needed "$@" | ||
| exec "$@" | ||
| else | ||
| exec bash | ||
| fi | ||
| if [[ $# -eq 0 ]]; then | ||
| exec sleep infinity | ||
| else | ||
| start_services_if_needed "$@" | ||
| exec "$@" | ||
| fi | ||
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.
Chromium symlink broken on x86_64 Linux builds
High Severity
The symlink hardcodes
chrome-linux/chrome, but Playwright ≥1.57 on Linux x64 installs Chromium underchrome-linux64/chrome. Since CI usesubuntu-latest(x86_64) andnpx playwright install chromiumfetches the latest version, the glob resolves to a non-existent subdirectory, creating a broken symlink.File.exist?inspec_helper.rbthen returnsfalse, sooptions.binaryis never set, and Selenium cannot locate the Chrome binary — breaking e2e tests on x64 runners. The pathchrome-linux/chromeonly works on ARM64, which appears to be where the author tested (PR description showsaarch64-linux).Additional Locations (1)
spec/spec_helper.rb#L27-L28Reviewed by Cursor Bugbot for commit 9c27785. Configure here.