Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
271 changes: 140 additions & 131 deletions .github/workflows/cpp-ci-serial-programs-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: C++ CI Serial Programs base
on:
workflow_call:
inputs:
os:
os:
required: true
type: string

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

steps:
- name: Set variables
shell: bash
run: |
if [[ "${{inputs.compiler}}" == "clang" ]]; then
- 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"
Comment thread
pifopi marked this conversation as resolved.
fi
fi
echo "CMAKE_ADDITIONAL_FLAGS=$CMAKE_ADDITIONAL_FLAGS" >> $GITHUB_ENV

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++"
UPLOAD_FOLDER="Arduino-Source/SerialPrograms/bin/RelWithDebInfo"
else
UPLOAD_FOLDER="Arduino-Source/SerialPrograms/bin"
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)"
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
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
}

- 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
fi
8 changes: 6 additions & 2 deletions .github/workflows/cpp-ci-serial-programs-mac-intel.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: C++ CI Serial Programs Mac Intel
on: [push, pull_request, workflow_dispatch]
on:
push:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
build:
Expand All @@ -8,4 +12,4 @@ jobs:
with:
os: macos-15-intel
compiler: default
run-tests: true
run-tests: true
8 changes: 6 additions & 2 deletions .github/workflows/cpp-ci-serial-programs-mac.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: C++ CI Serial Programs Mac
on: [push, pull_request, workflow_dispatch]
on:
push:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
build:
Expand All @@ -8,4 +12,4 @@ jobs:
with:
os: macos-15
compiler: default
run-tests: true
run-tests: true
9 changes: 7 additions & 2 deletions .github/workflows/cpp-ci-serial-programs-ubuntu-clang.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: C++ CI Serial Programs Ubuntu clang
on: [push, pull_request, workflow_dispatch]
on:
push:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
build:
Expand All @@ -8,4 +12,5 @@ jobs:
with:
os: ubuntu-26.04
compiler: clang
run-clang-query: true
run-clang-query: true
run-tests: true
9 changes: 7 additions & 2 deletions .github/workflows/cpp-ci-serial-programs-ubuntu-default.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: C++ CI Serial Programs Ubuntu Default
on: [push, pull_request, workflow_dispatch]
on:
push:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
build:
Expand All @@ -8,4 +12,5 @@ jobs:
with:
os: ubuntu-26.04
compiler: default
run-clang-query: true
run-clang-query: true
run-tests: true
8 changes: 6 additions & 2 deletions .github/workflows/cpp-ci-serial-programs-windows-clang.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: C++ CI Serial Programs Windows Clang
on: [push, pull_request, workflow_dispatch]
on:
push:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
build:
Expand All @@ -9,4 +13,4 @@ jobs:
os: windows-2025
compiler: clang
upload-build: true
run-tests: true
run-tests: true
8 changes: 6 additions & 2 deletions .github/workflows/cpp-ci-serial-programs-windows-default.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: C++ CI Serial Programs Windows Default
on: [push, pull_request, workflow_dispatch]
on:
push:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
build:
Expand All @@ -9,4 +13,4 @@ jobs:
os: windows-2025
compiler: default
upload-build: true
run-tests: true
run-tests: true
Loading