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

DNM: Combine ceph-pull-requests and API jobs #1657

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions ceph-pr-api/config/definitions/ceph-pr-api.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- job:
disabled: true
name: ceph-api
project-type: freestyle
defaults: global
Expand Down
7 changes: 7 additions & 0 deletions ceph-pr-combined/build/api/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
github_status_setup

# the following two methods exist in scripts/build_utils.sh
pkgs=( "github-status>0.0.3" )
install_python_packages "pkgs[@]"
GITHUB_STATUS_STATE="pending" $VENV/github-status create
7 changes: 7 additions & 0 deletions ceph-pr-combined/build/api/success
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
github_status_setup

# the following two methods exist in scripts/build_utils.sh
pkgs=( "github-status>0.0.3" )
install_python_packages "pkgs[@]"
GITHUB_STATUS_STATE="success" $VENV/github-status create
14 changes: 14 additions & 0 deletions ceph-pr-combined/build/failure
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
github_status_setup

# the following two methods exist in scripts/build_utils.sh
pkgs=( "github-status>0.0.3" )
install_python_packages "pkgs[@]"

# The end of the build/make-check/build writes this sentinel file if `make check` passes.
if [[ -f "$WORKSPACE/.makecheckpassed" ]]; then
GITHUB_STATUS_CONTEXT="ceph PR - API tests"
else
GITHUB_STATUS_CONTEXT="ceph PR - make check"
fi
GITHUB_STATUS_STATE="failure" $VENV/github-status create
18 changes: 18 additions & 0 deletions ceph-pr-combined/build/make-check/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
github_status_setup

# the following two methods exist in scripts/build_utils.sh
pkgs=( "github-status>0.0.3" )
install_python_packages "pkgs[@]"
GITHUB_STATUS_STATE="pending" $VENV/github-status create

export NPROC=$(nproc)
export WITH_SEASTAR=true
timeout 3h ./run-make-check.sh
sleep 5
ps -ef | grep -v jnlp | grep ceph || true

# This is so ugly but in order for github-status to know if `make check` or API tests failed in the postbuildscript, the ceph-pr-combined/build/failure script can check for this sentinel file.
touch $WORKSPACE/.makecheckpassed

GITHUB_STATUS_STATE="success" $VENV/github-status create
19 changes: 19 additions & 0 deletions ceph-pr-combined/build/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -ex

# set up variables needed for
# githubstatus to report back to the github PR
# if this project was started manually
github_status_setup

# the following two methods exist in scripts/build_utils.sh
pkgs=( "github-status>0.0.3" )
install_python_packages "pkgs[@]"

# The github-status project checks if a job was triggered by github-pull-request-builder and will not updated PR statuses if it was.
# This is because github-pull-request-builder already updates PR statuses. However, we can't set stages in the status message.
# So I'm unsetting the ghprb vars to trick github-status into running.
# https://github.com/alfredodeza/github-status/blob/master/github_status/util.py
for var in ghprbActualCommit ghprbTriggerAuthor ghprbTargetBranch ghprbTriggerAuthorLogin ghprbCredentialsId ghprbGhRepository; do
unset $var
done
135 changes: 135 additions & 0 deletions ceph-pr-combined/config/definitions/ceph-pr-combined.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
- job:
name: ceph-pr-combined
description: 'make check and ceph API tests combined'
project-type: freestyle
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this would imply much change to everything else, but we might keep the Jenkins Job Builder YAML syntax while introducing project-type: pipeline...

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, I'm sure in the future we can streamline this job by making pipeline. The two troubles I had with that were

  1. Ensuring all steps run on the same machine
  2. Having two separate "checks" in GitHub and having them get updated accordingly

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

defaults: global
concurrent: true
node: huge && bionic && x86_64 && !xenial && !trusty
display-name: 'ceph PRs: make check and API tests'
quiet-period: 5
block-downstream: false
block-upstream: false
retry-count: 3
properties:
- build-discarder:
days-to-keep: 15
num-to-keep: 300
artifact-days-to-keep: -1
artifact-num-to-keep: -1
- github:
url: https://github.com/ceph/ceph/
- rebuild:
auto-rebuild: true
- inject:
properties-content: |
TERM=xterm

