Skip to content

Commit ce83f21

Browse files
authored
Merge pull request #5 from mbdevpl/feature/boilerplate-package
Depend on `boilerplates` package
2 parents 2ca7c67 + 33d03d4 commit ce83f21

15 files changed

Lines changed: 147 additions & 860 deletions

.github/workflows/python.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ubuntu-latest, macos-latest, windows-latest]
15-
python-version: ['3.8', '3.9', '3.10']
15+
python-version: ['3.8', '3.9', '3.10', '3.11']
1616

1717
steps:
18-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v3
1919
with:
2020
fetch-depth: 0
21-
- uses: actions/setup-python@v2
21+
- uses: actions/setup-python@v4
2222
with:
2323
python-version: ${{ matrix.python-version }}
2424
architecture: x64
@@ -31,12 +31,12 @@ jobs:
3131
needs: test
3232
runs-on: ubuntu-latest
3333
steps:
34-
- uses: actions/checkout@v2
34+
- uses: actions/checkout@v3
3535
with:
3636
fetch-depth: 0
37-
- uses: actions/setup-python@v2
37+
- uses: actions/setup-python@v4
3838
with:
39-
python-version: '3.10'
39+
python-version: '3.11'
4040
architecture: x64
4141
- run: pip install -r requirements_test.txt
4242
- run: python setup.py bdist_wheel sdist

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ARG GROUP_ID=1000
2525
ARG AUX_GROUP_IDS=""
2626

2727
RUN set -Eeuxo pipefail && \
28-
addgroup --gid "${GROUP_ID}" user && \
28+
(addgroup --gid "${GROUP_ID}" user || echo "group ${GROUP_ID} already exists, so not adding it") && \
2929
adduser --disabled-password --gecos "User" --uid "${USER_ID}" --gid "${GROUP_ID}" user && \
3030
echo ${AUX_GROUP_IDS} | xargs -n1 echo | xargs -I% addgroup --gid % group% && \
3131
echo ${AUX_GROUP_IDS} | xargs -n1 echo | xargs -I% usermod --append --groups group% user
@@ -37,7 +37,7 @@ WORKDIR /home/user/argunparse
3737
COPY --chown=${USER_ID}:${GROUP_ID} requirements*.txt ./
3838

3939
RUN set -Eeuxo pipefail && \
40-
pip3 install -r requirements_ci.txt
40+
pip3 install --no-cache-dir -r requirements_ci.txt
4141

4242
USER user
4343

Jenkinsfile

Lines changed: 96 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -9,93 +9,115 @@ pipeline {
99
}
1010

1111
environment {
12-
PYTHON_MODULES = 'argunparse test *.py'
12+
PYTHON_PACKAGE = 'argunparse'
1313
}
1414

15-
agent any
15+
agent {
16+
dockerfile {
17+
additionalBuildArgs '--build-arg USER_ID=${USER_ID} --build-arg GROUP_ID=${GROUP_ID}' \
18+
+ ' --build-arg AUX_GROUP_IDS="${AUX_GROUP_IDS}" --build-arg TIMEZONE=${TIMEZONE}'
19+
label 'docker'
20+
}
21+
}
1622

