-
-
Notifications
You must be signed in to change notification settings - Fork 4
187 lines (176 loc) · 6.09 KB
/
main.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: CI
on:
# This trigger is required by fastapi-mvc automation to dispatch this concrete workflow
# from fastapi-mvc 'CI workflow' (https://github.com/fastapi-mvc/cookiecutter/actions/workflows/main.yml),
# and await its result. NOTE! This is not included in the template.
workflow_dispatch:
inputs:
distinct_id:
required: true
description: "Input required by codex-/return-dispatch@v1"
push:
branches:
- master
pull_request:
branches:
- master
env:
POETRY_HOME: /opt/poetry
POETRY_CONFIG_DIR: /opt/poetry
POETRY_CACHE_DIR: /opt/poetry/cache
POETRY_VIRTUALENVS_PATH: /opt/poetry/store
DEFAULT_PYTHON: '3.10'
jobs:
meta:
runs-on: ubuntu-latest
steps:
# This echo is required by codex-/return-dispatch@v1 in order to identify dispatched workflow.
# NOTE! This is not included in the template.
- name: echo distinct ID ${{ github.event.inputs.distinct_id }}
run: echo ${{ github.event.inputs.distinct_id }}
# This job checks if an identical workflow is being triggered by different
# event and skips it. For instance there is no need to run the same pipeline
# twice for pull_request and push for identical commit sha.
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/[email protected]
with:
skip_after_successful_duplicate: 'true'
concurrent_skipping: same_content
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]'
install:
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11' ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Init Poetry cache
id: cached-poetry
uses: actions/cache@v3
with:
path: ${{ env.POETRY_HOME }}
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('./pyproject.toml') }}-${{ hashFiles('./poetry.lock') }}
- name: Install package
run: make install
if: steps.cached-poetry.outputs.cache-hit != 'true'
build:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Load Poetry cache
uses: actions/cache@v3
with:
path: ${{ env.POETRY_HOME }}
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-${{ hashFiles('./pyproject.toml') }}-${{ hashFiles('./poetry.lock') }}
- name: Build wheel
run: make build
- name: Archive build artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ format('fastapi_mvc-{0}', github.sha) }}
path: dist
retention-days: 60
metrics:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Load Poetry cache
uses: actions/cache@v3
with:
path: ${{ env.POETRY_HOME }}
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-${{ hashFiles('./pyproject.toml') }}-${{ hashFiles('./poetry.lock') }}
- name: Run metrics checks
run: make metrics
unit-tests:
needs: install
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11' ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Load Poetry cache
uses: actions/cache@v3
with:
path: ${{ env.POETRY_HOME }}
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('./pyproject.toml') }}-${{ hashFiles('./poetry.lock') }}
- name: Run unit tests
run: make unit-test
integration-tests:
needs: install
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11' ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Load Poetry cache
uses: actions/cache@v3
with:
path: ${{ env.POETRY_HOME }}
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('./pyproject.toml') }}-${{ hashFiles('./poetry.lock') }}
- name: Run integration tests
run: make integration-test
coverage:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Load Poetry cache
uses: actions/cache@v3
with:
path: ${{ env.POETRY_HOME }}
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-${{ hashFiles('./pyproject.toml') }}-${{ hashFiles('./poetry.lock') }}
- name: Run coverage
run: make coverage
mypy:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Load Poetry cache
uses: actions/cache@v3
with:
path: ${{ env.POETRY_HOME }}
key: ${{ runner.os }}-${{ env.DEFAULT_PYTHON }}-${{ hashFiles('./pyproject.toml') }}-${{ hashFiles('./poetry.lock') }}
- name: Run mypy checks
run: make mypy