Skip to content
Snippets Groups Projects
Commit 2104d99f authored by Jakob Moser's avatar Jakob Moser
Browse files

Merge branch 'update-pipeline' into 'master'

Update pipeline to check types and formatting

See merge request !24
parents 533884ec 723f7eef
No related branches found
No related tags found
1 merge request!24Update pipeline to check types and formatting
Pipeline #6717 passed
...@@ -3,12 +3,34 @@ ...@@ -3,12 +3,34 @@
# * Author: (c) 2011-present GitLab B.V. # * Author: (c) 2011-present GitLab B.V.
# * URL: https://docs.gitlab.com/ee/ci/docker/using_kaniko.html#building-a-docker-image-with-kaniko # * URL: https://docs.gitlab.com/ee/ci/docker/using_kaniko.html#building-a-docker-image-with-kaniko
# * License: CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0) # * License: CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0)
stages:
- test
- build
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
testing:
image: python:latest
cache:
paths:
- .cache/pip
stage: test
before_script:
- pip install pipenv
- pipenv requirements --dev > requirements.txt
- pip install -r requirements.txt
script:
- black --check $CI_PROJECT_DIR
- mypy .
docker-build: docker-build:
image: image:
name: gcr.io/kaniko-project/executor:debug name: gcr.io/kaniko-project/executor:debug
entrypoint: [""] entrypoint: [""]
stage: build stage: build
# Run build stage regardless of the status of the test stage
when: always
before_script: before_script:
- mkdir -p /kaniko/.docker - mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
......
...@@ -93,6 +93,17 @@ Alembic must always be up to date in order to update the database schema. ...@@ -93,6 +93,17 @@ Alembic must always be up to date in order to update the database schema.
Please run `alembic upgrade head` after pulling changes from the repository. Please run `alembic upgrade head` after pulling changes from the repository.
--- ---
## Compliance
### Formatting
We use [black](https://github.com/psf/black) as formatting tool.
Use `black .` to run the formatter.
### Static Type Checking
Run `mypy .` to let [mypy](https://www.mypy-lang.org/) validate the Python types.
## How to move around in this repo ## How to move around in this repo
## `/portal/`: Main Application ## `/portal/`: Main Application
......
...@@ -9,7 +9,7 @@ from flask_sqlalchemy import SQLAlchemy ...@@ -9,7 +9,7 @@ from flask_sqlalchemy import SQLAlchemy
from .db_config import get_database_uri, get_uri_for_sqlite from .db_config import get_database_uri, get_uri_for_sqlite
db = SQLAlchemy() db: SQLAlchemy = SQLAlchemy()
from .model import * from .model import *
......
from flask import Flask from flask import Flask
from flask_sqlalchemy import DefaultMeta
from portal import db from portal import db
BaseModel: DefaultMeta = db.Model
class FlaskConfigEntry(db.Model):
class FlaskConfigEntry(BaseModel):
""" """
A configuration entry for Flask (a key-value pair) as persisted in a database A configuration entry for Flask (a key-value pair) as persisted in a database
""" """
......
from abc import abstractmethod from abc import abstractmethod
from typing import Any, List, Optional, Self from typing import Any, List, Optional, Self
from flask_sqlalchemy import DefaultMeta
from sqlalchemy import Column
from flask import g from flask import g
from portal import db from portal import db
BaseModel: DefaultMeta = db.Model
class Retrievable(db.Model):
class Retrievable(BaseModel):
""" """
A type whose instances can be retrieved from the database. A type whose instances can be retrieved from the database.
...@@ -17,7 +21,7 @@ class Retrievable(db.Model): ...@@ -17,7 +21,7 @@ class Retrievable(db.Model):
__abstract__ = True __abstract__ = True
@classmethod @classmethod
def get_canonical_order_column(cls) -> Optional[db.Column]: def get_canonical_order_column(cls) -> Optional[Column]:
""" """
Return the colum by which instances of this type should be canonically ordered Return the colum by which instances of this type should be canonically ordered
when retrieving them all from the database. when retrieving them all from the database.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment