-
Notifications
You must be signed in to change notification settings - Fork 72
192 lines (177 loc) · 7.9 KB
/
main.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
name: OctoBot-Tentacles-CI
on:
push:
branches:
- 'master'
- 'dev'
- 'beta'
tags:
- '*'
pull_request:
jobs:
tests:
name: ${{ matrix.os }}${{ matrix.arch }} - Python - ${{ matrix.python }} - Tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-13, windows-latest, ubuntu-latest ]
arch: [ x64 ]
python: [ '3.10' ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.arch }}
- name: Install OctoBot on Unix
if: matrix.os != 'windows-latest'
env:
OCTOBOT_GH_REPO: https://github.com/Drakkar-Software/OctoBot.git
OCTOBOT_DEFAULT_BRANCH: dev
run: |
echo "GITHUB_REF=$GITHUB_REF"
TARGET_BRANCH=$([ "$GITHUB_HEAD_REF" == "" ] && echo ${GITHUB_REF##*/} || echo "$GITHUB_HEAD_REF")
git clone -q $OCTOBOT_GH_REPO -b ${TARGET_BRANCH} || git clone -q $OCTOBOT_GH_REPO -b $OCTOBOT_DEFAULT_BRANCH
cd OctoBot
git status
pip install --prefer-binary -r dev_requirements.txt -r requirements.txt
cd ..
mkdir new_tentacles
cp -r Automation Backtesting Evaluator Meta Services Trading profiles new_tentacles
cd OctoBot
python start.py tentacles -d "../new_tentacles" -p "../../any_platform.zip"
python start.py tentacles --install --location "../any_platform.zip" --all
- name: Install OctoBot on Windows
if: matrix.os == 'windows-latest'
env:
OCTOBOT_GH_REPO: https://github.com/Drakkar-Software/OctoBot.git
OCTOBOT_DEFAULT_BRANCH: dev
run: |
echo "GITHUB_REF=$env:GITHUB_REF"
$env:TARGET_BRANCH = $env:GITHUB_REF
If ((Test-Path env:GITHUB_HEAD_REF) -and -not ([string]::IsNullOrWhiteSpace($env:GITHUB_HEAD_REF))) {
echo "using GITHUB_HEAD_REF"
$env:TARGET_BRANCH = $env:GITHUB_HEAD_REF
}
echo "TARGET_BRANCH=$env:TARGET_BRANCH"
If ($env:TARGET_BRANCH -notcontains "refs/tags/") {
$env:TENTACLES_URL_TAG = "latest"
}
echo "cleaned TARGET_BRANCH=$env:TARGET_BRANCH"
git clone -q $env:OCTOBOT_GH_REPO -b $env:TARGET_BRANCH.Replace('refs/heads/','')
if ($LastExitCode -ne 0) {
git clone -q $env:OCTOBOT_GH_REPO -b $env:OCTOBOT_DEFAULT_BRANCH
}
cd OctoBot
git status
pip install --upgrade pip setuptools wheel
pip install --prefer-binary -r dev_requirements.txt -r requirements.txt
cd ..
mkdir new_tentacles
xcopy Automation new_tentacles\\Automation /E/H/I
xcopy Backtesting new_tentacles\\Backtesting /E/H/I
xcopy Evaluator new_tentacles\\Evaluator /E/H/I
xcopy Meta new_tentacles\\Meta /E/H/I
xcopy Services new_tentacles\\Services /E/H/I
xcopy Trading new_tentacles\\Trading /E/H/I
xcopy profiles new_tentacles\\profiles /E/H/I
cd OctoBot
python start.py tentacles -d "../new_tentacles" -p "../../any_platform.zip"
python start.py tentacles --install --location "../any_platform.zip" --all
shell: powershell
- name: Pytests
run: |
cd OctoBot
pytest --cov=. --cov-config=.coveragerc --durations=0 -rw --ignore=tentacles/Trading/Exchange tentacles
- name: Publish coverage
if: github.event_name == 'push'
continue-on-error: true
run: coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
upload_tentacles:
needs: tests
name: ${{ matrix.os }}${{ matrix.arch }} - Python - ${{ matrix.python }} - Upload
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
arch: [ x64 ]
python: [ '3.10' ]
steps:
- uses: actions/checkout@v4
- name: Set Environment Variables
run: |
echo "S3_API_KEY=${{ secrets.S3_API_KEY }}" >> $GITHUB_ENV
echo "S3_API_SECRET_KEY=${{ secrets.S3_API_SECRET_KEY }}" >> $GITHUB_ENV
echo "S3_REGION_NAME=${{ secrets.S3_REGION_NAME }}" >> $GITHUB_ENV
echo "S3_ENDPOINT_URL=${{ secrets.S3_ENDPOINT_URL }}" >> $GITHUB_ENV
echo "CLOUDFLARE_TOKEN=${{ secrets.CLOUDFLARE_TOKEN }}" >> $GITHUB_ENV
echo "CLOUDFLARE_ZONE=${{ secrets.CLOUDFLARE_ZONE }}" >> $GITHUB_ENV
TARGET_BRANCH=$([ "$GITHUB_HEAD_REF" == "" ] && echo ${GITHUB_REF##*/} || echo "$GITHUB_HEAD_REF")
echo "TARGET_BRANCH=${TARGET_BRANCH}" >> $GITHUB_ENV
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.arch }}
- name: Produce tentacles package
env:
OCTOBOT_GH_REPO: https://github.com/Drakkar-Software/OctoBot.git
OCTOBOT_DEFAULT_BRANCH: dev
run: |
git clone -q $OCTOBOT_GH_REPO -b ${TARGET_BRANCH} || git clone -q $OCTOBOT_GH_REPO -b $OCTOBOT_DEFAULT_BRANCH
cd OctoBot
git status
pip install --prefer-binary -r dev_requirements.txt -r requirements.txt
cd ..
mkdir new_tentacles
cp -r Automation Backtesting Evaluator Meta Services Trading profiles new_tentacles
- name: Publish tag tentacles
if: startsWith(github.ref, 'refs/tags')
env:
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
run: |
sed -i "s/VERSION_PLACEHOLDER/${TARGET_BRANCH#refs/*/}/g" metadata.yaml
cd OctoBot
python start.py tentacles -m "../metadata.yaml" -d "../new_tentacles" -p "../../any_platform.zip" -ite -ute ${{ secrets.TENTACLES_OFFICIAL_PATH }}/tentacles -upe ${{ secrets.TENTACLES_OFFICIAL_PATH }}/packages/full/${{ secrets.TENTACLES_REPOSITORY_NAME }}/
python ../scripts/clear_cloudflare_cache.py ${TARGET_BRANCH#refs/*/}
- name: Publish latest tentacles
if: github.ref == 'refs/heads/dev' && startsWith(github.ref, 'refs/tags') != true
env:
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
run: |
sed -i "s/VERSION_PLACEHOLDER/latest/g" metadata.yaml
cd OctoBot
python start.py tentacles -m "../metadata.yaml" -d "../new_tentacles" -p "../../any_platform.zip" -upe ${{ secrets.TENTACLES_OFFICIAL_PATH }}/packages/full/${{ secrets.TENTACLES_REPOSITORY_NAME }}/
python ../scripts/clear_cloudflare_cache.py latest
- name: Publish stable tentacles
if: github.ref == 'refs/heads/master'
env:
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
run: |
sed -i "s/VERSION_PLACEHOLDER/stable/g" metadata.yaml
cd OctoBot
python start.py tentacles -m "../metadata.yaml" -d "../new_tentacles" -p "../../any_platform.zip" -upe ${{ secrets.TENTACLES_OFFICIAL_PATH }}/packages/full/${{ secrets.TENTACLES_REPOSITORY_NAME }}/
python ../scripts/clear_cloudflare_cache.py stable
- name: Publish cleaned branch tentacles
if: startsWith(github.ref, 'refs/tags') != true && github.ref != 'refs/heads/master'
env:
S3_BUCKET_NAME: ${{ secrets.S3_DEV_BUCKET_NAME }}
run: |
branch="${TARGET_BRANCH##*/}"
sed -i "s/VERSION_PLACEHOLDER/$branch/g" metadata.yaml
sed -i "s/base/$branch/g" metadata.yaml
sed -i "s/officials/dev/g" metadata.yaml
cd OctoBot
python start.py tentacles -m "../metadata.yaml" -d "../new_tentacles" -p "../../any_platform.zip" -upe ${{ secrets.TENTACLES_OFFICIAL_PATH }}/packages/full/${{ secrets.TENTACLES_REPOSITORY_NAME }}/
python ../scripts/clear_cloudflare_cache.py $branch
notify:
if: ${{ failure() }}
needs:
- tests
- upload_tentacles
uses: Drakkar-Software/.github/.github/workflows/failure_notify_workflow.yml@master
secrets:
DISCORD_GITHUB_WEBHOOK: ${{ secrets.DISCORD_GITHUB_WEBHOOK }}