Skip to content

CI

CI #2475

Workflow file for this run

name: CI
on:
push:
pull_request:
schedule:
- cron: '0 8 * * *'
jobs:
clang-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DoozyX/[email protected]
with:
source: '.'
build-linux:
strategy:
matrix:
build_type: [DEBUG, RELEASE]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
key: ccache-${{ github.job }}-${{ matrix.build_type }}
max-size: 2G
- name: Build
run: |
cmake -S . -B build \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DOPENCV_PATH=3rdparty/opencv/build
cmake --build build --parallel
env:
CTEST_OUTPUT_ON_FAILURE: 1
- name: Prepare OpenCV libs
run: |
mkdir -p build/bin/opencv_libs
cp -a 3rdparty/opencv/build/lib/libopencv_* build/bin/opencv_libs/
echo "Library permissions after copy:"
stat -c "%A %n" build/bin/opencv_libs/libopencv_imgcodecs.so*
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: mnist-${{ matrix.build_type }}
path: |
build/bin/ACC_MNIST*
build/bin/opencv_libs/*
build/setenv.sh
- name: Test
run: cmake --build build -t test
env:
CTEST_OUTPUT_ON_FAILURE: 1
- name: Test (valgrind)
run: |
sudo apt-get update
sudo apt-get install -y valgrind
valgrind cmake --build build -t test
env:
CTEST_OUTPUT_ON_FAILURE: 1
build-linux-clang:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install prerequisites
run: |
sudo apt install clang libomp-dev
- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
key: ccache-${{ github.job }}
- name: Build
run: |
cmake -S . -B build \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
cmake --build build --parallel
- name: Test
run: cmake --build build -t test
env:
CTEST_OUTPUT_ON_FAILURE: 1
- name: Test (valgrind)
run: |
sudo apt-get update
sudo apt-get install -y valgrind
valgrind cmake --build build -t test
env:
CTEST_OUTPUT_ON_FAILURE: 1
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install prerequisites
run: |
brew install libomp
brew link libomp --overwrite --force
- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
key: ccache-${{ github.job }}
- name: Build
run: |
cmake -S . -B build \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_FLAGS="-I$(brew --prefix libomp)/include" \
-DCMAKE_CXX_FLAGS="-I$(brew --prefix libomp)/include"
cmake --build build --parallel
- name: Test
run: cmake --build build -t test
env:
CTEST_OUTPUT_ON_FAILURE: 1
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
key: ccache-${{ github.job }}
max-size: 2G
variant: sccache
- name: Build
run: |
cmake -S . -B build -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
cmake --build build --parallel
- name: Test
run: |
cd build
ctest --output-on-failure
codecov:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y gcovr
- uses: actions/checkout@v4
with:
submodules: true
- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
key: ccache-${{ github.job }}-${{ matrix.build_type }}
max-size: 2G
- name: Build
run: |
cmake -S . -B build \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_FLAGS="--coverage" \
-DCMAKE_CXX_FLAGS="--coverage" \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake --build build --parallel
- name: Test
run: cmake --build build -t test
env:
CTEST_OUTPUT_ON_FAILURE: 1
- name: Generate Coverage Data
run: gcovr -r . --xml -o coverage.xml --gcov-ignore-parse-errors
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: embedded-dev-research/itlab_2023
evaluate-model:
runs-on: ubuntu-latest
needs: [build-linux]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libgtk-3-0 \
libtbb12 \
libjpeg-dev \
libpng-dev \
libtiff-dev
sudo ldconfig
- name: Generate model JSON
run: |
cd app/AlexNet
pip install -r requirements.txt
python parser.py
cd ../..
- name: Download MNIST test dataset
run: |
mkdir -p docs/mnist/mnist/test
if [ ! -f "docs/mnist/mnist/test/0_000000.png" ]; then
echo "Downloading test images..."
wget -q https://github.com/DeepTrackAI/MNIST_dataset/archive/main.zip
unzip -q main.zip
cp MNIST_dataset-main/mnist/test/*.png docs/mnist/mnist/test/
rm -rf main.zip MNIST_dataset-main
echo "Downloaded $(ls docs/mnist/mnist/test | wc -l) images"
fi
- name: Download binary and libs
uses: actions/download-artifact@v4
with:
name: mnist-RELEASE
path: build/
- name: Prepare environment
run: |
chmod +x build/bin/ACC_MNIST*
export LD_LIBRARY_PATH=$PWD/build/bin/opencv_libs:/usr/lib/x86_64-linux-gnu
echo "Final LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
- name: Verify library integrity
run: |
echo "### Library verification ###"
file build/bin/opencv_libs/libopencv_imgcodecs.so.4.9.0 | grep "shared object"
ldd build/bin/opencv_libs/libopencv_imgcodecs.so.4.9.0 || true
realpath build/bin/opencv_libs/libopencv_imgcodecs.so.409
- name: Run evaluation
run: |
echo "### Pre-run checks ###"
export LD_LIBRARY_PATH=$PWD/build/bin/opencv_libs:/usr/lib/x86_64-linux-gnu
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
LD_DEBUG=files ./build/bin/ACC_MNIST* 2> ld_debug.log || true
echo "### Library loading debug ###"
grep -i "opencv_imgcodecs" ld_debug.log
./build/bin/ACC_MNIST* > accuracy.txt
echo "Accuracy: $(cat accuracy.txt)"
- name: Update README (master only)
if: github.ref == 'refs/heads/master'
run: |
ACCURACY=$(cat accuracy.txt | sed 's/%//g')
DATE=$(date '+%Y-%m-%d')
echo "Updating README with:"
echo "Accuracy: $ACCURACY"
echo "Date: $DATE"
echo "Current README content:"
grep -A 2 -B 2 "ACCURACY_PLACEHOLDER" README.md || echo "Placeholder not found"
sed -i "s/<!--ACCURACY_PLACEHOLDER-->.*<!--END_ACCURACY-->/<!--ACCURACY_PLACEHOLDER-->Accuracy: ${ACCURACY}% (updated: ${DATE})<!--END_ACCURACY-->/" README.md
echo "Updated README content:"
grep -A 2 -B 2 "ACCURACY_PLACEHOLDER" README.md
- name: Commit and push changes (master only)
if: github.ref == 'refs/heads/master'
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git add README.md
if git diff-index --quiet HEAD --; then
echo "No changes to commit"
else
git commit -m "[CI] Update accuracy: $(cat accuracy.txt)%"
git push origin master
echo "Changes pushed to master branch"
fi