-
Notifications
You must be signed in to change notification settings - Fork 5
122 lines (119 loc) · 3.67 KB
/
python.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
name: Python CI
on:
push:
branches:
- main
- develop
pull_request:
release:
types: [ released ]
jobs:
linting:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files
test-app:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- name: Setup and run ganache
run: |
docker network create ganache
docker run --detach --publish 8545:8545 --network ganache -e DOCKER=true trufflesuite/ganache:latest --defaultBalanceEther 10000 --gasLimit 10000000 -a 30 --chain.chainId 1337 --chain.networkId 1337 -d
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'requirements*.txt'
- name: Install dependencies
run: |
pip install wheel
pip install -r requirements-test.txt
env:
PIP_USE_MIRRORS: true
- name: Run tests and coverage
run: |
python manage.py check
# python manage.py makemigrations --check --dry-run
coverage run --source=$SOURCE_FOLDER -m pytest -rxXs --reruns 3
env:
SOURCE_FOLDER: safe_price_service
DJANGO_SETTINGS_MODULE: config.settings.test
ETHEREUM_MAINNET_NODE: ${{ secrets.ETHEREUM_MAINNET_NODE }}
ETHEREUM_NODES_URLS: http://localhost:8545
ETH_HASH_BACKEND: pysha3
- name: Coveralls
uses: coverallsapp/github-action@v2
docker-deploy:
runs-on: ubuntu-latest
needs:
- linting
- test-app
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || (github.event_name == 'release' && github.event.action == 'released')
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- uses: docker/setup-buildx-action@v3
- name: Dockerhub login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Deploy main
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: .
file: docker/web/Dockerfile
push: true
tags: safeglobal/safe-price-service:staging
platforms: |
linux/amd64
linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Deploy Develop
if: github.ref == 'refs/heads/develop'
uses: docker/build-push-action@v6
with:
context: .
file: docker/web/Dockerfile
push: true
tags: safeglobal/safe-price-service:develop
platforms: |
linux/amd64
linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Deploy Tag
if: (github.event_name == 'release' && github.event.action == 'released')
uses: docker/build-push-action@v6
with:
context: .
file: docker/web/Dockerfile
push: true
tags: |
safeglobal/safe-price-service:${{ github.event.release.tag_name }}
safeglobal/safe-price-service:latest
platforms: |
linux/amd64
linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max