Bump black from 24.4.2 to 24.10.0 #493
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Python CI | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
pull_request: | |
release: | |
types: [ released ] | |
concurrency: | |
# Each run is grouped as follows: | |
# - Each branch has its own group (per workflow) | |
# - Each PR has its own group (per workflow) | |
# - Each tag has its own group (per workflow) | |
group: ${{ github.workflow }}-${{ github.ref }} | |
# github.head_ref is only available when the event is of type pull_request or pull_request_target | |
# Here we just need it's truthy value i.e., if there is a head_ref then the value is true. The value is false otherwise. | |
# This means that non-PR runs should not cancel previous runs in the same group (example: tag creation, main branch) | |
# See https://docs.github.com/en/actions/learn-github-actions/contexts#github-context | |
cancel-in-progress: ${{ github.head_ref && true || false }} | |
jobs: | |
linting: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.12"] | |
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.12"] | |
services: | |
postgres: | |
image: postgres:14 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
rabbitmq: | |
image: rabbitmq:alpine | |
options: >- | |
--health-cmd "rabbitmqctl await_startup" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- "5672:5672" | |
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 setuptools | |
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_locking_service | |
CELERY_BROKER_URL: redis://localhost:6379/0 | |
DATABASE_URL: psql://postgres:postgres@localhost/postgres | |
DJANGO_SETTINGS_MODULE: config.settings.test | |
ETHEREUM_MAINNET_NODE: ${{ secrets.ETHEREUM_MAINNET_NODE }} | |
ETHEREUM_NODE_URL: 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-locking-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-locking-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-locking-service:${{ github.event.release.tag_name }} | |
safeglobal/safe-locking-service:latest | |
platforms: | | |
linux/amd64 | |
linux/arm64 | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
autodeploy: | |
runs-on: ubuntu-latest | |
needs: [docker-deploy] | |
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Deploy Staging | |
if: github.ref == 'refs/heads/main' | |
run: bash scripts/autodeploy.sh | |
env: | |
AUTODEPLOY_URL: ${{ secrets.AUTODEPLOY_URL }} | |
AUTODEPLOY_TOKEN: ${{ secrets.AUTODEPLOY_TOKEN }} | |
TARGET_ENV: "staging" | |
- name: Deploy Develop | |
if: github.ref == 'refs/heads/develop' | |
run: bash scripts/autodeploy.sh | |
env: | |
AUTODEPLOY_URL: ${{ secrets.AUTODEPLOY_URL }} | |
AUTODEPLOY_TOKEN: ${{ secrets.AUTODEPLOY_TOKEN }} | |
TARGET_ENV: "develop" |