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

Migrate sdformat to GitHub CI #168

Merged
merged 32 commits into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
385b1df
Remove set_status_script
j-rivero Apr 17, 2020
55ce172
New class for checkout github code
j-rivero Apr 17, 2020
6919697
Update URL to github
j-rivero Apr 17, 2020
ef1dd5d
Migrate sdformat to use github checkouts
j-rivero Apr 17, 2020
03ba936
Use short github format for repos
j-rivero Apr 17, 2020
8baad6f
Migrate gazebo_ros_pkg to checkout using class
j-rivero Apr 17, 2020
d497684
Disable pipeline job
j-rivero Apr 17, 2020
f40fa07
Fix repo name
j-rivero Apr 17, 2020
209a97f
Use GitHub PR integration in linux ci
j-rivero Apr 17, 2020
332fa6d
Use GithubPR for all Any jobs
j-rivero Apr 17, 2020
7db179e
Use github for ABI job
j-rivero Apr 17, 2020
e49eecc
Use git in ABI jobs
j-rivero Apr 17, 2020
2ff458b
Merge with default
j-rivero Apr 17, 2020
e17af8c
Use GitHub class
j-rivero Apr 17, 2020
bd7bd9f
Use GITHUB var to select ported jobs
j-rivero Apr 17, 2020
f1005a4
Run ABI checker on non master branch
j-rivero Apr 17, 2020
3536e81
Use custom names
j-rivero Apr 17, 2020
19f364f
Restore original classes
j-rivero Apr 17, 2020
db7b697
Use github PR vars
j-rivero Apr 17, 2020
34114a1
Fix for ABI check with git
j-rivero Apr 17, 2020
af5da89
Use params from github PR plugin
j-rivero Apr 17, 2020
e83ca6e
Use original vars
j-rivero Apr 17, 2020
8e3c35b
git fixes
j-rivero Apr 17, 2020
7c3774e
Use pr refspec
j-rivero Apr 17, 2020
a3458ad
Fix merge refspec
j-rivero Apr 17, 2020
52fa019
Need to work with remote forks
j-rivero Apr 17, 2020
beacd04
Use ghprbSourceBranch for source branch
j-rivero Apr 17, 2020
04d3946
Need fetch
j-rivero Apr 17, 2020
e3a9087
Use Field for global vars
j-rivero Apr 17, 2020
7329d5f
Fix typo
j-rivero Apr 17, 2020
97bc6ba
Revert changes from master to default
j-rivero Apr 17, 2020
77e13de
Add supported_ros_distros to Win/Brew calls
j-rivero Apr 17, 2020
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
3 changes: 3 additions & 0 deletions jenkins-scripts/docker/lib/boilerplate_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,7 @@ rm -fr ${WORKSPACE}/build.sh
# to kill global bash variables
echo "${MAKE_JOBS}" > "${WORKSPACE}/make_jobs"

# Use GitHub repositories (useful only in bitbucket-github migration)
export GITHUB=${GITHUB:-false}

cd ${WORKSPACE}
18 changes: 14 additions & 4 deletions jenkins-scripts/docker/lib/generic-abi-base.bash
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ echo '# BEGIN SECTION: compile and install branch: ${DEST_BRANCH}'
cp -a $WORKSPACE/${ABI_JOB_SOFTWARE_NAME} /tmp/${ABI_JOB_SOFTWARE_NAME}
chown -R root:root /tmp/${ABI_JOB_SOFTWARE_NAME}
cd /tmp/${ABI_JOB_SOFTWARE_NAME}
hg pull
hg up ${DEST_BRANCH}
if ${GITHUB}; then
git checkout origin/${DEST_BRANCH}
else
hg pull
hg up ${DEST_BRANCH}
fi
# Normal cmake routine for ${ABI_JOB_SOFTWARE_NAME}
rm -rf $WORKSPACE/build
mkdir -p $WORKSPACE/build
Expand All @@ -88,8 +92,14 @@ echo '# BEGIN SECTION: compile and install branch: ${SRC_BRANCH}'
# Reusing the same building and source directory to save bandwith and
chapulina marked this conversation as resolved.
Show resolved Hide resolved
# compilation time.
cd /tmp/${ABI_JOB_SOFTWARE_NAME}
hg pull ${SRC_REPO} -b ${SRC_BRANCH}
hg up ${SRC_BRANCH}
if ${GITHUB}; then
git remote add source_repo ${SRC_REPO}
git fetch source_repo
git checkout source_repo/${SRC_BRANCH}
else
hg pull ${SRC_REPO} -b ${SRC_BRANCH}
hg up ${SRC_BRANCH}
fi
# Normal cmake routine for ${ABI_JOB_SOFTWARE_NAME}
cd $WORKSPACE/build
cmake ${ABI_JOB_CMAKE_PARAMS} \\
Expand Down
87 changes: 87 additions & 0 deletions jenkins-scripts/dsl/_configs_/GenericAnyJobGitHub.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package _configs_

