From 418350408b19e946a85a19e79b658c05da5b2dac Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 20 Oct 2021 09:48:07 +0100 Subject: [PATCH] [pre-commit] for linting merge-conflict, pipelines and JJBB (#28501) (#28537) (cherry picked from commit 0a2425021bfb488cf21927443bbfafc0ec450bb7) Co-authored-by: Victor Martinez --- .pre-commit-config.yaml | 12 ++++++++++++ Jenkinsfile | 16 +++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000000..af7954520b93 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,12 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - id: check-merge-conflict + +- repo: https://github.com/elastic/apm-pipeline-library.git + rev: current + hooks: + - id: check-jenkins-pipelines + files: ^(.ci/(.*\.groovy|Jenkinsfile)|Jenkinsfile)$ + - id: check-jjbb diff --git a/Jenkinsfile b/Jenkinsfile index 2b318dfbb503..692c7ac0b618 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -203,10 +203,24 @@ def runLinting() { } } mapParallelTasks['default'] = { cmd(label: 'make check-default', script: 'make check-default') } - + mapParallelTasks['pre-commit'] = runPreCommit() parallel(mapParallelTasks) } +def runPreCommit() { + return { + withNode(labels: 'ubuntu-18 && immutable', forceWorkspace: true){ + withGithubNotify(context: 'Check pre-commit', tab: 'tests') { + deleteDir() + unstashV2(name: 'source', bucket: "${JOB_GCS_BUCKET}", credentialsId: "${JOB_GCS_CREDENTIALS}") + dir("${BASE_DIR}"){ + preCommit(commit: "${GIT_BASE_COMMIT}", junit: true) + } + } + } + } +} + def runBuildAndTest(Map args = [:]) { def filterStage = args.get('filterStage', 'mandatory') deleteDir()