Skip to content

Commit b3a97a9

Browse files
committed
Add github action
Add github action Add github action Add github action Add github action Add github action Add github action Add github action Add github action Add github action Add github action
1 parent 618aa44 commit b3a97a9

File tree

2 files changed

+258
-0
lines changed

2 files changed

+258
-0
lines changed

.github/workflows/control.yaml

+220
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
---
2+
name: Code Quality & Build
3+
4+
on: # yamllint disable-line rule:truthy
5+
workflow_dispatch:
6+
push:
7+
branches:
8+
- development
9+
- main
10+
- master
11+
paths:
12+
- "src/**"
13+
- "tests/**"
14+
15+
env:
16+
PYTHON_VERSION: "3.10"
17+
ARTIFACT_NAME: "mypkg"
18+
PACKAGE_NAME: "mypkg"
19+
20+
jobs:
21+
check:
22+
name: Check Python Code
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: "Checkout GitHub Action"
26+
uses: actions/checkout@v3
27+
28+
- name: Setup Python ${{ env.PYTHON_VERSION }} Environment
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: ${{ env.PYTHON_VERSION }}
32+
33+
- name: Install dependencies with Pip
34+
run: |
35+
python${{ env.PYTHON_VERSION }} -m venv .venv
36+
source .venv/bin/activate
37+
.venv/bin/pip install --upgrade pip
38+
.venv/bin/pip install -r requirements.txt
39+
.venv/bin/pip install -r requirements-dev.txt
40+
41+
- name: Initialize environment variables
42+
run: |
43+
CURRENT_PWD=$(pwd)
44+
PYTHONPATH="$CURRENT_PWD/src"
45+
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV
46+
WORKINGPATH="$CURRENT_PWD"
47+
echo "WORKINGPATH=$WORKINGPATH" >> $GITHUB_ENV
48+
49+
- name: Pyright
50+
id: pyright
51+
run: |
52+
. $WORKINGPATH/.venv/bin/activate
53+
pyright $PYTHONPATH -p $WORKINGPATH/tools/pyrightconfig.json
54+
55+
- name: Pylint
56+
id: pylint
57+
if: ${{ always() }}
58+
run: |
59+
. $WORKINGPATH/.venv/bin/activate
60+
pylint $PYTHONPATH/${{ env.PACKAGE_NAME }} --score=false
61+
62+
- name: Flake8
63+
id: flake8
64+
if: ${{ always() }}
65+
run: |
66+
. $WORKINGPATH/.venv/bin/activate
67+
flake8 $PYTHONPATH/${{ env.PACKAGE_NAME }}
68+
69+
- name: Mypy
70+
id: mypy
71+
if: ${{ always() }}
72+
run: |
73+
. $WORKINGPATH/.venv/bin/activate
74+
mypy $PYTHONPATH/${{ env.PACKAGE_NAME }}
75+
76+
- name: Pylama
77+
id: pylama
78+
if: ${{ always() }}
79+
run: |
80+
. $WORKINGPATH/.venv/bin/activate
81+
pylama $PYTHONPATH/${{ env.PACKAGE_NAME }}
82+
83+
- name: Yapf
84+
id: yapf
85+
if: ${{ always() }}
86+
run: |
87+
. $WORKINGPATH/.venv/bin/activate
88+
yapf --diff $PYTHONPATH/${{ env.PACKAGE_NAME }} --recursive
89+
90+
- name: Linter Results
91+
if: |
92+
(success() || failure())
93+
&& (steps.flake8.outcome == 'failure'
94+
|| steps.mypy.outcome == 'failure'
95+
|| steps.pylama.outcome == 'failure'
96+
|| steps.pylint.outcome == 'failure'
97+
|| steps.pyright.outcome == 'failure'
98+
|| steps.yapf.outcome == 'failure')
99+
run: |
100+
echo "Pyright: ${{ steps.pyright.outcome }}"
101+
echo "Pylint: ${{ steps.pylint.outcome }}"
102+
echo "Pylint: ${{ steps.pylama.outcome }}"
103+
echo "Flake8: ${{ steps.flake8.outcome }}"
104+
echo "Mypy: ${{ steps.mypy.outcome }}"
105+
echo "Yapf: ${{ steps.yapf.outcome }}"
106+
echo "On failure, please check the previous steps to identify the linter issue(s)."
107+
exit 1
108+
109+
unit_test:
110+
name: Unit Tests Python
111+
runs-on: ubuntu-latest
112+
needs: [check]
113+
steps:
114+
- name: "Checkout GitHub Action"
115+
uses: actions/checkout@v3
116+
117+
- name: Setup Python ${{ env.PYTHON_VERSION }} Environment
118+
uses: actions/setup-python@v4
119+
with:
120+
python-version: ${{ env.PYTHON_VERSION }}
121+
122+
- name: Install dependencies with Pip
123+
run: |
124+
python${{ env.PYTHON_VERSION }} -m venv .venv
125+
source .venv/bin/activate
126+
.venv/bin/pip install --upgrade pip
127+
.venv/bin/pip install -r requirements.txt
128+
.venv/bin/pip install -r requirements-test.txt
129+
130+
- name: Initialize environment variables
131+
run: |
132+
CURRENT_PWD=$(pwd)
133+
PYTHONPATH="$CURRENT_PWD/src"
134+
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV
135+
WORKINGPATH="$CURRENT_PWD"
136+
echo "WORKINGPATH=$WORKINGPATH" >> $GITHUB_ENV
137+
138+
- name: Pytest
139+
id: pytest
140+
run: |
141+
. $WORKINGPATH/.venv/bin/activate
142+
cd $WORKINGPATH
143+
pytest tests -vv -s -n auto
144+
145+
- name: Coverage Analysis
146+
id: coverage
147+
run: |
148+
. $WORKINGPATH/.venv/bin/activate
149+
cd $WORKINGPATH
150+
coverage run -m pytest tests -q --disable-warnings
151+
152+
- name: Coverage Report
153+
id: coverage_report
154+
run: |
155+
. $WORKINGPATH/.venv/bin/activate
156+
cd $WORKINGPATH
157+
coverage report -m
158+
159+
configuration:
160+
name: Check User Configuration
161+
runs-on: ubuntu-latest
162+
steps:
163+
- name: "Checkout GitHub Action"
164+
uses: actions/checkout@v3
165+
166+
- name: Setup Python ${{ env.PYTHON_VERSION }} Environment
167+
uses: actions/setup-python@v4
168+
with:
169+
python-version: ${{ env.PYTHON_VERSION }}
170+
171+
- name: Initialize environment variables
172+
run: |
173+
CURRENT_PWD=$(pwd)
174+
PYTHONPATH="$CURRENT_PWD/src"
175+
echo "PYTHONPATH=$PYTHONPATH" >> $GITHUB_ENV
176+
WORKINGPATH="$CURRENT_PWD"
177+
echo "WORKINGPATH=$WORKINGPATH" >> $GITHUB_ENV
178+
179+
- name: Install dependencies with Pip
180+
run: |
181+
pip install yamllint
182+
183+
- name: "YAML Lint"
184+
id: yaml_lint
185+
run: |
186+
yamllint $PYTHONPATH/${{ env.PACKAGE_NAME }}
187+
188+
- name: Configuration Results
189+
if: (success() || failure()) && (steps.yaml_lint.outcome == 'failure')
190+
run: |
191+
echo "YAML Lint: ${{ steps.yaml_lint.outcome }}"
192+
echo "On failure, please check the previous steps to identify the linter issue(s)."
193+
exit 1
194+
195+
build:
196+
name: Build
197+
needs: [check, configuration, unit_test]
198+
runs-on: ubuntu-latest
199+
if: github.ref == 'refs/heads/master'
200+
steps:
201+
- name: "Checkout GitHub Action"
202+
uses: actions/checkout@v3
203+
204+
- name: Initialize environment variables
205+
run: |
206+
CURRENT_PWD=$(pwd)
207+
WORKINGPATH="$CURRENT_PWD"
208+
echo "WORKINGPATH=$WORKINGPATH" >> $GITHUB_ENV
209+
210+
- uses: actions/upload-artifact@v3
211+
with:
212+
name: ${{ env.ARTIFACT_NAME }}
213+
path: |
214+
${{ env.WORKINGPATH }}
215+
!${{ env.WORKINGPATH }}/.devcontainer
216+
!${{ env.WORKINGPATH }}/.git
217+
!${{ env.WORKINGPATH }}/.github
218+
!${{ env.WORKINGPATH }}/.vscode
219+
!${{ env.WORKINGPATH }}/tests
220+
!${{ env.WORKINGPATH }}/tools

.yamllint

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
yaml-files:
3+
- "*.yaml"
4+
- "*.yml"
5+
- ".yamllint"
6+
7+
rules:
8+
anchors: enable
9+
braces: enable
10+
brackets: enable
11+
colons: enable
12+
commas: enable
13+
comments-indentation:
14+
level: warning
15+
document-end: disable
16+
document-start:
17+
level: warning
18+
empty-lines: enable
19+
empty-values: disable
20+
float-values: disable
21+
hyphens: enable
22+
indentation: enable
23+
key-duplicates: enable
24+
key-ordering: disable
25+
new-line-at-end-of-file: enable
26+
new-lines: enable
27+
octal-values: disable
28+
quoted-strings: disable
29+
trailing-spaces: enable
30+
truthy:
31+
level: warning
32+
line-length:
33+
max: 150
34+
allow-non-breakable-words: true
35+
allow-non-breakable-inline-mappings: false
36+
comments:
37+
level: warning
38+
min-spaces-from-content: 1

0 commit comments

Comments
 (0)