From 976b66f0994b9504371c6c6f1f443a61c73b8ab5 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 23 Aug 2022 15:18:54 +0100 Subject: [PATCH] [7.17](backport #32723) action: run check, check-default and pre-commit (#32741) --- .github/workflows/check-default.yml | 29 ++++++++++++++++++++++++ .github/workflows/check-docs.yml | 35 +++++++++++++++++++++++++++++ .github/workflows/opentelemetry.yml | 3 +++ .github/workflows/pre-commit.yml | 27 ++++++++++++++++++++++ Jenkinsfile | 19 ---------------- 5 files changed, 94 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/check-default.yml create mode 100644 .github/workflows/check-docs.yml create mode 100644 .github/workflows/pre-commit.yml diff --git a/.github/workflows/check-default.yml b/.github/workflows/check-default.yml new file mode 100644 index 00000000000..e2aa374e4c9 --- /dev/null +++ b/.github/workflows/check-default.yml @@ -0,0 +1,29 @@ +name: check-default + +on: + pull_request: + push: + branches: + - main + - 7.1* + - 8.* + +permissions: + contents: read + pull-requests: read + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Fetch Go version from .go-version + run: echo "GO_VERSION=$(cat .go-version)" >> $GITHUB_ENV + - uses: actions/setup-go@v2 + with: + go-version: ${{ env.GO_VERSION }} + - name: Run check-default + run: | + export PATH=$PATH:$(go env GOPATH)/bin + go install github.com/magefile/mage@latest + make check-default diff --git a/.github/workflows/check-docs.yml b/.github/workflows/check-docs.yml new file mode 100644 index 00000000000..fb7ea0fe1c5 --- /dev/null +++ b/.github/workflows/check-docs.yml @@ -0,0 +1,35 @@ +name: check-docs + +on: + pull_request: + paths: + - '.github/workflows/check-docs.yml' + - '**/*.asciidoc' + - '**/*.md' + - 'deploy/kubernetes/*-kubernetes.yaml' + +permissions: + contents: read + pull-requests: read + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Fetch Go version from .go-version + run: echo "GO_VERSION=$(cat .go-version)" >> $GITHUB_ENV + - uses: actions/setup-go@v2 + with: + go-version: ${{ env.GO_VERSION }} + - name: Install libpcap-dev + run: sudo apt-get install -y libpcap-dev + - name: Install libsystemd-dev + run: sudo apt-get install -y libsystemd-dev + - name: Install librpm-dev + run: sudo apt-get install -y librpm-dev + - name: Run check + run: | + export PATH=$PATH:$(go env GOPATH)/bin + go install github.com/magefile/mage@latest + make check diff --git a/.github/workflows/opentelemetry.yml b/.github/workflows/opentelemetry.yml index d7e54e0a632..c12ba375fe8 100644 --- a/.github/workflows/opentelemetry.yml +++ b/.github/workflows/opentelemetry.yml @@ -16,6 +16,9 @@ on: - x-pack-metricbeat - x-pack-osquerybeat - x-pack-packetbeat + - pre-commit + - check-default + - check-docs types: [completed] jobs: diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 00000000000..a54c1447145 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,27 @@ +name: pre-commit + +on: + pull_request: + +permissions: + contents: read + pull-requests: read + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507 + with: ## let's skip to run for all the files + extra_args: --help + - id: files + uses: jitterbit/get-changed-files@b17fbb00bdc0c0f63fcf166580804b4d2cdc2a42 + - name: Configure PATH + run: echo "${GITHUB_WORKSPACE}/.ci/scripts" >> $GITHUB_PATH + - name: Precommit changes + run: | + for changed_file in ${{ steps.files.outputs.all }}; do + pre-commit run --files "${changed_file}" + done diff --git a/Jenkinsfile b/Jenkinsfile index e96e5b0f42d..745b34fbc3e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -89,9 +89,6 @@ pipeline { stageStatusCache(id: 'Lint'){ withBeatsEnv(archive: false, id: "lint") { dumpVariables() - whenTrue(env.ONLY_DOCS == 'true') { - cmd(label: "make check", script: "make check") - } whenTrue(env.ONLY_DOCS == 'false') { runLinting() } @@ -224,25 +221,9 @@ def runLinting() { mapParallelTasks["${k}"] = v } } - 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()