Skip to content

Commit

Permalink
Update github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Uxio0 committed Oct 10, 2022
1 parent 6e34386 commit 95e2423
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 29 deletions.
48 changes: 27 additions & 21 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@ name: Python CI
on: [push, pull_request]

jobs:
linting:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
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:
Expand Down Expand Up @@ -35,57 +52,46 @@ jobs:
docker run --detach --publish 8545:8545 --network-alias ganache -e DOCKER=true trufflesuite/ganache:latest --defaultBalanceEther 10000 --gasLimit 10000000 -a 30 --chain.chainId 1337 --chain.networkId 1337 -d
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
name: Cache pip
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-test.txt') }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/cache@v3
name: Cache pre-commit
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-precommit-${{ hashFiles('**/.pre-commit-config.yaml') }}
restore-keys: |
${{ runner.os }}-precommit-
cache: 'pip'
cache-dependency-path: 'requirements*.txt'
- name: Install dependencies
run: |
pip install wheel
pip install -r requirements-test.txt coveralls pre-commit
pip install -r requirements-test.txt coveralls
env:
PIP_USE_MIRRORS: true
- name: Run pre-commit
run: pre-commit run --all-files
- name: Run tests and coverage
run: |
python manage.py check
python manage.py makemigrations --check --dry-run
coverage run --source=$SOURCE_FOLDER -m py.test -rxXs
env:
SOURCE_FOLDER: safe_relay_service
CELERY_BROKER_URL: redis://localhost:6379/0
DJANGO_SETTINGS_MODULE: config.settings.test
DATABASE_URL: psql://postgres:postgres@localhost/postgres
ETHEREUM_NODE_URL: http://localhost:8545
ETHEREUM_TRACING_NODE_URL: http://localhost:8545
ETH_HASH_BACKEND: pysha3
REDIS_URL: redis://localhost:6379/0
CELERY_BROKER_URL: redis://localhost:6379/0
- name: Send results to coveralls
continue-on-error: true # Ignore coveralls problems
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Required for coveralls
docker-deploy:
runs-on: ubuntu-latest
needs: test-app
needs:
- linting
- test-app
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
- name: Dockerhub login
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ repos:
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.10.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 5.0.4
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.3.0
hooks:
- id: check-docstring-first
- id: check-merge-conflict
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ djangorestframework==3.13.1
djangorestframework-camel-case==1.3.0
docutils==0.18.1
drf-yasg[validation]==1.20.0
gnosis-py[django]==3.9.2
gunicorn[gevent]==20.1.0
hexbytes==0.2.2
lxml==4.8.0
Expand All @@ -24,4 +23,5 @@ psycogreen==1.0.2
psycopg2-binary==2.9.3
redis==4.2.1
requests==2.27.1
safe-eth-py[django]==4.5.1
web3==5.28.0
2 changes: 1 addition & 1 deletion safe_relay_service/relay/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SafeCreation2Serializer(
ThresholdValidatorSerializerMixin, serializers.Serializer
):
salt_nonce = serializers.IntegerField(
min_value=0, max_value=2 ** 256 - 1
min_value=0, max_value=2**256 - 1
) # Uint256
owners = serializers.ListField(child=EthereumAddressField(), min_length=1)
threshold = serializers.IntegerField(min_value=1)
Expand Down
2 changes: 1 addition & 1 deletion safe_relay_service/tokens/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __str__(self):
return "%s - %s" % (self.name, self.address)

def get_eth_value(self) -> float:
multiplier = 1e18 / 10 ** self.decimals
multiplier = 1e18 / 10**self.decimals
if self.fixed_eth_conversion: # `None` or `0` are ignored
# Ether has 18 decimals, but maybe the token has a different number
return round(multiplier * float(self.fixed_eth_conversion), 10)
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[flake8]
max-line-length = 88
select = C,E,F,W,B,B950
extend-ignore = E203, E501, F841
extend-ignore = E203,E501,F841,W503
exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv

[pycodestyle]
Expand All @@ -22,7 +22,7 @@ env =
DJANGO_DOT_ENV_FILE=.env.test

[mypy]
python_version = 3.9
python_version = 3.10
check_untyped_defs = True
ignore_missing_imports = True
warn_unused_ignores = True
Expand Down

0 comments on commit 95e2423

Please sign in to comment.