generated from cicirello/python-github-action-template
-
-
Notifications
You must be signed in to change notification settings - Fork 43
199 lines (164 loc) · 7.55 KB
/
build.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
unit-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Run Python unit tests
run: python3 -u -B -m unittest tests/tests.py
cli-mode-tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Integration test of CLI use-case
id: integrationCLI
run: |
export PYTHONPATH=$PWD/src
echo $PYTHONPATH
python3 -B -m jacoco_badge_generator --jacoco-csv-file tests/jacoco.csv --badges-directory tests/cli/badges --generate-branches-badge true
python3 -B -m jacoco_badge_generator --jacoco-csv-file tests/multi1.csv tests/multi2.csv --badges-directory tests/cli/badges --generate-branches-badge true --coverage-badge-filename coverageMulti.svg --branches-badge-filename branchesMulti.svg
python3 -B -m jacoco_badge_generator --jacoco-csv-file tests/jacoco.csv --badges-directory tests/cli/badgesJSON --generate-coverage-badge false --generate-coverage-endpoint true --generate-branches-endpoint true
python3 -B -m jacoco_badge_generator --jacoco-csv-file tests/summaryReportTest.csv --badges-directory tests/cli/summary --generate-coverage-badge false --generate-summary true
python3 -B -m jacoco_badge_generator --jacoco-csv-file tests/jacoco.csv --badges-directory tests/cli/badges --generate-branches-badge true --generate-coverage-endpoint true --generate-branches-endpoint true --coverage-badge-filename customCoverage.svg --branches-badge-filename customBranches.svg --coverage-endpoint-filename customCoverage.json --branches-endpoint-filename customBranches.json --coverage-label "custom coverage label one" --branches-label "custom coverage label two"
python3 -B -m jacoco_badge_generator --jacoco-csv-file **/multi*.csv --badges-directory tests/glob/badges --generate-branches-badge true --coverage-badge-filename coverageMultiCLI.svg --branches-badge-filename branchesMultiCLI.svg
- name: Verify integration test results
run: python3 -u -B -m unittest tests/integration-cli-mode.py
actions-mode-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Verify that the Docker image for the action builds
run: docker build . --file Dockerfile
- name: Integration test with a single jacoco.csv
id: integration1
uses: ./
with:
jacoco-csv-file: tests/jacoco.csv
badges-directory: tests/badges
generate-branches-badge: true
- name: Log integration test outputs with a single jacoco.csv
run: |
echo "coverage = ${{ steps.integration1.outputs.coverage }}"
echo "branch coverage = ${{ steps.integration1.outputs.branches }}"
- name: Integration test with multiple jacoco.csv files
id: integration2
uses: ./
with:
jacoco-csv-file: >
tests/multi1.csv
tests/multi2.csv
badges-directory: tests/badges
generate-branches-badge: true
coverage-badge-filename: coverageMulti.svg
branches-badge-filename: branchesMulti.svg
workflow-summary-heading: "JaCoCo Test Coverage Summary: Multimodule Testcase"
- name: Log integration test outputs with multiple jacoco.csv files
run: |
echo "coverage = ${{ steps.integration2.outputs.coverage }}"
echo "branch coverage = ${{ steps.integration2.outputs.branches }}"
- name: Integration endpoints test
id: integration3
uses: ./
with:
jacoco-csv-file: tests/jacoco.csv
badges-directory: tests/endpoints
generate-coverage-badge: false
generate-branches-badge: false
generate-coverage-endpoint: true
generate-branches-endpoint: true
workflow-summary-heading: "JaCoCo Test Coverage Summary: Endpoints Testcase"
- name: Log integration endpoints test outputs
run: |
echo "coverage = ${{ steps.integration3.outputs.coverage }}"
echo "branch coverage = ${{ steps.integration3.outputs.branches }}"
- name: Integration test for summary report
id: integration4
uses: ./
with:
jacoco-csv-file: tests/summaryReportTest.csv
badges-directory: tests/summary
generate-coverage-badge: false
generate-branches-badge: false
generate-coverage-endpoint: false
generate-branches-endpoint: false
generate-summary: true
workflow-summary-heading: "JaCoCo Test Coverage Summary: Summary Report Testcase"
- name: Log integration summary report test outputs
run: |
echo "coverage = ${{ steps.integration4.outputs.coverage }}"
echo "branch coverage = ${{ steps.integration4.outputs.branches }}"
- name: Integration test with custom labels
id: integration5
uses: ./
with:
jacoco-csv-file: tests/jacoco.csv
badges-directory: tests/badges
generate-branches-badge: true
generate-coverage-endpoint: true
generate-branches-endpoint: true
coverage-badge-filename: customCoverage.svg
branches-badge-filename: customBranches.svg
coverage-endpoint-filename: customCoverage.json
branches-endpoint-filename: customBranches.json
coverage-label: custom coverage label one
branches-label: custom coverage label two
workflow-summary-heading: "JaCoCo Test Coverage Summary: Custom Labels Testcase"
- name: Log integration test outputs with custom labels
run: |
echo "coverage = ${{ steps.integration5.outputs.coverage }}"
echo "branch coverage = ${{ steps.integration5.outputs.branches }}"
- name: Integration test with multiple csv files with glob
id: integration6
uses: ./
with:
jacoco-csv-file: "**/multi*.csv"
badges-directory: tests/glob/badges
generate-branches-badge: true
coverage-badge-filename: coverageMulti.svg
branches-badge-filename: branchesMulti.svg
workflow-summary-heading: "JaCoCo Test Coverage Summary: Glob Testcase"
- name: Log integration test outputs with multiple csv files with glob
run: |
echo "coverage = ${{ steps.integration6.outputs.coverage }}"
echo "branch coverage = ${{ steps.integration6.outputs.branches }}"
- name: Verify integration test results
run: python3 -u -B -m unittest tests/integration-actions-mode.py
# This test can be used to test failing the workflow run on decrease.
# Uncomment to use. Success is if this fails the workflow.
# - name: Integration test for fail on decrease
# id: integrationFailures
# uses: ./
# with:
# jacoco-csv-file: tests/summaryReportTest.csv
# badges-directory: tests
# generate-coverage-badge: false
# generate-branches-badge: false
# generate-coverage-endpoint: false
# generate-branches-endpoint: false
# generate-summary: true
# summary-filename: reportTestFail.json
# fail-on-coverage-decrease: true
# fail-on-branches-decrease: true