Skip to content

Commit

Permalink
Merge pull request #5 from mbdevpl/feature/boilerplate-package
Browse files Browse the repository at this point in the history
Depend on `boilerplates` package
  • Loading branch information
mbdevpl authored Sep 2, 2023
2 parents 2ca7c67 + 33d03d4 commit ce83f21
Show file tree
Hide file tree
Showing 15 changed files with 147 additions and 860 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
Expand All @@ -31,12 +31,12 @@ jobs:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
architecture: x64
- run: pip install -r requirements_test.txt
- run: python setup.py bdist_wheel sdist
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ARG GROUP_ID=1000
ARG AUX_GROUP_IDS=""

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

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

USER user

Expand Down
170 changes: 96 additions & 74 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,93 +9,115 @@ pipeline {
}

environment {
PYTHON_MODULES = 'argunparse test *.py'
PYTHON_PACKAGE = 'argunparse'
}

agent any
agent {
dockerfile {
additionalBuildArgs '--build-arg USER_ID=${USER_ID} --build-arg GROUP_ID=${GROUP_ID}' \
+ ' --build-arg AUX_GROUP_IDS="${AUX_GROUP_IDS}" --build-arg TIMEZONE=${TIMEZONE}'
label 'docker'
}
}

stages {
stage('Matrix') {
matrix {

axes {
axis {
name 'PYTHON_VERSION'
values '3.8', '3.9', '3.10'
}
}

agent {
dockerfile {
additionalBuildArgs '--build-arg USER_ID=${USER_ID} --build-arg GROUP_ID=${GROUP_ID}' \
+ ' --build-arg AUX_GROUP_IDS="${AUX_GROUP_IDS}" --build-arg TIMEZONE=${TIMEZONE}' \
+ ' --build-arg PYTHON_VERSION=${PYTHON_VERSION}'
label 'docker'
}
}

stages {

stage('Lint') {
when {
environment name: 'PYTHON_VERSION', value: '3.10'
}
steps {
sh """#!/usr/bin/env bash
set -Eeux
python -m pylint ${PYTHON_MODULES} |& tee pylint.log
echo "\${PIPESTATUS[0]}" | tee pylint_status.log
python -m mypy ${PYTHON_MODULES} |& tee mypy.log
echo "\${PIPESTATUS[0]}" | tee mypy_status.log
python -m flake518 ${PYTHON_MODULES} |& tee flake518.log
echo "\${PIPESTATUS[0]}" | tee flake518_status.log
python -m pydocstyle ${PYTHON_MODULES} |& tee pydocstyle.log
echo "\${PIPESTATUS[0]}" | tee pydocstyle_status.log
"""
}
}
stage('Lint') {
environment {
PYTHON_MODULES = "${env.PYTHON_PACKAGE.replace('-', '_')} test *.py"
}
steps {
sh """#!/usr/bin/env bash
set -Eeux
python3 -m pylint ${PYTHON_MODULES} |& tee pylint.log
echo "\${PIPESTATUS[0]}" | tee pylint_status.log
python3 -m mypy ${PYTHON_MODULES} |& tee mypy.log
echo "\${PIPESTATUS[0]}" | tee mypy_status.log
python3 -m flake518 ${PYTHON_MODULES} |& tee flake518.log
echo "\${PIPESTATUS[0]}" | tee flake518_status.log
python3 -m pydocstyle ${PYTHON_MODULES} |& tee pydocstyle.log
echo "\${PIPESTATUS[0]}" | tee pydocstyle_status.log
"""
}
}

stage('Test') {
steps {
sh '''#!/usr/bin/env bash
set -Eeuxo pipefail
TEST_PACKAGING=1 python -m coverage run --branch --source . -m unittest -v
'''
}
}
stage('Test') {
steps {
sh '''#!/usr/bin/env bash
set -Eeuxo pipefail
python3 -m coverage run --branch --source . -m unittest -v
'''
}
}

stage('Coverage') {
when {
environment name: 'PYTHON_VERSION', value: '3.10'
}
steps {
sh '''#!/usr/bin/env bash
set -Eeux
python -m coverage report --show-missing |& tee coverage.log
echo "${PIPESTATUS[0]}" | tee coverage_status.log
'''
script {
defaultHandlers.afterPythonBuild()
}
}
}
stage('Coverage') {
steps {
sh '''#!/usr/bin/env bash
set -Eeux
python3 -m coverage report --show-missing |& tee coverage.log
echo "${PIPESTATUS[0]}" | tee coverage_status.log
'''
script {
defaultHandlers.afterPythonBuild()
}
}
}

stage('Codecov') {
environment {
CODECOV_TOKEN = credentials('codecov-token-mbdevpl-argunparse')
}
steps {
sh '''#!/usr/bin/env bash
set -Eeuxo pipefail
python -m codecov --token ${CODECOV_TOKEN}
'''
}
}
stage('Codecov') {
environment {
CODECOV_TOKEN = credentials('codecov-token-mbdevpl-argunparse')
}
steps {
sh '''#!/usr/bin/env bash
set -Eeuxo pipefail
python3 -m codecov --token ${CODECOV_TOKEN}
'''
}
}

stage('Upload') {
when {
anyOf {
branch 'main'
buildingTag()
}
}
environment {
VERSION = sh(script: 'python3 -m version_query --predict .', returnStdout: true).trim()
PYPI_AUTH = credentials('mbdev-pypi-auth')
TWINE_USERNAME = "${PYPI_AUTH_USR}"
TWINE_PASSWORD = "${PYPI_AUTH_PSW}"
TWINE_REPOSITORY_URL = credentials('mbdev-pypi-public-url')
}
steps {
sh """#!/usr/bin/env bash
set -Eeuxo pipefail
python3 -m twine upload \
dist/${PYTHON_PACKAGE.replace('-', '_')}-${VERSION}-py3-none-any.whl \
dist/${PYTHON_PACKAGE}-${VERSION}.tar.gz \
dist/${PYTHON_PACKAGE}-${VERSION}.zip
"""
}
}

stage('Release') {
when {
buildingTag()
}
environment {
VERSION = sh(script: 'python3 -m version_query .', returnStdout: true).trim()
}
steps {
script {
githubUtils.createRelease([
"dist/${PYTHON_PACKAGE.replace('-', '_')}-${VERSION}-py3-none-any.whl",
"dist/${PYTHON_PACKAGE}-${VERSION}.tar.gz",
"dist/${PYTHON_PACKAGE}-${VERSION}.zip"
])
}
}
}

}

post {
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
include setup_boilerplate.py
include requirements.txt
include LICENSE
include NOTICE
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Python libraries as specified in `<requirements.txt>`_.

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

Tested on Linux, OS X and Windows.
Tested on Linux, macOS and Windows.


Installation
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[build-system]
requires = ['docutils', 'setuptools', 'version-query', 'wheel']
requires = [
'boilerplates[setup] ~= 1.0'
]

[tool.flake8]
max-line-length = 100
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version-query ~= 1.1
version-query ~= 1.5
14 changes: 6 additions & 8 deletions requirements_ci.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
codecov ~= 2.1
coverage ~= 6.2
flake518 ~= 1.2
mypy ~= 0.930
pydocstyle ~= 6.1
pylint ~= 2.12
types-docutils ~= 0.17
types-setuptools ~= 57.4
-r requirements_test.txt
codecov ~= 2.1
coverage ~= 7.2
flake518 ~= 1.6; python_version >= '3.9'
mypy ~= 1.5
pydocstyle ~= 6.3
pylint ~= 2.17
6 changes: 1 addition & 5 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
docutils ~= 0.18
pip >= 21.0
Pygments ~= 2.11
setuptools >= 60.4
wheel >= 0.37
-r requirements.txt
boilerplates[logging,packaging_tests] ~= 1.0
11 changes: 6 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Setup script for argunparse package."""

import setup_boilerplate
import boilerplates.setup


class Package(setup_boilerplate.Package):
class Package(boilerplates.setup.Package):
"""Package metadata."""

name = 'argunparse'
Expand All @@ -15,16 +15,17 @@ class Package(setup_boilerplate.Package):
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: MacOS :: MacOS X',
'Operating System :: MacOS',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Scientific/Engineering',
'Topic :: Utilities'
]
'Topic :: Utilities',
'Typing :: Typed']
keywords = ['argparse', 'commandline arguments', 'pretty printing', 'unparsing']


Expand Down
Loading

0 comments on commit ce83f21

Please sign in to comment.