Skip to content

Commit fad0804

Browse files
authored
Merge pull request #913 from sir-gon/feature/pipenv
[BUGFIX] sonarcloud: Omitting "--only-binary :all:" can lead to the execution of setup scripts. Make sure it is safe here.
2 parents a1ac5e1 + 25df52d commit fad0804

9 files changed

Lines changed: 797 additions & 47 deletions

File tree

.github/workflows/python-coverage.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ env:
1515
jobs:
1616
coverage:
1717
name: "Python CI Coverage"
18-
strategy:
19-
fail-fast: false
20-
matrix:
21-
os: ["ubuntu-24.04"]
22-
python: ["3.14"]
23-
runs-on: ${{ matrix.os }}
18+
runs-on: ubuntu-24.04
2419
steps:
2520
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
2621
with:
@@ -30,30 +25,41 @@ jobs:
3025
- name: Setup Python
3126
uses: actions/setup-python@master
3227
with:
33-
python-version: ${{ matrix.python }}
28+
python-version: 3.14
29+
30+
- name: Install tooling
31+
run: >
32+
sudo apt install pipenv
33+
34+
- name: Tooling check
35+
run: |
36+
python3 --version
37+
pipenv --version
38+
make --version
3439
3540
- name: Install
3641
run: |
37-
pip3 install -r requirements.txt
42+
# Use the lockfile to install deterministic, audited dependencies
43+
pipenv sync --dev
3844
3945
- name: Test an coverage collect
4046
run: >
41-
python3 -m coverage run -m pytest --verbose
47+
pipenv run coverage run -m pytest --verbose
4248
-o log_cli=true
4349
--log-cli-level=INFO
4450
src/
4551
4652
- name: Coverage Report
4753
run: |
48-
python3 -m coverage report
54+
pipenv run coverage report
4955
5056
- name: Coverage lcov (codecov)
5157
run: |
52-
python3 -m coverage lcov -o coverage/lcov.info
58+
pipenv run coverage lcov -o coverage/lcov.info
5359
5460
- name: Coverage xml (sonarcloud)
5561
run: |
56-
python3 -m coverage xml -o coverage/coverage.xml
62+
pipenv run coverage xml -o coverage/coverage.xml
5763
5864
- name: Upload coverage artifact
5965
uses: actions/upload-artifact@v7

.github/workflows/python-lint.yml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,52 @@ jobs:
2626
with:
2727
python-version: ${{ matrix.python }}
2828

29+
- name: Install tooling on Ubuntu
30+
if: runner.os == 'Linux'
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get install -y pipenv
34+
shell: bash
35+
36+
- name: Install tooling on macOS
37+
if: runner.os == 'macOS'
38+
run: |
39+
brew install pipenv
40+
shell: bash
41+
42+
- name: Install tooling on Windows
43+
if: runner.os == 'Windows'
44+
run: |
45+
python -m pip install --user pipenv==2026.6.1
46+
shell: pwsh
47+
48+
- name: Tooling check
49+
run: |
50+
python3 --version
51+
pipenv --version
52+
make --version
53+
2954
- name: Install
3055
run: |
31-
pip3 install -r requirements.txt
56+
# Use the lockfile to install deterministic, audited dependencies
57+
pipenv sync --dev
3258
3359
- name: Lint (pylint)
3460
run: |
35-
pylint --verbose --recursive yes src/
61+
pipenv run pylint --verbose --recursive yes src/
3662
3763
- name: Lint (flake8)
3864
run: |
39-
python3 -m flake8 --verbose src/
65+
pipenv run flake8 --verbose src/
4066
4167
- name: Lint (pyright) static type checker
4268
run: |
43-
python3 -m pyright --verbose src/
69+
pipenv run pyright --verbose src/
4470
4571
- name: Styling (pycodestyle)
4672
run: |
47-
python3 -m pycodestyle --statistics src/
73+
pipenv run pycodestyle --statistics src/
4874
4975
- name: Styling (autopep8)
5076
run: |
51-
python3 -m autopep8 --diff --recursive --exit-code --verbose .
77+
pipenv run autopep8 --diff --recursive --exit-code --verbose .

.github/workflows/python-test.yml

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,43 @@ jobs:
2929
with:
3030
python-version: ${{ matrix.python }}
3131

