forked from PokemonAutomation/Arduino-Source
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpp-ci-serial-programs-base.yml
More file actions
149 lines (127 loc) · 4.7 KB
/
cpp-ci-serial-programs-base.yml
File metadata and controls
149 lines (127 loc) · 4.7 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
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++"
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@v6
with:
path: 'Arduino-Source'
submodules: 'recursive'
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
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
sudo apt install ./3rdPartyBinaries/libdpp-10.0.28-linux-x64.deb
- name: Install dependencies (Mac)
if: startsWith(inputs.os, 'mac')
run: |
cd Arduino-Source
brew install opencv onnxruntime
brew tap-new --no-git PA/libdpp
FORMULA_DIR="$(brew --repo PA/libdpp)/Formula"
mkdir -p "$FORMULA_DIR"
cp 3rdPartyBinaries/libdpp@10.0.28.rb "$FORMULA_DIR/"
brew install libdpp@10.0.28
- 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}}/commit/${{github.sha}} > ${{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: Checkout CommandLineTests
uses: actions/checkout@v6
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 (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
set output dump
match invocation(
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=150 clang-query -p SerialPrograms/bin/ -f query.txt >> output.txt
cat output.txt
if grep --silent "Match #" output.txt; then
echo "::error Forbidden std::filesystem::path construction detected!"
exit 1
fi