Skip to content

[PUT Project] Added CI with format testing and building #31

[PUT Project] Added CI with format testing and building

[PUT Project] Added CI with format testing and building #31

name: grabthecam build
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo .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 $(git status --porcelain | wc -l) -eq 0 || { git diff; false; }
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
pip install -r .github/scripts/requirements.txt
- 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: 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
- name: Upload test artifacts
uses: actions/upload-artifact@v3
with:
name: test_results
path: |
artifacts