Skip to content
Draft
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
96 changes: 59 additions & 37 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
@@ -1,73 +1,95 @@
name: Test Application
name: CI

on: [push, pull_request]
on:
push:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
lint:
name: Lint (ruff)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
- name: Install dev dependencies
run: make init-ci
- name: Lint & format check
run: make check

test:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
needs: lint
services:
postgres:
image: postgres:10.8
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
# will assign a random free host port
- 5432/tcp
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
mysql:
image: mysql:5.7
image: mysql:8.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: orm
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

- 3306/tcp
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
name: Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
make init-ci
- name: Test with pytest
cache: pip
- name: Install test dependencies
run: make init-ci
- name: Run migrations
env:
POSTGRES_DATABASE_HOST: localhost
POSTGRES_DATABASE_PORT: ${{ job.services.postgres.ports[5432] }}
POSTGRES_DATABASE_DATABASE: postgres
POSTGRES_DATABASE_USER: postgres
POSTGRES_DATABASE_PASSWORD: postgres
POSTGRES_DATABASE_PORT: ${{ job.services.postgres.ports[5432] }}
MYSQL_DATABASE_HOST: localhost
MYSQL_DATABASE_PORT: ${{ job.services.mysql.ports[3306] }}
MYSQL_DATABASE_DATABASE: orm
MYSQL_DATABASE_USER: root
MYSQL_DATABASE_PORT: ${{ job.services.mysql.ports[3306] }}
DB_CONFIG_PATH: tests/integrations/config/database.py
run: |
python orm migrate --connection postgres
python orm migrate --connection mysql
make test
lint:
runs-on: ubuntu-latest
name: Lint
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.6
uses: actions/setup-python@v3
with:
python-version: 3.12
- name: Install Flake8
run: |
pip install flake8-pyproject
- name: Lint
run: make lint
- name: Run tests
env:
POSTGRES_DATABASE_HOST: localhost
POSTGRES_DATABASE_PORT: ${{ job.services.postgres.ports[5432] }}
POSTGRES_DATABASE_DATABASE: postgres
POSTGRES_DATABASE_USER: postgres
POSTGRES_DATABASE_PASSWORD: postgres
MYSQL_DATABASE_HOST: localhost
MYSQL_DATABASE_PORT: ${{ job.services.mysql.ports[3306] }}
MYSQL_DATABASE_DATABASE: orm
MYSQL_DATABASE_USER: root
DB_CONFIG_PATH: tests/integrations/config/database.py
run: make test
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ coverage.xml
*.log
build
/orm.sqlite3
/.bootstrapped-pip
/.ignore-pre-commit
/.bootstrapped-*
48 changes: 20 additions & 28 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 6.0.1
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: isort
args: [--profile=black]
exclude: |
(?x)(
^build|
^conda
)
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-added-large-files
args: [--maxkb=500]
- id: debug-statements

- repo: https://github.com/psf/black
rev: 25.1.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.6
hooks:
- id: black
exclude: |
(?x)(
^build|
^conda
)

- repo: https://github.com/pycqa/flake8
rev: 7.1.2
hooks:
- id: flake8
additional_dependencies: [flake8-pyproject]
exclude: |
(?x)(
^build|
^conda
)
- id: ruff-check
args: [--fix, --exit-non-zero-on-fix]
exclude: &exclude_patterns |
(?x)(
^build/|
^conda/
)
- id: ruff-format
exclude: *exclude_patterns
70 changes: 44 additions & 26 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,54 +1,72 @@
SHELL := /bin/bash

init: .env .bootstrapped-pip .git/hooks/pre-commit
init-ci:
touch .ignore-pre-commit
make init
.PHONY: init
init: .env .bootstrapped-dev

.bootstrapped-pip: requirements.txt
.PHONY: init-ci
init-ci: .env .bootstrapped-tests

.bootstrapped-tests:
pip install -r requirements.txt
touch .bootstrapped-pip
touch .bootstrapped-tests

.git/hooks/pre-commit:
@if ! test -e ".ignore-pre-commit"; then \
pip install pre-commit; \
pre-commit install --install-hooks; \
fi
.bootstrapped-dev: .bootstrapped-tests
pip install pre-commit faker
pre-commit install
touch .bootstrapped-dev

.env:
cp .env-example .env

# Create MySQL Database
# Create Postgres Database
test: init

.PHONY: test
test: .bootstrapped-tests
python -m pytest tests

.PHONY: ci
ci:
make test
check: format sort lint
lint:
flake8 src/masoniteorm tests
format: init
black src/masoniteorm tests/
sort: init
isort src/masoniteorm tests/

.PHONY: check
check: lint format

.PHONY: lint
lint: .bootstrapped-tests
ruff check --fix --exit-non-zero-on-fix src/masoniteorm tests

.PHONY: format
format: .bootstrapped-tests
ruff format --check src/masoniteorm tests/

.PHONY: coverage
coverage:
python -m pytest --cov-report term --cov-report xml --cov=src/masoniteorm tests/
python -m coveralls

.PHONY: show
show:
python -m pytest --cov-report term --cov-report html --cov=src/masoniteorm tests/

.PHONY: cov
cov:
python -m pytest --cov-report term --cov-report xml --cov=src/masoniteorm tests/

.PHONY: publish
publish:
pip install twine
pip install build twine
make test
python setup.py sdist
python -m build
twine upload dist/*
rm -fr build dist .egg masonite.egg-info
rm -rf dist/*
rm -rf build dist *.egg-info

.PHONY: pub
pub:
python setup.py sdist
python -m build
twine upload dist/*
rm -fr build dist .egg masonite.egg-info
rm -rf dist/*
rm -rf build dist *.egg-info

.PHONY: pypirc
pypirc:
cp .pypirc ~/.pypirc
Binary file modified orm.sqlite3
Binary file not shown.
Loading