Skip to content
Open
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
102 changes: 62 additions & 40 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
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 }}
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
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
python orm migrate --connection postgres -d tests/integrations/migrations
python orm migrate --connection mysql -d tests/integrations/migrations
- 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
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,4 @@ coverage.xml
.coverage
*.log
build
/orm.sqlite3
/.bootstrapped-pip
/.ignore-pre-commit
/.bootstrapped-*
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,13 @@ repos:
^build|
^conda
)

- repo: local
hooks:
- id: check-test-asserts
name: Check tests have assertions
description: Ensures every test method contains at least one assert statement
entry: python scripts/check_test_asserts.py
language: system
files: ^tests/.*test_.*\.py$
pass_filenames: false
101 changes: 0 additions & 101 deletions app/observers/UserObserver.py

This file was deleted.

35 changes: 0 additions & 35 deletions config/test-database.py

This file was deleted.

28 changes: 0 additions & 28 deletions databases/migrations/2018_01_09_043202_create_users_table.py

This file was deleted.

18 changes: 0 additions & 18 deletions databases/migrations/2020_04_17_00000_create_articles_table.py

This file was deleted.

3 changes: 0 additions & 3 deletions databases/migrations/__init__.py

This file was deleted.

10 changes: 0 additions & 10 deletions databases/seeds/database_seeder.py

This file was deleted.

16 changes: 0 additions & 16 deletions databases/seeds/user_table_seeder.py

This file was deleted.

6 changes: 4 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ init-ci:

# Create MySQL Database
# Create Postgres Database
test: init
test: init test-asserts
python -m pytest tests
ci:
make test
check: format sort lint
check: format sort lint test-asserts
lint:
flake8 src/masoniteorm tests
test-asserts:
python scripts/check_test_asserts.py
format: init
black src/masoniteorm tests/
sort: init
Expand Down
Binary file removed orm.sqlite3
Binary file not shown.
Loading