Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Commit 3f4535b

Browse files
authored
Add CI/CD (#1)
* Add CI/CD pipeline with linting and formatting checks * Add release CI/CD workflow for automatic package release on PyPi
1 parent a33fa51 commit 3f4535b

File tree

6 files changed

+138
-4
lines changed

6 files changed

+138
-4
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Install dependencies
2+
3+
inputs:
4+
python_version:
5+
description: Version of python to prepare
6+
required: false
7+
default: "3.11"
8+
9+
runs:
10+
using: "composite"
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Set up Python ${{ inputs.python_version }}
14+
uses: actions/setup-python@v3
15+
with:
16+
python-version: ${{ inputs.python_version }}
17+
- name: Install dependencies
18+
shell: bash
19+
run: |
20+
python -m pip install --upgrade pip
21+
python -m pip install -r ci_requirements.txt

.github/workflows/quality.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Quality
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'pydocstyle_gitlab_code_quality/**'
7+
- 'ci_requirements.txt'
8+
- 'pyproject.toml'
9+
10+
jobs:
11+
pylint:
12+
name: Pylint - Python ${{ matrix.python_version }}
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
18+
steps:
19+
- uses: actions/checkout@v3
20+
- uses: ./.github/actions/install_dependencies
21+
with:
22+
python_version: ${{ matrix.python_version }}
23+
- name: Run pylint
24+
run: |
25+
pylint --output-format=colorized $(git ls-files '*.py')
26+
mypy:
27+
name: Mypy - Python ${{ matrix.python_version }}
28+
runs-on: ubuntu-latest
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
33+
steps:
34+
- uses: actions/checkout@v3
35+
- uses: ./.github/actions/install_dependencies
36+
with:
37+
python_version: ${{ matrix.python_version }}
38+
- name: Run mypy
39+
run: |
40+
mypy --config-file pyproject.toml .
41+
isort:
42+
name: Isort - Python ${{ matrix.python_version }}
43+
runs-on: ubuntu-latest
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
48+
steps:
49+
- uses: actions/checkout@v3
50+
- uses: ./.github/actions/install_dependencies
51+
with:
52+
python_version: ${{ matrix.python_version }}
53+
- name: Run isort
54+
run: |
55+
isort --settings-file pyproject.toml --check --diff --color .
56+
black:
57+
name: Black - Python ${{ matrix.python_version }}
58+
runs-on: ubuntu-latest
59+
strategy:
60+
fail-fast: false
61+
matrix:
62+
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
63+
steps:
64+
- uses: actions/checkout@v3
65+
- uses: ./.github/actions/install_dependencies
66+
with:
67+
python_version: ${{ matrix.python_version }}
68+
- name: Run black
69+
run: |
70+
black --config pyproject.toml --check --diff --color .

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release to PyPi
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish_to_pypi:
9+
name: Publish package to PyPi
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout the repository
13+
uses: actions/checkout@v3
14+
- name: Set up Python
15+
uses: actions/setup-python@v3
16+
with:
17+
python-version: 3.11
18+
- name: Install build and publish dependencies
19+
shell: bash
20+
run: |
21+
python -m pip install --upgrade pip
22+
python -m pip install build twine
23+
- name: Build package
24+
shell: bash
25+
run: |
26+
python -m build
27+
- name: Publish to PyPi
28+
shell: bash
29+
run: |
30+
python -m twine upload --non-interactive --username ${{ secrets.PYPI_USERNAME }} --password ${{ secrets.PYPI_PASSWORD }} --repository pypi dist/*

.vscode/extensions.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"recommendations": [
3+
"bungcip.better-toml",
4+
"kevinrose.vsc-python-indent",
5+
"ms-python.black-formatter",
6+
"ms-python.isort",
7+
"ms-python.mypy-type-checker",
8+
"ms-python.pylint",
9+
"ms-python.python",
10+
"ms-python.vscode-pylance",
11+
]
12+
}

.vscode/settings.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@
1717
"python.analysis.typeCheckingMode": "basic",
1818
"python.languageServer": "Pylance",
1919

20-
"python.linting.mypyEnabled": true,
21-
"python.linting.pylintEnabled": true,
22-
2320
"black-formatter.args": [ "--config", "pyproject.toml" ],
2421
"isort.args": [ "--settings-file", "pyproject.toml" ],
22+
"mypy-type-checker.args": ["--config-file", "pyproject.toml"],
2523
"pylint.args": [ "--rcfile", "pyproject.toml" ],
26-
"python.linting.mypyArgs": [ "--config-file", "pyproject.toml" ],
2724

2825
"python.testing.unittestEnabled": false,
2926
"python.testing.pytestEnabled": false,

ci_requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
black~=23.3.0
2+
isort[colors]~=5.11.0
3+
mypy~=1.4.1
4+
pylint~=2.17.4

0 commit comments

Comments
 (0)