diff --git a/jobs/templates/swh-cypress.groovy b/jobs/templates/swh-cypress.groovy index 5fc3655..c7b12b1 100644 --- a/jobs/templates/swh-cypress.groovy +++ b/jobs/templates/swh-cypress.groovy @@ -1,110 +1,111 @@ pipeline {{ agent {{ label '{docker-image}' }} environment {{ PHAB_CONDUIT_URL = 'https://forge.softwareheritage.org/api/' + CYPRESS_CACHE_FOLDER = '/tmp/cypress_cache' }} stages {{ stage('Checkout') {{ steps {{ withCredentials([ string(credentialsId: 'swh-public-ci', variable: 'PHAB_CONDUIT_TOKEN')]) {{ sh ''' if [ -n "$PHID" ]; then echo "{{ \\\"buildTargetPHID\\\": \\\"$PHID\\\", \\\"artifactKey\\\": \\\"link.jenkins\\\", \\\"artifactType\\\": \\\"uri\\\", \\\"artifactData\\\": {{ \\\"uri\\\": \\\"$BUILD_URL\\\", \\\"name\\\": \\\"Jenkins\\\", \\\"ui.external\\\": true }} }}" | arc call-conduit --conduit-uri $PHAB_CONDUIT_URL --conduit-token $PHAB_CONDUIT_TOKEN harbormaster.createartifact python3 -m pyarcanist send-message work $PHID fi ''' }} checkout([$class: 'GitSCM', branches: [[name: "${{params.REVISION}}"]], doGenerateSubmoduleConfigurations: false, extensions: [], gitTool: 'Default', submoduleCfg: [], userRemoteConfigs: [[url: 'https://forge.softwareheritage.org/source/{display-name}.git']], browser: [$class: 'Phabricator', repoUrl: 'https://forge.softwareheritage.org', repo: '{name}'] ]) }} }} stage('Setup environment') {{ steps {{ sh '''#!/bin/bash python3 -m pip install --user -e .[testing] yarn install && yarn build-test && yarn run cypress install ''' }} }} stage('Run cypress tests') {{ steps {{ sh '''#!/bin/bash set -e export PYTHONPATH=$PWD python3 swh/web/manage.py migrate --settings=swh.web.settings.tests python3 swh/web/manage.py createcachetable --settings=swh.web.settings.tests cat swh/web/tests/create_test_admin.py | python3 swh/web/manage.py shell --settings=swh.web.settings.tests python3 swh/web/manage.py runserver --nostatic --settings=swh.web.settings.tests & wait-for-it localhost:5004 yarn run cypress run yarn run mochawesome yarn run nyc-report ''' }} }} }} post {{ always {{ withCredentials([ string(credentialsId: 'swh-public-ci', variable: 'PHAB_CONDUIT_TOKEN')]) {{ withEnv(["JOBSTATUS=${{currentBuild.currentResult}}"]) {{ sh ''' if [ "$JOBSTATUS" = "SUCCESS" ]; then MSGTYPE=pass else MSGTYPE=fail fi echo "Current job status is $JOBSTATUS -> $MGSTYPE" if [ -n "$PHID" ]; then python3 -m pyarcanist send-message $MSGTYPE $PHID fi ''' }} }} publishHTML (target: [ allowMissing: true, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'cypress/mochawesome/report', reportFiles: 'mochawesome.html', reportName: "Mochawesome Tests Report" ]) publishHTML (target: [ allowMissing: true, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'cypress/coverage/lcov-report', reportFiles: 'index.html', reportName: "Istanbul Code Coverage" ]) }} }} }} diff --git a/jobs/templates/swh-cypress.yaml b/jobs/templates/swh-cypress.yaml index df4a263..e8dc411 100644 --- a/jobs/templates/swh-cypress.yaml +++ b/jobs/templates/swh-cypress.yaml @@ -1,97 +1,98 @@ - job-template: name: "{name}/cypress" display-name: "master branch (cypress)" project-type: pipeline docker-image: swh-cypress triggers: - timed: '@daily' sandbox: true auth-token: 'ph4br1cat0r' properties: - build-discarder: num-to-keep: 20 parameters: - git-parameter: name: REVISION type: PT_REVISION defaultValue: master description: Git revision to build. - string: name: PHID description: PHID of the Phabricator target object on which results will be reported. dsl: !include-raw: swh-cypress.groovy - job-template: name: "{name}/cypress-diff" display-name: 'Phab. Diff (cypress)' docker-image: swh-cypress node: "{docker-image}" auth-token: ph4br1cat0r parameters: - string: name: REPO description: PHID of the Diffusion repository - string: name: PHID description: PHID of the Target object - string: name: DIFF_ID description: ID of the Diff patch to apply, if any scm: - git: url: https://forge.softwareheritage.org/source/{display-name}.git branches: - origin/master wrappers: - phabricator-differential: apply-to-master: true patch-with-force-flag: true builders: - shell: | echo "Run cypress for:" echo " REPO=$REPO" echo " PHID=$PHID" echo " DIFF_ID=$DIFF_ID" - shell: | #!/bin/bash set -e python3 -m pip install --user -e .[testing] + export CYPRESS_CACHE_FOLDER=/tmp/cypress_cache/ yarn install && yarn build-test && yarn run cypress install export PYTHONPATH=$PWD python3 swh/web/manage.py migrate --settings=swh.web.settings.tests python3 swh/web/manage.py createcachetable --settings=swh.web.settings.tests cat swh/web/tests/create_test_admin.py | python3 swh/web/manage.py shell --settings=swh.web.settings.tests python3 swh/web/manage.py runserver --nostatic --settings=swh.web.settings.tests & wait-for-it localhost:5004 yarn run cypress run yarn run mochawesome yarn run nyc-report publishers: - phabricator: uberalls-enabled: false comment-on-success: true comment-with-console-link-on-failure: true process-lint: true lint-file: .phabricator-lint lint-file-size: 1000000 - html-publisher: name: 'Mochawesome Tests Report' dir: 'cypress/mochawesome/report' files: 'mochawesome.html' keep-all: true allow-missing: true link-to-last-build: false - html-publisher: name: 'Istanbul Code Coverage' dir: 'cypress/coverage/lcov-report' files: 'index.html' keep-all: true allow-missing: true link-to-last-build: false