Skip to content

Github Actions CI for the repo - sanity check #17

Github Actions CI for the repo - sanity check

Github Actions CI for the repo - sanity check #17

Workflow file for this run

name: Sanity check
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
env:
OS_LIST: "ubuntu-latest,windows-latest,macos-latest"
PYTHON_VERSIONS: "3.11"
jobs:
find-subprojects:
runs-on: ubuntu-latest
outputs:
notebook: ${{ steps.categorize-subprojects.outputs.notebook }}
gradio: ${{ steps.categorize-subprojects.outputs.gradio }}
webcam: ${{ steps.categorize-subprojects.outputs.webcam }}
js: ${{ steps.categorize-subprojects.outputs.js }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Categorize subprojects
id: categorize-subprojects
run: |
notebook=()
gradio=()
webcam=()
js=()
for dir in $(find demos -type f -name "requirements.txt" -exec dirname {} \; | sort -u); do
if [ -f "$dir/main.ipynb" ]; then
notebook+=("$dir")
elif grep -q "gradio" "$dir/requirements.txt"; then
gradio+=("$dir")
elif [ -f "$dir/package.json" ]; then
js+=("$dir")
elif python $dir/main.py -h 2>/dev/null | grep -q -- "--stream"; then
webcam+=("$dir")
fi
done
notebook_json=$(printf '%s\n' "${notebook[@]}" | jq -R -s -c 'split("\n")[:-1]')
gradio_json=$(printf '%s\n' "${gradio[@]}" | jq -R -s -c 'split("\n")[:-1]')
webcam_json=$(printf '%s\n' "${webcam[@]}" | jq -R -s -c 'split("\n")[:-1]')
js_json=$(printf '%s\n' "${js[@]}" | jq -R -s -c 'split("\n")[:-1]')
echo "notebook=$notebook_json" >> $GITHUB_OUTPUT
echo "gradio=$gradio_json" >> $GITHUB_OUTPUT
echo "webcam=$webcam_json" >> $GITHUB_OUTPUT
echo "js=$js_json" >> $GITHUB_OUTPUT
notebook:
needs: find-subprojects
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ${{ fromJson(env.OS_LIST) }}

Check failure on line 63 in .github/workflows/sanity-check.yml

View workflow run for this annotation

GitHub Actions / Sanity check

Invalid workflow file

The workflow is not valid. .github/workflows/sanity-check.yml (Line: 63, Col: 13): Unrecognized named-value: 'env'. Located at position 10 within expression: fromJson(env.OS_LIST) .github/workflows/sanity-check.yml (Line: 63, Col: 13): Unexpected value '${{ fromJson(env.OS_LIST) }}'
python: ${{ fromJson(env.PYTHON_VERSIONS) }}
subproject: ${{ fromJson(needs.find-subprojects.outputs.notebook) }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ${{ matrix.subproject }}/requirements.txt
- name: Execute Notebook
run: |
cd ${{ matrix.subproject }}
jupyter nbconvert --to notebook --execute main.ipynb
gradio:
needs: find-subprojects
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ${{ fromJson(env.OS_LIST) }}
python: ${{ fromJson(env.PYTHON_VERSIONS) }}
subproject: ${{ fromJson(needs.find-subprojects.outputs.gradio) }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ${{ matrix.subproject }}/requirements.txt
- name: Run Gradio App
run: |
cd ${{ matrix.subproject }}
python main.py
webcam:
needs: find-subprojects
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ${{ fromJson(env.OS_LIST) }}
python: ${{ fromJson(env.PYTHON_VERSIONS) }}
subproject: ${{ fromJson(needs.find-subprojects.outputs.webcam) }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
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: Run Webcam Demo
run: |
cd ${{ matrix.subproject }}
python main.py --stream sample_video.mp4
js:
needs: find-subprojects
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ${{ fromJson(env.OS_LIST) }}
subproject: ${{ fromJson(needs.find-subprojects.outputs.js) }}
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install dependencies
run: |
cd ${{ matrix.subproject }}
npm install
- name: Run JS Project
run: |
cd ${{ matrix.subproject }}
npm run start