generated from Danielhiversen/pyTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 13
93 lines (89 loc) · 3.11 KB
/
code_checker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Code-checker
on:
pull_request:
jobs:
black:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version:
- "3.11"
env:
SRC_FOLDER: custom_components/tibber_data
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install depencency
run: |
pip install isort black
- name: isort
run: isort $SRC_FOLDER
- name: Check for modified files
id: git-check-isort
run: git diff --quiet || echo "::set-output name=modified::true"
- name: Push changes isort
if: steps.git-check-isort.outputs.modified == 'true' && github.event.pull_request.head.repo.full_name == github.repository
run: |
git config --global user.name 'Daniel Hoyer'
git config --global user.email 'mail@dahoiv.net'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git fetch --depth=1;
git checkout $GITHUB_HEAD_REF
git commit -am "fixup! Format Python code with isort"
git push
- name: black
run: black $SRC_FOLDER
- name: Check for modified files
id: git-check-black
run: git diff --quiet || echo "::set-output name=modified::true"
- name: Push changes black
if: steps.git-check-black.outputs.modified == 'true' && github.event.pull_request.head.repo.full_name == github.repository
run: |
git config --global user.name 'Daniel Hoyer'
git config --global user.email 'mail@dahoiv.net'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git fetch --depth=1;
git checkout $GITHUB_HEAD_REF
git commit -am "fixup! Format Python code with black"
git push
- name: get sha
id: sha
run: |
sha_new=$(git rev-parse HEAD)
echo $sha_new
echo "::set-output name=SHA::$sha_new"
- run:
echo ${{ steps.sha.outputs.SHA }}
validate:
needs: black
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version:
- "3.11"
- "3.12"
env:
SRC_FOLDER: custom_components/tibber_data
steps:
- uses: actions/checkout@v2
with:
ref: ${{ needs.black.outputs.new_sha }}
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install depencency
run: |
pip install dlint flakeheaven flake8-deprecated flake8-executable pylint mypy homeassistant pyTibber
- name: Flake8 Code Linter
run: flakeheaven lint $SRC_FOLDER
# - name: Mypy Code Linter
# run: mypy $SRC_FOLDER
- name: Pylint Code Linter
run: pylint $SRC_FOLDER