Skip to content

remove Dockerfile.ci since it is redundant#6424

Merged
jakecoffman merged 7 commits intomainfrom
jakecoffman/remove-dockerfile-ci
Jan 13, 2023
Merged

remove Dockerfile.ci since it is redundant#6424
jakecoffman merged 7 commits intomainfrom
jakecoffman/remove-dockerfile-ci

Conversation

@jakecoffman
Copy link
Copy Markdown
Member

Second attempt at #6418 now with CI running!

@jakecoffman
Copy link
Copy Markdown
Member Author

I can reproduce the lint failures locally. The filesystem looks correct, .rubocop.yml looks right, really weird! I'll keep digging at this.

deivid-rodriguez and others added 2 commits January 12, 2023 22:58
In the `Dockerfile.updater`, the layout of rubocop configurations is
the following:

```
~/.rubocop.yml
~/updater/.rubocop.yml
```

Note that this slightly differs from the setup of other "components" in
the `Dockerfile.ci`. For example:

```
~/dependabot-core/.rubocop.yml
~/dependabot-core/bundler/.rubocop.yml
```

This subtle difference makes running the `script/lint` script in the
updater's CI fail, so we had to workaround that by passing explicit
folders to RuboCop (`docker_bundle_exec rubocop lib/ spec/`)

The reason is that in the updater CI, exclusions in the main RuboCop
config are not correctly interpreted, because they are resolved using
the current directory as a base, not the directory of the configuration
file itself.

So the following exclusion

```yaml
---
AllCops:
  DisplayCopNames: true
  Exclude:
  - "*/vendor/**/*"
```

is interpreted as `~/updater/*/vendor/**/*`, so the stuff installed at
`~/updater/vendor/**/*` is not properly ignored.

The reason for this is that a `~/.rubocop.yml` configuration (located at
the HOME folder) has special behavior with respect to exclusions.
Normally, this file is shared as a base configuration to be shared among
all your applications, so the special behavior of making exclude
patterns be based on the PWD instead of on the path to the configuration
itself makes sense to me. BUT, it breaks our particular case.

For the curious, this is where RuboCop special cases this:

https://github.com/rubocop/rubocop/blob/a643eaaa00dd65ba5aacff98b027e5b5a40c1561/lib/rubocop/config.rb#L211-L224

The solution is to move the common configuration to live in the omnibus
folder instead. This way, this special behavior does not affect us.

There were other alternatives like:

* Keep the current workaround, but RuboCop also behaves specially when
  given explicit folders, so I think better to normalize things to avoid
  surprises.

* Relax the current Exclude patterns to catch everything. That could
  work, but we leave the `~/.rubocop.yml` file in place, but I believe
  the special behavior of this file will be likely to bite us again.
@deivid-rodriguez
Copy link
Copy Markdown
Contributor

Have a look at #5609 @jakecoffman!

@deivid-rodriguez
Copy link
Copy Markdown
Contributor

I think our approach is good to fix lint issues, but according to CI we still may need to also restore this bit from the Dockerfile.ci?

RUN git config --global user.name dependabot-ci \
  && git config --global user.email no-reply@github.com

I guess we should move it to the specific specs that need it.

@jakecoffman
Copy link
Copy Markdown
Member Author

I'm going to briefly look into why it needs the name and email set in the tests but not the updates.

@jakecoffman
Copy link
Copy Markdown
Member Author

Ah we have git commit in the test setup itself:

Dependabot::SharedHelpers.run_shell_command("git commit -m init")

There's also at least one place in production code where we use git commit:

SharedHelpers.with_git_configured(credentials: []) do
`git config --global user.email "no-reply@github.com"`
`git config --global user.name "Dependabot"`
`git init .`
`git add .`
`git commit -m'fake repo_contents_path'`
end

It sets name and email right before it, so I don't think it's unreasonable to place it in the tests where needed too.

@jakecoffman jakecoffman force-pushed the jakecoffman/remove-dockerfile-ci branch 2 times, most recently from eae0c0c to c745301 Compare January 13, 2023 14:42
@jakecoffman jakecoffman changed the base branch from main to deivid-rodriguez/fix-rubocop-excludes-not-respected January 13, 2023 14:42
@jakecoffman jakecoffman marked this pull request as ready for review January 13, 2023 15:29
@jakecoffman jakecoffman requested a review from a team as a code owner January 13, 2023 15:29
@deivid-rodriguez
Copy link
Copy Markdown
Contributor

Looks great, all that'd be still needed would be to delete the file to give some meaning to the PR title 😆.

May I merge #5609 and then you can rebase this and wrap this up?

@jakecoffman
Copy link
Copy Markdown
Member Author

@deivid-rodriguez yep, thanks for the help getting this sorted!

Base automatically changed from deivid-rodriguez/fix-rubocop-excludes-not-respected to main January 13, 2023 16:19
@deivid-rodriguez
Copy link
Copy Markdown
Contributor

No, thanks to you, really excited about the work you and @pavera are doing!

@jakecoffman jakecoffman enabled auto-merge (squash) January 13, 2023 16:57
@jakecoffman jakecoffman merged commit 40b4020 into main Jan 13, 2023
@jakecoffman jakecoffman deleted the jakecoffman/remove-dockerfile-ci branch January 13, 2023 17:54
alcere pushed a commit that referenced this pull request Feb 20, 2023
Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
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