mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[precommit-hook] autofix precommit check failures on CI (#132141)
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
b932dcab0b
commit
eda92d49e0
5 changed files with 35 additions and 34 deletions
|
@ -5,7 +5,7 @@ set -euo pipefail
|
|||
export DISABLE_BOOTSTRAP_VALIDATION=false
|
||||
.buildkite/scripts/bootstrap.sh
|
||||
|
||||
.buildkite/scripts/steps/checks/commit/commit.sh
|
||||
.buildkite/scripts/steps/checks/precommit_hook.sh
|
||||
.buildkite/scripts/steps/checks/bazel_packages.sh
|
||||
.buildkite/scripts/steps/checks/telemetry.sh
|
||||
.buildkite/scripts/steps/checks/ts_projects.sh
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
source .buildkite/scripts/common/util.sh
|
||||
|
||||
# Runs pre-commit hook script for the files touched in the last commit.
|
||||
# That way we can ensure a set of quick commit checks earlier as we removed
|
||||
# the pre-commit hook installation by default.
|
||||
# If files are more than 200 we will skip it and just use
|
||||
# the further ci steps that already check linting and file casing for the entire repo.
|
||||
echo --- Quick commit checks
|
||||
checks-reporter-with-killswitch "Quick commit checks" \
|
||||
"$(dirname "${0}")/commit_check_runner.sh"
|
|
@ -1,13 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
run_quick_commit_checks() {
|
||||
echo "!!!!!!!! ATTENTION !!!!!!!!
|
||||
That check is intended to provide earlier CI feedback after we remove the automatic install for the local pre-commit hook.
|
||||
If you want, you can still manually install the pre-commit hook locally by running 'node scripts/register_git_hook locally'
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
"
|
||||
|
||||
node scripts/precommit_hook.js --ref HEAD~1..HEAD --max-files 200 --verbose
|
||||
}
|
||||
|
||||
run_quick_commit_checks
|
26
.buildkite/scripts/steps/checks/precommit_hook.sh
Executable file
26
.buildkite/scripts/steps/checks/precommit_hook.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
source .buildkite/scripts/common/util.sh
|
||||
|
||||
# Runs pre-commit hook script for the files touched in the last commit.
|
||||
# That way we can ensure a set of quick commit checks earlier as we removed
|
||||
# the pre-commit hook installation by default.
|
||||
# If files are more than 200 we will skip it and just use
|
||||
# the further ci steps that already check linting and file casing for the entire repo.
|
||||
echo --- Run Precommit Hook
|
||||
|
||||
echo "!!!!!!!! ATTENTION !!!!!!!!
|
||||
That check is intended to provide earlier CI feedback after we remove the automatic install for the local pre-commit hook.
|
||||
If you want, you can still manually install the pre-commit hook locally by running 'node scripts/register_git_hook locally'
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
|
||||
node scripts/precommit_hook.js \
|
||||
--ref HEAD~1..HEAD \
|
||||
--max-files 200 \
|
||||
--verbose \
|
||||
--fix \
|
||||
--no-stage # we have to disable staging or check_for_changed_files won't see the changes
|
||||
|
||||
check_for_changed_files 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' true
|
|
@ -49,7 +49,7 @@ run(
|
|||
fix: flags.fix,
|
||||
});
|
||||
|
||||
if (flags.fix) {
|
||||
if (flags.fix && flags.stage) {
|
||||
const simpleGit = new SimpleGit(REPO_ROOT);
|
||||
await simpleGit.add(filesToLint);
|
||||
}
|
||||
|
@ -68,16 +68,18 @@ run(
|
|||
Run checks on files that are staged for commit by default
|
||||
`,
|
||||
flags: {
|
||||
boolean: ['fix'],
|
||||
boolean: ['fix', 'stage'],
|
||||
string: ['max-files', 'ref'],
|
||||
default: {
|
||||
fix: false,
|
||||
stage: true,
|
||||
},
|
||||
help: `
|
||||
--fix Execute eslint in --fix mode
|
||||
--max-files Max files number to check against. If exceeded the script will skip the execution
|
||||
--ref Run checks against any git ref files (example HEAD or <commit_sha>) instead of running against staged ones
|
||||
`,
|
||||
--fix Execute eslint in --fix mode
|
||||
--max-files Max files number to check against. If exceeded the script will skip the execution
|
||||
--ref Run checks against any git ref files (example HEAD or <commit_sha>) instead of running against staged ones
|
||||
--no-stage By default when using --fix the changes are staged, use --no-stage to disable that behavior
|
||||
`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue