-
Notifications
You must be signed in to change notification settings - Fork 0
203 lines (171 loc) · 6.59 KB
/
commit_checks.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
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: Validation
on:
workflow_dispatch:
pull_request:
paths-ignore:
- '**.rst'
push:
jobs:
# NOTE: https://commitlint.js.org/guides/ci-setup.html
lint-commit:
name: Lint Commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install required dependencies
run: |
sudo apt update && sudo apt install -y git curl
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo DEBIAN_FRONTEND=noninteractive apt install -y nodejs
npm install conventional-changelog-conventionalcommits
npm install commitlint@latest @commitlint/config-conventional
- name: Print versions
run: |
echo "git version: $(git --version)" >> $GITHUB_STEP_SUMMARY
echo "node version: $(node --version)" >> $GITHUB_STEP_SUMMARY
echo "npm version: $(npm --version)" >> $GITHUB_STEP_SUMMARY
echo "commitlint version: $(npx commitlint --version)" >> $GITHUB_STEP_SUMMARY
- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push'
run: npx commitlint --last --verbose
lint-code:
name: Lint Code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Venv and Setup
run: |
echo -e "## Python Info\n" >> $GITHUB_STEP_SUMMARY
echo "- Python Version: \`$( python --version )\`" >> $GITHUB_STEP_SUMMARY
echo "- Python Binary: \`$( which python )\`" >> $GITHUB_STEP_SUMMARY
python -m venv .venv
source .venv/bin/activate
python -m pip install poetry mypy ruff
poetry install
- name: MyPy Check Source.
id: mypy_check_src
run: |
source .venv/bin/activate
echo -e "## MyPy \`./src\`\n\n~~~stdout" >> $GITHUB_STEP_SUMMARY
poetry run mypy --config-file pyproject.toml --pretty ./src >> $GITHUB_STEP_SUMMARY
echo -e "~~~\n" >> $GITHUB_STEP_SUMMARY
continue-on-error: true
- name: MyPy Check Tests.
id: mypy_check_tests
run: |
source .venv/bin/activate
echo -e "## MyPy \`./tests\`\n\n~~~stdout" >> $GITHUB_STEP_SUMMARY
poetry run mypy --config-file pyproject.toml --pretty ./tests >> $GITHUB_STEP_SUMMARY
echo -e "~~~\n" >> $GITHUB_STEP_SUMMARY
continue-on-error: true
- name: Ruff Linting.
id: ruff
run: |
source .venv/bin/activate
echo -e "## Ruff\n\n~~~stdout" >> $GITHUB_STEP_SUMMARY
poetry run ruff check --config pyproject.toml --output-format github .>> $GITHUB_STEP_SUMMARY
echo -e "~~~\n" >> $GITHUB_STEP_SUMMARY
continue-on-error: true
- run: |
if ( \
[ "${{ steps.mypy_check_src.outcome }}" != "success" ] \
|| [ "${{ steps.mypy_check_tests.outcome }}" != "success" ] \
|| [ "${{ steps.ruff.outcome }}" != 'success' ]
); then
echo "One or more checks failed. See the summary for details."
exit 1
fi
pytest:
name: PyTest
runs-on: ubuntu-latest
steps:
- name: Checkout.
uses: actions/checkout@v4
# NOTE: ``mkdir`` step is required for propper permissions on ``~/.venv``
# (not used here).
#
# Use ``docker compose --file docker/compose.yaml config | less``
# to see the config with interpolated variables from ``.env``.
# More about interpolation: https://docs.docker.com/compose/environment-variables/variable-interpolation/
- name: Setup.
run: |
docker_config_path='/home/captura/app/tests/assets/act.yaml'
echo "CAPTURA_CONFIG_CLIENT_TEST=$docker_config_path" > .env
echo "CAPTURA_CONFIG_CLIENT=$docker_config_path" >> .env
echo "CAPTURA_CONFIG_APP_TEST=$docker_config_path" >> .env
echo "CAPTURA_CONFIG_APP=$docker_config_path" >> .env
echo "CAPTURA_FLAKEY=/home/captura/flakey.yaml" >> .env
- name: Start Docker Compose Project.
run: |
docker compose \
--file docker/compose.ci.yaml \
--env-file .env \
up --detach --quiet-pull
docker compose \
--file docker/compose.ci.yaml \
exec server \
bash -c ' \
mkdir --parents ~/app/.venv \
&& python -m venv ~/app/.venv'
# NOTE: ``act.yaml`` defined everything necessary for the client and server.
- name: Install Dependencies In Server.
run: |
docker compose \
--file docker/compose.ci.yaml \
exec server \
bash -c ' \
source ~/app/.venv/bin/activate \
&& pip install --quiet poetry \
&& poetry install --with test'
- name: Generate Dummy Data In Server.
run: |
version=$( \
docker compose \
--file docker/compose.ci.yaml \
exec db mysql --version \
)
echo "MySQL Version: $version" >> $GITHUB_STEP_SUMMARY
docker compose \
--file docker/compose.ci.yaml \
exec server \
bash -c ' \
source ~/app/.venv/bin/activate \
&& poetry run simulatus initialize \
&& poetry run simulatus apply'
echo -e "# Dummy Data Report\n\n~~~" >> $GITHUB_STEP_SUMMARY
docker compose \
--file docker/compose.ci.yaml \
exec server \
bash -c ' \
source ~/app/.venv/bin/activate \
&& poetry run simulatus --loud reports aggregate' \
>> $GITHUB_STEP_SUMMARY
echo -e "~~~\n" >> $GITHUB_STEP_SUMMARY
- name: Run Tests.
run: |
docker compose \
--file docker/compose.ci.yaml \
exec server \
bash -c ' \
source ~/app/.venv/bin/activate \
&& pip install poetry \
&& poetry run coverage run -m pytest --count 1'
continue-on-error: true
- name: Create Coverage Report.
run: |
docker compose \
--file docker/compose.ci.yaml \
exec server \
bash -c ' \
source ~/app/.venv/bin/activate \
&& poetry run coverage html'
- name: Stop Compose Project.
if: always()
run: docker compose --file docker/compose.ci.yaml down