Skip to content

Commit 0f67466

Browse files
authored
Merge pull request #264 from itkovian/parallel-jenkins-stages
feat: allow parallel Jenkins stages for tests
2 parents b02661a + 8f758c5 commit 0f67466

4 files changed

Lines changed: 338 additions & 173 deletions

File tree

Jenkinsfile

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,42 @@
22
// This file was automatically generated using 'python -m vsc.install.ci'
33
// DO NOT EDIT MANUALLY
44

5-
node {
5+
pipeline {
6+
agent any
7+
stages {
68
stage('checkout git') {
7-
checkout scm
8-
// remove untracked files (*.pyc for example)
9-
sh 'git clean -fxd'
9+
steps {
10+
checkout scm
11+
// remove untracked files (*.pyc for example)
12+
sh 'git clean -fxd'
13+
}
1014
}
11-
stage ('ruff format') {
12-
sh 'curl -L --silent https://github.com/astral-sh/ruff/releases/download/0.13.1/ruff-x86_64-unknown-linux-gnu.tar.gz --output - | tar -xzv'
13-
sh 'cp ruff-x86_64-unknown-linux-gnu/ruff .'
14-
sh './ruff --version'
15-
sh './ruff format --check .'
15+
stage('install ruff') {
16+
steps {
17+
sh 'curl -L --silent https://github.com/astral-sh/ruff/releases/download/0.13.1/ruff-x86_64-unknown-linux-gnu.tar.gz --output - | tar -xzv'
18+
sh 'cp ruff-x86_64-unknown-linux-gnu/ruff .'
19+
sh './ruff --version'
20+
}
1621
}
17-
stage ('ruff check') {
18-
sh 'curl -L --silent https://github.com/astral-sh/ruff/releases/download/0.13.1/ruff-x86_64-unknown-linux-gnu.tar.gz --output - | tar -xzv'
19-
sh 'cp ruff-x86_64-unknown-linux-gnu/ruff .'
20-
sh './ruff --version'
21-
sh './ruff check .'
22+
stage('test pipeline') {
23+
parallel {
24+
stage ('ruff format') {
25+
steps {
26+
sh './ruff format --check .'
27+
}
28+
}
29+
stage ('ruff check') {
30+
steps {
31+
sh './ruff check .'
32+
}
33+
}
34+
stage('test') {
35+
steps {
36+
sh 'pip3 install --ignore-installed --prefix $PWD/.vsc-tox tox'
37+
sh 'export PATH=$PWD/.vsc-tox/bin:$PATH && export PYTHONPATH=$PWD/.vsc-tox/lib/python$(python3 -c "import sys; print(\\"%s.%s\\" % sys.version_info[:2])")/site-packages:$PYTHONPATH && tox -v -c tox.ini'
38+
sh 'rm -r $PWD/.vsc-tox'
39+
}
40+
}
41+
}
2242
}
23-
stage('test') {
24-
sh 'pip3 install --ignore-installed --prefix $PWD/.vsc-tox tox'
25-
sh 'export PATH=$PWD/.vsc-tox/bin:$PATH && export PYTHONPATH=$PWD/.vsc-tox/lib/python$(python3 -c "import sys; print(\\"%s.%s\\" % sys.version_info[:2])")/site-packages:$PYTHONPATH && tox -v -c tox.ini'
26-
sh 'rm -r $PWD/.vsc-tox'
27-
}
28-
}
43+
}}

lib/vsc/install/ci.py

Lines changed: 73 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -492,68 +492,104 @@ def indent(line, level=1):
492492

493493
lines = header + [
494494
"",
495-
"node {",
495+
"pipeline {",
496+
"agent any",
497+
"stages {",
496498
indent("stage('checkout git') {"),
497-
indent("checkout scm", level=2),
498-
indent("// remove untracked files (*.pyc for example)", level=2),
499-
indent("sh 'git clean -fxd'", level=2),
499+
indent("steps {", level=2),
500+
indent("checkout scm", level=3),
501+
indent("// remove untracked files (*.pyc for example)", level=3),
502+
indent("sh 'git clean -fxd'", level=3),
503+
indent("}", level=2),
500504
indent("}"),
501505
]
502506

507+
if vsc_ci_cfg[RUN_RUFF_CHECK] or vsc_ci_cfg[RUN_RUFF_FORMAT_CHECK]:
508+
r_url = (
509+
f"https://github.com/astral-sh/ruff/releases/download/{RUFF_VERSION}/ruff-x86_64-unknown-linux-gnu.tar.gz"
510+
)
511+
ruff_install_lines = [
512+
indent("stage('install ruff') {"),
513+
indent("steps {", level=2),
514+
indent(f"sh 'curl -L --silent {r_url} --output - | tar -xzv'", level=3),
515+
indent("sh 'cp ruff-x86_64-unknown-linux-gnu/ruff .'", level=3),
516+
indent("sh './ruff --version'", level=3),
517+
indent("}", level=2),
518+
indent("}"),
519+
]
520+
lines.extend(ruff_install_lines)
521+
522+
lines.extend([
523+
indent("stage('test pipeline') {"),
524+
indent("parallel {", level=2),
525+
])
526+
503527
if vsc_ci_cfg[RUN_SHELLCHECK]:
504528
# see https://github.com/koalaman/shellcheck#installing-a-pre-compiled-binary
505529
shellcheck_url = "https://github.com/koalaman/shellcheck/releases/download/latest/"
506530
shellcheck_url += "shellcheck-latest.linux.x86_64.tar.xz"
507531
lines.extend([
508-
indent("stage ('shellcheck') {"),
509-
indent(f"sh 'curl -L --silent {shellcheck_url} --output - | tar -xJv'", level=2),
510-
indent("sh 'cp shellcheck-latest/shellcheck .'", level=2),
511-
indent("sh 'rm -r shellcheck-latest'", level=2),
512-
indent("sh './shellcheck --version'", level=2),
513-
indent("sh './shellcheck bin/*.sh'", level=2),
514-
indent("}"),
532+
indent("stage ('shellcheck') {", level=3),
533+
indent("steps {", level=4),
534+
indent(f"sh 'curl -L --silent {shellcheck_url} --output - | tar -xJv'", level=5),
535+
indent("sh 'cp shellcheck-latest/shellcheck .'", level=5),
536+
indent("sh 'rm -r shellcheck-latest'", level=5),
537+
indent("sh './shellcheck --version'", level=5),
538+
indent("sh './shellcheck bin/*.sh'", level=5),
539+
indent("}", level=4),
540+
indent("}", level=3),
515541
])
516542

517-
r_url = f"https://github.com/astral-sh/ruff/releases/download/{RUFF_VERSION}/ruff-x86_64-unknown-linux-gnu.tar.gz"
518-
ruff_install_lines = [
519-
indent(f"sh 'curl -L --silent {r_url} --output - | tar -xzv'", level=2),
520-
indent("sh 'cp ruff-x86_64-unknown-linux-gnu/ruff .'", level=2),
521-
indent("sh './ruff --version'", level=2),
522-
]
523543
if vsc_ci_cfg[RUN_RUFF_FORMAT_CHECK]:
524-
lines.extend([indent("stage ('ruff format') {")])
525-
lines.extend(ruff_install_lines)
526-
lines.extend([indent("sh './ruff format --check .'", level=2), indent("}")])
544+
lines.extend([
545+
indent("stage ('ruff format') {", level=3),
546+
indent("steps {", level=4),
547+
indent("sh './ruff format --check .'", level=5),
548+
indent("}", level=4),
549+
indent("}", level=3),
550+
])
527551

528552
if vsc_ci_cfg[RUN_RUFF_CHECK]:
529-
lines.extend([indent("stage ('ruff check') {")])
530-
lines.extend(ruff_install_lines)
531-
lines.extend([indent("sh './ruff check .'", level=2), indent("}")])
553+
lines.extend([
554+
indent("stage ('ruff check') {", level=3),
555+
indent("steps {", level=4),
556+
indent("sh './ruff check .'", level=5),
557+
indent("}", level=4),
558+
indent("}", level=3),
559+
])
532560

533-
lines.append(indent("stage('test') {"))
561+
lines.append(indent("stage('test') {", level=3))
562+
lines.append(indent("steps {", level=4))
534563
for test_cmd in test_cmds:
535564
# be careful with test commands that include single quotes!
536565
if "'" in test_cmd:
537-
lines.append(indent(f'sh """{test_cmd}"""', level=2))
566+
lines.append(indent(f'sh """{test_cmd}"""', level=5))
538567
else:
539-
lines.append(indent(f"sh '{test_cmd}'", level=2))
540-
lines.append(indent("}"))
568+
lines.append(indent(f"sh '{test_cmd}'", level=5))
569+
lines.append(indent("}", level=4))
570+
lines.append(indent("}", level=3))
541571

542572
if vsc_ci_cfg[JIRA_ISSUE_ID_IN_PR_TITLE]:
543573
lines.extend([
544-
indent("stage('PR title JIRA link') {"),
545-
indent("if (env.CHANGE_ID) {", level=2),
546-
indent(r"if (env.CHANGE_TITLE =~ /\s+\(?HPC-\d+\)?/) {", level=3),
547-
indent('echo "title ${env.CHANGE_TITLE} seems to contain JIRA ticket number."', level=4),
548-
indent("} else {", level=3),
549-
indent("echo \"ERROR: title ${env.CHANGE_TITLE} does not end in 'HPC-number'.\"", level=4),
550-
indent('error("malformed PR title ${env.CHANGE_TITLE}.")', level=4),
574+
indent("stage('PR title JIRA link') {", level=3),
575+
indent("steps {", level=4),
576+
indent("if (env.CHANGE_ID) {", level=5),
577+
indent(r"if (env.CHANGE_TITLE =~ /\s+\(?HPC-\d+\)?/) {", level=6),
578+
indent('echo "title ${env.CHANGE_TITLE} seems to contain JIRA ticket number."', level=7),
579+
indent("} else {", level=6),
580+
indent("echo \"ERROR: title ${env.CHANGE_TITLE} does not end in 'HPC-number'.\"", level=7),
581+
indent('error("malformed PR title ${env.CHANGE_TITLE}.")', level=7),
582+
indent("}", level=6),
583+
indent("}", level=5),
584+
indent("}", level=4),
551585
indent("}", level=3),
552-
indent("}", level=2),
553-
indent("}"),
554586
])
555587

556-
lines.append("}")
588+
# close parallel stages
589+
lines.append(indent("}", level=2))
590+
lines.append(indent("}"))
591+
592+
lines.append("}}")
557593

558594
return "\n".join(lines) + "\n"
559595

lib/vsc/install/shared_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def _log(self, level, msg, args):
200200

201201
RELOAD_VSC_MODS = False
202202

203-
VERSION = "0.22.6"
203+
VERSION = "0.23.0"
204204

205205
log.info("This is (based on) vsc.install.shared_setup %s", VERSION)
206206
log.info("(using setuptools version %s located at %s)", setuptools.__version__, setuptools.__file__)

0 commit comments

Comments
 (0)