parameters:
- string:
name: ghprbPullId
description: "the GitHub pull id, like '72' in 'ceph/pull/72'"

triggers:
- github-pull-request:
cancel-builds-on-update: true
allow-whitelist-orgs-as-admins: true
org-list:
- ceph
white-list-target-branches:
- master
- octopus
- nautilus
trigger-phrase: '^jenkins test make check|^jenkins test pr.*|^jenkins retest.*|^jenkins test api'
skip-build-phrase: '^jenkins do not test.*'
only-trigger-phrase: false
github-hooks: true
permit-all: true
auto-close-on-fail: false
# The option below requires jenkins-job-builder>=3.5.0
no-commit-status: true
# I had hoped to get these working by running 'make check' and the API tests in the same job
# and somehow changing {stage} throughout the job but that doesn't appear to be possible.
# So I'm using github.com/alfredodeza/github-status
# status-context: "ceph PR: {stage}"
# started-status: "ceph PR: {stage} running"
# success-status: "ceph PR: {stage} succeeded"
# failure-status: "ceph PR: {stage} failed"

scm:
- git:
url: https://github.com/ceph/ceph.git
branches:
- ${sha1}
refspec: +refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*
browser: auto
timeout: 20
skip-tag: true
shallow-clone: true
wipe-workspace: true

## TODO: (maybe) I'm sure there's a cleaner/prettier way to do this. Maybe doing an actual Jenkins pipeline.
Copy link
Member

@epuertat epuertat Sep 15, 2020

Choose a reason for hiding this comment

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

I think this is a great improvement in terms of resource usage, and Jenkins pipelines will definitely improve also the reporting of the different stages. If you need any help for a next PR, I'll gladly volunteer for helping bring pipelines into Ceph.

builders:
- inject:
properties-content: |
GITHUB_REPOSITORY="ceph/ceph"
GITHUB_STATUS_CONTEXT="ceph PR - make check"
GITHUB_STATUS_STARTED="running"
GITHUB_STATUS_SUCCESS="OK"
GITHUB_STATUS_FAILURE="failed"
GITHUB_STATUS_ERROR="completed with errors"
GITHUB_SHA=${ghprbActualCommit}
- shell:
!include-raw:
- ../../../scripts/build_utils.sh
- ../../build/setup
- ../../build/make-check/build
- inject:
properties-content: |
GITHUB_REPOSITORY="ceph/ceph"
GITHUB_STATUS_CONTEXT="ceph PR - API tests"
GITHUB_STATUS_STARTED="running"
GITHUB_STATUS_SUCCESS="OK"
GITHUB_STATUS_FAILURE="failed"
GITHUB_STATUS_ERROR="completed with errors"
GITHUB_SHA=${ghprbActualCommit}
- shell:
!include-raw:
- ../../../scripts/build_utils.sh
- ../../build/setup
- ../../build/api/start
- ../../../scripts/dashboard/install-backend-api-test-deps.sh
- shell: "cd src/pybind/mgr/dashboard; timeout 7200 ./run-backend-api-tests.sh"
- shell:
!include-raw:
- ../../../scripts/build_utils.sh
- ../../build/setup
- ../../build/api/success

publishers:
- postbuildscript:
builders:
- role: SLAVE
build-on:
- FAILURE
- ABORTED
build-steps:
- inject:
properties-content: |
GITHUB_REPOSITORY="ceph/ceph"
GITHUB_STATUS_STARTED="running"
GITHUB_STATUS_SUCCESS="OK"
GITHUB_STATUS_FAILURE="failed"
GITHUB_STATUS_ERROR="completed with errors"
GITHUB_SHA=${ghprbActualCommit}
- shell:
!include-raw:
- ../../../scripts/build_utils.sh
- ../../build/setup
- ../../build/failure

wrappers:
- ansicolor
- credentials-binding:
- text:
credential-id: 8dff73ff-506c-4397-969d-023f15aedea9
variable: GITHUB_OAUTH_TOKEN
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- job:
disabled: true
name: ceph-pull-requests
project-type: freestyle
defaults: global
Expand Down