-
Notifications
You must be signed in to change notification settings - Fork 2
82 lines (77 loc) · 2.54 KB
/
python.yml
File metadata and controls
82 lines (77 loc) · 2.54 KB
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
name: python
on:
push:
branches: [main]
pull_request:
branches: [main]
paths:
- "fact/**"
- "test/**"
- "tools/**"
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: "3.9"
id: setup-python
- uses: actions/cache@v2
with:
path: |
~/.cache/pip
~/.cache/pypoetry/artifacts
~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-python${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-python${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
- name: Install Poetry
run: python -m pip install --user poetry
- name: Install dependencies
run: poetry install --no-interaction --no-root
- name: Format with black
run: poetry run black .
- name: Commit changes if any
run: |
git config user.name "GitHub Actions"
git config user.email "action@github.com"
if output=$(git status --porcelain) && [ ! -z "$output" ]; then
git commit -m "style: Automatic code formatting" -a
git push
fi
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
id: setup-python
- uses: actions/cache@v2
with:
path: |
~/.cache/pip
~/.cache/pypoetry/artifacts
~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-python${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-python${{ steps.setup-python.outputs.python-version }}-poetry-${{ hashFiles('poetry.lock') }}
- name: Install Poetry
run: python -m pip install --user poetry
- name: Install dependencies
run: poetry install --no-interaction --no-root
- name: Lint with flake8
run: poetry run flake8
- name: Type-check with mypy
run: poetry run mypy .
- name: Test with pytest
run: poetry run python -m pytest
# vim: set et ts=2 sw=2: