-
Notifications
You must be signed in to change notification settings - Fork 2
144 lines (126 loc) · 3.8 KB
/
Copy pathapi-quality.tpl.yml
File metadata and controls
144 lines (126 loc) · 3.8 KB
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
135
136
137
138
139
140
141
142
143
144
---
name: "Template: Run code checks on Python project"
on:
workflow_call:
inputs:
## General
working-directory:
required: true
type: string
description: |
"Directory in which the terraform project is located"
python-version:
required: false
default: "3.12"
type: string
description: |
"Python version to use"
run-tests:
required: false
type: boolean
description: |
"Run tests before zipping the lambda"
default: true
permissions:
id-token: write
contents: read
pull-requests: write
jobs:
check:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working-directory }}
services:
postgres:
image: postgres:17.5
env:
POSTGRES_DB: app
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_PORT: 5432
options: >-
--health-cmd "pg_isready --dbname=app --username=postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
id: setup-python
with:
version: 0.7.5
python-version: ${{ inputs.python-version }}
enable-cache: true
cache-dependency-glob: |
**/uv.lock
**/pyproject.toml
- name: Cache hit
run: echo '${{ steps.setup-python.outputs.cache-hit }}' # true if cache-hit occured on the primary key
- name: Install CI dependencies
run: uv sync --all-extras
- name: Run migrations
run: uv run app database upgrade head --no-prompt
- name: pytest
id: pytest
if: ${{ inputs.run-tests }}
run: uv run pytest
continue-on-error: true
- name: PyTest Failure
if: inputs.run-tests && steps.pytest.outcome == 'failure'
uses: mshick/add-pr-comment@v2
with:
message-id: check-zip-lambda-pytest-${{ inputs.working-directory }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
message: |
#### PyTest failed for **${{ inputs.working-directory }}**:
```
${{ steps.pytest.outputs.stdout }}
```
- name: mypy
id: mypy
run: uv run mypy .
continue-on-error: true
- name: Mypy Failure
if: steps.mypy.outcome == 'failure'
uses: mshick/add-pr-comment@v2
with:
message-id: check-zip-lambda-mypy-${{ inputs.working-directory }}
allow-repeats: true
repo-token: ${{ secrets.GITHUB_TOKEN }}
message: |
#### Mypy failed for **${{ inputs.working-directory }}**:
```
${{ steps.mypy.outputs.stdout }}
```
```
${{ steps.mypy.outputs.stderr }}
```
- name: ruff check
id: ruff
run: uv run ruff check --output-format=github --fix .
continue-on-error: true
- name: Ruff Failure
if: steps.ruff.outcome == 'failure'
uses: mshick/add-pr-comment@v2
with:
message-id: check-zip-lambda-ruff-${{ inputs.working-directory }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
message: |
#### Ruff failed for **${{ inputs.working-directory }}**:
```
${{ steps.ruff.outputs.stdout }}
```
```
${{ steps.ruff.outputs.stderr }}
```
- name: Errors Found
if: >-
steps.pytest.outcome == 'failure' ||
steps.mypy.outcome == 'failure' ||
steps.ruff.outcome == 'failure'
run: exit 1