Commit 5deff621 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab master

parents 18c49781 e6ecd254
......@@ -56,6 +56,7 @@ eslint-report.html
/doc/code/*
/dump.rdb
/jsconfig.json
/lefthook-local.yml
/log/*.log*
/node_modules
/nohup.out
......
......@@ -37,7 +37,8 @@ def build_message(commit, message, more_info: true)
end
def squash_mr?
gitlab_danger.ci? ? gitlab.mr_json['squash'] : false
# Locally, we assume the MR is set to be squashed so that the user only sees warnings instead of errors.
gitlab_danger.ci? ? gitlab.mr_json['squash'] : true
end
def wip_mr?
......@@ -112,7 +113,7 @@ def lint_commits(commits)
if multi_line_commit_linter && multi_line_commit_linter.failed?
warn_or_fail_commits(multi_line_commit_linter)
else
elsif gitlab_danger.ci? # We don't have access to the MR title locally
title_linter = lint_mr_title(gitlab.mr_json['title'])
if title_linter.failed?
warn_or_fail_commits(title_linter)
......
......@@ -15,25 +15,35 @@ settings automatically by default. If your editor/IDE does not automatically sup
we suggest investigating to see if a plugin exists. For instance here is the
[plugin for vim](https://github.com/editorconfig/editorconfig-vim).
## Pre-commit static analysis
## Pre-push static analysis
You should install [`overcommit`](https://github.com/sds/overcommit) to automatically check for
static analysis offenses before committing locally.
We strongly recommend installing
[Lefthook](https://github.com/Arkweid/lefthook) to automatically check for
static analysis offenses before pushing your changes.
After installing `overcommit`, run the following in your GitLab source directory:
```shell
make -C tooling/overcommit
# Make sure to uninstall Overcommit first
overcommit --uninstall
# Install lefthook
gem install lefthook && lefthook install -f
```
Then before a commit is created, `overcommit` automatically checks for RuboCop (and other checks)
offenses on every modified file.
Before you push your changes, Lefthook will then automatically run Danger checks, as well
as RuboCop, ES Lint, HAML Lint, and SCSS Lint for the changed files.
This saves you time as you don't have to wait for the same errors to be detected by CI/CD.
`overcommit` relies on a pre-commit hook to prevent commits that violate its ruleset. To override
this behavior, pass the `OVERCOMMIT_DISABLE` environment variable. For example,
`OVERCOMMIT_DISABLE=1 git rebase master` to rebase while disabling the Git hook.
Lefthook relies on a pre-push hook to prevent commits that violate its ruleset.
If you wish to override this behavior, pass the environment variable `LEFTHOOK=0`.
That is, `LEFTHOOK=0 git push`.
You can also:
- Define [local configuration](https://github.com/Arkweid/lefthook/blob/master/docs/full_guide.md#local-config).
- Skip [checks per tag on the fly](https://github.com/Arkweid/lefthook/blob/master/docs/full_guide.md#skip-some-tags-on-the-fly).
## Ruby, Rails, RSpec
......
......@@ -716,7 +716,7 @@ Sample configuration for `overcommit` is available in the
file for the [`gitlab`](https://gitlab.com/gitlab-org/gitlab) project.
To set up `overcommit` for documentation linting, see
[Pre-commit static analysis](../contributing/style_guides.md#pre-commit-static-analysis).
[Pre-commit static analysis](../contributing/style_guides.md#pre-push-static-analysis).
#### Disable Vale tests
......
pre-push:
parallel: true
commands:
danger:
run: bundle exec danger dry_run
eslint:
tags: frontend style
files: git diff --name-only $(git merge-base origin/master HEAD)..HEAD
glob: "*.{js,vue}"
run: yarn eslint --cache --max-warnings 0 --report-unused-disable-directives {files}
haml-lint:
tags: view haml style
files: git diff --name-only $(git merge-base origin/master HEAD)..HEAD
glob: "*.html.haml"
run: bundle exec haml-lint --config .haml-lint.yml {files}
scss-lint:
tags: stylesheet css style
files: git diff --name-only $(git merge-base origin/master HEAD)..HEAD
glob: "*.scss.css"
exclude: "app/assets/stylesheets/pages/emojis.scss"
run: bundle exec scss-lint --config .scss-lint.yml {files}
rubocop:
tags: backend style
files: git diff --name-only $(git merge-base origin/master HEAD)..HEAD
glob: "*.rb"
run: bundle exec rubocop --parallel --force-exclusion {files}
......@@ -168,7 +168,7 @@ module Gitlab
%r{\A(\.gitlab-ci\.yml\z|\.gitlab\/ci)} => :engineering_productivity,
%r{\A\.codeclimate\.yml\z} => :engineering_productivity,
%r{\A\.overcommit\.yml\.example\z} => :engineering_productivity,
%r{\Alefthook.yml\z} => :engineering_productivity,
%r{\A\.editorconfig\z} => :engineering_productivity,
%r{Dangerfile\z} => :engineering_productivity,
%r{\A(ee/)?(danger/|lib/gitlab/danger/)} => :engineering_productivity,
......
......@@ -278,9 +278,9 @@ RSpec.describe Gitlab::Danger::Helper do
'scripts/foo' | [:engineering_productivity]
'lib/gitlab/danger/foo' | [:engineering_productivity]
'ee/lib/gitlab/danger/foo' | [:engineering_productivity]
'.overcommit.yml.example' | [:engineering_productivity]
'lefthook.yml' | [:engineering_productivity]
'.editorconfig' | [:engineering_productivity]
'tooling/overcommit/foo' | [:engineering_productivity]
'tooling/bin/find_foss_tests' | [:engineering_productivity]
'.codeclimate.yml' | [:engineering_productivity]
'.gitlab/CODEOWNERS' | [:engineering_productivity]
......
......@@ -2,11 +2,11 @@
require 'spec_helper'
# This is temporary while https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45733 gets rolled out.
# TODO: clean this up once the MR has been merged.
# As each associated, backwards-compatible experiment gets cleaned up and removed from the EXPERIMENTS list, its key will also get removed from this list. Once the list here is empty, we can remove the backwards compatibility code altogether.
# Originally created as part of https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45733 for https://gitlab.com/gitlab-org/gitlab/-/issues/270858.
RSpec.describe Gitlab::Experimentation::EXPERIMENTS do
it 'temporarily ensures we know what experiments exist for backwards compatibility' do
known_experiments = [
expected_experiment_keys = [
:signup_flow,
:onboarding_issues,
:ci_notification_dot,
......@@ -23,7 +23,10 @@ RSpec.describe Gitlab::Experimentation::EXPERIMENTS do
:default_to_issues_board
]
expect(described_class.keys).to match(known_experiments)
backwards_compatible_experiment_keys = described_class.filter { |_, v| v[:use_backwards_compatible_subject_index] }.keys
expect(backwards_compatible_experiment_keys).not_to be_empty, "Oh, hey! Let's clean up that :use_backwards_compatible_subject_index stuff now :D"
expect(backwards_compatible_experiment_keys).to match(expected_experiment_keys)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment