-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (71 loc) · 2.81 KB
/
.github_ci.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
# This workflow is based on the Python package workflow
# It will install Python dependencies, run tests and lint with a set of recent Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Github CI
on:
push:
branches:
- main
- "dev/**"
pull_request:
branches:
- main
- "dev/**"
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
# Reference: https://github.community/t/create-matrix-with-multiple-os-and-env-for-each-one/16895
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry dependency manager
shell: bash
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Configure poetry
shell: bash
run: poetry config virtualenvs.in-project true
# These cache steps prevent unnecessary full dependency builds from scratch
# and save build time overall.
- name: Set up cache
uses: actions/cache@v2
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
shell: bash
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
- name: Install dependencies (if there are new ones)
shell: bash
run: poetry install
- name: Lint with flake8 using Poetry
# stop the build if there are Python syntax errors or undefined names
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
run: |
poetry run flake8 ./hon_patch_notes_game_bot --count --select=E9,F63,F7,F82 --show-source --statistics
poetry run flake8 ./hon_patch_notes_game_bot --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Run optional static type checking with mypy
run: |
poetry run mypy .
- name: Run bandit to check for vulnerabilities
run: |
poetry run bandit -r ./hon_patch_notes_game_bot/
- name: Run Pytest and generate coverage report
run: |
poetry run pytest --cov=hon_patch_notes_game_bot tests/ --cov-report=term-missing --cov-report=xml
- name: "Upload coverage report to Codecov"
uses: codecov/codecov-action@v1
with:
files: coverage.xml
fail_ci_if_error: true
verbose: true