-
Notifications
You must be signed in to change notification settings - Fork 0
184 lines (182 loc) 路 7.09 KB
/
Copy pathpr.yml
File metadata and controls
184 lines (182 loc) 路 7.09 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
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
name: Pull Request Check
on: [pull_request]
jobs:
build:
name: "Build docker image"
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ./.github/actions/setup-test-image
lint-ruff:
name: "Lint check (ruff and pyright)"
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: astral-sh/ruff-action@278981a28ce3188b1e39527901f38254bf3aac89 # v4.1.0
- name: Install uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock
- name: Restore cache
id: cache-venv
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/pyproject.toml', '**/uv.lock') }}
restore-keys: |
venv-${{ runner.os }}-
- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
env:
UV_MALWARE_CHECK: "1"
run: |
uv sync --frozen --no-install-project
- name: Run typecheck
run: |
make typecheck
guardrail-check:
name: "Guardrail checks"
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock
- name: Restore cache
id: cache-venv
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/pyproject.toml', '**/uv.lock') }}
restore-keys: |
venv-${{ runner.os }}-
- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
env:
UV_MALWARE_CHECK: "1"
run: |
uv sync --frozen --no-install-project
- name: Run guardrail checks
run: |
make test_guardrail_check
unit-test:
name: "Unit tests"
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: true
matrix:
include:
- db: postgres
test_target: "tests/app/"
- db: mysql
test_target: "tests/app/"
- db: postgres
test_target: "tests/batch/"
- db: mysql
test_target: "tests/batch/"
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ./.github/actions/setup-test-image
- name: build image on compose
run: docker compose build
- name: Change owner of output directory
run: |
sudo chown runner:docker /home/runner/work/ibet-Wallet-API/ibet-Wallet-API/cov
sudo chmod 777 /home/runner/work/ibet-Wallet-API/ibet-Wallet-API/cov
- name: run unit test using ${{ matrix.db }}
run: docker compose run -e TEST_TARGET="${{ matrix.test_target }}" ibet-wallet-api-${{ matrix.db }}
- run: mv cov/.coverage cov/.coverage-${{ strategy.job-index }}
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: matrix.db == 'postgres'
with:
name: .coverage-${{ strategy.job-index }}
path: cov/.coverage-${{ strategy.job-index }}
include-hidden-files: true
- run: mv cov/pytest.xml cov/pytest-${{ strategy.job-index }}.xml
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: matrix.db == 'postgres'
with:
name: pytest-${{ strategy.job-index }}
path: cov/pytest-${{ strategy.job-index }}.xml
collect_coverage:
runs-on: ubuntu-latest
needs: unit-test
permissions:
actions: read
contents: read
packages: read
pull-requests: write
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ./.github/actions/setup-test-image
- name: build image on compose
run: docker compose build
- name: Change owner of output directory
run: |
sudo chown runner:docker /home/runner/work/ibet-Wallet-API/ibet-Wallet-API/cov
sudo chmod 777 /home/runner/work/ibet-Wallet-API/ibet-Wallet-API/cov
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: ".coverage-*"
path: cov/
merge-multiple: true
- name: combine coverage files
run: docker compose run -w /app/ibet-Wallet-API/cov ibet-wallet-api-postgres bash --login -c 'uv run coverage combine .coverage-*'
- name: generate coverage xml file
run: docker compose run -w /app/ibet-Wallet-API ibet-wallet-api-postgres bash --login -c 'uv run coverage xml --data-file=cov/.coverage -o cov/coverage.xml'
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: "pytest-*"
path: cov/
merge-multiple: true
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
- name: Install junit-report-merger
run: npm install -g junit-report-merger@9.0.3
- name: Merge reports
run: jrm cov/pytest.xml "cov/pytest-*.xml"
- name: Pytest coverage comment
id: coverageComment
uses: MishaKav/pytest-coverage-comment@09c28b6767e12a048e0b23e821ed03133ee48a1a # v1.11.0
with:
report-only-changed-files: true
pytest-xml-coverage-path: cov/coverage.xml
junitxml-path: cov/pytest.xml
- name: Count test cases in repository
id: countTest
run: |
RESULT=$(docker compose run -w /app/ibet-Wallet-API ibet-wallet-api-postgres bash --login -c 'uv run pytest --collect-only | grep -e "<Function" -e "<Coroutine"' | wc -l)
echo "test_count=${RESULT}" >> $GITHUB_OUTPUT
- run: echo ${{ steps.coverageComment.outputs.tests }}
- run: echo ${{ steps.countTest.outputs.test_count }}
- name: Check the count of test cases in CI
if: steps.coverageComment.outputs.tests != steps.countTest.outputs.test_count
run: exit 1
migration-test:
name: "Migration tests"
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: true
matrix:
db: [postgres, mysql]
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ./.github/actions/setup-test-image
- name: run unit test using ${{ matrix.db }}
run: docker compose run ibet-wallet-api-${{ matrix.db }} bash --login -c "cd /app/ibet-Wallet-API && uv run pytest -vv --test-alembic -m 'alembic'"