-
Notifications
You must be signed in to change notification settings - Fork 383
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
Fix/no commit hash on the deployed project #611
base: master
Are you sure you want to change the base?
Fix/no commit hash on the deployed project #611
Conversation
WalkthroughThe pull request introduces a mechanism to capture and expose the Git commit SHA in a deployed Ruby on Rails application. This is achieved by adding a build argument and environment variable in the Dockerfile, modifying the Changes
Assessment against linked issues
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 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
CodeRabbit Configuration File (
|
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
🧹 Nitpick comments (1)
spec/system/pages_spec.rb (1)
20-29
: Consider using a more robust approach to stub environment variables.Manually setting and deleting
ENV["GIT_COMMIT_SHA"]
works but can be fragile if additional tests run in parallel or the environment remains altered after a failure. Libraries likeClimateControl
isolate environment variable changes per test. This approach helps ensure consistency and concurrency safety.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.controlplane/Dockerfile
(1 hunks)app/models/git_commit_sha.rb
(1 hunks)spec/system/pages_spec.rb
(2 hunks)
🔇 Additional comments (3)
app/models/git_commit_sha.rb (1)
8-10
: Ensure proper handling of empty or malformed environment variables.
By relying on .presence
, this correctly treats empty strings as invalid. However, consider adding a test case for the scenario where GIT_COMMIT_SHA
is set but empty. This helps ensure robust fallback behavior to the file-based or git-based retrieval.
spec/system/pages_spec.rb (1)
46-56
: Test coverage for fallback logic looks good.
Stubbing retrieve_sha_from_git
ensures the fallback scenario is thoroughly tested. This approach is a clean way to validate that the application correctly retrieves the SHA when the environment variable and file-based methods are unavailable.
.controlplane/Dockerfile (1)
79-82
: Great addition of a build argument for the commit SHA.
Defining ARG GIT_COMMIT_SHA
and setting it to the environment variable ensures reproducible builds and easy identification of the deployed commit. Confirm that your build pipeline passes --build-arg GIT_COMMIT_SHA=$(git rev-parse HEAD)
(or similar) so the SHA is set accurately in production.
Fixes #567
Follows this approach
This change is
Summary by CodeRabbit
New Features
Tests
Infrastructure