From f3e0163d9faeba9ea1c810cd23c6ae0173e90f7f Mon Sep 17 00:00:00 2001 From: Rex Fleischer Date: Tue, 5 Nov 2019 10:02:37 -0800 Subject: [PATCH] add non frontend linters to new jenkins build fixes: CCI-37 Test-Plan: look at the build logs and ensure the linters run Change-Id: I6abed7e07296e72d5ddfea4356e98184c0a8d698 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/215975 Tested-by: Service Cloud Jenkins Tested-by: Jenkins Reviewed-by: James Butters Reviewed-by: S. Jacob Powell QA-Review: S. Jacob Powell Product-Review: Rex Fleischer --- Jenkinsfile | 25 ++++---- Jenkinsfile.linters | 64 +++++++++++++++---- build/new-jenkins/docker-cleanup.sh | 5 ++ build/new-jenkins/frontend/linter-eslint.sh | 5 -- .../new-jenkins/frontend/linter-stylelint.sh | 5 -- build/new-jenkins/frontend/linter-xss.sh | 5 -- build/new-jenkins/linters/run-brakeman.sh | 6 ++ .../new-jenkins/linters/run-commit-message.sh | 6 ++ build/new-jenkins/linters/run-eslint.sh | 6 ++ .../new-jenkins/linters/run-master-bouncer.sh | 10 +++ build/new-jenkins/linters/run-rlint.sh | 6 ++ build/new-jenkins/linters/run-stylelint.sh | 6 ++ build/new-jenkins/linters/run-tatl-tael.sh | 6 ++ build/new-jenkins/linters/run-xss.sh | 7 ++ build/new-jenkins/linters/test-gergich.sh | 12 ++++ 15 files changed, 134 insertions(+), 40 deletions(-) delete mode 100755 build/new-jenkins/frontend/linter-eslint.sh delete mode 100755 build/new-jenkins/frontend/linter-stylelint.sh delete mode 100755 build/new-jenkins/frontend/linter-xss.sh create mode 100755 build/new-jenkins/linters/run-brakeman.sh create mode 100755 build/new-jenkins/linters/run-commit-message.sh create mode 100755 build/new-jenkins/linters/run-eslint.sh create mode 100755 build/new-jenkins/linters/run-master-bouncer.sh create mode 100755 build/new-jenkins/linters/run-rlint.sh create mode 100755 build/new-jenkins/linters/run-stylelint.sh create mode 100755 build/new-jenkins/linters/run-tatl-tael.sh create mode 100755 build/new-jenkins/linters/run-xss.sh create mode 100755 build/new-jenkins/linters/test-gergich.sh diff --git a/Jenkinsfile b/Jenkinsfile index a48080a863e..a22029ec902 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -108,7 +108,7 @@ pipeline { stage('Print Env Variables') { steps { timeout(time: 20, unit: 'SECONDS') { - sh 'printenv | sort' + sh 'printenv | sort' } } } @@ -226,6 +226,18 @@ pipeline { } } + stage('Linters') { + steps { + skipIfPreviouslySuccessful("linters") { + build( + job: 'test-suites/linters', + propagate: false, + parameters: build_parameters + ) + } + } + } + stage('Vendored Gems') { steps { skipIfPreviouslySuccessful("vendored-gems") { @@ -304,17 +316,6 @@ pipeline { * } * } * - * stage('Linters') { - * steps { - * skipIfPreviouslySuccessful("linters") { - * build( - * job: 'test-suites/linters', - * parameters: build_parameters - * ) - * } - * } - * } - * * stage('Xbrowser') { * steps { * skipIfPreviouslySuccessful("xbrowser") { diff --git a/Jenkinsfile.linters b/Jenkinsfile.linters index 130a05cc27f..c412d1d6ac6 100644 --- a/Jenkinsfile.linters +++ b/Jenkinsfile.linters @@ -26,11 +26,19 @@ pipeline { environment { COMPOSE_FILE = 'docker-compose.new-jenkins-web.yml' + // 'refs/changes/63/181863/8' -> '63.181863.8' NAME = "${env.GERRIT_REFSPEC}".minus('refs/changes/').replaceAll('/','.') PATCHSET_TAG = "$DOCKER_REGISTRY_FQDN/jenkins/canvas-lms:$NAME" } stages { + stage('Print Env Variables') { + steps { + timeout(time: 20, unit: 'SECONDS') { + sh 'printenv | sort' + } + } + } // this is here because someone forgot to add the post cleanup in this build. // remove this after it runs for a little bit. stage('temp-cleanup') { @@ -38,19 +46,49 @@ pipeline { sh 'build/new-jenkins/docker-cleanup.sh' } } - stage('ESLint - JSX') { - steps { - sh 'build/new-jenkins/frontend/linter-eslint.sh' - } - } - stage('Stylelint') { - steps { - sh 'build/new-jenkins/frontend/linter-stylelint.sh' - } - } - stage('XSSLint') { - steps { - sh 'build/new-jenkins/frontend/linter-xss.sh' + + stage("All Linters") { + parallel { + stage('rlint') { + steps { + sh 'build/new-jenkins/linters/run-rlint.sh' + } + } + stage('brakeman') { + steps { + sh 'build/new-jenkins/linters/run-brakeman.sh' + } + } + stage('master bouncer') { + steps { + sh 'build/new-jenkins/linters/run-master-bouncer.sh' + } + } + stage('commit message') { + steps { + sh 'build/new-jenkins/linters/run-commit-message.sh' + } + } + stage('tatl tael') { + steps { + sh 'build/new-jenkins/linters/run-tatl-tael.sh' + } + } + stage('ESLint - JSX') { + steps { + sh 'build/new-jenkins/linters/run-eslint.sh' + } + } + stage('Stylelint') { + steps { + sh 'build/new-jenkins/linters/run-stylelint.sh' + } + } + stage('XSSLint') { + steps { + sh 'build/new-jenkins/linters/run-xss.sh' + } + } } } } diff --git a/build/new-jenkins/docker-cleanup.sh b/build/new-jenkins/docker-cleanup.sh index b5f86928ec8..7fe2a21b2c8 100755 --- a/build/new-jenkins/docker-cleanup.sh +++ b/build/new-jenkins/docker-cleanup.sh @@ -11,9 +11,14 @@ docker rm --force --volumes $(docker ps --all --quiet) # delete all containers docker rmi -f $(docker images --all --quiet) +# remove any extra networks (errors saying unable to remove is ok) +docker network rm $(docker network ls | grep "bridge" | awk '/ / { print $1 }') + echo "running docker images" docker ps -a echo "images locally" docker images -a echo "volumes left over" docker volume ls +echo "networks left over" +docker network ls \ No newline at end of file diff --git a/build/new-jenkins/frontend/linter-eslint.sh b/build/new-jenkins/frontend/linter-eslint.sh deleted file mode 100755 index a50f2220502..00000000000 --- a/build/new-jenkins/frontend/linter-eslint.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -export COMPOSE_FILE=./docker-compose.new-jenkins-web.yml - -docker-compose run --name linter-eslint web bundle exec ruby script/eslint diff --git a/build/new-jenkins/frontend/linter-stylelint.sh b/build/new-jenkins/frontend/linter-stylelint.sh deleted file mode 100755 index d0f8e118bbb..00000000000 --- a/build/new-jenkins/frontend/linter-stylelint.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -export COMPOSE_FILE=./docker-compose.new-jenkins-web.yml - -docker-compose run --name linter-stylelint web bundle exec ruby script/stylelint diff --git a/build/new-jenkins/frontend/linter-xss.sh b/build/new-jenkins/frontend/linter-xss.sh deleted file mode 100755 index 83672310131..00000000000 --- a/build/new-jenkins/frontend/linter-xss.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -export COMPOSE_FILE=./docker-compose.new-jenkins-web.yml - -docker-compose run --name linter-xsslint web bundle exec gergich capture custom:./build/gergich/xsslint:Gergich::XSSLint "node script/xsslint.js" diff --git a/build/new-jenkins/linters/run-brakeman.sh b/build/new-jenkins/linters/run-brakeman.sh new file mode 100755 index 00000000000..97c102cf050 --- /dev/null +++ b/build/new-jenkins/linters/run-brakeman.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -ex + +docker-compose --file $WORKSPACE/docker-compose.new-jenkins-web.yml \ + run --name linter-brakeman --rm web bundle exec ruby script/brakeman diff --git a/build/new-jenkins/linters/run-commit-message.sh b/build/new-jenkins/linters/run-commit-message.sh new file mode 100755 index 00000000000..7ca71d00b32 --- /dev/null +++ b/build/new-jenkins/linters/run-commit-message.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -e + +docker-compose --file $WORKSPACE/docker-compose.new-jenkins-web.yml \ + run --name linter-commit-message --rm web bundle exec ruby script/lint_commit_message diff --git a/build/new-jenkins/linters/run-eslint.sh b/build/new-jenkins/linters/run-eslint.sh new file mode 100755 index 00000000000..10c60224732 --- /dev/null +++ b/build/new-jenkins/linters/run-eslint.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -e + +docker-compose --file $WORKSPACE/docker-compose.new-jenkins-web.yml \ + run --name linter-eslint --rm web bundle exec ruby script/eslint diff --git a/build/new-jenkins/linters/run-master-bouncer.sh b/build/new-jenkins/linters/run-master-bouncer.sh new file mode 100755 index 00000000000..dfb0be112ed --- /dev/null +++ b/build/new-jenkins/linters/run-master-bouncer.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -e +if [[ -z "${MASTER_BOUNCER_KEY}" ]]; then + echo "MASTER_BOUNCER_KEY not set. cannot run master_bouncer check" + exit 0 +fi + +docker-compose --file $WORKSPACE/docker-compose.new-jenkins-web.yml \ + run --name linter-master-bouncer --rm web bundle exec master_bouncer diff --git a/build/new-jenkins/linters/run-rlint.sh b/build/new-jenkins/linters/run-rlint.sh new file mode 100755 index 00000000000..ca890b79b82 --- /dev/null +++ b/build/new-jenkins/linters/run-rlint.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -e + +docker-compose --file $WORKSPACE/docker-compose.new-jenkins-web.yml \ + run --name linter-rlint --rm web bundle exec ruby script/rlint diff --git a/build/new-jenkins/linters/run-stylelint.sh b/build/new-jenkins/linters/run-stylelint.sh new file mode 100755 index 00000000000..a18bdef8593 --- /dev/null +++ b/build/new-jenkins/linters/run-stylelint.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -e + +docker-compose --file $WORKSPACE/docker-compose.new-jenkins-web.yml \ + run --name linter-stylelint --rm web bundle exec ruby script/stylelint diff --git a/build/new-jenkins/linters/run-tatl-tael.sh b/build/new-jenkins/linters/run-tatl-tael.sh new file mode 100755 index 00000000000..65afa795e28 --- /dev/null +++ b/build/new-jenkins/linters/run-tatl-tael.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -e + +docker-compose --file $WORKSPACE/docker-compose.new-jenkins-web.yml \ + run --name linter-tatl-tael --rm web bundle exec ruby script/tatl_tael diff --git a/build/new-jenkins/linters/run-xss.sh b/build/new-jenkins/linters/run-xss.sh new file mode 100755 index 00000000000..f525af0cdae --- /dev/null +++ b/build/new-jenkins/linters/run-xss.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +docker-compose --file $WORKSPACE/docker-compose.new-jenkins-web.yml \ + run --name linter-xsslint --rm web \ + bundle exec gergich capture custom:./build/gergich/xsslint:Gergich::XSSLint "node script/xsslint.js" diff --git a/build/new-jenkins/linters/test-gergich.sh b/build/new-jenkins/linters/test-gergich.sh new file mode 100755 index 00000000000..c6abea71f98 --- /dev/null +++ b/build/new-jenkins/linters/test-gergich.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e +printenv | sort + +docker run --volume $WORKSPACE/containertmp:/tmp/ \ + --volume $WORKSPACE/.git:/usr/src/app/.git \ + --env GERRIT_PATCHSET_REVISION=$GERRIT_PATCHSET_REVISION \ + --env GERRIT_CHANGE_ID=$GERRIT_CHANGE_ID \ + --env GERRIT_PROJECT=$GERRIT_PROJECT \ + --env GERRIT_BRANCH=$GERRIT_BRANCH \ + $PATCHSET_TAG gergich citest