-
-
Notifications
You must be signed in to change notification settings - Fork 73
223 lines (208 loc) · 8.65 KB
/
w11-workflow-test-coverage.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# """
# The MIT License (MIT)
# Copyright (c) 2023 pkjmesra
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# """
name: 11. pkscreener Test Coverage
on:
# schedule:
# # # Nightly at 1:32 A.M. UTC
# - cron: "32 1 */1 * *"
# push:
# branches:
# - main
# # Release branches of the format 0.45.20240910.554
# - "[0-9]+.[0-9]+.[0-9]+.[0-9]"
pull_request:
branches:
- main
- "[0-9]+.[0-9]+.[0-9]+.[0-9]"
workflow_dispatch:
inputs:
branch-name:
description: 'Branch name'
required: false
default: 'main'
targetPythonVersion:
description: 'Target Python version: 3.9 , 3.10, 3.11 ?'
required: false
type: string
default: '3.11'
workflow_call:
inputs:
branch-name:
required: true
type: string
default: 'new-features'
targetPythonVersion:
description: 'Target Python version: 3.9 , 3.10, 3.11 ?'
required: false
type: string
default: '3.11'
jobs:
# Job for testing coverage
Build:
name: Build and test/update coverage
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-20.04
TARGET: Linux
CMD_BUILD: |
rm -rf .pytest_cache
rm -rf pkscreener/__pycache__
rm -rf test/__pycache__
rm -rf test/.coverage
rm -rf .coverage
find . -name "*.pyc" -exec rm -rf {} \;
sudo find /tmp/ -name "*.py" -exec rm -rf {} \;
find . -name ".coverage.*" -exec rm -rf {} \;
DEP_BUILD: |
cd .github/dependencies/
pwd
tar -xzf ta-lib-0.4.0-src.tar.gz
cd ta-lib/
./configure --prefix=/usr
make
sudo make install
cd /home/runner/work/PKScreener/PKScreener/
python3 -m pip install --upgrade pip
pip3 install -r requirements.txt
pip3 install -r requirements-dev.txt
pip3 install ta-lib==0.4.32
pip3 install .
# note: the following also installs "coverage"
python3 -m pip install coveralls
TEST_BUILD: |
coverage erase
coverage run --source=${package_name} --branch -m pytest -vv --durations-min=0.005 --cov-config=.coveragerc --durations=0
coverage combine
# quick local report output to console:
coverage report -i
coverage html -i
coverage xml -i
curl -s https://codecov.io/bash | bash
coveralls --service=github
# coverage run --source=${package_name} --branch -m pytest --cov=pkscreener test/
# coveralls --service=github
- os: windows-latest
TARGET: Windows
CMD_BUILD: |
echo Building
DEP_BUILD: |
python3 -m pip install --upgrade pip
echo Installing TA-lib...
cd .github/dependencies/
if [[ "${{ inputs.targetPythonVersion }}" == "" ]] ;then
pip3 install TA_Lib-0.4.29-cp311-cp311-win_amd64.whl
elif [[ "${{ inputs.targetPythonVersion }}" == "3.9" ]] ;then
pip3 install TA_Lib-0.4.19-cp39-cp39-win_amd64.whl
elif [[ "${{ inputs.targetPythonVersion }}" == "3.11" ]] ;then
pip3 install TA_Lib-0.4.29-cp311-cp311-win_amd64.whl
elif [[ "${{ inputs.targetPythonVersion }}" == "3.12" ]] ;then
pip3 install TA_Lib-0.4.29-cp312-cp312-win_amd64.whl
fi
cd ..
cd ..
python3 -m pip install --upgrade pip
pip3 install -r requirements.txt
pip3 install -r requirements-dev.txt
pip3 install .
TEST_BUILD: |
pytest -vv --durations-min=0.005 --cov-config=.coveragerc --durations=0
- os: macos-latest
TARGET: MacOS
CMD_BUILD: |
rm -rf .pytest_cache
rm -rf pkscreener/__pycache__
rm -rf test/__pycache__
rm -rf test/.coverage
rm -rf .coverage
find . -name "*.pyc" -exec rm -rf {} \;
find . -name ".coverage.*" -exec rm -rf {} \;
DEP_BUILD: |
brew install ta-lib
python3 -m pip install --upgrade pip
pip3 install -r requirements.txt
pip3 install -r requirements-dev.txt
pip3 install ta-lib==0.4.32
pip3 install .
TEST_BUILD: |
pytest -vv --durations-min=0.005 --cov-config=.coveragerc --durations=0
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch-name || github.head_ref || github.ref }}
- name: Declare env variables
id: vars
env:
CHAT_ID_DEV : ${{secrets.CHAT_ID_DEV}}
TOKEN_DEV : ${{secrets.TOKEN_DEV}}
CHAT_IDADMIN_DEV : ${{secrets.CHAT_IDADMIN_DEV}}
shell: bash
run: |
python3 -c "import os; file = open('pkscreener/.env.dev', 'w'); file.write('CHAT_ID='+os.environ['CHAT_ID_DEV']+'\n'); file.write('TOKEN='+os.environ['TOKEN_DEV']+'\n'); file.write('chat_idADMIN='+os.environ['CHAT_IDADMIN_DEV']+'\n'); file.close()"
GITHUB_REF=${GITHUB_REF#refs/tags/}
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.targetPythonVersion || 3.11 }}
- name: Load Cache for Linux Dependencies
uses: actions/cache@v4
if: startsWith(runner.os, 'Linux')
with:
path: |
/usr/include/ta-lib
/usr/bin/ta-lib-config
key: ${{ runner.os }}-talib
restore-keys: |
${{ runner.os }}-talib
- name: Install dependencies for ${{ matrix.TARGET }}
shell: bash
run: ${{ matrix.DEP_BUILD }}
- name: Build for ${{ matrix.TARGET }}
run: ${{ matrix.CMD_BUILD }}
- name: Test Built Binary for ${{ matrix.TARGET }}
shell: bash
timeout-minutes: 30
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: ${{ matrix.TEST_BUILD }}
continue-on-error: false
# Delete_Workflow_Run:
# runs-on: ubuntu-20.04
# needs: [Build]
# name: Delete workflow run
# steps:
# - uses: actions/checkout@v4
# with:
# ref: main
# - name: Delete this workflow run
# if: startsWith(runner.os, 'Linux')
# shell: bash
# run: |
# for id in $(gh run list --limit 100 --jq ".[] | select (.status == \"success\" ) | .databaseId" --json databaseId,status); do gh run delete $id; done
# for id in $(gh run list --limit 100 --jq ".[] | select (.status == \"cancelled\" ) | .databaseId" --json databaseId,status); do gh run delete $id; done
# for id in $(gh run list --limit 100 --jq ".[] | select (.status == \"failure\" ) | .databaseId" --json databaseId,status); do gh run delete $id; done
# # Cancel runs queued or in_progress. See https://cli.github.com/manual/gh_run_list
# # for id in $(gh run list -w "13. Backtest for Generic" --limit 100 --jq ".[] | select (.status == \"queued\" ) | .databaseId" --json databaseId,status); do gh run cancel $id; done
# env:
# GH_TOKEN : ${{secrets.GITHUB_TOKEN}}