-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (139 loc) · 5.69 KB
/
cx_build_compare.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
name: Compare Build Outputs
on:
pull_request:
types: [labeled]
concurrency:
group: ci-${{github.workflow}}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-compare:
if: github.event.label.name == 'CX_NO_CODE_CHANGE'
runs-on: ubuntu-20.04
container: ardupilot/ardupilot-dev-${{ matrix.toolchain }}:v0.0.29
strategy:
fail-fast: false # don't cancel if a job from the matrix fails
matrix:
toolchain: [
chibios,
#chibios-clang,
]
gcc: [10]
exclude:
- gcc: 10
toolchain: chibios-clang
board: ["CarbonixF405", "Volanti-M1"]
# board: ["CarbonixCubeOrange", "CarbonixF405", "Volanti-M1", "Volanti-M2", "Volanti-M3", "Volanti-M4", "Volanti-M5", "Volanti-LWing", "Volanti-RWing", "Volanti-LTail", "Volanti-RTail", "Ottano-M1", "Ottano-M2", "Ottano-M3", "Ottano-M4", "Ottano-M5", "Ottano-LWing", "Ottano-RWing", "Ottano-LTail", "Ottano-RTail"]
steps:
# git checkout the PR
- uses: actions/checkout@v3
with:
submodules: 'recursive'
# Put ccache into github cache for faster build
- name: Prepare ccache timestamp
id: ccache_cache_timestamp
run: |
NOW=$(date -u +"%F-%T")
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT
- name: ccache cache files
uses: actions/cache@v3
with:
path: ~/.ccache
key: ${{github.workflow}}-ccache-${{steps.ccache_cache_timestamp.outputs.timestamp}}
restore-keys: ${{github.workflow}}-ccache- # restore ccache from either previous build on this branch or on master
- name: setup ccache
run: |
. .github/workflows/ccache.env
- name: Print commit ID
run: |
echo "Commit Head ID: ${{ github.sha }}"
- name: Add default environment version
run: |
export CHIBIOS_GIT_VERSION="12345678"
export GIT_VERSION="abcdef"
export GIT_VERSION_INT="15"
- name: Print commit ID
run: |
echo "Commit Head ID mod: ${{ github.sha }}"
- name: build head
shell: bash
run: ./Tools/Carbonix_scripts/carbonix_board_build.sh ${{ matrix.board }}
- name: Check build files
id: check_files
uses: andstor/file-existence-action@v2
with:
files: "build/${{ matrix.board }}/*"
fail: true
- name: Save head branch build output
uses: actions/upload-artifact@v2
with:
name: head-build-output
path: ./build
- name: Checkout base branch
uses: actions/checkout@v2
with:
submodules: 'recursive'
# ref: ${{ github.base_ref }}
- name: Print commit ID
run: |
echo "Commit base ID: ${{ github.sha }}"
- name: Add default environment version
run: |
export CHIBIOS_GIT_VERSION="12345678"
export GIT_VERSION="abcdef"
export GIT_VERSION_INT="15"
- name: Print commit ID
run: |
echo "Commit base ID mod: ${{ github.sha }}"
- name: build base
shell: bash
run: ./Tools/Carbonix_scripts/carbonix_board_build.sh ${{ matrix.board }}
- name: Check build files
id: check_files_base
uses: andstor/file-existence-action@v2
with:
files: "build/${{ matrix.board }}/*"
fail: true
- name: Save base branch build output
uses: actions/upload-artifact@v2
with:
name: base-build-output
path: ./build
- name: Download build outputs
uses: actions/download-artifact@v2
with:
path: ./artifacts
- name: List build output
run: ls -l ./artifacts/
- name: Compare build outputs
shell: bash
run: |
echo '<?xml version="1.0" encoding="UTF-8"?>' > junit.xml
echo '<testsuite name="CompareBuildOutputs" tests="1">' >> junit.xml
for base_file in ./artifacts/base-build-output/${{ matrix.board }}/bin/*.bin; do
base_filename=$(basename "$base_file")
head_file="./artifacts/head-build-output/${{ matrix.board }}/bin/$base_filename"
echo "Comparing $base_file with $head_file"
diff_output=$(diff "$base_file" "$head_file" || true)
base_file_size=$(du -b "$base_file" | cut -f1)
head_file_size=$(du -b "$head_file" | cut -f1)
if [ -n "$diff_output" ]; then
echo "Difference found between $base_file and $head_file"
echo "$diff_output" # print the diff output to the console
echo "<testcase classname=\"${base_filename}\" name=\"CompareBuildOutputs\">" >> junit.xml
echo "<failure message=\"Difference found between $base_file and $head_file. Base file size: $base_file_size bytes. Head file size: $head_file_size bytes.\">" >> junit.xml
echo "$diff_output" >> junit.xml
echo "</failure>" >> junit.xml
echo "</testcase>" >> junit.xml
else
echo "No difference found between $base_file and $head_file"
echo "<testcase classname=\"${base_filename}\" name=\"CompareBuildOutputs\">" >> junit.xml
echo "<system-out>No difference found between $base_file and $head_file. Base file size: $base_file_size bytes. Head file size: $head_file_size bytes.</system-out>" >> junit.xml
echo "</testcase>" >> junit.xml
fi
done
echo '</testsuite>' >> junit.xml
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
if: always()
with:
files: junit.xml