1723
stages {
18-
stage('Matrix') {
19-
matrix {
20-
21-
axes {
22-
axis {
23-
name 'PYTHON_VERSION'
24-
values '3.8', '3.9', '3.10'
25-
}
26-
}
27-
28-
agent {
29-
dockerfile {
30-
additionalBuildArgs '--build-arg USER_ID=${USER_ID} --build-arg GROUP_ID=${GROUP_ID}' \
31-
+ ' --build-arg AUX_GROUP_IDS="${AUX_GROUP_IDS}" --build-arg TIMEZONE=${TIMEZONE}' \
32-
+ ' --build-arg PYTHON_VERSION=${PYTHON_VERSION}'
33-
label 'docker'
34-
}
35-
}
36-
37-
stages {
3824

39-
stage('Lint') {
40-
when {
41-
environment name: 'PYTHON_VERSION', value: '3.10'
42-
}
43-
steps {
44-
sh """#!/usr/bin/env bash
45-
set -Eeux
46-
python -m pylint ${PYTHON_MODULES} |& tee pylint.log
47-
echo "\${PIPESTATUS[0]}" | tee pylint_status.log
48-
python -m mypy ${PYTHON_MODULES} |& tee mypy.log
49-
echo "\${PIPESTATUS[0]}" | tee mypy_status.log
50-
python -m flake518 ${PYTHON_MODULES} |& tee flake518.log
51-
echo "\${PIPESTATUS[0]}" | tee flake518_status.log
52-
python -m pydocstyle ${PYTHON_MODULES} |& tee pydocstyle.log
53-
echo "\${PIPESTATUS[0]}" | tee pydocstyle_status.log
54-
"""
55-
}
56-
}
25+
stage('Lint') {
26+
environment {
27+
PYTHON_MODULES = "${env.PYTHON_PACKAGE.replace('-', '_')} test *.py"
28+
}
29+
steps {
30+
sh """#!/usr/bin/env bash
31+
set -Eeux
32+
python3 -m pylint ${PYTHON_MODULES} |& tee pylint.log
33+
echo "\${PIPESTATUS[0]}" | tee pylint_status.log
34+
python3 -m mypy ${PYTHON_MODULES} |& tee mypy.log
35+
echo "\${PIPESTATUS[0]}" | tee mypy_status.log
36+
python3 -m flake518 ${PYTHON_MODULES} |& tee flake518.log
37+
echo "\${PIPESTATUS[0]}" | tee flake518_status.log
38+
python3 -m pydocstyle ${PYTHON_MODULES} |& tee pydocstyle.log
39+
echo "\${PIPESTATUS[0]}" | tee pydocstyle_status.log
40+
"""
41+
}
42+
}
5743

58-
stage('Test') {
59-
steps {
60-
sh '''#!/usr/bin/env bash
61-
set -Eeuxo pipefail
62-
TEST_PACKAGING=1 python -m coverage run --branch --source . -m unittest -v
63-
'''
64-
}
65-
}
44+
stage('Test') {
45+
steps {
46+
sh '''#!/usr/bin/env bash
47+
set -Eeuxo pipefail
48+
python3 -m coverage run --branch --source . -m unittest -v
49+
'''
50+
}
51+
}
6652

67-
stage('Coverage') {
68-
when {
69-
environment name: 'PYTHON_VERSION', value: '3.10'
70-
}
71-
steps {
72-
sh '''#!/usr/bin/env bash
73-
set -Eeux
74-
python -m coverage report --show-missing |& tee coverage.log
75-
echo "${PIPESTATUS[0]}" | tee coverage_status.log
76-
'''
77-
script {
78-
defaultHandlers.afterPythonBuild()
79-
}
80-
}
81-
}
53+
stage('Coverage') {
54+
steps {
55+
sh '''#!/usr/bin/env bash
56+
set -Eeux
57+
python3 -m coverage report --show-missing |& tee coverage.log
58+
echo "${PIPESTATUS[0]}" | tee coverage_status.log
59+
'''
60+
script {
61+
defaultHandlers.afterPythonBuild()
62+
}
63+
}
64+
}
8265

83-
stage('Codecov') {
84-
environment {
85-
CODECOV_TOKEN = credentials('codecov-token-mbdevpl-argunparse')
86-
}
87-
steps {
88-
sh '''#!/usr/bin/env bash
89-
set -Eeuxo pipefail
90-
python -m codecov --token ${CODECOV_TOKEN}
91-
'''
92-
}
93-
}
66+
stage('Codecov') {
67+
environment {
68+
CODECOV_TOKEN = credentials('codecov-token-mbdevpl-argunparse')
69+
}
70+
steps {
71+
sh '''#!/usr/bin/env bash
72+
set -Eeuxo pipefail
73+
python3 -m codecov --token ${CODECOV_TOKEN}
74+
'''
75+
}
76+
}
9477

78+
stage('Upload') {
79+
when {
80+
anyOf {
81+
branch 'main'
82+
buildingTag()
9583
}
84+
}
85+
environment {
86+
VERSION = sh(script: 'python3 -m version_query --predict .', returnStdout: true).trim()
87+
PYPI_AUTH = credentials('mbdev-pypi-auth')
88+
TWINE_USERNAME = "${PYPI_AUTH_USR}"
89+
TWINE_PASSWORD = "${PYPI_AUTH_PSW}"
90+
TWINE_REPOSITORY_URL = credentials('mbdev-pypi-public-url')
91+
}
92+
steps {
93+
sh """#!/usr/bin/env bash
94+
set -Eeuxo pipefail
95+
python3 -m twine upload \
96+
dist/${PYTHON_PACKAGE.replace('-', '_')}-${VERSION}-py3-none-any.whl \
97+
dist/${PYTHON_PACKAGE}-${VERSION}.tar.gz \
98+
dist/${PYTHON_PACKAGE}-${VERSION}.zip
99+
"""
100+
}
101+
}
96102

103+
stage('Release') {
104+
when {
105+
buildingTag()
106+
}
107+
environment {
108+
VERSION = sh(script: 'python3 -m version_query .', returnStdout: true).trim()
109+
}
110+
steps {
111+
script {
112+
githubUtils.createRelease([
113+
"dist/${PYTHON_PACKAGE.replace('-', '_')}-${VERSION}-py3-none-any.whl",
114+
"dist/${PYTHON_PACKAGE}-${VERSION}.tar.gz",
115+
"dist/${PYTHON_PACKAGE}-${VERSION}.zip"
116+
])
117+
}
97118
}
98119
}
120+
99121
}
100122

101123
post {

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
include setup_boilerplate.py
21
include requirements.txt
32
include LICENSE
43
include NOTICE

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Python libraries as specified in `<requirements.txt>`_.
8585

8686
Building and running tests additionally requires packages listed in `<requirements_test.txt>`_.
8787

88-
Tested on Linux, OS X and Windows.
88+
Tested on Linux, macOS and Windows.
8989

9090

9191
Installation

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[build-system]
2-
requires = ['docutils', 'setuptools', 'version-query', 'wheel']
2+
requires = [
3+
'boilerplates[setup] ~= 1.0'
4+
]
35

46
[tool.flake8]
57
max-line-length = 100

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version-query ~= 1.1
1+
version-query ~= 1.5

requirements_ci.txt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
codecov ~= 2.1
2-
coverage ~= 6.2
3-
flake518 ~= 1.2
4-
mypy ~= 0.930
5-
pydocstyle ~= 6.1
6-
pylint ~= 2.12
7-
types-docutils ~= 0.17
8-
types-setuptools ~= 57.4
91
-r requirements_test.txt
2+
codecov ~= 2.1
3+
coverage ~= 7.2
4+
flake518 ~= 1.6; python_version >= '3.9'
5+
mypy ~= 1.5
6+
pydocstyle ~= 6.3
7+
pylint ~= 2.17

requirements_test.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
docutils ~= 0.18
2-
pip >= 21.0
3-
Pygments ~= 2.11
4-
setuptools >= 60.4
5-
wheel >= 0.37
61
-r requirements.txt
2+
boilerplates[logging,packaging_tests] ~= 1.0

setup.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""Setup script for argunparse package."""
22

3-
import setup_boilerplate
3+
import boilerplates.setup
44

55

6-
class Package(setup_boilerplate.Package):
6+
class Package(boilerplates.setup.Package):
77
"""Package metadata."""
88

99
name = 'argunparse'
@@ -15,16 +15,17 @@ class Package(setup_boilerplate.Package):
1515
'Intended Audience :: Developers',
1616
'License :: OSI Approved :: Apache Software License',
1717
'Natural Language :: English',
18-
'Operating System :: MacOS :: MacOS X',
18+
'Operating System :: MacOS',
1919
'Operating System :: Microsoft :: Windows',
2020
'Operating System :: POSIX :: Linux',
2121
'Programming Language :: Python :: 3.8',
2222
'Programming Language :: Python :: 3.9',
2323
'Programming Language :: Python :: 3.10',
24+
'Programming Language :: Python :: 3.11',
2425
'Programming Language :: Python :: 3 :: Only',
2526
'Topic :: Scientific/Engineering',
26-
'Topic :: Utilities'
27-
]
27+
'Topic :: Utilities',
28+
'Typing :: Typed']
2829
keywords = ['argparse', 'commandline arguments', 'pretty printing', 'unparsing']
2930

3031

0 commit comments

Comments
 (0)