Skip to content

Commit 935cfec

Browse files
committed
Enable Ubuntu Tests
1 parent 9cb8a51 commit 935cfec

3 files changed

Lines changed: 142 additions & 131 deletions

File tree

.github/workflows/cpp-ci-serial-programs-base.yml

Lines changed: 140 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: C++ CI Serial Programs base
22
on:
33
workflow_call:
44
inputs:
5-
os:
5+
os:
66
required: true
77
type: string
88

@@ -27,136 +27,145 @@ jobs:
2727
runs-on: ${{inputs.os}}
2828

2929
steps:
30-
- name: Set variables
31-
shell: bash
32-
run: |
33-
if [[ "${{inputs.compiler}}" == "clang" ]]; then
30+
- name: Set variables
31+
shell: bash
32+
run: |
33+
if [[ "${{inputs.compiler}}" == "clang" ]]; then
34+
if [[ "${{inputs.os}}" == windows* ]]; then
35+
CMAKE_ADDITIONAL_FLAGS="-T ClangCL"
36+
elif [[ "${{inputs.os}}" == ubuntu* ]]; then
37+
CMAKE_ADDITIONAL_FLAGS="-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo"
38+
fi
39+
fi
40+
echo "CMAKE_ADDITIONAL_FLAGS=$CMAKE_ADDITIONAL_FLAGS" >> $GITHUB_ENV
41+
3442
if [[ "${{inputs.os}}" == windows* ]]; then
35-
CMAKE_ADDITIONAL_FLAGS="-T ClangCL"
36-
elif [[ "${{inputs.os}}" == ubuntu* ]]; then
37-
CMAKE_ADDITIONAL_FLAGS="-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++"
43+
UPLOAD_FOLDER="Arduino-Source/SerialPrograms/bin/RelWithDebInfo"
44+
else
45+
UPLOAD_FOLDER="Arduino-Source/SerialPrograms/bin"
3846
fi
39-
fi
40-
echo "CMAKE_ADDITIONAL_FLAGS=$CMAKE_ADDITIONAL_FLAGS" >> $GITHUB_ENV
41-
42-
if [[ "${{inputs.os}}" == windows* ]]; then
43-
UPLOAD_FOLDER="Arduino-Source/SerialPrograms/bin/RelWithDebInfo"
44-
else
45-
UPLOAD_FOLDER="Arduino-Source/SerialPrograms/bin"
46-
fi
47-
echo "UPLOAD_FOLDER=$UPLOAD_FOLDER" >> $GITHUB_ENV
48-
49-
- name: Checkout Arduino-Source
50-
uses: actions/checkout@v7
51-
with:
52-
path: 'Arduino-Source'
53-
submodules: 'recursive'
54-
55-
- name: Install Qt
56-
uses: jurplel/install-qt-action@v4
57-
with:
58-
# Delete aqtsource once https://github.com/miurahr/aqtinstall/issues/1007 is fixed and released
59-
aqtsource: 'git+https://github.com/miurahr/aqtinstall'
60-
version: '6.10.2'
61-
modules: 'qtmultimedia qtserialport'
62-
63-
- name: Install dependencies (Ubuntu)
64-
if: startsWith(inputs.os, 'ubuntu')
65-
run: |
66-
cd Arduino-Source
67-
sudo apt update
68-
sudo apt upgrade
69-
sudo apt install clang-tools libopencv-dev libsystemd-dev
70-
71-
sudo apt install ./3rdPartyBinaries/libdpp-10.1.5-linux-x64.deb
72-
73-
- name: Install dependencies (Mac)
74-
if: startsWith(inputs.os, 'mac')
75-
run: |
76-
cd Arduino-Source
77-
brew install opencv@4 onnxruntime
78-
79-
brew tap-new --no-git PA/libdpp
80-
brew trust PA/libdpp
81-
FORMULA_DIR="$(brew --repo PA/libdpp)/Formula"
82-
mkdir -p "$FORMULA_DIR"
83-
cp 3rdPartyBinaries/libdpp@10.1.5.rb "$FORMULA_DIR/"
84-
brew install libdpp@10.1.5
85-
86-
- name: Generate binaries
87-
run: |
88-
cd Arduino-Source/SerialPrograms
89-
mkdir bin
90-
cd bin
91-
cmake .. -DQT_MAJOR:STRING=6 ${{env.CMAKE_ADDITIONAL_FLAGS}}
92-
cmake --build . --config RelWithDebInfo --parallel 10
93-
94-
- name: Prepare upload build
95-
if: inputs.upload-build
96-
shell: bash
97-
run: |
98-
{
99-
echo "https://github.com/${{github.repository_owner}}/Arduino-Source/commit/$(git -C Arduino-Source rev-parse HEAD)"
100-
echo "https://github.com/${{github.repository_owner}}/Packages/commit/$(git -C Arduino-Source/Packages rev-parse HEAD)"
101-
} > ${{env.UPLOAD_FOLDER}}/version.txt
102-
103-
- name: Upload Build
104-
uses: actions/upload-artifact@v7
105-
if: inputs.upload-build
106-
with:
107-
name: Serial Programs (os=${{inputs.os}} - compiler=${{inputs.compiler}})
108-
path: ${{env.UPLOAD_FOLDER}}
109-
110-
- name: Upload Executable Only
111-
uses: actions/upload-artifact@v7
112-
if: inputs.upload-build && startsWith(inputs.os, 'windows')
113-
with:
114-
name: Standalone Executable (os=${{inputs.os}})
115-
path: ${{env.UPLOAD_FOLDER}}/SerialPrograms.exe
116-
117-
- name: Checkout CommandLineTests
118-
uses: actions/checkout@v7
119-
if: inputs.run-tests
120-
with:
121-
repository: 'PokemonAutomation/CommandLineTests'
122-
path: 'CommandLineTests'
123-
124-
- name: Run tests (Windows)
125-
if: startsWith(inputs.os, 'windows') && inputs.run-tests
126-
run: |
127-
cd Arduino-Source/SerialPrograms/bin
128-
$process = Start-Process -FilePath "./RelWithDebInfo/SerialPrograms.exe" `
129-
-ArgumentList "--command-line-test-mode --command-line-test-folder ../../../CommandLineTests" `
130-
-NoNewWindow -Wait -PassThru
131-
if ($process.ExitCode -ne 0) {
132-
Write-Error "Tests failed with exit code $($process.ExitCode)"
47+
echo "UPLOAD_FOLDER=$UPLOAD_FOLDER" >> $GITHUB_ENV
48+
49+
- name: Checkout Arduino-Source
50+
uses: actions/checkout@v7
51+
with:
52+
path: 'Arduino-Source'
53+
submodules: 'recursive'
54+
55+
- name: Install Qt
56+
uses: jurplel/install-qt-action@v4
57+
with:
58+
# Delete aqtsource once https://github.com/miurahr/aqtinstall/issues/1007 is fixed and released
59+
aqtsource: 'git+https://github.com/miurahr/aqtinstall'
60+
version: '6.10.2'
61+
modules: 'qtmultimedia qtserialport'
62+
63+
- name: Install dependencies (Ubuntu)
64+
if: startsWith(inputs.os, 'ubuntu')
65+
run: |
66+
cd Arduino-Source
67+
sudo apt update
68+
sudo apt upgrade
69+
sudo apt install clang-tools libopencv-dev libsystemd-dev
70+
71+
sudo apt install ./3rdPartyBinaries/libdpp-10.1.5-linux-x64.deb
72+
73+
- name: Install dependencies (Mac)
74+
if: startsWith(inputs.os, 'mac')
75+
run: |
76+
cd Arduino-Source
77+
brew install opencv@4 onnxruntime
78+
79+
brew tap-new --no-git PA/libdpp
80+
brew trust PA/libdpp
81+
FORMULA_DIR="$(brew --repo PA/libdpp)/Formula"
82+
mkdir -p "$FORMULA_DIR"
83+
cp 3rdPartyBinaries/libdpp@10.1.5.rb "$FORMULA_DIR/"
84+
brew install libdpp@10.1.5
85+
86+
- name: Generate binaries
87+
run: |
88+
cd Arduino-Source/SerialPrograms
89+
mkdir bin
90+
cd bin
91+
cmake .. -DQT_MAJOR:STRING=6 ${{env.CMAKE_ADDITIONAL_FLAGS}}
92+
cmake --build . --config RelWithDebInfo --parallel 10
93+
94+
- name: Prepare upload build
95+
if: inputs.upload-build
96+
shell: bash
97+
run: |
98+
{
99+
echo "https://github.com/${{github.repository_owner}}/Arduino-Source/commit/$(git -C Arduino-Source rev-parse HEAD)"
100+
echo "https://github.com/${{github.repository_owner}}/Packages/commit/$(git -C Arduino-Source/Packages rev-parse HEAD)"
101+
} > ${{env.UPLOAD_FOLDER}}/version.txt
102+
103+
- name: Upload Build
104+
uses: actions/upload-artifact@v7
105+
if: inputs.upload-build
106+
with:
107+
name: Serial Programs (os=${{inputs.os}} - compiler=${{inputs.compiler}})
108+
path: ${{env.UPLOAD_FOLDER}}
109+
110+
- name: Upload Executable Only
111+
uses: actions/upload-artifact@v7
112+
if: inputs.upload-build && startsWith(inputs.os, 'windows')
113+
with:
114+
name: Standalone Executable (os=${{inputs.os}})
115+
path: ${{env.UPLOAD_FOLDER}}/SerialPrograms.exe
116+
117+
- name: Checkout CommandLineTests
118+
uses: actions/checkout@v7
119+
if: inputs.run-tests
120+
with:
121+
repository: 'PokemonAutomation/CommandLineTests'
122+
path: 'CommandLineTests'
123+
124+
- name: Run tests (Windows)
125+
if: startsWith(inputs.os, 'windows') && inputs.run-tests
126+
run: |
127+
cd Arduino-Source/SerialPrograms/bin
128+
$process = Start-Process -FilePath "./RelWithDebInfo/SerialPrograms.exe" `
129+
-ArgumentList "--command-line-test-mode --command-line-test-folder ../../../CommandLineTests" `
130+
-NoNewWindow -Wait -PassThru
131+
if ($process.ExitCode -ne 0) {
132+
Write-Error "Tests failed with exit code $($process.ExitCode)"
133+
exit 1
134+
}
135+
136+
- name: Run tests (Ubuntu)
137+
if: startsWith(inputs.os, 'ubuntu') && inputs.run-tests
138+
env:
139+
QT_QPA_PLATFORM: offscreen
140+
TESSDATA_PREFIX: ${{ github.workspace }}/Arduino-Source/SerialPrograms/bin/Resources/Tesseract
141+
run: |
142+
cd Arduino-Source/SerialPrograms/bin
143+
./SerialPrograms --command-line-test-mode --command-line-test-folder ../../../CommandLineTests
144+
145+
- name: Run tests (Mac)
146+
if: startsWith(inputs.os, 'mac') && inputs.run-tests
147+
run: |
148+
cd Arduino-Source/SerialPrograms/bin
149+
./SerialPrograms.app/Contents/MacOS/SerialPrograms --command-line-test-mode --command-line-test-folder ../../../CommandLineTests
150+
151+
- name: Run clang query
152+
if: inputs.run-clang-query
153+
run : |
154+
cd Arduino-Source
155+
156+
cat << 'EOF' > query.txt
157+
set output dump
158+
match invocation(
159+
isExpansionInFileMatching("SerialPrograms/"),
160+
hasDeclaration(cxxConstructorDecl(ofClass(hasName("std::filesystem::path")))),
161+
hasArgument(0, hasType(asString("std::string")))
162+
)
163+
EOF
164+
165+
files=$(jq -r '.[].file' SerialPrograms/bin/compile_commands.json)
166+
echo "$files" | xargs --max-args=150 clang-query -p SerialPrograms/bin/ -f query.txt >> output.txt
167+
cat output.txt
168+
if grep --silent "Match #" output.txt; then
169+
echo "::error Forbidden std::filesystem::path construction detected!"
133170
exit 1
134-
}
135-
136-
- name: Run tests (Mac)
137-
if: startsWith(inputs.os, 'mac') && inputs.run-tests
138-
run: |
139-
cd Arduino-Source/SerialPrograms/bin
140-
./SerialPrograms.app/Contents/MacOS/SerialPrograms --command-line-test-mode --command-line-test-folder ../../../CommandLineTests
141-
142-
- name: Run clang query
143-
if: inputs.run-clang-query
144-
run : |
145-
cd Arduino-Source
146-
147-
cat << 'EOF' > query.txt
148-
set output dump
149-
match invocation(
150-
isExpansionInFileMatching("SerialPrograms/"),
151-
hasDeclaration(cxxConstructorDecl(ofClass(hasName("std::filesystem::path")))),
152-
hasArgument(0, hasType(asString("std::string")))
153-
)
154-
EOF
155-
156-
files=$(jq -r '.[].file' SerialPrograms/bin/compile_commands.json)
157-
echo "$files" | xargs --max-args=150 clang-query -p SerialPrograms/bin/ -f query.txt >> output.txt
158-
cat output.txt
159-
if grep --silent "Match #" output.txt; then
160-
echo "::error Forbidden std::filesystem::path construction detected!"
161-
exit 1
162-
fi
171+
fi

.github/workflows/cpp-ci-serial-programs-ubuntu-clang.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ jobs:
1313
os: ubuntu-26.04
1414
compiler: clang
1515
run-clang-query: true
16+
run-tests: true

.github/workflows/cpp-ci-serial-programs-ubuntu-default.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ jobs:
1313
os: ubuntu-26.04
1414
compiler: default
1515
run-clang-query: true
16+
run-tests: true

0 commit comments

Comments
 (0)