From 8f5bc4b77ad847fd90b0ae9d6faa681a6b1dddd9 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 30 Nov 2022 13:01:59 +0000 Subject: [PATCH 1/8] actions: use github actions for the linting/UTs --- .ci/Jenkinsfile | 102 ---------------------------- .ci/jobs/defaults.yml | 59 ---------------- .ci/jobs/ecs-logging-python-mbp.yml | 5 -- .github/workflows/test.yml | 47 +++++++++++++ README.md | 2 +- 5 files changed, 48 insertions(+), 167 deletions(-) delete mode 100644 .ci/Jenkinsfile delete mode 100644 .ci/jobs/defaults.yml delete mode 100644 .ci/jobs/ecs-logging-python-mbp.yml create mode 100644 .github/workflows/test.yml diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile deleted file mode 100644 index 166c030..0000000 --- a/.ci/Jenkinsfile +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env groovy - -@Library('apm@current') _ - -pipeline { - agent { label 'linux && immutable' } - environment { - REPO = 'ecs-logging-python' - BASE_DIR = "src/go.elastic.co/apm/${env.REPO}" - NOTIFY_TO = credentials('notify-to') - } - options { - timeout(time: 1, unit: 'HOURS') - buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20', daysToKeepStr: '30')) - timestamps() - ansiColor('xterm') - disableResume() - durabilityHint('PERFORMANCE_OPTIMIZED') - rateLimitBuilds(throttle: [count: 60, durationName: 'hour', userBoost: true]) - quietPeriod(10) - } - triggers { - issueCommentTrigger("${obltGitHubComments()}") - // Only main branch will run on a timer basis - cron(env.BRANCH_NAME == 'main' ? '@daily' : '') - } - stages { - stage('Checkout') { - options { skipDefaultCheckout() } - steps { - pipelineManager([ cancelPreviousRunningBuilds: [ when: 'PR' ] ]) - deleteDir() - gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true) - stash allowEmpty: true, name: 'source', useDefaultExcludes: false - } - } - stage('Lint') { - options { skipDefaultCheckout() } - steps { - withGithubNotify(context: 'Lint') { - deleteDir() - unstash 'source' - dir("${BASE_DIR}"){ - preCommit(commit: "${GIT_BASE_COMMIT}", junit: true) - } - python(version: '3.7') { - sh('.ci/scripts/lint.sh') - } - } - } - } - stage('Test') { - matrix { - agent { label 'linux && immutable' } - axes { - axis { - name 'VERSION' - values '3.6', '3.7', '3.8', '3.9', '3.10' - } - } - stages { - stage('Test') { - options { skipDefaultCheckout() } - steps { - withGithubNotify(context: "Test ${VERSION}") { - deleteDir() - unstash 'source' - python(version: VERSION) { - sh(".ci/scripts/test.sh ${VERSION}") - } - } - } - post { - always { - junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/junit*.xml") - } - } - } - } - } - } - } - post { - cleanup { - notifyBuildResult() - } - } -} - -def python(Map v = [:], body) { - def dockerImage = "python:${v.version}" - // If dockerhub got issues then let's retry twice - retry(2) { - sleep 5 - sh "docker pull ${dockerImage}" - } - docker.image(dockerImage).inside("-e HOME=${env.WORKSPACE}"){ - dir("${BASE_DIR}"){ - body() - } - } -} diff --git a/.ci/jobs/defaults.yml b/.ci/jobs/defaults.yml deleted file mode 100644 index 97dba5c..0000000 --- a/.ci/jobs/defaults.yml +++ /dev/null @@ -1,59 +0,0 @@ ---- - -##### GLOBAL METADATA - -- meta: - cluster: apm-ci - -##### JOB DEFAULTS - -- job: - view: APM-CI - project-type: multibranch - logrotate: - daysToKeep: 30 - numToKeep: 100 - number-to-keep: '5' - days-to-keep: '1' - concurrent: true - node: linux - script-path: .ci/Jenkinsfile - scm: - - github: - branch-discovery: no-pr - discover-pr-forks-strategy: merge-current - discover-pr-forks-trust: permission - discover-pr-origin: merge-current - discover-tags: true - repo: ecs-logging-python - repo-owner: elastic - credentials-id: 2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken - ssh-checkout: - credentials: f6c7695a-671e-4f4f-a331-acdce44ff9ba - build-strategies: - - tags: - ignore-tags-older-than: -1 - ignore-tags-newer-than: -1 - - regular-branches: true - - change-request: - ignore-target-only-changes: false - clean: - after: true - before: true - prune: true - shallow-clone: true - depth: 3 - do-not-fetch-tags: true - submodule: - disable: false - recursive: true - parent-credentials: true - timeout: 100 - timeout: '15' - use-author: true - wipe-workspace: 'True' - periodic-folder-trigger: 1w - prune-dead-branches: true - publishers: - - email: - recipients: infra-root+build@elastic.co diff --git a/.ci/jobs/ecs-logging-python-mbp.yml b/.ci/jobs/ecs-logging-python-mbp.yml deleted file mode 100644 index 7165351..0000000 --- a/.ci/jobs/ecs-logging-python-mbp.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- job: - name: apm-agent-python/ecs-logging-python-mbp - display-name: ecs-logging-python - description: Logging formatters for the Elastic Common Schema (ECS) in Python diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..5624f0d --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,47 @@ +name: test + +on: + # Run daily at midnight + schedule: + - cron: "0 0 * * *" + push: + branches: [ "main" ] + paths-ignore: [ '*.md', '*.asciidoc' ] + pull_request: + branches: [ "main" ] + paths-ignore: [ '*.md', '*.asciidoc' ] + +permissions: + contents: read + +jobs: + pre-commit: + if: github.event_name != 'schedule' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - run: pre-commit/action@v3.0.0 + + lint: + if: github.event_name != 'schedule' + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - run: .ci/scripts/lint.sh + + test: + if: github.event_name == 'schedule' + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + matrix: + python: [ '3.6', '3.7', '3.8', '3.9', '3.10' ] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python }} + - run: .ci/scripts/test.sh ${{ matrix.python }} diff --git a/README.md b/README.md index a53e02c..e7217e4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ecs-logging-python -[![Build Status](https://apm-ci.elastic.co/job/apm-agent-python/job/ecs-logging-python-mbp/job/main/badge/icon)](https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-python%2Fecs-logging-python-mbp/branches) +[![Build Status](https://github.com/elastic/ecs-logging-python/actions/workflows/test.yml/badge.svg)](https://github.com/elastic/ecs-logging-pythonactions/workflows/test.yml) [![PyPI](https://img.shields.io/pypi/v/ecs-logging)](https://pypi.org/project/ecs-logging) [![Versions Supported](https://img.shields.io/pypi/pyversions/ecs-logging)](https://pypi.org/project/ecs-logging) From c9323a0651bee5c33218defce60b7aab1f94a27d Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 30 Nov 2022 13:04:46 +0000 Subject: [PATCH 2/8] fix ident --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5624f0d..d7aea11 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: - uses: actions/setup-python@v3 - run: .ci/scripts/lint.sh - test: + test: if: github.event_name == 'schedule' runs-on: ubuntu-latest timeout-minutes: 10 From 53bdceb158e6396927035a5803ea641979a48bca Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 30 Nov 2022 13:08:45 +0000 Subject: [PATCH 3/8] fix some minor things when to run the job use pre-commit lib --- .github/workflows/test.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d7aea11..675970e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,13 +15,13 @@ permissions: contents: read jobs: + pre-commit: if: github.event_name != 'schedule' + name: Run pre-commit runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 - - run: pre-commit/action@v3.0.0 + - uses: elastic/apm-pipeline-library/.github/actions/pre-commit@current lint: if: github.event_name != 'schedule' @@ -33,7 +33,6 @@ jobs: - run: .ci/scripts/lint.sh test: - if: github.event_name == 'schedule' runs-on: ubuntu-latest timeout-minutes: 10 strategy: From fa6a43db92b6725754b4f86285949a025cb01a1f Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 30 Nov 2022 13:11:19 +0000 Subject: [PATCH 4/8] fix version for linting and avoid fail fast --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 675970e..215327f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,6 +30,8 @@ jobs: steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v3 + with: + python-version: '3.7' - run: .ci/scripts/lint.sh test: @@ -37,7 +39,8 @@ jobs: timeout-minutes: 10 strategy: matrix: - python: [ '3.6', '3.7', '3.8', '3.9', '3.10' ] + python: [ '3.7', '3.8', '3.9', '3.10' ] + fail-fast: false steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v3 From 095ce842a8ca8d91b1f19ced6af29164ab97b061 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 30 Nov 2022 13:12:27 +0000 Subject: [PATCH 5/8] fix pre-commit --- .pre-commit-config.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 93cb869..5f0832a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,12 +5,10 @@ repos: - id: check-case-conflict - id: check-executables-have-shebangs - id: check-merge-conflict - - repo: git@github.com:elastic/apm-pipeline-library + - repo: https://github.com/elastic/apm-pipeline-library rev: current hooks: - id: check-bash-syntax - - id: check-jenkins-pipelines - - id: check-jjbb - repo: https://github.com/pre-commit/mirrors-mypy rev: v0.910 hooks: From 08a8ba9877c382c295d017ae660670435662bf51 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 30 Nov 2022 13:13:03 +0000 Subject: [PATCH 6/8] support python-3.11 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 215327f..ee23238 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,7 +39,7 @@ jobs: timeout-minutes: 10 strategy: matrix: - python: [ '3.7', '3.8', '3.9', '3.10' ] + python: [ '3.7', '3.8', '3.9', '3.10', '3.11' ] fail-fast: false steps: - uses: actions/checkout@v3 From 8b4bc35b03c0cf79ad32d3497f63e8bcdc42a8ca Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 30 Nov 2022 13:14:23 +0000 Subject: [PATCH 7/8] Revert "support python-3.11" This reverts commit 08a8ba9877c382c295d017ae660670435662bf51. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ee23238..215327f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,7 +39,7 @@ jobs: timeout-minutes: 10 strategy: matrix: - python: [ '3.7', '3.8', '3.9', '3.10', '3.11' ] + python: [ '3.7', '3.8', '3.9', '3.10' ] fail-fast: false steps: - uses: actions/checkout@v3 From ee0330a6360e45dd06d56474b25de0079feacef0 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 16 Jan 2023 08:46:36 +0000 Subject: [PATCH 8/8] Update .github/workflows/test.yml Co-authored-by: Adrien Mannocci --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 215327f..8244824 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,7 +43,7 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} - run: .ci/scripts/test.sh ${{ matrix.python }}