Skip to content

feat: add customer product status #34

feat: add customer product status

feat: add customer product status #34

Workflow file for this run

name: Check Migrations
on:
pull_request:
jobs:
prevent-changes:
runs-on: ubuntu-latest
needs: detect-diffs

Check failure on line 9 in .github/workflows/migrations.yml

View workflow run for this annotation

GitHub Actions / Check Migrations

Invalid workflow file

The workflow is not valid. .github/workflows/migrations.yml (Line: 9, Col: 12): Job 'prevent-changes' depends on unknown job 'detect-diffs'. .github/workflows/migrations.yml (Line: 31, Col: 12): Job 'check-missing-imports' depends on unknown job 'detect-diffs'.
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.base_ref }}
- name: prevent-changes-to-existing-migrations
run: |
EXISTING_MIGRATIONS=$(git ls-tree -r HEAD --name-only | grep "app/alembic/versions/.*\.py")
CHANGED_MIGRATION_FILES="${{ needs.detect-diffs.outputs.changed_migration_files }}"
for changed_migration in $CHANGED_MIGRATION_FILES; do
if echo $EXISTING_MIGRATIONS | grep "$changed_migration"; then
echo "An already existing migration should not be edited!"
exit 1
fi
done
check-missing-imports:
runs-on: ubuntu-latest
needs: detect-diffs
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Check for Missing imports in alembic
id: missing-imports
run: |
CHANGED_MODEL_FILES="${{ needs.detect-diffs.outputs.changed_model_files }}"
IMPORTS=$(grep -oP "from services\.\w+\.models\.\w+ import \w+" app/alembic/env.py)
MISSING_IMPORTS=()
for line in $CHANGED_MODEL_FILES; do
model_name=$(basename "$line" .py)
if ! echo "$IMPORTS" | grep -q "$model_name"; then
MISSING_IMPORTS+=("$model_name")
fi
done
if [ ${#MISSING_IMPORTS[@]} -ne 0 ]; then
echo "You probably forget to import follwoing models within the alembic/env file: ${MISSING_IMPORTS[*]}"
exit 1
fi
migrations:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
POSTGRES_USER: app
POSTGRES_PASSWORD: app
POSTGRES_DB: app
ports:
- "5432:5432"
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
cache: 'pip'
- name: Install requirements
working-directory: ./app
run: pip install -r requirements.txt
- name: Create .env File
working-directory: ./app
run: |
echo "DATABASE_HOST=localhost" >> .env
- name: Run Migrations UP
working-directory: ./app
run: alembic upgrade head
- name: Run alembic check
working-directory: ./app
run: |
alembic check
- name: Run Migrations DOWN
working-directory: ./app
run: alembic downgrade base