-
Notifications
You must be signed in to change notification settings - Fork 204
52 lines (49 loc) · 2.07 KB
/
github-actions-python.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
name: Python application
on: pull_request
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.5
uses: actions/setup-python@v3
with:
python-version: "3.5"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest paho-mqtt requests-mock jq
- name: Flake8 with annotations
uses: TrueBrain/actions-flake8@v2.1
with:
path: packages
- name: Test with pytest
run: |
PYTHONPATH=packages python -m pytest packages modules
- name: Check EditorConfig
run: |
curl --silent --location --output ec https://github.com/editorconfig-checker/editorconfig-checker/releases/download/2.6.0/ec-linux-amd64
chmod 700 ec
# Credits: awk-Script is based on: https://github.com/wow-rp-addons/actions-editorconfig-check/blob/5655d399e0bd89b5dbd705762265046d830d4377/action.yml#L56-L77
git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} HEAD | xargs ./ec -no-color -exclude '\.py$' -- | awk -F':' '
# Matches "path/to/file:" lines; each one will set a variable for
# the annotations we emit.
/^[a-zA-Z0-9_.\\/-]+:$/ {
file=substr($0, 1, length($0) - 1)
has_error=1
}
# Matches "<line number>: <message>" lines and annotates them with
# the last-found file path.
/^\t[0-9]+: .+$/ {
sub(/^\s+|\s+$/, "")
printf "::error file=%s,line=%s,title=.editorconfig check::%s\n", file, $1, substr($2, 2)
}
# As above but this is for diagnostics that do not have line numbers,
# such as "Wrong line endings or new final newline".
/^\t.+$/ {
sub(/^\s+|\s+$/, "")
printf "::error file=%s,title=.editorconfig check::%s\n", file, $1
}
END {exit has_error}'