diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..c916e1ec --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,142 @@ +name: Classifier Release +run-name: Build classifier +on: [push] +jobs: + tests: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + architecture: 'x64' + + - name: Display Python version + run: python -c "import sys; print(sys.version)" + + - run: sudo apt-get update + - run: python -m pip install --upgrade pip + + - run: pip install black --upgrade + - run: ./check-style + + - name: Install dependencies + run: | + pip install cmake freezegun gdown + sudo apt install -y python3-dbus ffmpeg build-essential libdbus-glib-1-dev libgirepository1.0-dev tzdata libcairo2-dev libjpeg-dev python3-cairo libhdf5-dev libopencv-dev cmake + pip install -r requirements.txt + + + - name: Run tests + run: | + pip install pytest + pytest -s + + - name: Test Build + run: python3 src/build.py -c tests/test-config.yaml tests --ext ".cptv" + + - name: Test Classify + run: | + sudo mkdir /var/spool/cptv + sudo chmod -R 777 /var/spool/cptv + wget -O thermal-model.tar https://github.com/TheCacophonyProject/AI-Model/releases/download/v0.5/inc3-19012023-tflite.tar + mkdir thermal-model + tar xzvf thermal-model.tar -C thermal-model --strip-components=1 + pip install tflite-runtime==2.14.0 + python3 src/classify.py -c tests/test-config.yaml ./tests/clips/ + python3 src/piclassify.py --file tests/clips/possum.cptv --thermal-config-file tests/config.toml -c tests/test-config.yaml + + pypi-build: + name: Build distribution 📦 + runs-on: ubuntu-latest + needs: + - tests + if: github.ref == 'refs/heads/pi-classifier' + + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + architecture: 'x64' + + - name: Install pypa/build + run: >- + python3 -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: python3 -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + pypi-publish: + name: Upload release to PyPI + needs: + - pypi-build + if: github.ref == 'refs/heads/pi-classifier' + + runs-on: ubuntu-latest + environment: + name: release + url: https://pypi.org/project/classifier-pipeline/ + + permissions: + id-token: write + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + docker: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v') + environment: + name: docker + needs: + - tests + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: cacophonyproject/classifier + + - + name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - + name: Build and push + uses: docker/build-push-action@v6 + with: + file: ./docker/Dockerfile + push: true + # tags: cacophonyproject/classifier:latest + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f7f59ee9..00000000 --- a/.travis.yml +++ /dev/null @@ -1,56 +0,0 @@ -dist: jammy -arch: - - amd64 -language: python -services: - - docker -python: -- '3.10' -install: -- sudo apt-get update -- python -m pip install --upgrade pip -- pip install cmake -- sudo apt install -y python3-dbus ffmpeg build-essential libdbus-glib-1-dev libgirepository1.0-dev tzdata libcairo2-dev libjpeg-dev python3-cairo libhdf5-dev libopencv-dev cmake -- pip install -r requirements.txt -before_script: -- pip install black --upgrade -- pip install gdown -script: -- pip install freezegun -- pytest -s -- "./check-style" -- python3 src/build.py -c tests/test-config.yaml tests --ext ".cptv" -- sudo mkdir /var/spool/cptv -- sudo chmod -R 777 /var/spool/cptv -- wget -O thermal-model.tar https://github.com/TheCacophonyProject/AI-Model/releases/download/v0.5/inc3-19012023-tflite.tar -- mkdir thermal-model -- tar xzvf thermal-model.tar -C thermal-model --strip-components=1 -- pip install tflite-runtime==2.14.0 -- python3 src/classify.py -c tests/test-config.yaml ./tests/clips/ -- python3 src/piclassify.py --file tests/clips/possum.cptv --thermal-config-file tests/config.toml - -c tests/test-config.yaml -before_deploy: -- python3 -m pip install --upgrade build -- pip install twine -# somethings broken with twine 3.9 -- pip install urllib3==1.26.15 requests-toolbelt==0.10.1 - -- echo $'[pypi]\nusername = __token__\npassword = '$PYPI_TOKEN > ~/.pypirc -deploy: - - provider: script - script: bash ./docker_push.sh - on: - repo: TheCacophonyProject/classifier-pipeline - tags: true - skip_cleanup: 'true' - - provider: script - script: bash ./pypi_push.sh - on: - branch: pi-classifier - skip_cleanup: 'true' - - provider: script - script: bash ./pypi_push.sh - on: - branch: add-event - skip_cleanup: 'true' - \ No newline at end of file