From fe17524e544a3853f435e63a605db3d9435e3a4c Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 17 Aug 2022 12:09:28 +0100 Subject: [PATCH 1/6] action: run check, check-default and pre-commit --- .github/workflows/check-default.yml | 21 +++++++++++++++++++++ .github/workflows/check-docs.yml | 26 ++++++++++++++++++++++++++ .github/workflows/opentelemetry.yml | 3 +++ .github/workflows/pre-commit.yml | 27 +++++++++++++++++++++++++++ Jenkinsfile | 21 --------------------- 5 files changed, 77 insertions(+), 21 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..1ec27fab1e2 --- /dev/null +++ b/.github/workflows/check-default.yml @@ -0,0 +1,21 @@ +name: check-default + +on: + pull_request: + +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: make check-default diff --git a/.github/workflows/check-docs.yml b/.github/workflows/check-docs.yml new file mode 100644 index 00000000000..6765766f74f --- /dev/null +++ b/.github/workflows/check-docs.yml @@ -0,0 +1,26 @@ +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: Run check + run: 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 1a89245c9b9..1df4d870814 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -89,9 +89,6 @@ pipeline { stageStatusCache(id: 'Checks'){ withBeatsEnv(archive: false, id: "checks") { dumpVariables() - whenTrue(env.ONLY_DOCS == 'true') { - cmd(label: "make check", script: "make check") - } whenTrue(env.ONLY_DOCS == 'false') { runChecks() } @@ -224,27 +221,9 @@ def runChecks() { 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() From 4063cebddb3d55b935c1124e6f5614c3c7b80c42 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 17 Aug 2022 15:27:59 +0100 Subject: [PATCH 2/6] use mage --- .github/workflows/check-default.yml | 5 ++++- .github/workflows/check-docs.yml | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-default.yml b/.github/workflows/check-default.yml index 1ec27fab1e2..5b09e29ff29 100644 --- a/.github/workflows/check-default.yml +++ b/.github/workflows/check-default.yml @@ -18,4 +18,7 @@ jobs: with: go-version: ${{ env.GO_VERSION }} - name: Run check-default - run: make 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 index 6765766f74f..e37fbcdbb0c 100644 --- a/.github/workflows/check-docs.yml +++ b/.github/workflows/check-docs.yml @@ -23,4 +23,7 @@ jobs: with: go-version: ${{ env.GO_VERSION }} - name: Run check - run: make check + run: | + export PATH=$PATH:$(go env GOPATH)/bin + go install github.com/magefile/mage@latest + make check From 402937a08ab2c5af89fcd0896f48630f8e91fc40 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 17 Aug 2022 16:23:28 +0100 Subject: [PATCH 3/6] Update .github/workflows/check-docs.yml --- .github/workflows/check-docs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/check-docs.yml b/.github/workflows/check-docs.yml index e37fbcdbb0c..d4243c8be23 100644 --- a/.github/workflows/check-docs.yml +++ b/.github/workflows/check-docs.yml @@ -22,6 +22,8 @@ jobs: - uses: actions/setup-go@v2 with: go-version: ${{ env.GO_VERSION }} + - name: Install libpcap-dev + run: sudo apt-get install -y libpcap-dev - name: Run check run: | export PATH=$PATH:$(go env GOPATH)/bin From f49b5567c86a62ac3916b92fbd12b3ee3ddb4c19 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 17 Aug 2022 17:35:49 +0100 Subject: [PATCH 4/6] Update .github/workflows/check-docs.yml --- .github/workflows/check-docs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/check-docs.yml b/.github/workflows/check-docs.yml index d4243c8be23..2ebe6631f50 100644 --- a/.github/workflows/check-docs.yml +++ b/.github/workflows/check-docs.yml @@ -24,6 +24,8 @@ jobs: 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: Run check run: | export PATH=$PATH:$(go env GOPATH)/bin From 0ea617f186e49ae52385ecda954c339f2adc22e5 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Thu, 18 Aug 2022 09:46:43 +0100 Subject: [PATCH 5/6] Update .github/workflows/check-docs.yml --- .github/workflows/check-docs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/check-docs.yml b/.github/workflows/check-docs.yml index 2ebe6631f50..fb7ea0fe1c5 100644 --- a/.github/workflows/check-docs.yml +++ b/.github/workflows/check-docs.yml @@ -26,6 +26,8 @@ jobs: 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 From 1b61c562e54d1dcf58c4acde3be3a6d6fdd59bc2 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Thu, 18 Aug 2022 12:05:23 +0100 Subject: [PATCH 6/6] Update .github/workflows/check-default.yml --- .github/workflows/check-default.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/check-default.yml b/.github/workflows/check-default.yml index 5b09e29ff29..e2aa374e4c9 100644 --- a/.github/workflows/check-default.yml +++ b/.github/workflows/check-default.yml @@ -2,6 +2,11 @@ name: check-default on: pull_request: + push: + branches: + - main + - 7.1* + - 8.* permissions: contents: read