-
Notifications
You must be signed in to change notification settings - Fork 2
151 lines (139 loc) · 4.26 KB
/
continuous-integration.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
name: Tests
on:
push:
branches:
- main
pull_request:
workflow_call:
inputs:
api_url:
required: true
type: string
deployment_env:
required: true
type: string
secrets:
API_KEY:
required: true
env:
HATCH_VERSION: "v1.7.0" # keep in sync with deploy.yml
jobs:
format-black:
name: Format black
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install Hatch
run: pip install hatch==${{ env.HATCH_VERSION }}
- name: Run black
run: hatch run code-quality:format
mypy:
name: MyPy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install Hatch
run: pip install hatch==${{ env.HATCH_VERSION }}
- name: Run mypy
run: hatch run code-quality:types
lint:
name: Lint Code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install Hatch
run: pip install hatch==${{ env.HATCH_VERSION }}
- name: Run pylint
run: hatch run code-quality:lint
isort:
name: Sort imports
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install Hatch
run: pip install hatch==${{ env.HATCH_VERSION }}
- name: Run mypy
run: hatch run code-quality:sort
pydocstyle:
name: Check docstrings
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install Hatch
run: pip install hatch==${{ env.HATCH_VERSION }}
- name: Run pydocstyle
run: hatch run code-quality:docstrings
scan-for-secrets:
name: Scan for secrets
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install gitleaks
run: wget -O - https://github.com/gitleaks/gitleaks/releases/download/v8.16.1/gitleaks_8.16.1_linux_x64.tar.gz | tar -xz
- run: ./gitleaks detect --log-opts "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
if: github.event_name == 'pull_request'
- run: ./gitleaks detect --log-opts "${{ github.event.before }}..${{ github.event.after }}"
if: github.event_name == 'push'
tests:
name: Tests
runs-on: ubuntu-latest
env:
API_KEY: "not-a-real-api-key"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install Hatch
run: pip install hatch==${{ env.HATCH_VERSION }}
- name: Run unit tests
run: hatch run test:unit-with-cov
- name: Coverage comment
if: github.event_name == 'push' || github.event_name == 'pull_request'
id: coverage_comment
uses: py-cov-action/python-coverage-comment-action@48708266a6e77ebf564b50d9cff2b7df9a25b458
with:
GITHUB_TOKEN: ${{ github.token }}
# the API_KEYs are stored as a secret in the repository
# we are using the "automated-tests" organization with predefined users and workspaces
integration_tests:
name: Integration Tests for deployment
environment: ${{ github.event.inputs.deployment_env }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run integration tests
uses: ./.github/actions/integration_tests
with:
API_KEY: "${{ inputs.deployment_env == 'release' && secrets.API_KEY_PROD || secrets.API_KEY}}"
API_URL: "${{ inputs.api_url || 'https://api.dev.cloud.dpst.dev/api/v1'}}"
build:
name: Build package
needs: [format-black, mypy, lint, tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install Hatch
run: pip install hatch==${{ env.HATCH_VERSION }}
- name: Build
run: hatch build