[PUT Project] Added CI with format testing and building #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: grabthecam build | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
env: | |
CC: /usr/bin/gcc-12 | |
CXX: /usr/bin/g++-12 | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
container: | |
image: debian:bookworm | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
.github/scripts/prepare-env.sh | |
- name: Build the project | |
run: | | |
mkdir build | |
cd build | |
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DADD_GRABTHECAM_FARSHOW_DEMO=ON .. | |
make | |
- name: Code linting | |
run: | | |
cd build | |
make format | |
test -z $(git diff) && exit 0 || exit 1 | |
example-build: | |
runs-on: ubuntu-latest | |
container: | |
image: debian:bookworm | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
.github/scripts/prepare-env.sh | |
- name: Build the project | |
run: | | |
mkdir build | |
cd build | |
cmake .. | |
make | |
- name: Install the project | |
run: | | |
cd build | |
make install | |
- name: Build the 'example-build' | |
run: | | |
cd tests/example-build | |
cp ../../src/example.cpp ./ | |
mkdir build | |
cd build | |
cmake .. | |
make | |
test-build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
# By default Github Ubuntu runner uses a regular user (non-root). | |
sudo .github/scripts/prepare-env.sh | |
sudo apt install v4l-utils linux-modules-extra-$(uname -r) 1>/dev/null | |
sudo modprobe vivid | |
lsmod | grep -i vivid | |
sudo chown $USER /dev/video0 | |
chmod a+rwx /dev/video0 | |
v4l2-ctl --list-formats -d /dev/video0 | |
- name: Build the project | |
run: | | |
# Prepare directories for the artifacts | |
mkdir artifacts | |
mkdir artifacts/frames | |
mkdir build | |
cd build | |
cmake .. -DBUILD_TESTS=ON | |
make | |
- name: Generate config for pyvidctrl | |
run: | | |
./build/grabthecam-demo -c /dev/video0 -s | |
cp .pyvidctrl-vivid artifacts/ | |
- name: Generate test samples | |
run: | | |
./build/grabthecam-test-frame-fetch /dev/video0 | |
cp frame_*.png artifacts/frames/ | |
- name: Upload test artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test | |
path: | | |
artifacts | |
test: | |
needs: test-build | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Download test artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: test | |
path: artifacts | |
- name: Install dependencies | |
run: | | |
# By default Github Ubuntu runner uses a regular user (non-root). | |
sudo .github/scripts/prepare-env.sh | |
sudo apt install v4l-utils linux-modules-extra-$(uname -r) 1>/dev/null | |
sudo modprobe vivid | |
lsmod | grep -i vivid | |
sudo chown $USER /dev/video0 | |
chmod a+rwx /dev/video0 | |
v4l2-ctl --list-formats -d /dev/video0 | |
pip install -r .github/scripts/requirements.txt | |
- name: Test pyvidctrl | |
run: | | |
# Try to restore settings saved from grabthecam | |
pyvidctrl -r ./artifacts/.pyvidctrl-vivid | grep -q "Couldn't restore value of" && exit 1 || true | |
- name: Compare images | |
run: | | |
# Using RGB3 as Ground Truth | |
.github/scripts/compare-images.py ./artifacts/frames ./artifacts/frames/frame_RGB3.png |