-
Notifications
You must be signed in to change notification settings - Fork 0
204 lines (180 loc) · 7.01 KB
/
Copy pathmcdc.yml
File metadata and controls
204 lines (180 loc) · 7.01 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
name: MCDC Analysis
on:
push:
branches:
- dev
- main
pull_request:
types:
- opened
- reopened
- synchronize
workflow_dispatch:
# Force bash to apply pipefail option so pipeline failures aren't masked
defaults:
run:
shell: bash
env:
SIMULATION: native
TESTS_RAN: false
jobs:
# Checks for duplicate actions. Skips push actions if there is a matching or
# duplicate pull-request action.
checks-for-duplicates:
runs-on: ubuntu-22.04
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
skip_after_successful_duplicate: 'true'
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]'
mcdc:
needs: checks-for-duplicates
if: ${{ needs.checks-for-duplicates.outputs.should_skip != 'true' || contains(github.ref, 'dev') || contains(github.ref, 'main') }}
name: Build and Run MCDC
runs-on: ubuntu-22.04
container: ghcr.io/core-flight-system/mcdc:latest
steps:
- name: Checkout MCDC Script
uses: actions/checkout@v6
with:
repository: nasa/cFS
path: mcdc
ref: dev
- name: Checkout OSAL
uses: actions/checkout@v6
with:
path: source
- name: Modify osal to include coverage flags
run: |
sed -i 's/target_compile_options.*)/target_compile_options(ut_coverage_compile INTERFACE -pg -O0 -fprofile-arcs -ftest-coverage -fcondition-coverage -fprofile-abs-path)/' source/src/bsp/generic-linux/CMakeLists.txt
sed -i 's/set(UT_COVERAGE_COMPILE_FLAGS.*)/set(UT_COVERAGE_COMPILE_FLAGS -pg --coverage -O0 -fcondition-coverage -fprofile-abs-path)/' source/src/bsp/generic-linux/build_options.cmake
sed -i 's/set(UT_COVERAGE_LINK_FLAGS.*)/set(UT_COVERAGE_LINK_FLAGS -pg --coverage -O0 -fcondition-coverage -fprofile-abs-path)/' source/src/bsp/generic-linux/build_options.cmake
- name: Set up build
run: cmake
-DCMAKE_BUILD_TYPE=Debug
-DENABLE_UNIT_TESTS=TRUE
-DOSAL_OMIT_DEPRECATED=FALSE
-DOSAL_VALIDATE_API=FALSE
-DOSAL_INSTALL_LIBRARIES=FALSE
-DOSAL_CONFIG_DEBUG_PERMISSIVE_MODE=TRUE
-DOSAL_SYSTEM_BSPTYPE=generic-linux
-DCMAKE_PREFIX_PATH=/usr/lib/cmake
-DCMAKE_INSTALL_PREFIX=/usr
-S source
-B build
- name: Build OSAL
working-directory: build
run: make VERBOSE=1
- name: Execute Tests
working-directory: build
run: |
echo "BASE_DIR=build/unit-test-coverage" >> $GITHUB_ENV
(ctest --output-on-failure -j4 2>&1 || true) | tee ../test_results.txt
echo "TESTS_RAN=true" >> $GITHUB_ENV
- name: Grab test modules
if: ${{ env.TESTS_RAN == 'true' }}
run: |
echo "MODULES=$(grep -oP 'Test\s+#\d+: \K[\w\-\_]+(?= )' test_results.txt | tr '\n' ' ' | sed 's/ $//')" >> $GITHUB_ENV
grep -oP 'Test #\d+: \K[\w\-\_]+' test_results.txt | tr '\n' ' ' | sed 's/ $//' >> modules.txt
- name: Run mcdc analysis
if: ${{ env.TESTS_RAN == 'true' }}
run: bash mcdc/.github/scripts/mcdc-analyze.sh
- name: Save PR number
if: github.event_name == 'pull_request' && always()
env:
PR_NUMBER: ${{ github.event.number }}
run: echo $PR_NUMBER > pr_number
- name: Archive unit test results
# Upload if success or failure which supports skipping, unlike always()
if: ${{ env.TESTS_RAN == 'true' }}
uses: actions/upload-artifact@v7
with:
name: Unit test results
path: |
test_results.txt
- name: Archive mcdc results
# Upload if success or failure which supports skipping, unlike always()
if: ${{ env.TESTS_RAN == 'true' }}
uses: actions/upload-artifact@v7
with:
name: MCDC results
path: |
**/*.gcov.json.gz
mcdc_results.txt
pr_number
modules.txt
summary-mcdc:
needs: mcdc
if: github.event_name == 'pull_request' && always()
name: Generate MCDC Comparison Summary
runs-on: ubuntu-22.04
steps:
- name: Checkout MCDC Script
uses: actions/checkout@v6
with:
repository: nasa/cFS
path: mcdc
ref: dev
- name: Download latest main branch artifact
continue-on-error: true
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: mcdc-internal.yml
search_artifacts: true
branch: dev
name: MCDC results
path: main-branch-results
- uses: actions/download-artifact@v8
with:
name: MCDC results
- name: Compare main and PR artifacts
run: |
if [ -f "main-branch-results/mcdc_results.txt" ]; then
echo "Main branch artifact found. Running comparison."
bash mcdc/.github/scripts/mcdc-compare.sh main-branch-results/mcdc_results.txt mcdc_results.txt main-branch-results/modules.txt
else
echo "Main branch artifact not found. Skipping comparison step."
fi
- name: Output summary to workflow
run: |
if [ -s "mcdc_comment.txt" ]; then
echo "### MC/DC Results (Comparison with dev branch)" >> $GITHUB_STEP_SUMMARY
echo '```plaintext' >> $GITHUB_STEP_SUMMARY
cat mcdc_comment.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
elif [ -s "mcdc_results.txt" ]; then
echo "### MC/DC Results (Current PR)" >> $GITHUB_STEP_SUMMARY
echo '```plaintext' >> $GITHUB_STEP_SUMMARY
cat mcdc_results.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
else
echo "No MCDC results found." >> $GITHUB_STEP_SUMMARY
fi
# Output uncovered branches if the file exists and is not empty
if [ -s "uncovered.json" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "<details>" >> $GITHUB_STEP_SUMMARY
echo "<summary>Click to view uncovered branches (uncovered.json)</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```json' >> $GITHUB_STEP_SUMMARY
cat uncovered.json >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
fi
- name: Archive mcdc comparison
# Upload if success or failure which supports skipping, unlike always()
if: success() || failure()
uses: actions/upload-artifact@v7
with:
name: MCDC main branch comparison
path: |
mcdc_comment.txt
mcdc_compare.txt