Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub action docker build #536

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This runs the test after merging in a PR or a direct push to main by maintainer.

paths:
- 'Dockerfile'
- '.github/workflows/docker-build.yml'
pull_request:
branches: [ main ]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means, this Github Action with run if a pull request is made on main. So you can quickly evaluate whether the PR contains obvious breaking changes.

You can see a history of runs in the “Actions” tab on github. It looks something like this…
Screenshot 2024-12-26 at 10 15 17 PM

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
Loading