forked from Fraunhofer-AISEC/ids-clearing-house-service
-
Notifications
You must be signed in to change notification settings - Fork 1
179 lines (142 loc) · 4.44 KB
/
test.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
name: test
on:
pull_request:
branches:
- master
- beta
- alpha
- development
permissions:
issues: write
pull-requests: write
jobs:
app-unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run cargo fmt --check
id: fmt
working-directory: ./clearing-house-app
continue-on-error: true
run: |
set +e
cargo fmt --check --message-format human >> cargo_fmt_output.txt
exit_code=$?
echo "code=$exit_code" >> $GITHUB_OUTPUT
echo "text<<EOF" >> $GITHUB_OUTPUT
cat cargo_fmt_output.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Build
id: build
working-directory: ./clearing-house-app
continue-on-error: false
run: |
cargo build
- name: Test
id: test
working-directory: ./clearing-house-app
continue-on-error: false
env:
NO_COLOR: true
run: |
set +e
cargo test &>> cargo_test_output.txt
exit_code=$?
echo "code=$exit_code" >> $GITHUB_OUTPUT
echo "text<<EOF" >> $GITHUB_OUTPUT
cat cargo_test_output.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Run cargo clippy
id: clippy
working-directory: ./clearing-house-app
continue-on-error: true
run: |
set +e
cargo clippy >> cargo_clippy_output.txt
exit_code=$?
echo "code=$exit_code" >> $GITHUB_OUTPUT
echo "text<<EOF" >> $GITHUB_OUTPUT
cat cargo_clippy_output.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Post results to PR
uses: actions/github-script@v7
if: always()
env:
FMT_OUTPUT: ${{ steps.fmt.outputs.text }}
TEST_OUTPUT: ${{ steps.test.outputs.text }}
LINTER_OUTPUT: ${{ steps.linter.outputs.text }}
with:
script: |
const fmtOutput = process.env.FMT_OUTPUT;
let fmtComment = `\`\`\`
${ fmtOutput }
\`\`\``;
if (fmtComment == "```\n\n```") {
fmtComment = "_No formatter warnings_";
}
const clippyOutput = process.env.LINTER_OUTPUT;
let linterComment = `\`\`\`
${ clippyOutput }
\`\`\``;
if (linterComment == "```\n\n```") {
linterComment = "_No linter warnings_";
}
const testOutput = process.env.TEST_OUTPUT;
let testComment = `<details><summary>Test log:</summary>
\`\`\`
${ testOutput }
\`\`\`
</details>`;
if (testComment.length <= 59) {
testComment = "_No test output_";
}
const body = `# Clearinghouse App Build report
## Formatter report ("cargo fmt --check"):
Exit code: ${{ steps.fmt.outputs.code }}
${fmtComment}
## Linter report ("cargo clippy"):
Exit code: ${{ steps.clippy.outputs.code }}
${linterComment}
## Test log
Exit code: ${{ steps.test.outputs.code }}
${testComment}
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
edc-unit-tests:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
- name: Build Project
run: |
cd clearing-house-edc
./gradlew clean build \
-Dorg.gradle.project.gitHubUserName=${{ github.actor }} \
-Dorg.gradle.project.gitHubUserPassword=${{ secrets.GITHUB_TOKEN }}
- name: Run Unit Tests
run: |
cd clearing-house-edc
./gradlew test jacocoTestReport
- name: Add Coverage Report
id: jacoco
uses: madrapps/jacoco-report@v1.6.1
with:
paths: |
${{ github.workspace }}/clearing-house-edc/core/build/reports/jacoco/test/jacocoTestReport.xml,
${{ github.workspace }}clearing-house-edc/extensions/multipart/build/reports/jacoco/test/jacocoTestReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 70
min-coverage-changed-files: 80