-
Notifications
You must be signed in to change notification settings - Fork 0
204 lines (193 loc) · 6.09 KB
/
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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
name: tests
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
types:
- opened
- synchronize
- reopened
- ready_for_review
concurrency:
group: python-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
permissions:
pull-requests: write
contents: read
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
COVERALLS_PARALLEL: true
PYTHONPATH: src
STOCKTRACER_CACHE_DIR: .stocktracer-cache
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
python-version: ["3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: |
pipx install poetry
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
- run: poetry install --extras "tensorflow"
if: ${{ matrix.python-version == '3.10' }}
- run: poetry install
if: ${{ matrix.python-version != '3.10' }}
- name: Cache Network Requests
uses: actions/cache@v3
with:
key: sqlite-${{ hashFiles('**/tests/fixtures/network.py', '**/stocktracer/cache.py', 'smoke-test.sh') }}
path: |
${{ env.STOCKTRACER_CACHE_DIR }}/data.sqlite
${{ env.STOCKTRACER_CACHE_DIR }}/tickers.sqlite
if: ${{ !github.event.pull_request.draft }}
- name: Run - unit-tests
run: |
poetry run coverage run --concurrency=multiprocessing -m pytest --doctest-modules
# Just to cut down on network testing while initially iterating
- name: Run - network-tests
run: |
poetry run coverage run --concurrency=multiprocessing -a -m pytest -m webtest --run-webtest
if: ${{ !github.event.pull_request.draft }}
- name: Run - smoke-tests
run: |
./smoke-test.sh
if: ${{ !github.event.pull_request.draft && matrix.python-version == '3.10' }}
- name: Coveralls
run: |
poetry run coverage combine
poetry run coveralls --service=github
# - name: Coveralls
# uses: coverallsapp/github-action@v2
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# flag-name: run-${{ join(matrix.*, '-') }}
# parallel: true
# format: python
# if: ${{ success() }}
- uses: actions/upload-artifact@v3
with:
retention-days: 5
name: smoke-results ${{ matrix.python-version }}
path: ${{ github.workspace }}/docs/.smoke-tests
if: ${{ !github.event.pull_request.draft && matrix.python-version == '3.10'}}
# - name: Upload pytest test results
# uses: actions/upload-artifact@v3
# with:
# name: pytest-results-${{ matrix.python-version }}
# path: junit/test-results-${{ matrix.python-version }}.xml
# # Use always() to always run this step to publish test results when there are test failures
# if: ${{ always() }}
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: |
pipx install poetry
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10" # pylint wrapt not supported on 3.11 yet
cache: "poetry"
- run: poetry install --extras "tensorflow"
- name: Lint - Ruff
run: poetry run ruff src
if: ${{ always() }}
- name: Lint - Black
run: poetry run black --check src
if: ${{ always() }}
- name: Lint - isort
run: poetry run isort --check src
if: ${{ always() }}
- name: Lint - pylint (src/stocktracer)
run: poetry run pylint -E src/stocktracer
if: ${{ always() }}
# - name: Lint - pydocstyle
# run: |
# pydocstyle
# if: ${{ always() }}
- name: Lint - pydoctest
run: PYTHONPATH=src poetry run pydoctest --config pydocktest.json
if: ${{ always() }}
verify-packaging:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: |
pipx install poetry
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "poetry"
- run: poetry install
- name: Run Test
run: |
./verify-packaging.sh
finish:
needs: build
if: ${{ always() }}
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
cache: "pip"
- name: Install dependencies
run: |
pip install coveralls
- name: Coveralls Finished
run: |
coveralls --service=github --finish
# - name: Coveralls Finished
# uses: coverallsapp/github-action@v2
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# parallel-finished: true
# carryforward: "run-1,run-2,run-3"
docs:
runs-on: ubuntu-latest
needs: [build]
if: ${{ !github.event.pull_request.draft }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # so we get the correct modification date
- name: Install poetry
run: |
pipx install poetry
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "poetry"
- run: poetry install --with docs
- uses: actions/download-artifact@v3
with:
name: smoke-results 3.10
path: ${{ github.workspace }}/docs/.smoke-tests
- name: Test
if: github.ref != 'refs/heads/main'
run: |
poetry run mkdocs build --strict
- name: Deploy
if: github.ref == 'refs/heads/main'
run: |
poetry run mkdocs gh-deploy --force