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

Run codecov CI #587

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft
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
81 changes: 81 additions & 0 deletions .jenkins/codecov.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env groovy
@Library('rocJenkins@pong') _
import com.amd.project.*
import com.amd.docker.*
import java.nio.file.Path;

def runCI =
{
nodeDetails, jobName->

def prj = new rocProject('rocPRIM', 'codecov')
prj.paths.build_command = './install -gc --codecoverage'
prj.timeout.compile = 600

def nodes = new dockerNodes(nodeDetails, jobName, prj)

def commonGroovy

boolean formatCheck = false

def compileCommand =
{
platform, project->

commonGroovy = load "${project.paths.project_src_prefix}/.jenkins/common.groovy"
commonGroovy.runCompileCommand(platform, project, jobName, debug=true, buildTypeDir="debug", isCodeCovOn=true)
}

def packageCommand =
{
platform, project->

commonGroovy.runPackageCommand(platform, project, buildTypeDir="debug")
}

def testCommand =
{
platform, project->

commonGroovy.runCodecovTestCommand(platform, project)
}

buildProject(prj, formatCheck, nodes.dockerArray, compileCommand, testCommand, packageCommand)
}

ci: {
String urlJobName = auxiliary.getTopJobName(env.BUILD_URL)

def propertyList = ["compute-rocm-dkms-no-npi":[pipelineTriggers([cron('0 1 * * 0')])],
"compute-rocm-dkms-no-npi-hipclang":[pipelineTriggers([cron('0 1 * * 0')])],
"rocm-docker":[]]
propertyList = auxiliary.appendPropertyList(propertyList)

def jobNameList = ["compute-rocm-dkms-no-npi-hipclang":([ubuntu22:['gfx90a'],rhel9:['gfx1101'],sles15sp1:['gfx908']])]
jobNameList = auxiliary.appendJobNameList(jobNameList, 'rocPRIM')

propertyList.each
{
jobName, property->
if (urlJobName == jobName)
properties(auxiliary.addCommonProperties(property))
}

jobNameList.each
{
jobName, nodeDetails->
if (urlJobName == jobName)
stage(jobName) {
runCI(nodeDetails, jobName)
}
}

// For url job names that are not listed by the jobNameList i.e. compute-rocm-dkms-no-npi-1901
if(!jobNameList.keySet().contains(urlJobName))
{
properties(auxiliary.addCommonProperties([pipelineTriggers([cron('0 1 * * *')])]))
stage(urlJobName) {
runCI([ubuntu22:['gfx90a']], urlJobName)
}
}
}
50 changes: 45 additions & 5 deletions .jenkins/common.groovy
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// This file is for internal AMD use.
// If you are interested in running your own Jenkins, please raise a github issue for assistance.

def runCompileCommand(platform, project, jobName, boolean debug=false)
def runCompileCommand(platform, project, jobName, boolean debug=false, String buildTypeDir="release", boolean isCodeCovOn=false)
{
project.paths.construct_build_prefix()

String buildTypeArg = debug ? '-DCMAKE_BUILD_TYPE=Debug' : '-DCMAKE_BUILD_TYPE=Release'
String buildTypeDir = debug ? 'debug' : 'release'
String codeCovArg = isCodeCovOn ? '-DBUILD_CODE_COVERAGE=ON' : ''
String cmake = platform.jenkinsLabel.contains('centos') ? 'cmake3' : 'cmake'
//Set CI node's gfx arch as target if PR, otherwise use default targets of the library
String amdgpuTargets = env.BRANCH_NAME.startsWith('PR-') ? '-DAMDGPU_TARGETS=\$gfx_arch' : ''
Expand All @@ -16,7 +16,7 @@ def runCompileCommand(platform, project, jobName, boolean debug=false)
cd ${project.paths.project_build_prefix}
mkdir -p build/${buildTypeDir} && cd build/${buildTypeDir}
${auxiliary.gfxTargetParser()}
${cmake} --toolchain=toolchain-linux.cmake ${buildTypeArg} ${amdgpuTargets} -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON ../..
${cmake} --toolchain=toolchain-linux.cmake ${buildTypeArg} ${amdgpuTargets} -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON ${codeCovArg} ../..
make -j\$(nproc)
"""

Expand Down Expand Up @@ -65,9 +65,49 @@ def runTestCommand (platform, project)
platform.runCommand(this, command)
}

def runPackageCommand(platform, project)
def runCodecovTestCommand(platform, project)
{
def packageHelper = platform.makePackage(platform.jenkinsLabel,"${project.paths.project_build_prefix}/build/release")
String dirmode = "debug"

def testCommand = """#!/usr/bin/env bash
set -x
cd ${project.paths.project_build_prefix}/build/${dirmode}
ls
cat Makefile
export LD_LIBRARY_PATH=/opt/rocm/lib/
ctest --output-on-failure
GTEST_LISTENER=NO_PASS_LINE_IN_LOG make coverage_cleanup coverage
"""

platform.runCommand(this, testCommand)

this.publishHTML([allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: false,
reportDir: "${project.paths.project_build_prefix}/build/${dirmode}/lcoverage",
reportFiles: "index.html",
reportName: "Code coverage report",
reportTitles: "Code coverage report"])

if (this.env.BRANCH_NAME ==~ /PR-\d+/)
{
def commentBody = "${this.env.BUILD_URL}../Code_20coverage_20report/"

this.writeFile(file: 'comment.py', text: this.libraryResource("com/amd/scripts/comment.py"))

this.withCredentials([this.string(credentialsId: 'ROCmMathLibrariesBot-PAT', variable: 'GH_AUTH')])
{
def commentCommand = """
python comment.py -u ROCmMathLibrariesBot -o ROCm -r ${project.paths.project_name} -n ${this.env.CHANGE_ID} -b ${commentBody}
"""
platform.runCommand(this, commentCommand)
}
}
}

def runPackageCommand(platform, project, String buildTypeDir="release")
{
def packageHelper = platform.makePackage(platform.jenkinsLabel,"${project.paths.project_build_prefix}/build/${buildTypeDir}")

platform.runCommand(this, packageHelper[0])
platform.archiveArtifacts(this, packageHelper[1])
Expand Down