import javaposse.jobdsl.dsl.Job

/*
Implements:
- parameters: SRC_REPO, SRC_BRANCH, JOB_DESCRIPTION
- job.Description
- scm check with SRC_REPO + SRC_BRANCH
*/


class GenericAnyJobGitHub
{
static void create(Job job,
String github_repo,
ArrayList supported_ros_distros = [])
{
// setup special mail subject
GenericMail.update_field(job, 'defaultSubject',
'$PROJECT_NAME - Branch: $SRC_BRANCH (#$BUILD_NUMBER) - $BUILD_STATUS!')
GenericMail.update_field(job, 'defaultContent',
'$JOB_DESCRIPTION \n' + GenericCompilation.get_compilation_mail_content())

// Get repo name for relativeTargetDirectory
String github_repo_name = github_repo.substring(github_repo.lastIndexOf("/") + 1)

ArrayList supported_ros_branches = []
supported_ros_distros.each { ros_distro ->
if (ros_distro == Globals.get_ros2_development_distro()) {
// Latest unreleased distro points to ros2
supported_ros_branches.add("ros2")
} else if (Globals.get_ros2_suported_distros().contains(ros_distro)) {
supported_ros_branches.add(ros_distro)
} else {
// Keep the toString method to be sure that String is used and not
// GStringImp which will make the whole thing to fail.
supported_ros_branches.add("${ros_distro}-devel".toString())
}
}

job.with
{
parameters
{
stringParam('sha1', '', 'commit or refname to build')
}

scm
{
git {
remote {
github(github_repo)
refspec('+refs/pull/*:refs/remotes/origin/pr/*')
}
extensions {
relativeTargetDirectory(github_repo_name)
}

branch('${sha1}')
}
}

triggers {
githubPullRequest {
admins(['osrf-jenkins', 'j-rivero'])
useGitHubHooks()
cron('')
triggerPhrase('.*(re)?run test(s).*')
allowMembersOfWhitelistedOrgsAsAdmin()
if (supported_ros_branches) {
// Only will be triggered in supported_ros_branches
whiteListTargetBranches(supported_ros_branches)
}
permitAll(true)
extensions {
commitStatus {
context('${JOB_NAME}')
triggeredStatus('starting deployment to build.osrfoundation.org')
startedStatus('deploying to build.osrfoundation.org')
}
}
}
} // end of triggers
} // end of with
} // end of create method
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package _configs_

import javaposse.jobdsl.dsl.Job

/*
-> OSRFBrewCompilation
-> GenericAnyJob

Implements:
- compiler warning
*/
class OSRFBrewCompilationAnyGitHub
{
static void create(Job job,
String github_repo,
boolean enable_testing = true,
ArrayList supported_ros_distros = [])
j-rivero marked this conversation as resolved.
Show resolved Hide resolved
{
OSRFBrewCompilation.create(job, enable_testing)

GenericAnyJobGitHub.create(job, github_repo)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package _configs_

import javaposse.jobdsl.dsl.Job

/*
-> OSRFCIWorkFlow

Implements:
- parameters
- definition (pipeline plugin)
*/

class OSRFCIWorkFlowMultiAnyGitHub
{
static void create(Job job, String build_any_job_name)
{
OSRFCIWorkFlowMultiAnyGitHub.create(job, [build_any_job_name])
}

static String build_stage_name(String ci_job_name)
{
try
{
return ci_job_name.split("-ci-pr_any-")[1]
}
catch (java.lang.ArrayIndexOutOfBoundsException e)
{
return ci_job_name
}
}

static void create(Job job, ArrayList any_job_name_list)
{
OSRFCIWorkFlow.create(job)

String build_jobs_with_status = "";

any_job_name_list.eachWithIndex { build_any_job_name, index ->
// Handle job parallelization
String stage_name = build_stage_name(build_any_job_name)

String parallel_init = ""
if (index == 0) {
parallel_init = "def jobs = [ \n"
}
parallel_init = build_jobs_with_status + parallel_init + "'${stage_name}' : {"

String parallel_end = "}"
if (index == any_job_name_list.size() - 1) {
String end_of_map_and_call = """\
]

stage "Executing testing jobs"
parallel jobs
"""
parallel_end = parallel_end + end_of_map_and_call
} else {
// not the last element in map
parallel_end = parallel_end + ",\n"
}

build_jobs_with_status = parallel_init +
parallel_end
}

job.with
{
// TODO: share parameters with ci-py_any- jobs
parameters {
stringParam('RTOOLS_BRANCH','master','release-tools branch to send to jobs')
stringParam('SRC_REPO','','URL pointing to repository')
stringParam('SRC_BRANCH','default','Branch of SRC_REPO to test')
stringParam('JOB_DESCRIPTION','','Description of the job in course. For information proposes.')
stringParam('DEST_BRANCH','default','Branch to merge in')
}

definition
{
cps
{
// Disable sandbox until the bug/issue is resolved
// https://issues.jenkins-ci.org/browse/JENKINS-28178
sandbox(false)
script(
(build_jobs_with_status +
OSRFCIWorkFlow.script_code_end_hook()).stripIndent()
)
} // end of cps
} // end of definition
} // end of job
} // end of create
}
4 changes: 4 additions & 0 deletions jenkins-scripts/dsl/_configs_/OSRFGitHub.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class OSRFGitHub
}
}
}

