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

Commit 0167d70

Browse files
committed
CI/CD: Added linting and build/publish workflow
1 parent 8b1fd14 commit 0167d70

File tree

3 files changed

+174
-1
lines changed

3 files changed

+174
-1
lines changed

.github/workflows/linting.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Linting
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
7+
jobs:
8+
lint-flake8:
9+
name: Linting with flake8
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Setup Python
14+
uses: actions/setup-python@v5
15+
with:
16+
python-version: '3.11'
17+
cache: 'pip'
18+
cache-dependency-path: |
19+
requirements.txt
20+
requirements-dev.txt
21+
- uses: actions/cache@v4
22+
with:
23+
path: ~/.cache/pip
24+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
25+
restore-keys: |
26+
${{ runner.os }}-pip-
27+
- name: Install requirements
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install -r requirements-dev.txt
31+
- name: Lint with flake8
32+
run: flake8 --max-line-length=120 . --exclude env,configuration,venv,src,scripts,.venv,e2e
33+
34+
lint-black:
35+
name: Linting with black
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
- name: Setup Python
40+
uses: actions/setup-python@v5
41+
with:
42+
python-version: '3.11'
43+
cache: 'pip'
44+
cache-dependency-path: |
45+
requirements.txt
46+
requirements-dev.txt
47+
- uses: actions/cache@v4
48+
with:
49+
path: ~/.cache/pip
50+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
51+
restore-keys: |
52+
${{ runner.os }}-pip-
53+
- name: Install requirements
54+
run: |
55+
python -m pip install --upgrade pip
56+
pip install -r requirements-dev.txt
57+
- name: Lint with black
58+
run: black flask_utils -l119 --check
59+
60+
lint-imports-order:
61+
name: Checking imports order
62+
runs-on: ubuntu-latest
63+
steps:
64+
- uses: actions/checkout@v4
65+
- name: Setup Python
66+
uses: actions/setup-python@v5
67+
with:
68+
python-version: '3.11'
69+
cache: 'pip'
70+
cache-dependency-path: |
71+
requirements.txt
72+
requirements-dev.txt
73+
- uses: actions/cache@v4
74+
with:
75+
path: ~/.cache/pip
76+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
77+
restore-keys: |
78+
${{ runner.os }}-pip-
79+
- name: Install requirements
80+
run: |
81+
python -m pip install --upgrade pip
82+
pip install -r requirements-dev.txt
83+
- name: Lint with reorder-python-imports
84+
run: reorder-python-imports flask_utils/**/*.py tests/*.py
85+
86+
lint-typing:
87+
name: Checking Typing with MyPy
88+
runs-on: ubuntu-latest
89+
steps:
90+
- uses: actions/checkout@v4
91+
- name: Setup Python
92+
uses: actions/setup-python@v5
93+
with:
94+
python-version: '3.11'
95+
cache: 'pip'
96+
cache-dependency-path: |
97+
requirements.txt
98+
requirements-dev.txt
99+
- uses: actions/cache@v4
100+
with:
101+
path: ~/.cache/pip
102+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
103+
restore-keys: |
104+
${{ runner.os }}-pip-
105+
- name: Install requirements
106+
run: |
107+
python -m pip install --upgrade pip
108+
pip install -r requirements-dev.txt
109+
pip install types-flask
110+
- name: Lint with mypy
111+
run: mypy flask_utils

.github/workflows/publish.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Publish Python Package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
needs:
11+
- set_version
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: '3.11'
19+
- name: Install dependencies
20+
run: |
21+
python3.11 -m pip install --upgrade pip
22+
python3.11 -m pip install --upgrade setuptools wheel twine build
23+
- name: Create Github Release
24+
id: create_release
25+
uses: softprops/action-gh-release@v2
26+
with:
27+
draft: false
28+
prerelease: false
29+
tag_name: v${{ needs.set_version.outputs.version }}
30+
generate_release_notes: true
31+
- name: Upload .whl artifact to GitHub release
32+
uses: actions/upload-release-asset@v1
33+
env:
34+
GITHUB_TOKEN: ${{ github.token }}
35+
with:
36+
upload_url: ${{ steps.create_release.outputs.upload_url }}
37+
asset_path: ./dist/flask_utils-${{ needs.set_version.outputs.version }}-py3-none-any.whl
38+
asset_name: flask_utils-${{ needs.set_version.outputs.version }}-py3-none-any.whl
39+
asset_content_type: application/zip
40+
- name: Upload .tar.gz artifact to GitHub release
41+
uses: actions/upload-release-asset@v1
42+
env:
43+
GITHUB_TOKEN: ${{ github.token }}
44+
with:
45+
upload_url: ${{ steps.create_release.outputs.upload_url }}
46+
asset_path: ./dist/flask_utils-${{ needs.set_version.outputs.version }}.tar.gz
47+
asset_name: flask_utils-${{ needs.set_version.outputs.version }}.tar.gz
48+
asset_content_type: application/gzip
49+
50+
set_version:
51+
name: Set the version of the release
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Checkout
55+
uses: actions/checkout@v4
56+
57+
- name: Set version
58+
id: set_version
59+
run: |
60+
echo version=$( sed -e 's/__version__ = "\(.*\)"/\1/g' <<< $(grep -E '__version__ = ' flask_utils/__init__.py)) >> "$GITHUB_OUTPUT"
61+
outputs:
62+
version: ${{ steps.set_version.outputs.version }}

flask_utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Increment versions here according to SemVer
2-
__version__ = "0.1.1"
2+
__version__ = "0.1.2"
33

44
from flask_utils.errors import ConflictError
55
from flask_utils.errors import ForbiddenError

0 commit comments

Comments
 (0)