Skip to content

Commit

Permalink
Publish linter warnings as Github PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Nic Cope <negz@rk0n.org>
  • Loading branch information
negz committed Mar 7, 2019
1 parent 8a7a8ed commit bb4a6d3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
27 changes: 27 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pipeline {

environment {
RUNNING_IN_CI = 'true'
REPOSITORY_NAME = "${env.GIT_URL.tokenize('/')[3].split('\\.')[0]}"
REPOSITORY_OWNER = "${env.GIT_URL.tokenize('/')[2]}"
DOCKER = credentials('dockerhub-upboundci')
AWS = credentials('aws-upbound-bot')
GITHUB_UPBOUND_BOT = credentials('github-upbound-jenkins')
Expand Down Expand Up @@ -47,6 +49,31 @@ pipeline {
sh './build/run make vendor.check'
sh './build/run make -j\$(nproc) build.all'
}
post {
always {
archiveArtifacts "_output/lint/**/*"
ViolationsToGitHub([
gitHubUrl: env.GIT_URL,
repositoryName: env.REPOSITORY_NAME,
repositoryOwner: env.REPOSITORY_OWNER,
pullRequestId: env.CHANGE_ID,
oAuth2Token: env.GITHUB_UPBOUND_BOT_PSW,

createCommentWithAllSingleFileComments: false,
createSingleFileComments: true,
keepOldComments: false,
commentOnlyChangedContent: true,
commentTemplate: readFile('hack/linter-violation.tmpl'),

violationConfigs: [[
reporter: 'make lint',
parser: 'CHECKSTYLE',
// This is a regex run against the absolute path of the file.
pattern: '.*/_output/lint/.+/checkstyle\\.xml\$',
]]
])
}
}
}

stage('Unit Tests') {
Expand Down
2 changes: 1 addition & 1 deletion build
3 changes: 3 additions & 0 deletions hack/linter-violation.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
`{{violation.rule}}`: {{violation.message}}

Refer to Crossplane's [coding style documentation](CONTRIBUTING.md#coding-style-and-linting) for more information.

0 comments on commit bb4a6d3

Please sign in to comment.