Skip to content

Commit

Permalink
action: run check, check-default and pre-commit (#32723)
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v authored and chrisberkhout committed Jun 1, 2023
1 parent 1b7a59e commit 249b9f5
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 21 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/check-default.yml
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions .github/workflows/check-docs.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .github/workflows/opentelemetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ on:
- x-pack-metricbeat
- x-pack-osquerybeat
- x-pack-packetbeat
- pre-commit
- check-default
- check-docs
types: [completed]

jobs:
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 0 additions & 21 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 249b9f5

Please sign in to comment.