Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

action: run check, check-default and pre-commit #32723

Merged
merged 6 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/check-default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: check-default

on:
pull_request:
v1v marked this conversation as resolved.
Show resolved Hide resolved

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
v1v marked this conversation as resolved.
Show resolved Hide resolved
v1v marked this conversation as resolved.
Show resolved Hide resolved
v1v marked this conversation as resolved.
Show resolved Hide resolved
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