pa11y: extraction des variables par défaut liées au MSE

This commit is contained in:
wpetit 2022-11-21 12:19:14 -06:00
parent 67b6e21093
commit 2c514cf61b
2 changed files with 17 additions and 17 deletions

View File

@ -10,7 +10,7 @@ cd reports
export PUPPETEER_EXECUTABLE_PATH=$(which chromium-browser) export PUPPETEER_EXECUTABLE_PATH=$(which chromium-browser)
export PA11Y_REPORTER="${PA11Y_REPORTER:-html}" export PA11Y_REPORTER="${PA11Y_REPORTER:-html}"
export PA11Y_STANDARD="${PA11Y_STANDARD:-WCAG2AA}" export PA11Y_STANDARD="${PA11Y_STANDARD:-WCAG2AA}"
export PA11Y_IGNORE="${PA11Y_IGNORE:-'WCAG2AA.Principle1.Guideline1_4.1_4_3.G18.Fail;WCAG2AA.Principle1.Guideline1_4.1_4_3.G145.Fail'}" export PA11Y_IGNORE="${PA11Y_IGNORE}"
PA11Y_ARGS="" PA11Y_ARGS=""

View File

@ -1,11 +1,12 @@
def audit(String url, Map params = [:]) { def audit(String url, Map params = [:]) {
def reporter = params.reporter ? params.reporter : 'html' def reporter = params.reporter ? params.reporter : 'html'
def username = params.username ? params.username : ''; def username = params.username ? params.username : ''
def password = params.password ? params.password : ''; def password = params.password ? params.password : ''
def standard = params.standard ? params.standard : 'WCAG2AA'; def standard = params.standard ? params.standard : 'WCAG2AA'
def includeWarnings = params.includeWarnings ? params.includeWarnings : false; def includeWarnings = params.includeWarnings ? params.includeWarnings : false
def includeNotices = params.includeNotices ? params.includeNotices : false; def includeNotices = params.includeNotices ? params.includeNotices : false
def cookie_value = params.cookie_value ? params.cookie_value : 'fr_FR'; def cookie = params.cookie ? params.cookie : ''
def ignoredRules = params.ignoredRules ? params.ignoredRules : ''
def pa11yImage = buildDockerImage() def pa11yImage = buildDockerImage()
@ -17,7 +18,8 @@ def audit(String url, Map params = [:]) {
-e PA11Y_STANDARD='${standard}' -e PA11Y_STANDARD='${standard}'
-e PA11Y_INCLUDE_WARNINGS='${includeWarnings}' -e PA11Y_INCLUDE_WARNINGS='${includeWarnings}'
-e PA11Y_INCLUDE_NOTICES='${includeNotices}' -e PA11Y_INCLUDE_NOTICES='${includeNotices}'
-e PA11Y_COOKIE='${cookie_value}' -e PA11Y_COOKIE='${cookie}'
-e PA11Y_IGNORE='${ignoredRules}'
""" """
pa11yImage.inside(dockerArgs) { pa11yImage.inside(dockerArgs) {
@ -31,24 +33,22 @@ def audit(String url, Map params = [:]) {
} }
} }
def buildDockerImage() { def buildDockerImage() {
dir('.pa11y') { dir('.pa11y') {
def resourceFiles = [ def resourceFiles = [
'com/cadoles/pa11y/Dockerfile', 'com/cadoles/pa11y/Dockerfile',
'com/cadoles/pa11y/patty.json.tmpl', 'com/cadoles/pa11y/patty.json.tmpl',
'com/cadoles/pa11y/run-audit.sh' 'com/cadoles/pa11y/run-audit.sh'
]; ]
for (res in resourceFiles) { for (res in resourceFiles) {
def fileContent = libraryResource res def fileContent = libraryResource res
def fileName = res.substring(res.lastIndexOf("/")+1) def fileName = res.substring(res.lastIndexOf('/') + 1)
writeFile file:fileName, text:fileContent writeFile file:fileName, text:fileContent
} }
def safeJobName = URLDecoder.decode(env.JOB_NAME).toLowerCase().replace('/', '-').replace(' ', '-') def safeJobName = URLDecoder.decode(env.JOB_NAME).toLowerCase().replace('/', '-').replace(' ', '-')
def imageTag = "${safeJobName}-${env.BUILD_ID}" def imageTag = "${safeJobName}-${env.BUILD_ID}"
return docker.build("pa11y:${imageTag}", ".") return docker.build("pa11y:${imageTag}", '.')
} }
} }