parameters {
booleanParam('GITHUB', true, 'used during porting from bitbucket to github')
}
}
}
}
112 changes: 112 additions & 0 deletions jenkins-scripts/dsl/_configs_/OSRFLinuxABIGitHub.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package _configs_

import javaposse.jobdsl.dsl.Job

/*
-> OSRFLinuxBase

Implements:
- priority 300
- logrotator
- concurrent builds
- parameter: DEST_BRANCH, SRC_BRANCH
- set description
- parse log for result
- publish report in HTML
*/

class OSRFLinuxABIGitHub
{
static void create(Job job, String repo)
{
OSRFLinuxABIGitHub.create(job)
OSRFGitHub.create(job, repo, '${DEST_BRANCH}')
}

static void create(Job job)
{
OSRFLinuxBase.create(job)

GenericMail.update_field(job, 'defaultSubject',
'$PROJECT_NAME - Branches: $DEST_BRANCH, $SRC_BRANCH (#$BUILD_NUMBER) - $BUILD_STATUS!')
GenericMail.update_field(job, 'defaultContent',
'$JOB_DESCRIPTION \n' +
'destination branch: $DEST_BRANCH \n' +
'source branch: $SRC_BRANCH \n' +
'source repository: $SRC_REPO \n' +
'RTOOLS branch: $RTOOLS_BRANCH \n' +
GenericMail.get_default_content() + '\n' +
'ABI report : $BUILD_URL/API_ABI_report/\n')

job.with
{
properties {
priority 300
}

logRotator {
artifactNumToKeep(10)
}

concurrentBuild(true)

throttleConcurrentBuilds {
maxPerNode(1)
maxTotal(5)
}

parameters {
stringParam("DEST_BRANCH", null,
'Branch to use as base for the comparison')
stringParam("SRC_BRANCH", null,
'Git BRANCH (not pr refspec) to use to compare against DEST_BRANCH')
stringParam('SRC_REPO', null,
'URL pointing to repository containing SRC_BRANCH')
stringParam("JOB_DESCRIPTION", "",
'Description of the job for informational purposes.')
}

steps {
systemGroovyCommand("""\
job_description = build.buildVariableResolver.resolve("JOB_DESCRIPTION")

if (job_description == "")
{
job_description = 'destination branch: ' +
'<b>' + build.buildVariableResolver.resolve('DEST_BRANCH') + '</b><br />' +
'source branch: ' +
'<b>' + build.buildVariableResolver.resolve('SRC_BRANCH') + '</b><br />' +
'source repository: ' +
'<b>' + build.buildVariableResolver.resolve('SRC_REPO') + '</b><br />' +
'<br />' +
'RTOOLS_BRANCH: ' + build.buildVariableResolver.resolve('RTOOLS_BRANCH');
}

build.setDescription(job_description)
""".stripIndent()
)
}

publishers {
publishHtml {
report('reports/') {
reportFiles('compat_report.html')
reportName('API_ABI report')
keepAll()
allowMissing(false)
alwaysLinkToLastBuild()
}
}
}

// Added the checker result parser (UNSTABLE if not compatible)
configure { project ->
project / publishers << 'hudson.plugins.logparser.LogParserPublisher' {
unstableOnWarning true
failBuildOnError true
parsingRulesPath('/var/lib/jenkins/logparser_warn_on_abichecker_error')
}
} // end of configure
} // end of with
} // end of create
} // end of class
Loading