From c17d34684fbcfde65dabe7a78f519a4b3ee1414a Mon Sep 17 00:00:00 2001 From: henrikstranneheim Date: Wed, 28 Feb 2024 17:27:19 +0100 Subject: [PATCH 1/6] feat(black) --- .github/workflows/black.yml | 21 +++++++++++++++++++++ genotype_api/api/app.py | 1 + genotype_api/api/endpoints/analyses.py | 1 + genotype_api/api/endpoints/plates.py | 1 + genotype_api/api/endpoints/snps.py | 1 + genotype_api/constants.py | 1 + genotype_api/database.py | 1 + 7 files changed, 27 insertions(+) create mode 100644 .github/workflows/black.yml diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml new file mode 100644 index 0000000..c49d2e7 --- /dev/null +++ b/.github/workflows/black.yml @@ -0,0 +1,21 @@ +name: Black + +on: [pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Check out git repository + uses: actions/checkout@v4.1.1 + + - 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" diff --git a/genotype_api/api/app.py b/genotype_api/api/app.py index b97f48d..e547a7f 100644 --- a/genotype_api/api/app.py +++ b/genotype_api/api/app.py @@ -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 diff --git a/genotype_api/api/endpoints/analyses.py b/genotype_api/api/endpoints/analyses.py index acad268..93193b5 100644 --- a/genotype_api/api/endpoints/analyses.py +++ b/genotype_api/api/endpoints/analyses.py @@ -1,4 +1,5 @@ """Routes for analysis""" + from pathlib import Path from typing import List diff --git a/genotype_api/api/endpoints/plates.py b/genotype_api/api/endpoints/plates.py index b75f19c..4cd695a 100644 --- a/genotype_api/api/endpoints/plates.py +++ b/genotype_api/api/endpoints/plates.py @@ -1,4 +1,5 @@ """Routes for plates""" + from datetime import datetime from io import BytesIO from pathlib import Path diff --git a/genotype_api/api/endpoints/snps.py b/genotype_api/api/endpoints/snps.py index 988945c..ffb654a 100644 --- a/genotype_api/api/endpoints/snps.py +++ b/genotype_api/api/endpoints/snps.py @@ -1,4 +1,5 @@ """Routes for the snps""" + from genotype_api.models import SNP, User from typing import List diff --git a/genotype_api/constants.py b/genotype_api/constants.py index b79fbac..7a8431c 100644 --- a/genotype_api/constants.py +++ b/genotype_api/constants.py @@ -1,4 +1,5 @@ """Constants used over the package""" + from enum import Enum from pydantic import BaseModel diff --git a/genotype_api/database.py b/genotype_api/database.py index 82bd656..c082e69 100644 --- a/genotype_api/database.py +++ b/genotype_api/database.py @@ -1,4 +1,5 @@ """Hold the database information""" + from sqlmodel import Session, SQLModel, create_engine from genotype_api.config import settings From 345f55c8e4943f35452ab3f65f40e40eb298576a Mon Sep 17 00:00:00 2001 From: henrikstranneheim Date: Wed, 28 Feb 2024 17:33:24 +0100 Subject: [PATCH 2/6] feat(deps): Frezze sendmail-container --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8b9b107..72cf0b7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,6 +18,6 @@ python-jose[cryptography] bcrypt numpy aiofiles -sendmail-container +sendmail-container==0.2.0 python-dotenv google-auth From 3bad6e95c1eb84a335ea834986f03f99cb1d353b Mon Sep 17 00:00:00 2001 From: henrikstranneheim Date: Fri, 1 Mar 2024 17:31:25 +0100 Subject: [PATCH 3/6] feat(sendmail.container): Remove --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 72cf0b7..d268008 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,6 +18,5 @@ python-jose[cryptography] bcrypt numpy aiofiles -sendmail-container==0.2.0 python-dotenv google-auth From 2934dfcc911a684509943ad6d50f8ff50ed353c6 Mon Sep 17 00:00:00 2001 From: henrikstranneheim Date: Fri, 1 Mar 2024 17:37:01 +0100 Subject: [PATCH 4/6] feat(pre-commot): Add --- .pre-commit-config.yaml | 16 ++++++++++++++++ requirements-dev.txt | 7 ++++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..e860672 --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 + diff --git a/requirements-dev.txt b/requirements-dev.txt index 467952e..261bbf2 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,6 @@ -pytest>=5.2 -pytest-cov +bump2version coveralls +pre-commit pylint -bump2version \ No newline at end of file +pytest-cov +pytest>=5.2 \ No newline at end of file From f5cce5eaa11fb843dd4053444d3028ef899c63f6 Mon Sep 17 00:00:00 2001 From: henrikstranneheim Date: Fri, 1 Mar 2024 17:52:14 +0100 Subject: [PATCH 5/6] feat(actions): Update versions --- .github/workflows/merge_master_ci.yml | 12 ++++++------ .github/workflows/pull_request_ci.yml | 16 ++++++++-------- .github/workflows/release_ci.yml | 8 ++++---- requirements-dev.txt | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/merge_master_ci.yml b/.github/workflows/merge_master_ci.yml index 867b5ca..bfdc806 100644 --- a/.github/workflows/merge_master_ci.yml +++ b/.github/workflows/merge_master_ci.yml @@ -23,7 +23,7 @@ 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 @@ -31,18 +31,18 @@ jobs: 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 @@ -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" diff --git a/.github/workflows/pull_request_ci.yml b/.github/workflows/pull_request_ci.yml index 7b98fb0..3aad712 100644 --- a/.github/workflows/pull_request_ci.yml +++ b/.github/workflows/pull_request_ci.yml @@ -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" @@ -20,7 +20,7 @@ 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 @@ -28,18 +28,18 @@ jobs: 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 @@ -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" diff --git a/.github/workflows/release_ci.yml b/.github/workflows/release_ci.yml index 8f74478..6a2dfcf 100644 --- a/.github/workflows/release_ci.yml +++ b/.github/workflows/release_ci.yml @@ -12,7 +12,7 @@ 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 @@ -20,18 +20,18 @@ jobs: 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 diff --git a/requirements-dev.txt b/requirements-dev.txt index 261bbf2..8c2cca8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,4 +3,4 @@ coveralls pre-commit pylint pytest-cov -pytest>=5.2 \ No newline at end of file +pytest>=5.2< \ No newline at end of file From cc4d04781b2ceff607bbc55b9a19040fb3b128a2 Mon Sep 17 00:00:00 2001 From: henrikstranneheim Date: Sat, 2 Mar 2024 10:01:15 +0100 Subject: [PATCH 6/6] feat(actions): Split and clean --- .../workflows/build_dockerfile_on_push.yml | 37 +++++++++ ...ci.yml => build_dockerfile_on_release.yml} | 0 .github/workflows/bumpversion.yml | 18 +++++ .github/workflows/merge_master_ci.yml | 79 ------------------- .github/workflows/pull_request_ci.yml | 78 ------------------ 5 files changed, 55 insertions(+), 157 deletions(-) create mode 100644 .github/workflows/build_dockerfile_on_push.yml rename .github/workflows/{release_ci.yml => build_dockerfile_on_release.yml} (100%) create mode 100644 .github/workflows/bumpversion.yml delete mode 100644 .github/workflows/merge_master_ci.yml delete mode 100644 .github/workflows/pull_request_ci.yml diff --git a/.github/workflows/build_dockerfile_on_push.yml b/.github/workflows/build_dockerfile_on_push.yml new file mode 100644 index 0000000..38d91fc --- /dev/null +++ b/.github/workflows/build_dockerfile_on_push.yml @@ -0,0 +1,37 @@ +--- + +name: Build and publish docker image on push + +on: [push] + +jobs: + docker-image-push: + runs-on: ubuntu-latest + name: Create staging docker image + steps: + - name: Check out git repository + 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@v3.0.0 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3.1.0 + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v5.1.0 + with: + context: ./ + file: ./Dockerfile + push: true + tags: "clinicalgenomics/genotype-api-stage:${{steps.get_branch_name.outputs.branch}}, clinicalgenomics/genotype-api-stage:latest" diff --git a/.github/workflows/release_ci.yml b/.github/workflows/build_dockerfile_on_release.yml similarity index 100% rename from .github/workflows/release_ci.yml rename to .github/workflows/build_dockerfile_on_release.yml diff --git a/.github/workflows/bumpversion.yml b/.github/workflows/bumpversion.yml new file mode 100644 index 0000000..5662933 --- /dev/null +++ b/.github/workflows/bumpversion.yml @@ -0,0 +1,18 @@ +name: "Bump2version-CI" +on: + push: + branches: + - "master" + - "main" +jobs: + bump-version: + runs-on: ubuntu-latest + name: Bump version and push tags to master + steps: + - name: Bump version + uses: Clinical-Genomics/bump2version-ci@v3 + env: + BUMPVERSION_TOKEN: ${{ secrets.BUMPVERSION_TOKEN }} + BUMPVERSION_AUTHOR: ${{ secrets.BUMPVERSION_AUTHOR }} + BUMPVERSION_EMAIL: ${{ secrets.BUMPVERSION_EMAIL }} + GITHUB_REPOSITORY: ${{ github.repository }} diff --git a/.github/workflows/merge_master_ci.yml b/.github/workflows/merge_master_ci.yml deleted file mode 100644 index bfdc806..0000000 --- a/.github/workflows/merge_master_ci.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: 'Merge-master-CI' -on: - push: - branches: - - 'master' - - 'main' - -jobs: - bump-version: - runs-on: ubuntu-latest - name: Bump version and push tags to master - steps: - - name: Bump version - uses: Clinical-Genomics/bump2version-ci@v3 - env: - BUMPVERSION_TOKEN: ${{ secrets.BUMPVERSION_TOKEN }} - BUMPVERSION_AUTHOR: ${{ secrets.BUMPVERSION_AUTHOR }} - BUMPVERSION_EMAIL: ${{ secrets.BUMPVERSION_EMAIL }} - GITHUB_REPOSITORY: ${{ github.repository }} - - docker-image-push: - runs-on: ubuntu-latest - name: Create staging image - steps: - - name: Check out git repository - 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@v3.0.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3.1.0 - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v5.1.0 - with: - context: ./ - file: ./Dockerfile - push: true - tags: "clinicalgenomics/genotype-api-stage:${{steps.get_branch_name.outputs.branch}}, clinicalgenomics/genotype-api-stage:latest" - - tests-coverage: - runs-on: ubuntu-latest - name: Test and coveralls - steps: - - name: Set up Python - uses: actions/setup-python@v5.0.0 - with: - python-version: "3.10" - - - name: Check out genotype-api - uses: actions/checkout@v4.1.1 - with: - repository: "Clinical-Genomics/genotype-api" - - - name: Install genotype-api dependencies - run: | - pip install -r requirements.txt -r requirements-dev.txt . - - name: Install coveralls dependencies - run: | - pip install pytest-cov coveralls - - name: Test with pytest & Coveralls - run: | - pytest --cov=genotype-api/ - coveralls - env: - GITHUB: 1 - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} diff --git a/.github/workflows/pull_request_ci.yml b/.github/workflows/pull_request_ci.yml deleted file mode 100644 index 3aad712..0000000 --- a/.github/workflows/pull_request_ci.yml +++ /dev/null @@ -1,78 +0,0 @@ ---- - -name: Pull Request Actions - -on: [push] - -jobs: - black-lint: - runs-on: ubuntu-latest - name: Black - steps: - - uses: actions/checkout@v4.1.1 - - uses: actions/setup-python@v5.0.0 - - uses: psf/black@stable - with: - black_args: ". --check --line-length 100" - - docker-image-push: - runs-on: ubuntu-latest - name: Create staging docker image - steps: - - name: Check out git repository - 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@v3.0.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3.1.0 - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v5.1.0 - with: - context: ./ - file: ./Dockerfile - push: true - tags: "clinicalgenomics/genotype-api-stage:${{steps.get_branch_name.outputs.branch}}, clinicalgenomics/genotype-api-stage:latest" - - tests-coverage: - runs-on: ubuntu-latest - name: Test and coveralls - steps: - - name: Set up Python - uses: actions/setup-python@v5.0.0 - with: - python-version: "3.10" - - - name: Check out genotype-api - uses: actions/checkout@v4.1.1 - with: - repository: "Clinical-Genomics/genotype-api" - - - name: Install genotype-api dependencies - run: | - pip install -r requirements.txt -r requirements-dev.txt . - - - name: Install coveralls dependencies - run: | - pip install pytest-cov coveralls - - - name: Test with pytest & Coveralls - run: | - pytest --cov=genotype_api/ - coveralls - env: - GITHUB: 1 - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}