| 1 | name: Freqtrade CI |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: |
| 6 | - master |
| 7 | - stable |
| 8 | - develop |
| 9 | tags: |
| 10 | release: |
| 11 | types: [published] |
| 12 | pull_request: |
| 13 | schedule: |
| 14 | - cron: '0 5 * * 4' |
| 15 | |
| 16 | jobs: |
| 17 | build_linux: |
| 18 | |
| 19 | runs-on: ${{ matrix.os }} |
| 20 | strategy: |
| 21 | matrix: |
| 22 | os: [ ubuntu-18.04, ubuntu-20.04 ] |
| 23 | python-version: [3.7, 3.8, 3.9] |
| 24 | |
| 25 | steps: |
| 26 | - uses: actions/checkout@v2 |
| 27 | |
| 28 | - name: Set up Python |
| 29 | uses: actions/setup-python@v2 |
| 30 | with: |
| 31 | python-version: ${{ matrix.python-version }} |
| 32 | |
| 33 | - name: Cache_dependencies |
| 34 | uses: actions/cache@v2 |
| 35 | id: cache |
| 36 | with: |
| 37 | path: ~/dependencies/ |
| 38 | key: ${{ runner.os }}-dependencies |
| 39 | |
| 40 | - name: pip cache (linux) |
| 41 | uses: actions/cache@v2 |
| 42 | if: startsWith(matrix.os, 'ubuntu') |
| 43 | with: |
| 44 | path: ~/.cache/pip |
| 45 | key: test-${{ matrix.os }}-${{ matrix.python-version }}-pip |
| 46 | |
| 47 | - name: TA binary *nix |
| 48 | if: steps.cache.outputs.cache-hit != 'true' |
| 49 | run: | |
| 50 | cd build_helpers && ./install_ta-lib.sh ${HOME}/dependencies/; cd .. |
| 51 | |
| 52 | - name: Installation - *nix |
| 53 | run: | |
| 54 | python -m pip install --upgrade pip |
| 55 | export LD_LIBRARY_PATH=${HOME}/dependencies/lib:$LD_LIBRARY_PATH |
| 56 | export TA_LIBRARY_PATH=${HOME}/dependencies/lib |
| 57 | export TA_INCLUDE_PATH=${HOME}/dependencies/include |
| 58 | pip install -r requirements-dev.txt |
| 59 | pip install -e . |
| 60 | |
| 61 | - name: Tests |
| 62 | run: | |
| 63 | pytest --random-order --cov=freqtrade --cov-config=.coveragerc |
| 64 | if: matrix.python-version != '3.9' |
| 65 | |
| 66 | - name: Tests incl. ccxt compatibility tests |
| 67 | run: | |
| 68 | pytest --random-order --cov=freqtrade --cov-config=.coveragerc --longrun |
| 69 | if: matrix.python-version == '3.9' |
| 70 | |
| 71 | - name: Coveralls |
| 72 | if: (startsWith(matrix.os, 'ubuntu-20') && matrix.python-version == '3.8') |
| 73 | env: |
| 74 | # Coveralls token. Not used as secret due to github not providing secrets to forked repositories |
| 75 | COVERALLS_REPO_TOKEN: 6D1m0xupS3FgutfuGao8keFf9Hc0FpIXu |
| 76 | run: | |
| 77 | # Allow failure for coveralls |
| 78 | coveralls -v || true |
| 79 | |
| 80 | - name: Backtesting |
| 81 | run: | |
| 82 | cp config_bittrex.json.example config.json |
| 83 | freqtrade create-userdir --userdir user_data |
| 84 | freqtrade backtesting --datadir tests/testdata --strategy SampleStrategy |
| 85 | |
| 86 | - name: Hyperopt |
| 87 | run: | |
| 88 | cp config_bittrex.json.example config.json |
| 89 | freqtrade create-userdir --userdir user_data |
| 90 | freqtrade hyperopt --datadir tests/testdata -e 5 --strategy SampleStrategy --hyperopt SampleHyperOpt --hyperopt-loss SharpeHyperOptLossDaily --print-all |
| 91 | |
| 92 | - name: Flake8 |
| 93 | run: | |
| 94 | flake8 |
| 95 | |
| 96 | - name: Sort imports (isort) |
| 97 | run: | |
| 98 | isort --check . |
| 99 | |
| 100 | - name: Mypy |
| 101 | run: | |
| 102 | mypy freqtrade scripts |
| 103 | |
| 104 | - name: Slack Notification |
| 105 | uses: lazy-actions/slatify@v3.0.0 |
| 106 | if: failure() && ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false) |
| 107 | with: |
| 108 | type: ${{ job.status }} |
| 109 | job_name: '*Freqtrade CI ${{ matrix.os }}*' |
| 110 | mention: 'here' |
| 111 | mention_if: 'failure' |
| 112 | channel: '#notifications' |
| 113 | url: ${{ secrets.SLACK_WEBHOOK }} |
| 114 | |
| 115 | build_macos: |
| 116 | runs-on: ${{ matrix.os }} |
| 117 | strategy: |
| 118 | matrix: |
| 119 | os: [ macos-latest ] |
| 120 | python-version: [3.7, 3.8, 3.9] |
| 121 | |
| 122 | steps: |
| 123 | - uses: actions/checkout@v2 |
| 124 | |
| 125 | - name: Set up Python |
| 126 | uses: actions/setup-python@v2 |
| 127 | with: |
| 128 | python-version: ${{ matrix.python-version }} |
| 129 | |
| 130 | - name: Cache_dependencies |
| 131 | uses: actions/cache@v2 |
| 132 | id: cache |
| 133 | with: |
| 134 | path: ~/dependencies/ |
| 135 | key: ${{ runner.os }}-dependencies |
| 136 | |
| 137 | - name: pip cache (macOS) |
| 138 | uses: actions/cache@v2 |
| 139 | if: startsWith(matrix.os, 'macOS') |
| 140 | with: |
| 141 | path: ~/Library/Caches/pip |
| 142 | key: test-${{ matrix.os }}-${{ matrix.python-version }}-pip |
| 143 | |
| 144 | - name: TA binary *nix |
| 145 | if: steps.cache.outputs.cache-hit != 'true' |
| 146 | run: | |
| 147 | cd build_helpers && ./install_ta-lib.sh ${HOME}/dependencies/; cd .. |
| 148 | |
| 149 | - name: Installation - macOS |
| 150 | run: | |
| 151 | brew update |
| 152 | brew install hdf5 c-blosc |
| 153 | python -m pip install --upgrade pip |
| 154 | export LD_LIBRARY_PATH=${HOME}/dependencies/lib:$LD_LIBRARY_PATH |
| 155 | export TA_LIBRARY_PATH=${HOME}/dependencies/lib |
| 156 | export TA_INCLUDE_PATH=${HOME}/dependencies/include |
| 157 | pip install -r requirements-dev.txt |
| 158 | pip install -e . |
| 159 | |
| 160 | - name: Tests |
| 161 | run: | |
| 162 | pytest --random-order --cov=freqtrade --cov-config=.coveragerc |
| 163 | |
| 164 | - name: Coveralls |
| 165 | if: (startsWith(matrix.os, 'ubuntu-20') && matrix.python-version == '3.8') |
| 166 | env: |
| 167 | # Coveralls token. Not used as secret due to github not providing secrets to forked repositories |
| 168 | COVERALLS_REPO_TOKEN: 6D1m0xupS3FgutfuGao8keFf9Hc0FpIXu |
| 169 | run: | |
| 170 | # Allow failure for coveralls |
| 171 | coveralls -v || true |
| 172 | |
| 173 | - name: Backtesting |
| 174 | run: | |
| 175 | cp config_bittrex.json.example config.json |
| 176 | freqtrade create-userdir --userdir user_data |
| 177 | freqtrade backtesting --datadir tests/testdata --strategy SampleStrategy |
| 178 | |
| 179 | - name: Hyperopt |
| 180 | run: | |
| 181 | cp config_bittrex.json.example config.json |
| 182 | freqtrade create-userdir --userdir user_data |
| 183 | freqtrade hyperopt --datadir tests/testdata -e 5 --strategy SampleStrategy --hyperopt SampleHyperOpt --hyperopt-loss SharpeHyperOptLossDaily --print-all |
| 184 | |
| 185 | - name: Flake8 |
| 186 | run: | |
| 187 | flake8 |
| 188 | |
| 189 | - name: Sort imports (isort) |
| 190 | run: | |
| 191 | isort --check . |
| 192 | |
| 193 | - name: Mypy |
| 194 | run: | |
| 195 | mypy freqtrade scripts |
| 196 | |
| 197 | - name: Slack Notification |
| 198 | uses: lazy-actions/slatify@v3.0.0 |
| 199 | if: failure() && ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false) |
| 200 | with: |
| 201 | type: ${{ job.status }} |
| 202 | job_name: '*Freqtrade CI ${{ matrix.os }}*' |
| 203 | mention: 'here' |
| 204 | mention_if: 'failure' |
| 205 | channel: '#notifications' |
| 206 | url: ${{ secrets.SLACK_WEBHOOK }} |
| 207 | |
| 208 | |
| 209 | build_windows: |
| 210 | |
| 211 | runs-on: ${{ matrix.os }} |
| 212 | strategy: |
| 213 | matrix: |
| 214 | os: [ windows-latest ] |
| 215 | python-version: [3.7, 3.8] |
| 216 | |
| 217 | steps: |
| 218 | - uses: actions/checkout@v2 |
| 219 | |
| 220 | - name: Set up Python |
| 221 | uses: actions/setup-python@v2 |
| 222 | with: |
| 223 | python-version: ${{ matrix.python-version }} |
| 224 | |
| 225 | - name: Pip cache (Windows) |
| 226 | uses: actions/cache@preview |
| 227 | if: startsWith(runner.os, 'Windows') |
| 228 | with: |
| 229 | path: ~\AppData\Local\pip\Cache |
| 230 | key: ${{ matrix.os }}-${{ matrix.python-version }}-pip |
| 231 | |
| 232 | - name: Installation |
| 233 | run: | |
| 234 | ./build_helpers/install_windows.ps1 |
| 235 | |
| 236 | - name: Tests |
| 237 | run: | |
| 238 | pytest --random-order --cov=freqtrade --cov-config=.coveragerc |
| 239 | |
| 240 | - name: Backtesting |
| 241 | run: | |
| 242 | cp config_bittrex.json.example config.json |
| 243 | freqtrade create-userdir --userdir user_data |
| 244 | freqtrade backtesting --datadir tests/testdata --strategy SampleStrategy |
| 245 | |
| 246 | - name: Hyperopt |
| 247 | run: | |
| 248 | cp config_bittrex.json.example config.json |
| 249 | freqtrade create-userdir --userdir user_data |
| 250 | freqtrade hyperopt --datadir tests/testdata -e 5 --strategy SampleStrategy --hyperopt SampleHyperOpt --hyperopt-loss SharpeHyperOptLossDaily --print-all |
| 251 | |
| 252 | - name: Flake8 |
| 253 | run: | |
| 254 | flake8 |
| 255 | |
| 256 | - name: Mypy |
| 257 | run: | |
| 258 | mypy freqtrade scripts |
| 259 | |
| 260 | - name: Slack Notification |
| 261 | uses: lazy-actions/slatify@v3.0.0 |
| 262 | if: failure() && ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false) |
| 263 | with: |
| 264 | type: ${{ job.status }} |
| 265 | job_name: '*Freqtrade CI windows*' |
| 266 | mention: 'here' |
| 267 | mention_if: 'failure' |
| 268 | channel: '#notifications' |
| 269 | url: ${{ secrets.SLACK_WEBHOOK }} |
| 270 | |
| 271 | docs_check: |
| 272 | runs-on: ubuntu-20.04 |
| 273 | steps: |
| 274 | - uses: actions/checkout@v2 |
| 275 | |
| 276 | - name: Documentation syntax |
| 277 | run: | |
| 278 | ./tests/test_docs.sh |
| 279 | |
| 280 | - name: Set up Python |
| 281 | uses: actions/setup-python@v2 |
| 282 | with: |
| 283 | python-version: 3.8 |
| 284 | |
| 285 | - name: Documentation build |
| 286 | run: | |
| 287 | pip install -r docs/requirements-docs.txt |
| 288 | pip install mkdocs |
| 289 | mkdocs build |
| 290 | |
| 291 | - name: Slack Notification |
| 292 | uses: lazy-actions/slatify@v3.0.0 |
| 293 | if: failure() && ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false) |
| 294 | with: |
| 295 | type: ${{ job.status }} |
| 296 | job_name: '*Freqtrade Docs*' |
| 297 | channel: '#notifications' |
| 298 | url: ${{ secrets.SLACK_WEBHOOK }} |
| 299 | |
| 300 | cleanup-prior-runs: |
| 301 | runs-on: ubuntu-20.04 |
| 302 | steps: |
| 303 | - name: Cleanup previous runs on this branch |
| 304 | uses: rokroskar/workflow-run-cleanup-action@v0.3.2 |
| 305 | if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/stable' && github.repository == 'freqtrade/freqtrade'" |
| 306 | env: |
| 307 | GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 308 | |
| 309 | # Notify on slack only once - when CI completes (and after deploy) in case it's successfull |
| 310 | notify-complete: |
| 311 | needs: [ build_linux, build_macos, build_windows, docs_check ] |
| 312 | runs-on: ubuntu-20.04 |
| 313 | steps: |
| 314 | |
| 315 | - name: Check user permission |
| 316 | id: check |
| 317 | uses: scherermichael-oss/action-has-permission@1.0.6 |
| 318 | with: |
| 319 | required-permission: write |
| 320 | env: |
| 321 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 322 | |
| 323 | - name: Slack Notification |
| 324 | uses: lazy-actions/slatify@v3.0.0 |
| 325 | if: always() && steps.check.outputs.has-permission && ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false) |
| 326 | with: |
| 327 | type: ${{ job.status }} |
| 328 | job_name: '*Freqtrade CI*' |
| 329 | channel: '#notifications' |
| 330 | url: ${{ secrets.SLACK_WEBHOOK }} |
| 331 | |
| 332 | deploy: |
| 333 | needs: [ build_linux, build_macos, build_windows, docs_check ] |
| 334 | runs-on: ubuntu-20.04 |
| 335 | |
| 336 | if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'release') && github.repository == 'freqtrade/freqtrade' |
| 337 | steps: |
| 338 | - uses: actions/checkout@v2 |
| 339 | |
| 340 | - name: Set up Python |
| 341 | uses: actions/setup-python@v2 |
| 342 | with: |
| 343 | python-version: 3.8 |
| 344 | |
| 345 | - name: Extract branch name |
| 346 | shell: bash |
| 347 | run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF##*/})" |
| 348 | id: extract_branch |
| 349 | |
| 350 | - name: Build distribution |
| 351 | run: | |
| 352 | pip install -U setuptools wheel |
| 353 | python setup.py sdist bdist_wheel |
| 354 | |
| 355 | - name: Publish to PyPI (Test) |
| 356 | uses: pypa/gh-action-pypi-publish@master |
| 357 | if: (github.event_name == 'release') |
| 358 | with: |
| 359 | user: __token__ |
| 360 | password: ${{ secrets.pypi_test_password }} |
| 361 | repository_url: https://test.pypi.org/legacy/ |
| 362 | |
| 363 | - name: Publish to PyPI |
| 364 | uses: pypa/gh-action-pypi-publish@master |
| 365 | if: (github.event_name == 'release') |
| 366 | with: |
| 367 | user: __token__ |
| 368 | password: ${{ secrets.pypi_password }} |
| 369 | |
| 370 | - name: Dockerhub login |
| 371 | env: |
| 372 | DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} |
| 373 | DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} |
| 374 | run: | |
| 375 | echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin |
| 376 | |
| 377 | - name: Build and test and push docker image |
| 378 | env: |
| 379 | IMAGE_NAME: freqtradeorg/freqtrade |
| 380 | BRANCH_NAME: ${{ steps.extract_branch.outputs.branch }} |
| 381 | run: | |
| 382 | build_helpers/publish_docker.sh |
| 383 | |
| 384 | # We need docker experimental to pull the ARM image. |
| 385 | - name: Switch docker to experimental |
| 386 | run: | |
| 387 | docker version -f '{{.Server.Experimental}}' |
| 388 | echo $'{\n "experimental": true\n}' | sudo tee /etc/docker/daemon.json |
| 389 | sudo systemctl restart docker |
| 390 | docker version -f '{{.Server.Experimental}}' |
| 391 | |
| 392 | - name: Set up Docker Buildx |
| 393 | id: buildx |
| 394 | uses: crazy-max/ghaction-docker-buildx@v1 |
| 395 | with: |
| 396 | buildx-version: latest |
| 397 | qemu-version: latest |
| 398 | |
| 399 | - name: Available platforms |
| 400 | run: echo ${{ steps.buildx.outputs.platforms }} |
| 401 | |
| 402 | - name: Build Raspberry docker image |
| 403 | env: |
| 404 | IMAGE_NAME: freqtradeorg/freqtrade |
| 405 | BRANCH_NAME: ${{ steps.extract_branch.outputs.branch }}_pi |
| 406 | run: | |
| 407 | build_helpers/publish_docker_pi.sh |
| 408 | |
| 409 | |
| 410 | - name: Slack Notification |
| 411 | uses: lazy-actions/slatify@v3.0.0 |
| 412 | if: always() && ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false) |
| 413 | with: |
| 414 | type: ${{ job.status }} |
| 415 | job_name: '*Freqtrade CI Deploy*' |
| 416 | mention: 'here' |
| 417 | mention_if: 'failure' |
| 418 | channel: '#notifications' |
| 419 | url: ${{ secrets.SLACK_WEBHOOK }} |
| 420 | |