32+
- name: Install tooling on Ubuntu
33+
if: runner.os == 'Linux'
34+
run: |
35+
sudo apt-get update
36+
sudo apt-get install -y pipenv
37+
shell: bash
38+
39+
- name: Install tooling on macOS
40+
if: runner.os == 'macOS'
41+
run: |
42+
brew install pipenv
43+
shell: bash
44+
45+
- name: Install tooling on Windows
46+
if: runner.os == 'Windows'
47+
run: |
48+
python -m pip install --user pipenv==2026.6.1
49+
shell: pwsh
50+
51+
- name: Tooling check
52+
run: |
53+
python3 --version
54+
pipenv --version
55+
make --version
56+
3257
- name: Install
3358
run: |
34-
pip3 install -r requirements.txt
59+
# Use the lockfile to install deterministic, audited dependencies
60+
pipenv sync --dev
3561
3662
- name: Test
3763
run: >
38-
coverage run -m pytest --verbose
64+
pipenv run coverage run -m pytest --verbose
3965
-o log_cli=true
4066
--log-cli-level=INFO
4167
src/
4268
4369
- name: Coverage
4470
run: |
45-
coverage report
71+
pipenv run coverage report

.github/workflows/yamllint.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,17 @@ jobs:
1717
- name: Checkout repository
1818
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
1919

20+
- name: Set up Python
21+
uses: actions/setup-python@v6
22+
with:
23+
python-version: 3.14
24+
25+
- name: Install pipenv
26+
run: >
27+
sudo apt install pipenv
2028
- name: Install yamllint
21-
run: pip install yamllint
29+
run: >
30+
pipenv sync --dev
2231
2332
- name: Lint YAML files
2433
run: >

Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@ RUN apk add --update --no-cache make \
1313
FROM init AS base
1414

1515
ENV WORKDIR=/app
16+
ENV LANG=C.UTF-8
1617
WORKDIR ${WORKDIR}
1718

1819
COPY ./Makefile ${WORKDIR}/
19-
COPY ./requirements.txt ${WORKDIR}/
20-
RUN make dependencies
20+
COPY Pipfile ${WORKDIR}/
21+
COPY Pipfile.lock ${WORKDIR}/
22+
23+
RUN python -m pip install --no-cache-dir --root-user-action=ignore pipenv==2026.6.1
24+
RUN pipenv sync --dev --python=$(which python)
2125

2226
###############################################################################
2327
FROM base AS lint

Makefile

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ BRUTEFORCE :=$(shell echo '${BRUTEFORCE}'| tr '[:lower:]' '[:upper:]'| tr -d '[:
2727
.EXPORT_ALL_VARIABLES: # (2)
2828

2929
RUNTIME_TOOL=python3
30-
PACKAGE_TOOL=pip3
30+
PACKAGE_TOOL=pipenv
3131

3232
# DOCKER
3333
BUILDKIT_PROGRESS=plain
@@ -36,11 +36,10 @@ DOCKER_COMPOSE=docker compose
3636
help: list
3737
@echo ""
3838
@echo "Note: create and activate the environment in your local shell type (example):"
39-
@echo " python3 -m venv ./.venv"
40-
@echo " source .venv/bin/activate"
39+
@echo " pipenv install --dev"
40+
@echo " pipenv shell"
4141
@echo "See: "
42-
@echo " https://docs.python.org/3/library/venv.html#creating-virtual-environments"
43-
@echo " https://docs.python.org/3/library/venv.html#how-venvs-work"
42+
@echo " https://pipenv.pypa.io/en/latest/"
4443

4544
list:
4645
@LC_ALL=C $(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
@@ -65,20 +64,20 @@ dependencies:
6564
@echo "################################################################################"
6665
@echo "## Dependencies: ###############################################################"
6766
@echo "################################################################################"
68-
${PACKAGE_TOOL} install -r requirements.txt
67+
${PACKAGE_TOOL} install --dev
6968
@echo "################################################################################"
7069

7170
outdated:
72-
${PACKAGE_TOOL} list --outdated
71+
${PACKAGE_TOOL} update --outdated
7372

7473
update:
75-
${PACKAGE_TOOL} freeze > requirements.txt
74+
${PACKAGE_TOOL} lock --requirements > requirements.txt
7675

7776
upgrade:
78-
${PACKAGE_TOOL} list --outdated | cut -f1 -d' ' | tr " " "\n" | awk '{if(NR>=3)print}' | cut -d' ' -f1 | xargs -n1 pip3 install -U
77+
${PACKAGE_TOOL} update --dev
7978

8079
clean:
81-
${PACKAGE_TOOL} freeze > unins ; ${PACKAGE_TOOL} uninstall -y -r unins ; rm unins
80+
${PACKAGE_TOOL} --rm || true
8281
rm -f .coverage
8382
rm -fr .pytest_cache
8483
rm -fr htmlcov
@@ -113,37 +112,37 @@ format/json:
113112
prettier --write ./src/**/*.json
114113

115114
format/sources:
116-
${RUNTIME_TOOL} -m autopep8 --in-place --recursive --aggressive --aggressive --verbose src/
115+
${PACKAGE_TOOL} run autopep8 --in-place --recursive --aggressive --aggressive --verbose src/
117116

118117
format: format/sources format/json
119118

120119
## Static code analysis
121120
test/static: dependencies
122-
${RUNTIME_TOOL} -m pylint --verbose --recursive yes src/
123-
${RUNTIME_TOOL} -m flake8 --verbose src/
124-
${RUNTIME_TOOL} -m pyright --verbose src/
121+
${PACKAGE_TOOL} run pylint --verbose --recursive yes src/
122+
${PACKAGE_TOOL} run flake8 --verbose src/
123+
${PACKAGE_TOOL} run pyright --verbose src/
125124

126125
test/styling: dependencies
127-
${RUNTIME_TOOL} -m pycodestyle --statistics src/
128-
${RUNTIME_TOOL} -m autopep8 --diff --recursive --exit-code --verbose .
126+
${PACKAGE_TOOL} run pycodestyle --statistics src/
127+
${PACKAGE_TOOL} run autopep8 --diff --recursive --exit-code --verbose .
129128

130129
## Unit tests and coverage
131130
test: env dependencies
132-
${RUNTIME_TOOL} -m coverage run -m \
131+
${PACKAGE_TOOL} run coverage run -m \
133132
pytest --verbose \
134133
-o log_cli=true \
135134
--log-cli-level=${LOG_LEVEL} \
136135
--full-trace src/
137-
${RUNTIME_TOOL} -m coverage report
136+
${PACKAGE_TOOL} run coverage report
138137

139138
coverage: test
140-
${RUNTIME_TOOL} -m coverage lcov -o coverage/lcov.info
139+
${PACKAGE_TOOL} run coverage lcov -o coverage/lcov.info
141140

142141
coverage/xml: test
143-
${RUNTIME_TOOL} -m coverage xml -o coverage/coverage.xml
142+
${PACKAGE_TOOL} run coverage xml -o coverage/coverage.xml
144143

145144
coverage/html: test
146-
${RUNTIME_TOOL} -m coverage html
145+
${PACKAGE_TOOL} run coverage html
147146
open htmlcov/index.html
148147

149148
## Docker Compose commands

Pipfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
8+
[dev-packages]
9+
yamllint = "==1.32.0"
10+
astroid = "==4.0.3"
11+
attrs = "==26.1.0"
12+
autopep8 = "==2.3.2"
13+
coverage = "==7.13.5"
14+
dill = "==0.4.1"
15+
exceptiongroup = "==1.3.1"
16+
flake8 = "==7.3.0"
17+
iniconfig = "==2.3.0"
18+
isort = "==8.0.1"
19+
lazy-object-proxy = "==1.12.0"
20+
mccabe = "==0.7.0"
21+
nodeenv = "==1.10.0"
22+
packaging = "==26.2"
23+
platformdirs = "==4.9.6"
24+
pluggy = "==1.6.0"
25+
pycodestyle = "==2.14.0"
26+
pyflakes = "==3.4.0"
27+
pylint = "==4.0.5"
28+
pyright = "==1.1.409"
29+
pytest = "==9.0.3"
30+
pytest-cov = "==7.1.0"
31+
tomli = "==2.4.1"
32+
tomlkit = "==0.14.0"
33+
typing-extensions = "==4.15.0"
34+
wrapt = "==2.1.2"
35+
zipp = ">=3.23.1"
36+
37+
[requires]
38+
python_version = "3"

0 commit comments

Comments
 (0)