forked from hummingbot/hummingbot
-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (125 loc) · 5.45 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
name: ci
on:
push:
branches: [master, development, 'refactor/unit_tests**', 'main/**']
pull_request:
branches: [master, development, 'refactor/unit_tests**', 'main/**']
types: [ready_for_review, opened, synchronize, reopened]
jobs:
build_hummingbot:
name: build + stable tests
if: github.event.pull_request.draft == false
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/*') }}
# Remove envs directory if exists to prevent bin/tar restore errors
- name: Remove envs directory
run: rm -Rf /usr/share/miniconda/envs
# 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 python/conda to check if core code has changed
- uses: actions/setup-python@v2
if: steps.program-changes.outputs.cache-hit != 'true' || steps.conda-dependencies.outputs.cache-hit != 'true'
with:
python-version: 3.x
- name: Install Miniconda and nose
if: steps.program-changes.outputs.cache-hit != 'true' || steps.conda-dependencies.outputs.cache-hit != 'true'
shell: bash
run: |
MINICONDA_FILENAME=Miniconda3-latest-Linux-x86_64.sh
curl -o $MINICONDA_FILENAME "https://repo.continuum.io/miniconda/$MINICONDA_FILENAME"
bash ${MINICONDA_FILENAME} -b -f -p $HOME/miniconda3
source /usr/share/miniconda/etc/profile.d/conda.sh
conda install -c anaconda nose
# Install pre_commit if code has changed
- name: Install pre_commit
if: steps.program-changes.outputs.cache-hit != 'true' || steps.conda-dependencies.outputs.cache-hit != 'true'
shell: bash
run: |
source /usr/share/miniconda/etc/profile.d/conda.sh
conda install -c conda-forge pre_commit
# Install hummingbot env if environment-linux.yml has changed
- name: Install Hummingbot
if: steps.conda-dependencies.outputs.cache-hit != 'true'
shell: bash -l {0}
run: |
source /usr/share/miniconda/etc/profile.d/conda.sh
./install
# Compile and run tests if code has changed
- name: Run Flake8
shell: bash
if: steps.program-changes.outputs.cache-hit != 'true' || steps.conda-dependencies.outputs.cache-hit != 'true'
run: |
source /usr/share/miniconda/etc/profile.d/conda.sh
conda activate hummingbot
pre-commit run --all-files
- name: Compile Hummingbot
shell: bash
if: steps.program-changes.outputs.cache-hit != 'true' || steps.conda-dependencies.outputs.cache-hit != 'true'
env:
WITHOUT_CYTHON_OPTIMIZATIONS: true
run: |
source /usr/share/miniconda/etc/profile.d/conda.sh
conda info --envs
conda activate hummingbot
conda env export
./compile
- 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 /usr/share/miniconda/etc/profile.d/conda.sh
conda activate hummingbot
coverage run -m nose test.hummingbot
- 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 /usr/share/miniconda/etc/profile.d/conda.sh
conda activate hummingbot
coverage report
- 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 /usr/share/miniconda/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=66 coverage.xml
# Notify results to discord
- uses: actions/setup-ruby@v1
- name: Send Webhook Notification
if: always()
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