-
Notifications
You must be signed in to change notification settings - Fork 4
134 lines (121 loc) · 3.2 KB
/
ci_python.yaml
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
134
name: Continuous Integration (Python)
on:
push:
branches:
- main
paths:
- 'src/**'
- 'tests/**'
- 'pyproject.toml'
- 'poetry.lock'
- '.github/workflows/ci_python.yaml'
- '.github/python_deps/action.yaml'
pull_request:
paths:
- 'src/**'
- 'tests/**'
- 'pyproject.toml'
- 'poetry.lock'
- '.github/workflows/ci_python.yaml'
- '.github/python_deps/action.yaml'
defaults:
run:
shell: bash
working-directory: .
concurrency:
group: python-ci-${{ github.ref }}
cancel-in-progress: true
jobs:
setup:
name: Python Setup
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/python_deps
format:
name: Format
runs-on: ubuntu-22.04
needs: setup
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/python_deps
- run: poetry run black . --check
typing:
name: Type Check
runs-on: ubuntu-22.04
needs: setup
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/python_deps
- run: poetry run mypy .
lint:
name: Lint
runs-on: ubuntu-22.04
needs: setup
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/python_deps
- run: poetry run pylint src tests --rcfile pyproject.toml
test:
name: Test
runs-on: ubuntu-22.04
needs: setup
env:
BOOTSTRAPPED: 1
MD_DB_HOST: local_rds
MD_DB_PORT: 5433
MD_DB_NAME: metadata
MD_DB_USER: postgres
MD_DB_PASSWORD: postgres
ALEMBIC_MD_DB_NAME: metadata_prod
RPM_DB_HOST: local_rds
RPM_DB_PORT: 5434
RPM_DB_NAME: performance_manager
RPM_DB_USER: postgres
RPM_DB_PASSWORD: postgres
ALEMBIC_RPM_DB_NAME: performance_manager_prod
services:
rpm_postgres:
image: postgres:14.4
ports:
- 5434:5432
env:
POSTGRES_PASSWORD: ${{env.RPM_DB_PASSWORD}}
POSTGRES_USER: ${{env.RPM_DB_USER}}
POSTGRES_DB: ${{env.RPM_DB_NAME}}
options:
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
md_postgres:
image: postgres:14.4
ports:
- 5433:5432
env:
POSTGRES_PASSWORD: ${{env.MD_DB_PASSWORD}}
POSTGRES_USER: ${{env.MD_DB_USER}}
POSTGRES_DB: ${{env.MD_DB_NAME}}
options:
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/python_deps
# Execute tests and generate coverage report
- name: Run pytest With Coverage
run: |
poetry run pytest \
--cov-report lcov:coverage.info \
--cov-report term-missing \
--cov-branch \
--cov=lamp_py
# Upload Coverage as an Artifact for Subsequent Jobs
- name: Report code coverage
uses: mbta/github-actions-report-lcov@v1
with:
coverage-files: coverage.info
artifact-name: python-code-coverage
github-token: ${{ secrets.GITHUB_TOKEN }}