Skip to content
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

Add a .ruby-version file #5483

Merged
merged 1 commit into from
Aug 8, 2022
Merged

Conversation

jeffwidman
Copy link
Member

We're starting to pin the desired ruby version in multiple places:

We used to not ship the .ruby-version file, with the thought that this
is a library... but this file isn't included in the gemfile spec, so
we're not tying the hands of our users. This merely sets the default
version of Ruby that we're using for development. We will keep this in
sync with the Dockerfile, so it'll target the version of Ruby we use in
production at GitHub. But since not included in the gem, others are free
to use a different Ruby version.

@jeffwidman
Copy link
Member Author

Test failure is weird:

dependabot-common.gemspec:21:32: C: Gemspec/RequiredRubyVersion: required_ruby_version and TargetRubyVersion (2.6, which may be specified in .rubocop.yml) should be equal.

The weird part is that according to the Rubocop docs, it honors .ruby-version, so should be reporting 2.7 not 2.6... I wonder if the problem is that .ruby-version is in the top-level directory and all the rubocops are in the child directories?

I wonder if it might make more sense to switch to either:

  1. running Rubocop from the top-level directory (not sure this is even possible given that we have separate gemspecs for each ecosystem)
  2. running the github super linter... but again, may run into the problems mentioned above of needing to configure it to run w/in the ecosystem subdirs.

@jeffwidman jeffwidman mentioned this pull request Aug 4, 2022
@deivid-rodriguez
Copy link
Contributor

@jeffwidman I think the issue is that you need to make sure to copy the .ruby-version file into the CI image, like this

diff --git a/Dockerfile.ci b/Dockerfile.ci
index c094ee0e7..da8e22857 100644
--- a/Dockerfile.ci
+++ b/Dockerfile.ci
@@ -7,6 +7,7 @@ ARG CODE_DIR=/home/dependabot/dependabot-core
 WORKDIR ${CODE_DIR}
 
 COPY --chown=dependabot:dependabot .rubocop.yml ${CODE_DIR}/.rubocop.yml
+COPY --chown=dependabot:dependabot .ruby-version ${CODE_DIR}/.ruby-version
 COPY --chown=dependabot:dependabot omnibus ${CODE_DIR}/omnibus
 COPY --chown=dependabot:dependabot git_submodules ${CODE_DIR}/git_submodules
 COPY --chown=dependabot:dependabot terraform ${CODE_DIR}/terraform

@jeffwidman jeffwidman force-pushed the add-a-ruby-version-file branch from d5a155d to 82247ef Compare August 7, 2022 21:11
@jeffwidman
Copy link
Member Author

Thanks @deivid-rodriguez that worked perfectly!

We're starting to pin the desired ruby version in multiple places:
* Rubocop
* the new `ruby/setup-ruby` action that we're adding in dependabot#5433

We used to not ship the `.ruby-version` file, with the thought that this
is a library... but this file isn't included in the gemfile spec, so
we're not tying the hands of our users. This merely sets the default
version of Ruby that we're using for development. We will keep this in
sync with the version of Ruby installed in the Dockerfile, so it'll
target the version of Ruby we use in production at GitHub. But since not
included in the gem, others are free to use a different Ruby version.

Copy the `.ruby-version` file into the CI container.
@jeffwidman jeffwidman force-pushed the add-a-ruby-version-file branch from 82247ef to 373a772 Compare August 7, 2022 21:48
@jurre jurre merged commit 707f77e into dependabot:main Aug 8, 2022
@jeffwidman jeffwidman deleted the add-a-ruby-version-file branch April 25, 2023 07:04
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