Skip to content

Github Actions CI for the repo - sanity check #7

Github Actions CI for the repo - sanity check

Github Actions CI for the repo - sanity check #7

Workflow file for this run

name: Sanity check
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
find-subprojects:
runs-on: ubuntu-latest
outputs:
subprojects: ${{ steps.get-subprojects.outputs.subproject_list }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Get list of Python subprojects (with requirements.txt)
id: get-subprojects
run: |
# Find all directories in repo that contain a requirements.txt file
subprojects=$(find demos -type f -name "requirements.txt" -exec dirname {} \; | sort -u)
subproject_list=$(echo "$subprojects" | jq -R -s -c 'split("\n")[:-1]')
echo "$subproject_list"
echo "subproject_list=$subproject_list" >> $GITHUB_OUTPUT # Use GITHUB_OUTPUT file for setting outputs
check-repo:
needs: find-subprojects
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python: [3.11]
subproject: ${{ fromJson(needs.find-subprojects.outputs.subprojects) }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install dependencies for ${{ matrix.subproject }}
run: |
python -m pip install --upgrade pip
pip install -r ${{ matrix.subproject }}/requirements.txt
- name: Download sample video file
run: |
cd ${{ matrix.subproject }}
curl -L -o sample_video.mp4 https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4
- name: Check if --stream is a valid option
id: check-stream-option
run: |
cd ${{ matrix.subproject }}
if python main.py -h | grep -q -- "--stream"; then
echo "Stream option found"
echo "stream=true" >> $GITHUB_ENV
else
echo "Stream option not found"
echo "stream=false" >> $GITHUB_ENV
fi
- name: Set environment to avoid OpenCV GUI errors
run: |
# This will prevent OpenCV from trying to display any GUI windows during execution
echo "DISPLAY=:99" >> $GITHUB_ENV
- name: Run the demo
run: |
cd ${{ matrix.subproject }}
if [ "${{ env.stream }}" = "true" ]; then
# Run the demo with --stream if it requires video input
python main.py --stream sample_video.mp4
else
# Run the demo without --stream if it does not require video input
python main.py
fi