-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (135 loc) · 4.41 KB
/
ci.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
name: tests
env:
COMPOSE_DOCKER_CLI_BUILD: 1
WEBAPP_COMPOSE_FILE: ${{ github.workspace }}/ankihub_web/compose.yml
AWS_REGION: us-east-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
on:
push:
branches:
- "main"
pull_request:
jobs:
test-addon:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Checkout ankihub_addon
uses: actions/checkout@v3
- name: Setup addon
uses: ./.github/actions/setup-addon
with:
google_api_key: ${{ secrets.GOOGLE_API_KEY }}
install_qt: true
- name: Run pytest with coverage
run: |
pytest ./tests/addon --cov --cov-report=xml -n 4
pytest ./tests/addon --performance -k performance -n1 --cov-report=xml --cov-append
- name: Upload coverage
uses: actions/upload-artifact@v2
with:
name: coverage_addon
path: .coverage
test-client:
runs-on: ubuntu-latest
strategy:
matrix:
group: [1, 2]
timeout-minutes: 30
steps:
- uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Checkout ankihub_addon
uses: actions/checkout@v3
- name: Setup addon
uses: ./.github/actions/setup-addon
with:
google_api_key: ${{ secrets.GOOGLE_API_KEY }}
install_qt: false
- name: Enable cloning web app repo
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.ANKIHUB_SSH_PRIVATE_KEY }}
- name: Checkout ankipalace/ankihub web app repo
uses: actions/checkout@v3
with:
repository: ankipalace/ankihub
ref: dev
path: ankihub_web
- name: Set up AnkiHub env
run: |
mv ${{ github.workspace }}/ankihub_web/.env.dev ${{ github.workspace }}/ankihub_web/.env
- uses: taiki-e/install-action@just
- name: Setup AnkiHub
working-directory: ${{ github.workspace }}/ankihub_web
run: |
just pull-all-images
docker compose run --rm django bash release.sh
just up
- name: Run pytest with coverage
run: |
pytest ./tests/client --disable-vcr --cov --cov-report=xml \
--splits 2 --group ${{ matrix.group }} --durations-path=tests/.test_durations
- name: Upload coverage
uses: actions/upload-artifact@v2
with:
name: coverage_client_${{ matrix.group }}
path: .coverage
coverage-and-static-checks:
needs: ["test-addon", "test-client"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: "3.9"
- name: Setup addon
uses: ./.github/actions/setup-addon
with:
google_api_key: ${{ secrets.GOOGLE_API_KEY }}
install_qt: false
- name: Download all artifacts
uses: actions/download-artifact@v2
- name: Run coverage
run: |
coverage combine coverage*/.coverage*
coverage html --fail-under=76
- name: Install smokeshow
run: |
python -m pip install smokeshow
- uses: codecov/codecov-action@v1
- name: Upload coverage report with smokeshow
run: smokeshow upload coverage_html_report
if: always()
env:
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Add-on Test Coverage {coverage-percentage}
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 66
SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
- name: Upload coverage to Codecov
if: always()
env:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: false
- name: Create ankiaddon file
run: |
bash ./scripts/release.sh
env:
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
- name: Archive .ankiaddon
uses: actions/upload-artifact@v3
with:
name: ankihub_addon_${{ github.sha }}
path: ankihub.ankiaddon
- name: Run pre-commit
run: pre-commit run --all
- name: Run mypy
run: mypy