Skip to content

Add files via upload #429

Add files via upload

Add files via upload #429

Workflow file for this run

# 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" ]
permissions:
contents: read
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-sdk
- 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-sdk
- name: Test with pytest
run: |
pytest
working-directory: ./hikvision-sdk
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-sdk
file: ./hikvision-sdk/Dockerfile
build-args: |
BUILD_FROM=library/python:3.10.8-slim
BUILD_ARCH=amd64
push: false
outputs: |
type=docker,dest=/tmp/image.tar
platforms: linux/amd64
tags: ${{github.repository_owner}}/hikvision-sdk:latest
- name: Upload artifact
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 to Docker
uses: docker/build-push-action@v4
with:
context: ./hikvision-sdk
file: ./hikvision-sdk/Dockerfile
build-args: |
BUILD_FROM=openeuler/openeuler:22.03-lts-sp1
BUILD_ARCH=aarch64
push: false
load: true
platforms: linux/arm64
tags: ${{github.repository_owner}}/hikvision-sdk:latest
# TODO: find a way to run the addon without Hikvision doorbell available
# test-image-amd64:
# runs-on: ubuntu-latest
# needs: docker-image_amd64
# name: Test docker image
# continue-on-error: true
# 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:
# IP: 192.168.0.250
# USERNAME: admin
# PASSWORD: admin
# run: |
# docker run -e IP -e USERNAME -e PASSWORD --rm ${{github.repository_owner}}/hikvision-sdk:latest