-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (91 loc) · 3.59 KB
/
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
88
89
90
91
92
93
####################################################################################################
# Continuous Integration [Lint, Test, Build] on All Pull-Requests + Push to Master
####################################################################################################
# References:
# - https://github.com/snok/install-poetry
# - https://github.com/actions/setup-python#caching-packages-dependencies
# - https://stackoverflow.com/questions/62977821/how-to-cache-poetry-install-for-github-actions
# - https://github.com/codecov/codecov-action
####################################################################################################
name: build
on:
push:
branches: ["master"]
pull_request:
jobs:
ci:
#----------------------------------------------
# ----- setup operating system (os) -----
#----------------------------------------------
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# TODO(amir): add "windows-latest"
os: ["ubuntu-latest", "macos-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
#----------------------------------------------
# ----- check-out repo and set-up python -----
#----------------------------------------------
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Python v${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
#----------------------------------------------
# ----- load cached dependencies -----
#----------------------------------------------
- name: Load Cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-v${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# ----- install dependencies -----
#----------------------------------------------
- name: Install Dependencies
run: poetry install -vv
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
#----------------------------------------------
# ----- Integration test suite -----
#----------------------------------------------
# TODO(amir): de-dup the `source .venv/bin/activate` (`source $VENV`) command
- name: Lint
run: |
source $VENV
poe check
- name: Test
run: |
source $VENV
poe test
- name: Build
run: |
source $VENV
poetry build
#----------------------------------------------
# --- Upload test coverage to Codecov ---
#----------------------------------------------
- name: Codecov
# NOTE: only run code coverage with one Python Version and OS; the rest is not needed
if: ${{ matrix.python-version == '3.9' && matrix.os == 'macos-latest' }}
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./xmlcov/
fail_ci_if_error: true
files: ./xmlcov/coverage.xml
flags: unittests
name: codecov-umbrella
verbose: true