Skip to content

Commit

Permalink
feat: configure the base setup on github (#1)
Browse files Browse the repository at this point in the history
* feat: configure the base setup on github

* fix: fix git and make installation

* fix: fix python version for testing

* fix: avoid pip cache from setup-python action
  • Loading branch information
allisson authored Aug 26, 2022
1 parent d4a92e5 commit 803b70c
Show file tree
Hide file tree
Showing 10 changed files with 563 additions and 1 deletion.
49 changes: 49 additions & 0 deletions .github/workflows/lint-and-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Execute lint and tests

on: [push]

env:
DATABASE_URL: "postgres://fastqueue:fastqueue@postgres:5432/fastqueue"

jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14-alpine
env:
POSTGRES_DB: fastqueue
POSTGRES_USER: fastqueue
POSTGRES_PASSWORD: fastqueue
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Install system dependencies
run: sudo apt update && sudo apt install --no-install-recommends -y make git
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cache/pypoetry/virtualenvs
~/.cache/pre-commit
key: self-runner-${{ runner.os }}-python-3.10-poetry-${{ hashFiles('poetry.lock') }}-precommit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Set up Python 3.10.6
uses: actions/setup-python@v4
with:
python-version: 3.10.6
- name: Install dependencies
run: |
cp env.sample .env
python -m pip install --upgrade pip
pip install poetry
poetry config virtualenvs.create false
poetry install
- name: pre-commit lint
run: make lint
- name: pytest
run: make test
41 changes: 41 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-ast
- id: fix-byte-order-marker
- id: check-docstring-first
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: destroyed-symlinks
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
hooks:
- id: absolufy-imports

- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
args: ["--overwrite-in-place"]

- repo: https://github.com/psf/black
rev: 22.6.0
hooks:
- id: black
args: ["--line-length=110"]

- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8
args: ["--max-line-length=110", "--ignore=E203,E501,W503"]
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
test:
poetry run pytest -v

lint:
poetry run pre-commit run --all-files

run-db:
docker run --name postgres-fastqueue \
--restart unless-stopped \
-e POSTGRES_USER=fastqueue \
-e POSTGRES_PASSWORD=fastqueue \
-e POSTGRES_DB=fastqueue \
-p 5432:5432 \
-d postgres:14-alpine

rm-db:
docker kill $$(docker ps -aqf name=postgres-fastqueue)
docker container rm $$(docker ps -aqf name=postgres-fastqueue)

.PHONY: test lint run-db rm-db
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# fastqueue
Simple queue system based on FastAPI and PostgreSQL
Simple queue system based on FastAPI and PostgreSQL.
Empty file added env.sample
Empty file.
1 change: 1 addition & 0 deletions fastqueue/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1.0"
Loading

0 comments on commit 803b70c

Please sign in to comment.