Skip to content

Commit 13fd3af

Browse files
31chtumaisch
authored andcommitted
Remove unused .pypirc
1 parent a9d7dd5 commit 13fd3af

File tree

11 files changed

+134
-63
lines changed

11 files changed

+134
-63
lines changed

.gitlab-ci.yml

Lines changed: 69 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,55 @@
22
default:
33
image: mcr.microsoft.com/devcontainers/python:1-3.12-bookworm
44

5+
workflow:
6+
name: '$CI_COMMIT_AUTHOR: $CI_COMMIT_TITLE'
7+
auto_cancel:
8+
on_new_commit: interruptible
9+
on_job_failure: all
10+
rules:
11+
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
12+
variables:
13+
DEPLOY_ENV: "development"
14+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
15+
variables:
16+
DEPLOY_ENV: "staging"
17+
- if: $CI_COMMIT_BRANCH == $CI_COMMIT_TAG
18+
variables:
19+
DEPLOY_ENV: "production"
20+
- when: never
21+
522
stages:
623
- build
724
- test
825
- deploy
926

10-
include:
11-
- template: Jobs/Code-Quality.gitlab-ci.yml
12-
1327
build-python-package:
1428
stage: build
1529
before_script:
16-
- pipenv install --system --dev
17-
- pip install packaging
30+
- pip install uv
1831
script:
19-
- echo "Building the project..."
20-
- python -m build --wheel
32+
- tools/build-package.sh
2133
artifacts:
2234
paths:
23-
- dist
35+
- 'dist/*.whl'
2436
expire_in: 1 week
2537

2638
build-documentation:
2739
stage: build
2840
before_script:
29-
- pipenv install --system --dev
30-
- pip install -e .
31-
- pip install packaging
32-
- pip install tomli
33-
- pip install certifi
41+
- pip install uv
3442
script:
35-
- cd docs
36-
- pipenv run make html
37-
38-
code_quality:
39-
when: manual
43+
- tools/build-docs.sh
44+
artifacts:
45+
paths:
46+
- build/html/
4047

4148
test-python-package:
4249
stage: test
4350
before_script:
44-
- pipenv install --system --dev
45-
- pip install -e .
51+
- pip install uv
4652
script:
47-
- echo "Running unit tests"
48-
- pytest
53+
- tools/test-package.sh
4954
coverage: '/TOTAL.*\s+(\d+%)$/'
5055
artifacts:
5156
reports:
@@ -54,10 +59,49 @@ test-python-package:
5459
coverage_format: cobertura
5560
path: coverage.xml
5661

62+
lint-python-package:
63+
stage: test
64+
before_script:
65+
# TODO: Add flake8-gl-codeclimate as dependency
66+
- pip install flake8-gl-codeclimate
67+
- pip install uv
68+
script:
69+
- uv run --all-extras flake8 src/python_training_project --format gl-codeclimate --output-file gl-code-quality-report.json
70+
artifacts:
71+
reports:
72+
codequality: gl-code-quality-report.json
73+
74+
additional-mr-checks:
75+
stage: test
76+
script:
77+
- echo "Additional checks for merge requests"
78+
rules:
79+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
80+
5781
deploy-python-package:
5882
stage: deploy
5983
before_script:
60-
- pip install build twine
84+
- pip install uv
85+
variables:
86+
UV_PUBLISH_URL: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi
87+
UV_PUBLISH_USERNAME: gitlab-ci-token
88+
UV_PUBLISH_PASSWORD: ${CI_JOB_TOKEN}
89+
90+
script:
91+
- tools/deploy-package.sh
92+
93+
pages:
94+
stage: deploy
95+
script:
96+
- mv build/html/ public/
97+
artifacts:
98+
paths:
99+
- public/
100+
101+
job-for-tags:
102+
stage: deploy
61103
script:
62-
- echo "Deploying the package..."
63-
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
104+
- echo "Tag pipeline"
105+
rules:
106+
- if: $CI_COMMIT_TAG
107+

.pypirc

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

Jenkinsfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ pipeline {
7171
),
7272
flake8(pattern: 'build/flake8.txt'),
7373
pyLint(pattern: 'build/pylint.txt'),
74-
myPy(pattern: 'build/mypy.txt')
74+
myPy(pattern: 'build/mypy.txt'),
75+
pyLint(pattern: 'build/ruff.txt', id: 'ruff', name: 'Ruff')
7576
]
7677
)
7778
}

Jenkinsfile.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ node {
5656
),
5757
flake8(pattern: 'build/flake8.txt'),
5858
pyLint(pattern: 'build/pylint.txt'),
59-
myPy(pattern: 'build/mypy.txt')
59+
myPy(pattern: 'build/mypy.txt'),
60+
pyLint(pattern: 'build/ruff.txt', id: 'ruff', name: 'Ruff')
6061
]
6162
)
6263
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The Python package is based on the following toolchain:
2525
* [Flake8](https://flake8.pycqa.org/en/latest/) for style guide enforcement
2626
* [mypy](https://mypy-lang.org/) for static type checking
2727
* [Pylint](https://www.pylint.org/) for static code analysis
28+
* [Ruff](https://docs.astral.sh/ruff/) for linting and code formatting
2829
* [pytest](https://docs.pytest.org/en/stable/) for test creation and execution
2930

3031

pylint.log

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

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ dev-dependencies = [
4242
"pytest",
4343
"pytest-cov",
4444
"pytest-mock",
45+
"ruff",
4546
"sphinx",
4647
"sphinx-rtd-theme",
4748
]
@@ -69,3 +70,11 @@ omit = [
6970
output = "build/test-coverage.xml"
7071

7172
source_pkgs = ["python_training_project"]
73+
74+
[tool.ruff]
75+
include = [
76+
"pyproject.toml",
77+
"src/**/*.py",
78+
"tests/**/*.py"
79+
]
80+
output-format = "pylint"

src/python_training_project/__main__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
The main entry point contains the command line interface.
33
"""
4+
45
import logging
56
import sys
67

@@ -18,16 +19,17 @@ def cli():
1819
logging.basicConfig(
1920
stream=sys.stdout,
2021
level=logging.INFO,
21-
format='%(asctime)s %(name)-16s %(levelname)-8s %(message)s')
22+
format="%(asctime)s %(name)-16s %(levelname)-8s %(message)s",
23+
)
2224

2325

24-
@cli.command(name='sum')
25-
@click.argument('a', type=float)
26-
@click.argument('b', type=float)
26+
@cli.command(name="sum")
27+
@click.argument("a", type=float)
28+
@click.argument("b", type=float)
2729
def cli_sum(a: float, b: float):
2830
"""Show the sum of two numbers on the console."""
29-
log.info('Sum of %f and %f is %f', a, b, sum(a, b))
31+
log.info("Sum of %f and %f is %f", a, b, sum(a, b))
3032

3133

32-
if __name__ == '__main__':
34+
if __name__ == "__main__":
3335
cli()

src/python_training_project/calculate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ def sum(a: float, b: float) -> float:
77
"""Calculate the sum of two numbers."""
88
return a + b
99

10+
1011
# TODO: add more functions here

tools/lint-package.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,26 @@ if [ $? -ne 0 ]; then
1616
STATUS=1
1717
fi
1818

19+
echo "Running mypy..."
20+
uv run --all-extras mypy src/python_training_project > build/mypy.txt
21+
if [ $? -ne 0 ]; then
22+
STATUS=1
23+
fi
24+
1925
echo "Running pylint..."
2026
uv run --all-extras pylint src/python_training_project --msg-template="{path}:{line}: [{msg_id}, {obj}] {msg} ({symbol})" > build/pylint.txt
2127
if [ $? -ne 0 ]; then
2228
STATUS=1
2329
fi
2430

25-
echo "Running mypy..."
26-
uv run --all-extras mypy src/python_training_project > build/mypy.txt
31+
echo "Running ruff check..."
32+
uv run --all-extras ruff check > build/ruff.txt
33+
if [ $? -ne 0 ]; then
34+
STATUS=1
35+
fi
36+
37+
echo "Running ruff format..."
38+
uv run --all-extras ruff format --check
2739
if [ $? -ne 0 ]; then
2840
STATUS=1
2941
fi

0 commit comments

Comments
 (0)