added DS-K1T502DBFWX #524
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will install Python dependencies, run tests and lint with a single version of Python | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
name: Python tests | |
on: | |
push: | |
# branches: [ "main" ] | |
pull_request: | |
branches: [ "main", "dev" ] | |
permissions: | |
contents: read | |
# To cancel a currently running workflow from the same PR, branch or tag when a new workflow is triggered you can use: | |
# Taken from https://stackoverflow.com/a/72408109 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 pytest | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
working-directory: ./hikvision-doorbell | |
- name: Lint with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
working-directory: ./hikvision-doorbell | |
- name: Test with pytest | |
run: | | |
pytest | |
working-directory: ./hikvision-doorbell | |
docker-image_amd64: | |
needs: test | |
name: Docker image (amd64) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build and export | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./hikvision-doorbell | |
file: ./hikvision-doorbell/Dockerfile | |
build-args: | | |
BUILD_ARCH=amd64 | |
push: false | |
outputs: | | |
type=docker,dest=/tmp/image.tar | |
platforms: linux/amd64 | |
tags: hikvision-doorbell:latest | |
- name: Upload image | |
uses: actions/upload-artifact@v3 | |
with: | |
name: image amd64 | |
path: /tmp/image.tar | |
retention-days: 1 | |
docker-image_aarch64: | |
needs: test | |
name: Docker image (aarch64) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build and export | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./hikvision-doorbell | |
file: ./hikvision-doorbell/Dockerfile | |
build-args: | | |
BUILD_ARCH=aarch64 | |
push: false | |
outputs: | | |
type=docker,dest=/tmp/image.tar | |
platforms: linux/arm64 | |
tags: hikvision-doorbell:latest | |
- name: Upload image | |
uses: actions/upload-artifact@v3 | |
with: | |
name: image aarch64 | |
path: /tmp/image.tar | |
retention-days: 1 | |
test-image-amd64: | |
runs-on: ubuntu-latest | |
needs: docker-image_amd64 | |
name: Test image (amd64) | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: image amd64 | |
path: /tmp | |
- name: Load image | |
run: | | |
docker load --input /tmp/image.tar | |
docker image ls -a | |
- name: Test image | |
env: | |
SYSTEM__LOG_LEVEL: DEBUG | |
SYSTEM__SDK_LOG_LEVEL: DEBUG | |
run: | | |
echo -n "" | docker run -i -e SYSTEM__LOG_LEVEL -e SYSTEM__SDK_LOG_LEVEL hikvision-doorbell:latest | |
test-image-aarch64: | |
runs-on: ubuntu-latest | |
needs: docker-image_aarch64 | |
name: Test image (aarch64) | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: image aarch64 | |
path: "artifacts/" | |
- uses: uraimo/run-on-arch-action@v2 | |
name: Run aarch64 commands | |
id: runcmd | |
with: | |
arch: aarch64 | |
distro: ubuntu22.04 | |
# Create an artifacts directory | |
setup: | | |
mkdir -p "${PWD}/artifacts" | |
# Mount the artifacts directory as /artifacts in the container | |
dockerRunArgs: | | |
--volume "${PWD}/artifacts:/artifacts" | |
env: | | |
SYSTEM__LOG_LEVEL: DEBUG | |
SYSTEM__SDK_LOG_LEVEL: DEBUG | |
install: | | |
# Setup Docker APT repository | |
apt-get update -q -y | |
apt-get install -y \ | |
ca-certificates \ | |
curl \ | |
gnupg \ | |
lsb-release | |
mkdir -m 0755 -p /etc/apt/keyrings | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg | |
echo \ | |
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ | |
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list | |
apt-get update -q -y | |
apt-get install -y docker-ce docker-ce-cli containerd.io | |
run: | | |
docker load --input /artifacts/image.tar | |
docker image ls -a | |
echo "Loaded image.tar" | |
echo -n "" | docker run -i -e SYSTEM__LOG_LEVEL -e SYSTEM__SDK_LOG_LEVEL hikvision-doorbell:latest | |