|
| 1 | +name: Test project {{ package.name }} |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - "{{ package.path }}/**" |
| 7 | + - "libs/jims*/**" |
| 8 | + - "libs/vedana*/**" |
| 9 | + # - "pyproject.toml" |
| 10 | + # - "uv.lock" |
| 11 | + push: |
| 12 | + branches: [master] |
| 13 | + paths: |
| 14 | + - "{{ package.path }}/**" |
| 15 | + - "pyproject.toml" |
| 16 | + - "uv.lock" |
| 17 | + |
| 18 | +jobs: |
| 19 | + test: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + {%- if package.generate_alembic_migration_check_step %} |
| 22 | + services: |
| 23 | + postgres: |
| 24 | + image: pgvector/pgvector:pg15 |
| 25 | + env: |
| 26 | + POSTGRES_USER: postgres |
| 27 | + POSTGRES_PASSWORD: postgres |
| 28 | + ports: |
| 29 | + - 5432:5432 |
| 30 | + options: >- |
| 31 | + --health-cmd="pg_isready -U postgres" |
| 32 | + --health-interval=10s |
| 33 | + --health-timeout=5s |
| 34 | + --health-retries=5 |
| 35 | + {%- endif %} |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v4 |
| 38 | + with: |
| 39 | + lfs: true |
| 40 | + |
| 41 | + - name: Set up Python 3.12 |
| 42 | + uses: actions/setup-python@v5 |
| 43 | + with: |
| 44 | + python-version: "3.12" |
| 45 | + |
| 46 | + - name: Install the latest version of uv |
| 47 | + uses: astral-sh/setup-uv@v6 |
| 48 | + |
| 49 | + - name: Install |
| 50 | + shell: bash |
| 51 | + run: | |
| 52 | + cd {{ package.path }} |
| 53 | + uv sync --all-groups |
| 54 | + {%- if package.custom_steps %} |
| 55 | + {%- for step in package.custom_steps %} |
| 56 | + |
| 57 | + - {{ step | to_nice_yaml | indent(8) }} |
| 58 | + {%- endfor %} |
| 59 | + {%- endif %} |
| 60 | + {%- if package.generate_standard_pytest_step %} |
| 61 | + |
| 62 | + - name: Run tests |
| 63 | + env: |
| 64 | + {% raw %}OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}{% endraw %} |
| 65 | + shell: bash |
| 66 | + run: | |
| 67 | + uv run pytest {{ package.path }}/ |
| 68 | + {%- endif %} |
| 69 | + |
| 70 | + - name: Check formatting |
| 71 | + shell: bash |
| 72 | + run: | |
| 73 | + uv run ruff check {{ package.path }} |
| 74 | + {%- if package.generate_typechecking_step and package.typechecker == "mypy" %} |
| 75 | + |
| 76 | + - name: Check typing |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + uv run mypy -p {{ package.package_name }} |
| 80 | + {%- endif %} |
| 81 | + {%- if package.generate_typechecking_step and package.typechecker == "ty" %} |
| 82 | + |
| 83 | + - name: Check typing |
| 84 | + shell: bash |
| 85 | + run: | |
| 86 | + uv run ty check {{ package.path }} |
| 87 | + {%- endif %} |
| 88 | + {%- if package.generate_alembic_migration_check_step %} |
| 89 | + |
| 90 | + - name: Check Alembic migrations |
| 91 | + shell: bash |
| 92 | + run: | |
| 93 | + cd {{ package.path }} |
| 94 | + env $(cat .env.ci-cd | grep -v '^#') uv run alembic upgrade heads |
| 95 | + env $(cat .env.ci-cd | grep -v '^#') uv run alembic check |
| 96 | + {%- endif %} |
0 commit comments