diff --git a/jobs/templates/swh-pipeline-diff.yaml b/jobs/templates/swh-pipeline-diff.yaml index 34cefa9..99fa975 100644 --- a/jobs/templates/swh-pipeline-diff.yaml +++ b/jobs/templates/swh-pipeline-diff.yaml @@ -1,44 +1,43 @@ - job-template: name: "{name}/tests-on-diff" display-name: Phab. Diff project-type: pipeline docker_image: tox cypress_docker_image: cypress sphinx_docker_image: sphinx default-tox-environment: py3 concurrent: true sandbox: true - auth-token: 'ph4br1cat0r' + auth-token: "ph4br1cat0r" phabricator_diff: true do_cypress: false timeout: 10 + max_concurrent: 0 properties: - build-discarder: days-to-keep: 90 artifact-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. - string: name: DIFF_ID description: ID of the Diff patch to apply, if any - string: name: REV_ID description: ID of the Phabricator revision, if any - string: name: STAGING_URI description: URI of the staging repository - string: name: TOX_ENVIRONMENT description: tox environment to use for the main tox run default: "{default-tox-environment}" - dsl: - !include-jinja2: swh-pipeline.groovy.j2 - + dsl: !include-jinja2: swh-pipeline.groovy.j2 diff --git a/jobs/templates/swh-pipeline.groovy.j2 b/jobs/templates/swh-pipeline.groovy.j2 index 8cac417..ff20db4 100644 --- a/jobs/templates/swh-pipeline.groovy.j2 +++ b/jobs/templates/swh-pipeline.groovy.j2 @@ -1,138 +1,151 @@ pipeline { {% filter indent(width=2) %} {%- include 'includes/agent-docker.groovy.j2' -%} {% endfilter %} + options { + // require "Throttle Concurrent Builds" Jenkins plugin + throttleJobProperty( + categories: [], + limitOneJobWithMatchingParams: false, + maxConcurrentPerNode: {{ max_concurrent }}, + maxConcurrentTotal: {{ max_concurrent }}, + paramsToUseForLimit: '', + throttleEnabled: true, + throttleOption: 'project', + ) + } + environment { PHAB_CONDUIT_URL = 'https://forge.softwareheritage.org/api/' } stages { stage('Checkout') { steps { {% filter indent(width=8) %} {%- include 'includes/create-phabricator-artifacts.groovy.j2' -%} {% endfilter %} checkout([ $class: 'GitSCM', branches: [[name: "${params.REVISION}"]], doGenerateSubmoduleConfigurations: false, extensions: [], gitTool: 'Default', submoduleCfg: [], userRemoteConfigs: [ [url: 'https://forge.softwareheritage.org/source/{{repo_name}}.git'], ], browser: [$class: 'Phabricator', repoUrl: 'https://forge.softwareheritage.org', repo: '{{name}}'] ]) } } {%- if phabricator_diff %} stage('Apply phabricator diff') { steps { {% filter indent(width=8) %} {%- include 'includes/script-apply-phabricator-diff.groovy.j2' -%} {% endfilter %} } } {%- endif %} stage ('flake8') { steps { sh '''python3 -m tox -e flake8''' } } stage ('mypy') { steps { sh '''python3 -m tox -e mypy''' } } stage ('radon') { steps { sh ''' mkdir -p reports python3 -m radon raw --json swh/ > reports/raw_report.json python3 -m radon cc --json swh/ > reports/cc_report.json python3 -m radon mi --json swh/ > reports/mi_report.json python3 -m radon hal --json swh/ > reports/hal_report.json python3 -m radon cc --xml swh/ > reports/cc_report.xml ''' } post { always { // Archive a few report files archiveArtifacts( allowEmptyArchive: true, artifacts: 'reports/*', fingerprint: true, ) // Warnings NG recordIssues( enabledForFailure: true, tools: [ ccm(pattern: '**/reports/cc_report.xml'), ], ) } } } stage('Tests') { options { timeout(time: {{ timeout }}, unit: 'MINUTES') } parallel { {% filter indent(width=8) %} {%- include 'includes/stage-python-tests.groovy.j2' -%} {% endfilter %} {%- if do_cypress %} {% filter indent(width=8) %} {%- include 'includes/stage-cypress-tests.groovy.j2' -%} {% endfilter %} {%- endif %} stage('Sphinx documentation') { {% filter indent(width=10) %} {%- include 'includes/agent-docker-sphinx.groovy.j2' -%} {% endfilter %} steps { sh ''' if tox -a | grep -x sphinx >/dev/null then tox -e sphinx else echo WARNING: no sphinx environment in tox.ini fi ''' } } // sphinx doc } // parallel } // Tests stage } // stages post { always { step([$class: 'PhabricatorNotifier', commentOnSuccess: true, commentWithConsoleLinkOnFailure: true, commentFile: '.phabricator-comment', commentSize: '1000000', preserveFormatting: true, processLint: true, lintFile: '.phabricator-lint', lintFileSize: '1000000', ]) } // always cleanup { cleanWs() } } // post } // pipeline diff --git a/jobs/templates/swh-pipeline.yaml b/jobs/templates/swh-pipeline.yaml index 1b49d99..053dd9b 100644 --- a/jobs/templates/swh-pipeline.yaml +++ b/jobs/templates/swh-pipeline.yaml @@ -1,37 +1,36 @@ - job-template: name: "{name}/tests" display-name: "master branch" project-type: pipeline docker_image: tox cypress_docker_image: cypress sphinx_docker_image: sphinx default-tox-environment: py3 concurrent: true triggers: - - timed: '@daily' + - timed: "@daily" sandbox: true - auth-token: 'ph4br1cat0r' + auth-token: "ph4br1cat0r" properties: - build-discarder: days-to-keep: 90 artifact-num-to-keep: 20 phabricator_diff: false do_cypress: false timeout: 10 + max_concurrent: 0 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. - string: name: TOX_ENVIRONMENT description: tox environment to use for the main tox run default: "{default-tox-environment}" - dsl: - !include-jinja2: swh-pipeline.groovy.j2 - + dsl: !include-jinja2: swh-pipeline.groovy.j2