-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathcpp-ci-serial-programs-base.yml
More file actions
184 lines (159 loc) · 6.91 KB
/
Copy pathcpp-ci-serial-programs-base.yml
File metadata and controls
184 lines (159 loc) · 6.91 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
name: C++ CI Serial Programs base
on:
workflow_call:
inputs:
os:
required: true
type: string
compiler:
required: true
type: string
upload-build:
type: boolean
default: false
run-tests:
type: boolean
default: false
run-clang-query:
type: boolean
default: false
jobs:
build:
runs-on: ${{inputs.os}}
steps:
- name: Set variables
shell: bash
run: |
if [[ "${{inputs.compiler}}" == "clang" ]]; then
if [[ "${{inputs.os}}" == windows* ]]; then
CMAKE_ADDITIONAL_FLAGS="-T ClangCL"
elif [[ "${{inputs.os}}" == ubuntu* ]]; then
CMAKE_ADDITIONAL_FLAGS="-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo"
fi
fi
echo "CMAKE_ADDITIONAL_FLAGS=$CMAKE_ADDITIONAL_FLAGS" >> $GITHUB_ENV
if [[ "${{inputs.os}}" == windows* ]]; then
UPLOAD_FOLDER="Arduino-Source/SerialPrograms/bin/RelWithDebInfo"
else
UPLOAD_FOLDER="Arduino-Source/SerialPrograms/bin"
fi
echo "UPLOAD_FOLDER=$UPLOAD_FOLDER" >> $GITHUB_ENV
- name: Checkout Arduino-Source
uses: actions/checkout@v7
with:
path: 'Arduino-Source'
submodules: 'recursive'
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
# Delete aqtsource once https://github.com/miurahr/aqtinstall/issues/1007 is fixed and released
aqtsource: 'git+https://github.com/miurahr/aqtinstall'
version: '6.10.2'
modules: 'qtmultimedia qtserialport'
- name: Install dependencies (Ubuntu)
if: startsWith(inputs.os, 'ubuntu')
run: |
cd Arduino-Source
sudo apt update
sudo apt upgrade
sudo apt install clang-tools libopencv-dev libsystemd-dev
sudo apt install ./3rdPartyBinaries/libdpp-10.1.5-linux-x64.deb
- name: Install dependencies (Mac)
if: startsWith(inputs.os, 'mac')
run: |
cd Arduino-Source
brew install opencv@4 onnxruntime
brew tap-new --no-git PA/libdpp
brew trust PA/libdpp
FORMULA_DIR="$(brew --repo PA/libdpp)/Formula"
mkdir -p "$FORMULA_DIR"
cp 3rdPartyBinaries/libdpp@10.1.5.rb "$FORMULA_DIR/"
brew install libdpp@10.1.5
- name: Generate binaries
run: |
cd Arduino-Source/SerialPrograms
mkdir bin
cd bin
cmake .. -DQT_MAJOR:STRING=6 ${{env.CMAKE_ADDITIONAL_FLAGS}}
cmake --build . --config RelWithDebInfo --parallel 10
- name: Prepare upload build
if: inputs.upload-build
shell: bash
run: |
{
echo "https://github.com/${{github.repository_owner}}/Arduino-Source/commit/$(git -C Arduino-Source rev-parse HEAD)"
echo "https://github.com/${{github.repository_owner}}/Packages/commit/$(git -C Arduino-Source/Packages rev-parse HEAD)"
} > ${{env.UPLOAD_FOLDER}}/version.txt
- name: Upload Build
uses: actions/upload-artifact@v7
if: inputs.upload-build
with:
name: Serial Programs (os=${{inputs.os}} - compiler=${{inputs.compiler}})
path: ${{env.UPLOAD_FOLDER}}
- name: Upload Executable Only
uses: actions/upload-artifact@v7
if: inputs.upload-build && startsWith(inputs.os, 'windows')
with:
name: Standalone Executable (os=${{inputs.os}})
path: ${{env.UPLOAD_FOLDER}}/SerialPrograms.exe
- name: Checkout CommandLineTests
uses: actions/checkout@v7
if: inputs.run-tests
with:
repository: 'PokemonAutomation/CommandLineTests'
path: 'CommandLineTests'
- name: Run tests (Windows)
if: startsWith(inputs.os, 'windows') && inputs.run-tests
run: |
cd Arduino-Source/SerialPrograms/bin
$process = Start-Process -FilePath "./RelWithDebInfo/SerialPrograms.exe" `
-ArgumentList "--command-line-test-mode --command-line-test-folder ../../../CommandLineTests" `
-NoNewWindow -Wait -PassThru
if ($process.ExitCode -ne 0) {
Write-Error "Tests failed with exit code $($process.ExitCode)"
exit 1
}
- name: Run tests (Ubuntu)
if: startsWith(inputs.os, 'ubuntu') && inputs.run-tests
env:
QT_QPA_PLATFORM: offscreen
TESSDATA_PREFIX: ${{ github.workspace }}/Arduino-Source/SerialPrograms/bin/Resources/Tesseract
run: |
cd Arduino-Source/SerialPrograms/bin
./SerialPrograms --command-line-test-mode --command-line-test-folder ../../../CommandLineTests
- name: Run tests (Mac)
if: startsWith(inputs.os, 'mac') && inputs.run-tests
run: |
cd Arduino-Source/SerialPrograms/bin
./SerialPrograms.app/Contents/MacOS/SerialPrograms --command-line-test-mode --command-line-test-folder ../../../CommandLineTests
- name: Run clang query
if: inputs.run-clang-query
run : |
cd Arduino-Source
cat << 'EOF' > query.txt
match cxxConstructExpr(
isExpansionInFileMatching("SerialPrograms/"),
hasDeclaration(cxxConstructorDecl(ofClass(hasName("std::filesystem::path")))),
hasArgument(0, hasType(asString("std::string")))
)
EOF
files=$(jq -r '.[].file' SerialPrograms/bin/compile_commands.json)
echo "$files" | xargs --max-args=100 clang-query -p SerialPrograms/bin/ -f query.txt >> clang-query-output.txt
echo "Clang query output (begin)"
cat clang-query-output.txt
echo "Clang query output (end)"
if grep --silent "Match #" clang-query-output.txt; then
echo "::error Forbidden code detected! It can be one of the following:"
echo "::error - std::filesystem::path created from std::string. More information https://discord.com/channels/695809740428673034/1462210406616531259/1462567541825339635"
echo "::error - ImageViewRGB32 created from VideoSnapshot&& that is stored. It is a dangling pointer as nothing hold the data anymore"
echo "::error You can read more about the exact error with the artifact below."
exit 1
fi
- name: Upload Clang query output
uses: actions/upload-artifact@v7
if: inputs.run-clang-query && always()
with:
name: Clang query output (compiler=${{inputs.compiler}})
path: |
Arduino-Source/SerialPrograms/bin/compile_commands.json
Arduino-Source/clang-query-output.txt