Skip to content

Commit 07153b4

Browse files
authored
Merge pull request #8 from mbdevpl/feature/jenkins-and-github-actions
Jenkins and GitHub actions
2 parents 7131b64 + 196dc83 commit 07153b4

22 files changed

+510
-305
lines changed

.build/install_pyenv.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.

.dockerignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## /.gitignore
2+
3+
# IDE: Visual Studio Code
4+
/.vscode
5+
6+
# OS: macOS
7+
.DS_Store
8+
9+
# OS: Windows
10+
desktop.ini
11+
System Volume Information
12+
Thumbs.db
13+
Thumbs.db*
14+
15+
# Python
16+
/build
17+
/dist
18+
/.cache
19+
__pycache__
20+
*.egg
21+
*.egg-info
22+
*.pyc
23+
24+
# Python: coverage
25+
/htmlcov
26+
/.coverage
27+
28+
# Python: Jupyter notebooks
29+
.ipynb_checkpoints
30+
*-checkpoint.ipynb

.github/workflows/python.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
branches:
7+
- $default-branch
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
python-version: ['3.8', '3.9', '3.10']
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
with:
20+
fetch-depth: 0
21+
- uses: actions/setup-python@v2
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
architecture: x64
25+
- run: pip install -r requirements_ci.txt
26+
- run: git clone https://github.com/PyCQA/pycodestyle ../pycodestyle
27+
- run: cd ../pycodestyle && python setup.py build && cd -
28+
- run: git clone https://github.com/mbdevpl/argunparse ../argunparse
29+
- run: cd ../argunparse && pip install -r test_requirements.txt && python setup.py build && cd -
30+
- run: git clone https://github.com/python-semver/python-semver ../semver
31+
- run: cd ../semver && python setup.py build && cd -
32+
- run: pip install jupyter
33+
- run: python -m coverage run --branch --source . -m unittest -v
34+
# - run: LOGGING_LEVEL=critical python -m coverage run --append --branch --source . -m unittest -v test.test_version
35+
- run: python -m coverage report --show-missing
36+
- run: codecov

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
# IDE: Visual Studio Code
2+
/.vscode
3+
14
# OS: macOS
25
.DS_Store
36

47
# OS: Windows
58
desktop.ini
9+
System Volume Information
10+
Thumbs.db
11+
Thumbs.db*
612

713
# Python
814
/build

.travis.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

Dockerfile

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
ARG PYTHON_VERSION="3.10"
2+
3+
FROM python:${PYTHON_VERSION}
4+
5+
SHELL ["/bin/bash", "-c"]
6+
7+
# set timezone
8+
9+
ARG TIMEZONE="Europe/Warsaw"
10+
11+
RUN set -Eeuxo pipefail && \
12+
apt-get update && \
13+
apt-get install --no-install-recommends -y \
14+
tzdata && \
15+
echo "${TIMEZONE}" > /etc/timezone && \
16+
cp "/usr/share/zoneinfo/${TIMEZONE}" /etc/localtime && \
17+
apt-get -qy autoremove && \
18+
apt-get clean && \
19+
rm -rf /var/lib/apt/lists/*
20+
21+
# add a non-root user
22+
23+
ARG USER_ID=1000
24+
ARG GROUP_ID=1000
25+
ARG AUX_GROUP_IDS=""
26+
27+
RUN set -Eeuxo pipefail && \
28+
addgroup --gid "${GROUP_ID}" user && \
29+
adduser --disabled-password --gecos "User" --uid "${USER_ID}" --gid "${GROUP_ID}" user && \
30+
echo ${AUX_GROUP_IDS} | xargs -n1 echo | xargs -I% addgroup --gid % group% && \
31+
echo ${AUX_GROUP_IDS} | xargs -n1 echo | xargs -I% usermod --append --groups group% user
32+
33+
# install dependencies
34+
35+
RUN set -Eeuxo pipefail && \
36+
apt-get update && \
37+
apt-get install --no-install-recommends -y \
38+
git && \
39+
apt-get -qy autoremove && \
40+
apt-get clean && \
41+
rm -rf /var/lib/apt/lists/*
42+
43+
# prepare version_query for testing
44+
45+
WORKDIR /home/user/version-query
46+
47+
COPY --chown=${USER_ID}:${GROUP_ID} requirements*.txt ./
48+
49+
RUN set -Eeuxo pipefail && \
50+
pip3 install -r requirements_ci.txt
51+
52+
USER user
53+
54+
WORKDIR /home/user
55+
56+
VOLUME ["/home/user/version-query"]
57+
58+
ENV EXAMPLE_PROJECTS_PATH="/home/user"
59+
60+
RUN set -Eeuxo pipefail && \
61+
git clone https://github.com/PyCQA/pycodestyle pycodestyle && \
62+
cd pycodestyle && \
63+
python setup.py build && \
64+
cd - && \
65+
git clone https://github.com/mbdevpl/argunparse argunparse && \
66+
cd argunparse && \
67+
pip install -r test_requirements.txt && \
68+
python setup.py build && \
69+
cd - && \
70+
git clone https://github.com/python-semver/python-semver semver && \
71+
cd semver && \
72+
python setup.py build && \
73+
cd - && \
74+
pip install jupyter
75+
76+
WORKDIR /home/user/version-query

Jenkinsfile

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/usr/bin/env groovy
2+
3+
library 'jenkins-mbdev-pl-libs'
4+
5+
pipeline {
6+
7+
options {
8+
ansiColor('xterm')
9+
}
10+
11+
environment {
12+
PYTHON_MODULES = 'version_query test *.py'
13+
}
14+
15+
agent any
16+
17+
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 {
38+
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 pipefail
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 pycodestyle ${PYTHON_MODULES} |& tee pycodestyle.log
51+
echo "\${PIPESTATUS[0]}" | tee pycodestyle_status.log
52+
python -m pydocstyle ${PYTHON_MODULES} |& tee pydocstyle.log
53+
echo "\${PIPESTATUS[0]}" | tee pydocstyle_status.log
54+
"""
55+
}
56+
}
57+
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+
}
66+
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+
}
82+
83+
stage('Codecov') {
84+
environment {
85+
CODECOV_TOKEN = credentials('codecov-token-mbdevpl-version-query')
86+
}
87+
steps {
88+
sh '''#!/usr/bin/env bash
89+
set -Eeuxo pipefail
90+
python -m codecov --token ${CODECOV_TOKEN}
91+
'''
92+
}
93+
}
94+
95+
}
96+
97+
}
98+
}
99+
}
100+
101+
post {
102+
unsuccessful {
103+
script {
104+
defaultHandlers.afterBuildFailed()
105+
}
106+
}
107+
regression {
108+
script {
109+
defaultHandlers.afterBuildBroken()
110+
}
111+
}
112+
fixed {
113+
script {
114+
defaultHandlers.afterBuildFixed()
115+
}
116+
}
117+
}
118+
119+
}

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ include LICENSE
44
include NOTICE
55
include ./*/py.typed
66

7-
include test_requirements.txt
7+
include requirements_test.txt
88
recursive-include ./test __init__.py
99
include test/examples.py

0 commit comments

Comments
 (0)