build(deps): bump node from 19.6.0-bullseye-slim to 20.8.0-bullseye-slim #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Python | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
pull_request: {} | |
permissions: | |
actions: write | |
contents: read | |
# TODO most of these should be versioned in .env.test and loaded, for another day | |
env: | |
PYTHONPATH: ${{ github.workspace }} | |
# for depreciated sklearn package, hopefully we can remove in the future | |
SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL: true | |
TEST_DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres | |
TEST_REDIS_URL: redis://localhost:6379/0 | |
PRISMA_EXPECTED_ENGINE_VERSION: aead147aa326ccb985dcfed5b065b4fdabd44b19 | |
OPENAI_KEY: sk-ca4240cf-ca50-4b16-8eaa-742a68473ff8 | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
FAISS_INDEXES_PATH: tmp/indexes | |
MODEL_DATA_PATH: tmp/models | |
DATASETS_PATH: tmp/datasets | |
VALIDATION_PATH: tmp/validation | |
FEW_SHOT_EMBEDDINGS_PATH: tmp/few_shot | |
jobs: | |
# TODO why can't we define runs-on this for the entire workflow? | |
lint: | |
name: PyLint | |
runs-on: ubuntu-latest | |
# https://stackoverflow.com/questions/71679568/github-actions-ignore-or-exclude-dependabot-pull-requests | |
if: ${{ github.triggering_actor != 'dependabot[bot]' }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/python-setup | |
- name: lint | |
run: bin/pylint | |
formatting: | |
name: Black Formatting | |
runs-on: ubuntu-latest | |
if: ${{ github.triggering_actor != 'dependabot[bot]' }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/python-setup | |
- name: code formatting | |
shell: bash | |
continue-on-error: true | |
run: | | |
poetry run black --version | |
poetry run black --check . | |
- name: import sorting | |
shell: bash | |
run: poetry run isort **/*.py -c -v | |
typecheck: | |
name: pyright | |
runs-on: ubuntu-latest | |
if: ${{ github.triggering_actor != 'dependabot[bot]' }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/python-setup | |
- name: 🔎 Type check | |
run: poetry run npx pyright | |
pytest: | |
name: Pytest | |
runs-on: ubuntu-latest | |
if: ${{ github.triggering_actor != 'dependabot[bot]' }} | |
services: | |
redis: | |
image: redis | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
# Maps port 6379 on service container to the host | |
- 6379:6379 | |
postgres: | |
image: postgres | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_PASSWORD: postgres | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/python-setup | |
- run: DATABASE_URL=$TEST_DATABASE_URL poetry run npx prisma migrate reset --force | |
- name: ⚡ Run Pytest | |
run: poetry run pytest | |
deploy: | |
name: 🚀 Deploy | |
runs-on: ubuntu-latest | |
# needs: [lint, typecheck, vitest, depcheck] | |
needs: [formatting, typecheck] | |
# only build/deploy main branch on pushes | |
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }} | |
steps: | |
- name: 🛑 Cancel Previous Runs | |
uses: styfle/[email protected] | |
- name: ⬇️ Checkout repo | |
uses: actions/checkout@v3 | |
- name: 👀 Read app name | |
uses: SebRollen/[email protected] | |
id: app_name | |
with: | |
file: "python.toml" | |
field: "app" | |
# TODO add staging deploy in the future if on dev branch | |
- name: 🚀 Deploy Production | |
if: ${{ github.ref == 'refs/heads/main' }} | |
uses: superfly/[email protected] | |
with: | |
args: "deploy --config python.toml" | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |