Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump deps #16

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
214 changes: 214 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
name: CI

on:
push:
branches:
- main
tags:
- v*
pull_request: {}

env:
POETRY_VERSION: "1.3.1"
MINIMUM_PYTHON_VERSION: "3.10"

jobs:
lint:
name: ${{ matrix.task.name }} (${{ matrix.os }})
strategy:
max-parallel: 4
fail-fast: false
matrix:
# Only run checks for ubuntu
os: [ubuntu]
task:
- name: Lint code
run: make lint

runs-on: ${{ matrix.os }}-latest

steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
- name: Set up python ${{ env.MINIMUM_PYTHON_VERSION }}
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('.github/workflows/ci.yml')}}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-root
poetry install --only ci
#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
run: poetry install --no-interaction
#----------------------------------------------
# Run matrix task
#----------------------------------------------
- name: ${{ matrix.task.name }}
run: ${{ matrix.task.run }}

check-fmt:
name: ${{ matrix.task.name }} (${{ matrix.os }})
strategy:
max-parallel: 4
fail-fast: false
matrix:
# Only run checks for ubuntu
os: [ubuntu]
task:
- name: Check formatting
run: make check-fmt

runs-on: ${{ matrix.os }}-latest

steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
- name: Set up python ${{ env.MINIMUM_PYTHON_VERSION }}
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('.github/workflows/ci.yml')}}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-root
poetry install --only ci
#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
run: poetry install --no-interaction
#----------------------------------------------
# Run matrix task
#----------------------------------------------
- name: ${{ matrix.task.name }}
run: ${{ matrix.task.run }}

type-check:
name: ${{ matrix.task.name }} (${{ matrix.os }})
strategy:
max-parallel: 4
fail-fast: false
matrix:
# Only run checks for ubuntu
os: [ubuntu]
task:
- name: Type check
run: make type-check

runs-on: ${{ matrix.os }}-latest

steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
- name: Set up python ${{ env.MINIMUM_PYTHON_VERSION }}
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('.github/workflows/ci.yml')}}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-root
poetry install --only ci
#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
run: poetry install --no-interaction
#----------------------------------------------
# Run matrix task
#----------------------------------------------
- name: ${{ matrix.task.name }}
run: ${{ matrix.task.run }}



# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
check:
if: always()
needs: [lint, type-check, check-fmt]
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}

39 changes: 0 additions & 39 deletions .github/workflows/python-app.yml

This file was deleted.

35 changes: 35 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
default: test

INVENV := if env_var_or_default('VIRTUAL_ENV', "") == "" { "poetry run" } else { "" }


alias dev := install-dev
# installs the project for development
install-dev:
poetry install

# installs the project for deployment
install:
poetry install --only main

# setup CI environment
install-ci: install-dev
poetry install --only ci


# lint all code
lint *flags="":
{{INVENV}} ruff {{flags}} app

# format all python files
fmt:
{{INVENV}} black src tests

# check formatting for all python files
check-fmt:
{{INVENV}} black --check src tests

# serve sblex-server with reloading
serve-dev:
{{INVENV}} watchfiles "gunicorn --chdir app --bind 'localhost:8000' app.views:app" app

70 changes: 70 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@


.default: help

ifeq (${VIRTUAL_ENV},)
INVENV = poetry run
else
INVENV =
endif

.PHONY: help
help:
@echo "USAGE"
@echo "====="
@echo ""
@echo "install-dev (alias: dev)"
@echo " installs the project for development"

@echo "install"
@echo " installs the project for deployment"

@echo "install-ci"
@echo " installs the project for CI"

@echo "lint"
@echo " lint all code"

@echo "fmt"
@echo " format all python files"

@echo "check-fmt"
@echo " check formatting for all python files"

@echo "serve-dev"
@echo " serve sblex-server with reloading"

dev: install-dev
install-dev:
poetry install

install:
poetry install --only main --sync

# setup CI environment
install-ci: install-dev
poetry install --only ci

.PHONY: lint
lint:
${INVENV} ruff app

fmt:
${INVENV} black app

.PHONY: check-fmt
check-fmt:
${INVENV} black --check app

# type-check the code
.PHONY: type-check
type-check:
${INVENV} mypy --config-file mypy.ini app

# build the project
build:
poetry build

serve-dev:
${INVENV} watchfiles "uvicorn --bind localhost:8000 app.views:app" app

16 changes: 0 additions & 16 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +0,0 @@
# -*- coding: utf-8 -*
import sys
from flask import Flask
import importlib


app = Flask(__name__)

# import all urls
from .views import *

if __name__ == '__main__':
if sys.version_info.major < 3:
importlib.reload(sys)
sys.setdefaultencoding('utf8')
app.run(port='5002')
10 changes: 0 additions & 10 deletions app/requirements.txt

This file was deleted.

Loading