Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
super-linter seems to be broken (#709)
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v authored Sep 3, 2020
1 parent eb158ec commit 1330d4e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 9 deletions.
45 changes: 43 additions & 2 deletions src/test/groovy/SuperLinterStepTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class SuperLinterStepTests extends ApmBasePipelineTest {
@Before
void setUp() throws Exception {
super.setUp()
helper.registerAllowedMethod('sh', [Map.class], { m ->
return 0
})
}

@Test
Expand Down Expand Up @@ -75,7 +78,7 @@ class SuperLinterStepTests extends ApmBasePipelineTest {
}

@Test
void test_with_installation_error() throws Exception {
void test_with_installation_error_with_not_failNever() throws Exception {
def script = loadScript(scriptName)
env.GIT_BASE_COMMIT = 'bar'
helper.registerAllowedMethod('sh', [Map.class], { m ->
Expand All @@ -84,7 +87,7 @@ class SuperLinterStepTests extends ApmBasePipelineTest {
}
})
try {
script.call()
script.call(failNever: false)
} catch(e) {
// NOOP
}
Expand All @@ -93,4 +96,42 @@ class SuperLinterStepTests extends ApmBasePipelineTest {
assertTrue(assertMethodCallContainsPattern('sh', "label=Install super-linter"))
assertJobStatusFailure()
}

@Test
void test_with_superlinter_error_and_not_failNever() throws Exception {
def script = loadScript(scriptName)
env.GIT_BASE_COMMIT = 'bar'
helper.registerAllowedMethod('sh', [Map.class], { m ->
if(m?.label?.contains('Run super-linter')){
return 1
}
})
try {
script.call(failNever: false)
} catch(e) {
// NOOP
}
printCallStack()
assertTrue(assertMethodCallContainsPattern('error', 'Super linter failed'))
assertJobStatusFailure()
}

@Test
void test_with_superlinter_error_and_failNever() throws Exception {
def script = loadScript(scriptName)
env.GIT_BASE_COMMIT = 'bar'
helper.registerAllowedMethod('sh', [Map.class], { m ->
if(m?.label?.contains('Run super-linter')){
return 1
}
})
try {
script.call(failNever: true)
} catch(e) {
// NOOP
}
printCallStack()
assertTrue(assertMethodCallOccurrences('error', 0))
assertJobStatusSuccess()
}
}
17 changes: 10 additions & 7 deletions vars/superLinter.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,19 @@ def call(Map args = [:]) {
varsEnv.each {
envFlags += " -e ${it}"
}
sh(label: 'Run super-linter', script: """
docker run ${envFlags} \
-e OUTPUT_FORMAT=tap -e OUTPUT_DETAILS=detailed -e OUTPUT_FOLDER=${output} \
-v \$(pwd):/tmp/lint \
-u \$(id -u):\$(id -g) \
${dockerImage}""")

def status = sh(label: 'Run super-linter',
script: """
docker run ${envFlags} \
-e OUTPUT_FORMAT=tap -e OUTPUT_DETAILS=detailed -e OUTPUT_FOLDER=${output} \
-v \$(pwd):/tmp/lint \
-u \$(id -u):\$(id -g) \
${dockerImage}""", returnStatus: true)
if(junitFlag) {
dir("${output}") {
tap2Junit(pattern: '*.tap', package: 'super-linter')
}
}
if (!failNever && status != 0) {
error 'Super linter failed'
}
}

0 comments on commit 1330d4e

Please sign in to comment.