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

github-action: support check/lint/pre-commit #38175

Merged
merged 13 commits into from
Jun 4, 2024
29 changes: 29 additions & 0 deletions .github/workflows/check-deploy-kubernetes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: check-deploy-kubernetes

on:
pull_request:
paths:
- "deploy/kubernetes/.*"
- "libbeat/docs/version.asciidoc"
- ".github/workflows/check-deploy-kubernetes.yml"
push:
branches:
- main
- 7.1*
- 8.*

permissions:
contents: read

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: .go-version
- name: Run deploy/kubernetes all
run: make -C deploy/kubernetes all
- name: Run check-no-changes
run: make check-no-changes
19 changes: 19 additions & 0 deletions .github/workflows/pre-commit.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are moving to BK, I would like to ask if we can split this PR into two smaller ones, one containing only the changes to the .pre-commit-config.yaml and then a follow-up to either try adding it to BK or, if that fails then the GH workflow.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: pre-commit

on:
# TODO: skip if doc changes only (.*\\.(asciidoc|md)|deploy/kubernetes/.*-kubernetes\\.yaml)
v1v marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
push:
branches:
- main
- 7.1*
- 8.*

permissions:
contents: read

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: elastic/apm-pipeline-library/.github/actions/pre-commit@current
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,3 @@ repos:
rev: v4.4.0
hooks:
- id: check-merge-conflict

- repo: https://github.com/elastic/apm-pipeline-library.git
Comment on lines -6 to -7
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to support this

rev: v1.1.397
hooks:
- id: check-jenkins-pipelines
files: ^(.ci/(.*\.groovy|Jenkinsfile)|Jenkinsfile)$
- id: check-jjbb
45 changes: 0 additions & 45 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,6 @@ pipeline {
}
}
}
stage('Checks'){
options { skipDefaultCheckout() }
environment {
GOFLAGS = '-mod=readonly'
}
steps {
withGithubNotify(context: "Checks") {
stageStatusCache(id: 'Checks'){
// test the ./dev-tools/run_with_go_ver used by the Unified Release process
dir("${BASE_DIR}") {
sh "HOME=${WORKSPACE} GO_VERSION=${GO_VERSION} ./dev-tools/run_with_go_ver make test-mage"
}
withBeatsEnv(archive: false, id: "checks") {
dumpVariables()
whenTrue(env.ONLY_DOCS == 'false') {
runChecks()
cmacknz marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
}
}
}
stage('Build&Test') {
options { skipDefaultCheckout() }
when {
Expand Down Expand Up @@ -218,29 +196,6 @@ def isGitHubIssueEnabled() {
return isBranch() && currentBuild.currentResult != "SUCCESS" && currentBuild.currentResult != "ABORTED"
}

def runChecks() {
def mapParallelTasks = [:]
def content = readYaml(file: 'Jenkinsfile.yml')
content['projects'].each { projectName ->
generateStages(project: projectName, changeset: content['changeset'], filterStage: 'checks').each { k,v ->
mapParallelTasks["${k}"] = v
}
}
// Run pre-commit within the current node and in Jenkins
// hence there is no need to use docker login in the GitHub actions
// some docker images are hosted in an internal docker registry.
mapParallelTasks['pre-commit'] = runPreCommit()
parallel(mapParallelTasks)
}

def runPreCommit() {
return {
withGithubNotify(context: 'Check pre-commit', tab: 'tests') {
preCommit(commit: "${GIT_BASE_COMMIT}", junit: true)
}
}
}

def runBuildAndTest(Map args = [:]) {
def filterStage = args.get('filterStage', 'mandatory')
deleteDir()
Expand Down
5 changes: 0 additions & 5 deletions deploy/kubernetes/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ when:
tags: true ## for all the tags
platform: "immutable && ubuntu-22" ## default label for all the stages
stages:
checks:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason these checks were not migrated in #32723

make: |
make -C deploy/kubernetes all;
make check-no-changes;
stage: checks
k8sTest:
k8sTest: "v1.29.0,v1.28.0,v1.27.3,v1.26.6"
stage: mandatory
Loading