-
-
Notifications
You must be signed in to change notification settings - Fork 22
178 lines (176 loc) · 5.19 KB
/
ci-main-test-coverage.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
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: CI - Main
on:
push:
branches: [main]
paths:
- icloudpy/**
- tests/**
- pylintrc
- pytest.ini
- requirements-test.txt
- /*requirements.txt
- run-ci.sh
workflow_dispatch:
jobs:
cache-requirements-install:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Cache pip dependencies
uses: actions/cache@v3
id: cache-dependencies
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: |
pip install -r requirements-test.txt
test:
needs: cache-requirements-install
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Restore pip cache dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install -r requirements-test.txt
- name: Test with pytest
run: |
pytest && rm htmlcov/.gitignore
- name: Upload coverage artifacts
uses: actions/upload-artifact@v3
if: ${{ success() }}
with:
name: coverage-output
path: htmlcov
retention-days: 1
- name: Checkout gh-pages
uses: actions/checkout@v3
if: always()
continue-on-error: true
with:
ref: gh-pages
path: gh-pages
- name: Generate Allure Report
uses: simple-elf/allure-report-action@master
if: always()
with:
allure_results: allure-results
subfolder: test-results
allure_report: allure-report
allure_history: allure-history
keep_reports: 100
- name: Generate badges
run: |
python generate_badges.py
- name: Upload tests artifacts
uses: actions/upload-artifact@v3
with:
name: test-output
path: allure-history/test-results/
retention-days: 1
- name: Upload coverage artifacts
uses: actions/upload-artifact@v3
with:
name: coverage-output
path: htmlcov
retention-days: 1
- name: Upload badges artifacts
uses: actions/upload-artifact@v3
with:
name: badges-output
path: badges
retention-days: 1
publish-test-report:
needs: test
runs-on: ubuntu-latest
steps:
- name: Download test artifacts
uses: actions/download-artifact@v3
with:
name: test-output
path: allure-history
- name: Checkout gh-pages
uses: actions/checkout@v3
if: always()
continue-on-error: true
with:
ref: gh-pages
path: gh-pages
- name: Publish test report to gh-pages
if: always()
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
publish_branch: gh-pages
publish_dir: allure-history
destination_dir: test-results
publish-coverage-report:
needs: publish-test-report
runs-on: ubuntu-latest
steps:
- name: Download coverage artifacts
uses: actions/download-artifact@v3
with:
name: coverage-output
path: coverage
- name: Checkout gh-pages
uses: actions/checkout@v3
if: always()
continue-on-error: true
with:
ref: gh-pages
path: gh-pages
- name: Publish test coverage to gh-pages
if: always()
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
publish_branch: gh-pages
publish_dir: coverage
destination_dir: test-coverage
publish-badges:
needs: publish-coverage-report
runs-on: ubuntu-latest
steps:
- name: Download badges artifacts
uses: actions/download-artifact@v3
with:
name: badges-output
path: badges
- name: Checkout gh-pages
uses: actions/checkout@v3
if: always()
continue-on-error: true
with:
ref: gh-pages
path: gh-pages
- name: Publish badges to gh-pages
if: always()
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
publish_branch: gh-pages
publish_dir: badges
destination_dir: badges