-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (136 loc) · 3.85 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: CI
on:
push:
branches:
- master
tags:
- v*
pull_request:
branches:
- master
env:
PYTHON_VERSION: 3.9
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: pre-commit/[email protected]
list:
runs-on: ubuntu-latest
name: Setup Matrix
outputs:
examples-matrix: ${{ steps.examples-matrix.outputs.examples }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Get experiments
id: examples-matrix
run: |
echo "::set-output name=examples::$(python .ci/list_examples.py)"
unittest:
strategy:
matrix:
python: [3.8, 3.9]
runs-on: ubuntu-latest
needs: [pre-commit]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: install
run: |
python -m pip install .[test]
- name: test
run: |
coverage run -m unittest discover -s tests/unit
coverage report -m --omit='tests/unit/*'
- if: ${{ matrix.python == '3.9' }}
name: Get Coverage for badge
run: |
coverage json
COVERAGE=$(LC_NUMERIC="en_US.UTF-8" printf "%.2f%%" $(cat coverage.json | jq .totals.percent_covered))
echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV
REF=${{ github.ref }}
echo "github.ref: $REF"
IFS='/' read -ra PATHS <<< "$REF"
BRANCH_NAME="${PATHS[1]}_${PATHS[2]}"
echo $BRANCH_NAME
echo "BRANCH=$(echo ${BRANCH_NAME})" >> $GITHUB_ENV
- if: ${{ matrix.python == '3.9' }}
name: Create the Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 9b54bd086e121233d2ad9a62d2136258
filename: frarch__${{ env.BRANCH }}.json
label: Test Coverage
message: ${{ env.COVERAGE }}
color: green
namedLogo: codecov
unittest-cross-platform:
strategy:
matrix:
os: [macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
needs: [pre-commit]
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: install
run: |
python -m pip install -q .[test]
- name: test
run: |
coverage run -m unittest discover -s tests/unit
coverage report -m --omit='tests/unit/*'
functional:
runs-on: ubuntu-latest
needs: [list]
strategy:
matrix:
examples: ${{ fromJSON(needs.list.outputs.examples-matrix) }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Set up yq
uses: frenck/action-setup-yq@v1
- name: install
run: |
python -m pip install -q .[test]
- name: Run ${{ matrix.example }}
run: |
./.ci/runExample.sh ${{ matrix.examples }}
package-and-release:
runs-on: ubuntu-latest
needs: [unittest, functional]
steps:
- name: checkout
uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: install
run: |
python -m pip install twine build
python -m build .
- name: Publish package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}