Skip to content

Commit

Permalink
feat(black) (#79)
Browse files Browse the repository at this point in the history
### Added

- Added Black actions
- Add pre-commit, black,isort and ruff
  • Loading branch information
henrikstranneheim authored Mar 6, 2024
1 parent ba109e3 commit 686cef8
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 23 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Black

on: [pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Check out git repository
uses: actions/[email protected]

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Set up Black
uses: psf/black@stable
with:
options: ". --check --line-length 100"
version: "~=24.1.0"
12 changes: 6 additions & 6 deletions .github/workflows/merge_master_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ jobs:
name: Create staging image
steps:
- name: Check out git repository
uses: actions/checkout@v2
uses: actions/checkout@v4.1.1

- name: Extract branch name and remove illegal chars
id: get_branch_name
shell: bash
run: echo "##[set-output name=branch;]$(echo "$(tr "/" "-" <<<${GITHUB_REF#refs/heads/})")"

- name: Login to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v3.0.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3.1.0

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5.1.0
with:
context: ./
file: ./Dockerfile
Expand All @@ -54,12 +54,12 @@ jobs:
name: Test and coveralls
steps:
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5.0.0
with:
python-version: "3.10"

- name: Check out genotype-api
uses: actions/checkout@v2
uses: actions/checkout@v4.1.1
with:
repository: "Clinical-Genomics/genotype-api"

Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/pull_request_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
runs-on: ubuntu-latest
name: Black
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4.1.1
- uses: actions/setup-python@v5.0.0
- uses: psf/black@stable
with:
black_args: ". --check --line-length 100"
Expand All @@ -20,26 +20,26 @@ jobs:
name: Create staging docker image
steps:
- name: Check out git repository
uses: actions/checkout@v2
uses: actions/checkout@v4.1.1

- name: Extract branch name and remove illegal chars
id: get_branch_name
shell: bash
run: echo "##[set-output name=branch;]$(echo "$(tr "/" "-" <<<${GITHUB_REF#refs/heads/})")"

- name: Login to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v3.0.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3.1.0

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5.1.0
with:
context: ./
file: ./Dockerfile
Expand All @@ -51,12 +51,12 @@ jobs:
name: Test and coveralls
steps:
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5.0.0
with:
python-version: "3.10"

- name: Check out genotype-api
uses: actions/checkout@v2
uses: actions/checkout@v4.1.1
with:
repository: "Clinical-Genomics/genotype-api"

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ jobs:
name: Push production docker image to dockerhub
steps:
- name: Check out git repository
uses: actions/checkout@v2
uses: actions/checkout@v4.1.1

- name: Extract branch name and remove illegal chars
id: get_branch_name
shell: bash
run: echo "##[set-output name=branch;]$(echo "$(tr "/" "-" <<<${GITHUB_REF#refs/heads/})")"

- name: Login to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v3.0.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3.1.0

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5.1.0
with:
context: ./
file: ./Dockerfile
Expand Down
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
repos:
- repo: https://github.com/psf/black
rev: 24.1.0
hooks:
- id: black
args: [--line-length=100]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.7
hooks:
- id: ruff

1 change: 1 addition & 0 deletions genotype_api/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Main functions for the genotype api
"""

from fastapi import FastAPI, status, Request
from fastapi.responses import JSONResponse
from fastapi.middleware.cors import CORSMiddleware
Expand Down
1 change: 1 addition & 0 deletions genotype_api/api/endpoints/analyses.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Routes for analysis"""

from pathlib import Path
from typing import List

Expand Down
1 change: 1 addition & 0 deletions genotype_api/api/endpoints/plates.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Routes for plates"""

from datetime import datetime
from io import BytesIO
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions genotype_api/api/endpoints/snps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Routes for the snps"""

from genotype_api.models import SNP, User
from typing import List

Expand Down
1 change: 1 addition & 0 deletions genotype_api/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Constants used over the package"""

from enum import Enum
from pydantic import BaseModel

Expand Down
1 change: 1 addition & 0 deletions genotype_api/database.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Hold the database information"""

from sqlmodel import Session, SQLModel, create_engine

from genotype_api.config import settings
Expand Down
7 changes: 4 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pytest>=5.2
pytest-cov
bump2version
coveralls
pre-commit
pylint
bump2version
pytest-cov
pytest>=5.2<
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

# server stuff
SQLAlchemy==1.4.30
aiofiles
bcrypt
Expand Down

0 comments on commit 686cef8

Please sign in to comment.