Skip to content

Commit

Permalink
GitHub action docker build (#536)
Browse files Browse the repository at this point in the history
* ci: add github action to confirm Dockerfile still works on any PR

* add badge

* rm refs of kenshih in favor of kahst
  • Loading branch information
kenshih authored Jan 10, 2025
1 parent 6729b57 commit 9e824e4
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Docker Build

on:
push:
branches: [ main ]
paths:
- 'Dockerfile'
- '.github/workflows/docker-build.yml'
pull_request:
branches: [ main ]
paths:
- 'Dockerfile'
- '.github/workflows/docker-build.yml'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build Docker image
run: docker build . --file Dockerfile --tag birdnet:local-test

# Optional: Add basic test to verify the image works
- name: Test Docker image
run: |
docker run -v $PWD/birdnet_analyzer/example:/audio birdnet:local-test -m birdnet_analyzer.analyze --i /audio --o /audio --slist /audio
# Verify output file content
expected_header="Selection View Channel Begin Time (s) End Time (s) Low Freq (Hz) High Freq (Hz) Common Name Species Code Confidence Begin Path File Offset (s)"
expected_first_line="1 Spectrogram 1 1 0 3.0 0 15000 Black-capped Chickadee bkcchi 0.8141 /audio/soundscape.wav 0"
actual_header=$(head -n 1 birdnet_analyzer/example/soundscape.BirdNET.selection.table.txt)
actual_first_line=$(head -n 2 birdnet_analyzer/example/soundscape.BirdNET.selection.table.txt | tail -n 1)
if [ "$actual_header" != "$expected_header" ] || [ "$actual_first_line" != "$expected_first_line" ]
then
echo "Output file content does not match expected content"
echo "Expected header: $expected_header"
echo "Actual header: $actual_header"
echo "Expected first line: $expected_first_line"
echo "Actual first line: $actual_first_line"
exit 1
else
echo "test received expected output file contents"
fi
2 changes: 2 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ image:{license-badge}[CC BY-NC-SA 4.0, link={cc-by-nc-sa}]
image:{os-badge}[Supported OS, link=""]
image:{species-badge}[Number of species, link=""]
image:{downloads-badge}[Downloads, link=""]
// build badge
image:https://github.com/kahst/BirdNET-Analyzer/actions/workflows/docker-build.yml/badge.svg[Docker Build, link="https://github.com/kahst/BirdNET-Analyzer/actions/workflows/docker-build.yml"]


[.text-center]
Expand Down

0 comments on commit 9e824e4

Please sign in to comment.