This repository has been archived by the owner on Mar 7, 2023. It is now read-only.
forked from hummingbot/hummingbot
-
Notifications
You must be signed in to change notification settings - Fork 2
209 lines (184 loc) · 7.55 KB
/
workflow.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
name: ci
on:
push:
branches: [master, development, 'refactor/unit_tests**', 'epic/**']
pull_request:
branches: [master, development, 'refactor/unit_tests**', 'epic/**', 'feat/gateway-v2']
types: [ready_for_review, opened, synchronize, reopened]
jobs:
build_hummingbot:
name: Hummingbot build + stable tests
if: github.event.pull_request.draft == false && github.base_ref != 'feat/gateway-v2'
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
# Use cache's hashFiles function to check for changes in core code
- name: Check for code changes
id: program-changes
uses: actions/cache@v2
env:
# Increase this value to manually reset cache if program files have not changed
CACHE_NUMBER: 0
with:
path: README.md # placeholder file
key: ${{ runner.os }}-build-${{ env.CACHE_NUMBER }}-${{ hashFiles('hummingbot/*', '**/*.py', '**/*.py*', '**/*.pxd', 'test/*') }}
# Check for setup/environmnet-linux.yml changes
- name: Cache conda dependencies
id: conda-dependencies
uses: actions/cache@v2
env:
# Increase this value to manually reset cache if setup/environment-linux.yml has not changed
CONDA_CACHE_NUMBER: 0
with:
path: |
/home/runner/conda_pkgs_dir/
/usr/share/miniconda/envs
key: ${{ runner.os }}-conda-${{ env.CONDA_CACHE_NUMBER }}-${{ hashFiles('setup/environment-linux.yml') }}
# Install environment and Hummingbot
- name: Install environment and Hummingbot
uses: ./.github/actions/install_env_and_hb
with:
program-cache-hit: ${{steps.program-changes.outputs.cache-hit}}
dependencies-cache-hit: ${{steps.conda-dependencies.outputs.cache-hit}}
# Install gateway
- name: Install Gateway Dependencies
run: yarn --cwd ./gateway install
# Compile and run tests if code has changed
- name: Run Flake8 and eslint
shell: bash
if: steps.program-changes.outputs.cache-hit != 'true' || steps.conda-dependencies.outputs.cache-hit != 'true'
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate hummingbot
pre-commit run
- name: Run stable tests and calculate coverage
if: steps.program-changes.outputs.cache-hit != 'true' || steps.conda-dependencies.outputs.cache-hit != 'true'
shell: bash
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate hummingbot
make test
- name: Check and report global coverage
if: steps.program-changes.outputs.cache-hit != 'true' || steps.conda-dependencies.outputs.cache-hit != 'true'
shell: bash
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate hummingbot
make report_coverage
- name: Validate coverage for the changes
if: github.event_name == 'pull_request' && (steps.program-changes.outputs.cache-hit != 'true' || steps.conda-dependencies.outputs.cache-hit != 'true')
shell: bash
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate hummingbot
git fetch --all -q
git checkout -b $GITHUB_SHA
coverage xml
diff-cover --compare-branch=origin/$GITHUB_BASE_REF --fail-under=80 coverage.xml
# Notify results to discord
- uses: actions/setup-ruby@v1
- name: Send Webhook Notification
if: github.event_name != 'pull_request'
env:
JOB_STATUS: ${{ job.status }}
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
HOOK_OS_NAME: ${{ runner.os }}
WORKFLOW_NAME: ${{ github.workflow }}
run: |
git clone --depth 1 https://github.com/DiscordHooks/github-actions-discord-webhook.git webhook
bash webhook/send.sh $JOB_STATUS $WEBHOOK_URL
shell: bash
build_gateway:
name: Gateway build + unit tests
if: github.base_ref == 'feat/gateway-v2'
runs-on: 'ubuntu-latest'
steps:
- name: Checkout commit
uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '16.x'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Dependencies
run: yarn --cwd ./gateway install
- name: Create yml config file
env:
INFURA_KEY: ${{ secrets.INFURA_KEY }}
ETH_GAS_STATION_API_KEY: ${{ secrets.ETH_GAS_STATION_API_KEY }}
run: |
mkdir -p ./gateway/conf/
cat << EOF >> ./gateway/conf/ethereum.yml
networks:
mainnet:
chainID: 1
nodeURL: https://mainnet.infura.io/v3/
tokenListType: URL
tokenListSource: >-
https://wispy-bird-88a7.uniswap.workers.dev/?url=http://tokens.1inch.eth.link
nativeCurrencySymbol: ETH
kovan:
chainID: 42
nodeURL: https://kovan.infura.io/v3/
tokenListType: FILE
tokenListSource: src/chains/ethereum/erc20_tokens_kovan.json
nativeCurrencySymbol: ETH
nodeAPIKey: "$INFURA_KEY"
manualGasPrice: 110
EOF
cat << EOF >> ./gateway/conf/ethereum-gas-station.yml
enabled: true
gasStationURL: 'https://ethgasstation.info/api/ethgasAPI.json?api-key='
APIKey: "$ETH_GAS_STATION_API_KEY"
gasLevel: fast
EOF
cat << EOF >> ./gateway/conf/avalanche.yml
networks:
fuji:
chainID: 43113
nodeURL: 'https://api.avax-test.network/ext/bc/C/rpc'
tokenListType: 'FILE'
tokenListSource: 'src/chains/avalanche/avalanche_tokens_fuji.json'
nativeCurrencySymbol: 'AVAX'
avalanche:
chainID: 43114
nodeURL: 'https://api.avax.network/ext/bc/C/rpc'
tokenListType: 'URL'
tokenListSource: 'https://raw.githubusercontent.com/pangolindex/tokenlists/main/top15.tokenlist.json'
nativeCurrencySymbol: 'AVAX'
nodeAPIKey: "$INFURA_KEY"
manualGasPrice: 100
EOF
- name: Create yml passphrase file
shell: bash
env:
CERT_PASSPHRASE: ${{ secrets.CERT_PASSPHRASE }}
run: |
mkdir -p ./gateway/conf/
cat << EOF >> ./gateway/conf/gateway-passphrase.yml
CERT_PASSPHRASE: "$CERT_PASSPHRASE"
EOF
chmod 0600 ./gateway/conf/gateway-passphrase.yml
- name: Build project
run: yarn --cwd ./gateway build
- name: Run unit test
run: yarn --cwd ./gateway test:unit
- name: Run unit test coverage
if: github.event_name == 'pull_request' && steps.program-changes.outputs.cache-hit != 'true'
shell: bash
run: |
git fetch --all -q
git checkout -b $GITHUB_SHA
yarn --cwd ./gateway test:cov
git diff origin/$GITHUB_BASE_REF | $(yarn --cwd ./gateway bin)/diff-test-coverage -c ./gateway/coverage/lcov.info -t lcov -b 65 -l 67