-
Notifications
You must be signed in to change notification settings - Fork 1
133 lines (115 loc) · 3.7 KB
/
python.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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 }}