Skip to content

Commit bd24058

Browse files
committed
Refactor pipelines to use new scripts
1 parent ac0efe3 commit bd24058

File tree

4 files changed

+35
-46
lines changed

4 files changed

+35
-46
lines changed

Jenkinsfile

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,21 @@ pipeline {
2424
stages {
2525
stage('Cleanup') {
2626
steps {
27-
sh 'rm -rf dist build docs/_build'
27+
sh 'rm -rf dist build'
2828
}
2929
}
3030
stage('Build documentation') {
3131
steps {
32-
sh 'pip install -e .' // required for python_training_project.version
33-
sh 'cd docs && pipenv run make html'
32+
sh './tools/build-docs.sh'
3433
archiveArtifacts(
35-
artifacts: 'docs/_build/html/**',
34+
artifacts: 'build/html/**',
3635
onlyIfSuccessful: true
3736
)
3837
publishHTML([
3938
allowMissing: false,
4039
alwaysLinkToLastBuild: false,
4140
keepAll: false,
42-
reportDir: 'docs/_build/html/',
41+
reportDir: 'build/html/',
4342
reportFiles: 'index.html',
4443
reportName: 'Documentation',
4544
reportTitles: '',
@@ -49,23 +48,17 @@ pipeline {
4948
}
5049
stage('Build Python package') {
5150
steps {
52-
sh 'python -m build --wheel'
51+
sh './tools/build-package.sh'
5352
archiveArtifacts(
54-
artifacts: 'dist/**/*.whl',
53+
artifacts: 'dist/*.whl',
5554
onlyIfSuccessful: true
5655
)
5756
}
5857
}
5958
stage('Static code analysis') {
6059
steps {
61-
warnError('flake8 issues found') {
62-
sh 'flake8 src/python_training_project --format=pylint > flake8.log'
63-
}
64-
warnError('pylint issues found') {
65-
sh 'pylint src/python_training_project --msg-template="{path}:{line}: [{msg_id}, {obj}] {msg} ({symbol})" > pylint.log'
66-
}
67-
warnError('mypy issues found') {
68-
sh 'mypy src/python_training_project > mypy.log'
60+
warnError('lint issues found') {
61+
sh './tools/lint-package.sh'
6962
}
7063
recordIssues(
7164
sourceCodeRetention: 'LAST_BUILD',
@@ -76,24 +69,23 @@ pipeline {
7669
lowTags: 'HACK',
7770
normalTags: 'TODO'
7871
),
79-
flake8(pattern: 'flake8.log'),
80-
pyLint(pattern: 'pylint.log'),
81-
myPy(pattern: 'mypy.log')
72+
flake8(pattern: 'build/flake8.txt'),
73+
pyLint(pattern: 'build/pylint.txt'),
74+
myPy(pattern: 'build/mypy.txt')
8275
]
8376
)
8477
}
8578
}
8679
stage('Test Python package') {
8780
steps {
88-
sh 'pip install -e .'
89-
sh 'pytest'
81+
sh './tools/test-package.sh'
9082
junit(
91-
testResults: 'report.xml'
83+
testResults: 'build/test-report.xml'
9284
)
9385
recordCoverage(
9486
tools: [
95-
[parser: 'JUNIT', pattern: 'report.xml'],
96-
[parser: 'COBERTURA', pattern: 'coverage.xml']
87+
[parser: 'JUNIT', pattern: 'build/test-report.xml'],
88+
[parser: 'COBERTURA', pattern: 'build/test-coverage.xml']
9789
]
9890
)
9991
}

Jenkinsfile.groovy

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,35 @@ node {
1515
}
1616
customImage.inside('--net="jenkins_default"') { // required for accessing the Gitea server
1717
stage('Cleanup') {
18-
sh 'rm -rf dist build docs/_build'
18+
sh 'rm -rf dist build'
1919
}
2020
stage('Build documentation') {
21-
sh 'pip install -e .' // required for python_training_project.version
22-
sh 'cd docs && pipenv run make html'
21+
sh './tools/build-docs.sh'
2322
archiveArtifacts(
24-
artifacts: 'docs/_build/html/**',
23+
artifacts: 'build/html/**',
2524
onlyIfSuccessful: true
2625
)
2726
publishHTML([
2827
allowMissing: false,
2928
alwaysLinkToLastBuild: false,
3029
keepAll: false,
31-
reportDir: 'docs/_build/html/',
30+
reportDir: 'build/html/',
3231
reportFiles: 'index.html',
3332
reportName: 'Documentation',
3433
reportTitles: '',
3534
useWrapperFileDirectly: true
3635
])
3736
}
3837
stage('Build Python package') {
39-
sh 'python -m build --wheel'
38+
sh './tools/build-package.sh'
4039
archiveArtifacts(
41-
artifacts: 'dist/**/*.whl',
40+
artifacts: 'dist/*.whl',
4241
onlyIfSuccessful: true
4342
)
4443
}
4544
stage('Static code analysis') {
46-
warnError('flake8 issues found') {
47-
sh 'flake8 src/python_training_project --format=pylint > flake8.log'
48-
}
49-
warnError('pylint issues found') {
50-
sh 'pylint --msg-template="{path}:{line}: [{msg_id}, {obj}] {msg} ({symbol})" src/python_training_project > pylint.log'
51-
}
52-
warnError('mypy issues found') {
53-
sh 'mypy src/python_training_project > mypy.log'
45+
warnError('lint issues found') {
46+
sh './tools/lint-package.sh'
5447
}
5548
recordIssues(
5649
sourceCodeRetention: 'LAST_BUILD',
@@ -61,22 +54,22 @@ node {
6154
lowTags: 'HACK',
6255
normalTags: 'TODO'
6356
),
64-
flake8(pattern: 'flake8.log'),
65-
pyLint(pattern: 'pylint.log'),
66-
myPy(pattern: 'mypy.log')
57+
flake8(pattern: 'build/flake8.txt'),
58+
pyLint(pattern: 'build/pylint.txt'),
59+
myPy(pattern: 'build/mypy.txt')
6760
]
6861
)
6962
}
7063
stage('Test Python package') {
7164
sh 'pip install -e .'
7265
sh 'pytest'
7366
junit(
74-
testResults: 'report.xml'
67+
testResults: 'build/test-report.xml'
7568
)
7669
recordCoverage(
7770
tools: [
78-
[parser: 'JUNIT', pattern: 'report.xml'],
79-
[parser: 'COBERTURA', pattern: 'coverage.xml']
71+
[parser: 'JUNIT', pattern: 'build/test-report.xml'],
72+
[parser: 'COBERTURA', pattern: 'build/test-coverage.xml']
8073
]
8174
)
8275
}

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SPHINXOPTS ?=
77
SPHINXBUILD ?= sphinx-build
88
SPHINXAPIDOC ?= sphinx-apidoc
99
SOURCEDIR = .
10-
BUILDDIR = _build
10+
BUILDDIR = ../build
1111
PACKAGEDIR = ../src
1212

1313
# Put it first so that "make" without argument is like "make help".

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ write_to = "src/python_training_project/version.py"
3737

3838
[tool.pytest.ini_options]
3939
minversion = "6.0"
40-
addopts = "--cov --cov-report term --cov-report xml --junitxml=report.xml"
40+
addopts = "--cov --cov-report term --cov-report xml --junitxml=build/test-report.xml"
4141
testpaths = [
4242
"tests",
4343
]
@@ -50,4 +50,8 @@ omit = [
5050
"*/version.py",
5151
"tests/*"
5252
]
53+
54+
[tool.coverage.xml]
55+
output = "build/test-coverage.xml"
56+
5357
source_pkgs = ["python_training_project"]

0 commit comments

Comments
 (0)