forked from cartsnitch/cartsnitch
4cf6f91e95
git-subtree-dir: common git-subtree-split: 28b2939037b5932ca5d5a6c734b292c012ac675f
89 lines
2.1 KiB
YAML
89 lines
2.1 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
concurrency:
|
|
group: ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: runners-cartsnitch
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
cache: pip
|
|
- run: pip install ruff
|
|
- name: Ruff lint
|
|
run: ruff check .
|
|
- name: Ruff format check
|
|
run: ruff format --check .
|
|
|
|
typecheck:
|
|
runs-on: runners-cartsnitch
|
|
continue-on-error: true
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
cache: pip
|
|
- run: pip install -e ".[dev]"
|
|
- name: Type check
|
|
run: mypy src/cartsnitch_common
|
|
|
|
test:
|
|
runs-on: runners-cartsnitch
|
|
services:
|
|
postgres:
|
|
image: postgres:15-alpine
|
|
credentials:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
env:
|
|
POSTGRES_USER: cartsnitch
|
|
POSTGRES_PASSWORD: cartsnitch_test
|
|
POSTGRES_DB: cartsnitch_test
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
env:
|
|
DATABASE_URL: postgresql://cartsnitch:cartsnitch_test@localhost:5432/cartsnitch_test
|
|
CARTSNITCH_DATABASE_URL_SYNC: postgresql://cartsnitch:cartsnitch_test@localhost:5432/cartsnitch_test
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
cache: pip
|
|
- run: pip install -e ".[dev]"
|
|
- name: Run migrations
|
|
run: alembic upgrade head
|
|
- name: Run tests
|
|
run: pytest --tb=short -q
|
|
|
|
build:
|
|
runs-on: runners-cartsnitch
|
|
needs: [lint, test]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
- run: pip install build
|
|
- name: Build package
|
|
run: python -m build
|