add docker testing

This commit is contained in:
Sergey Krashevich
2023-02-21 18:11:15 +03:00
parent 3b9a0059df
commit d3b2b8fdae
2 changed files with 62 additions and 10 deletions
+49 -6
View File
@@ -9,7 +9,7 @@ on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
test: build-test:
strategy: strategy:
matrix: matrix:
os: [windows-latest, ubuntu-latest, macos-latest] os: [windows-latest, ubuntu-latest, macos-latest]
@@ -35,18 +35,18 @@ jobs:
if: matrix.os == 'ubuntu-latest' if: matrix.os == 'ubuntu-latest'
run: | run: |
if [ "${{ matrix.arch }}" = "amd64" ]; then if [ "${{ matrix.arch }}" = "amd64" ]; then
./go2rtc --help ./go2rtc -version
else else
sudo apt-get update && sudo apt-get install -y qemu-user-static sudo apt-get update && sudo apt-get install -y qemu-user-static
sudo cp /usr/bin/qemu-aarch64-static . sudo cp /usr/bin/qemu-aarch64-static .
sudo chown $USER:$USER ./qemu-aarch64-static sudo chown $USER:$USER ./qemu-aarch64-static
qemu-aarch64-static ./go2rtc --help qemu-aarch64-static ./go2rtc -version
fi fi
- name: Test Go binary on macos - name: Test Go binary on macos
if: matrix.os == 'macos-latest' if: matrix.os == 'macos-latest'
run: | run: |
if [ "${{ matrix.arch }}" = "amd64" ]; then if [ "${{ matrix.arch }}" = "amd64" ]; then
./go2rtc --help ./go2rtc -version
else else
echo "ARM64 architecture is not yet supported on macOS" echo "ARM64 architecture is not yet supported on macOS"
fi fi
@@ -54,7 +54,50 @@ jobs:
if: matrix.os == 'windows-latest' if: matrix.os == 'windows-latest'
run: | run: |
if ("${{ matrix.arch }}" -eq "amd64") { if ("${{ matrix.arch }}" -eq "amd64") {
.\go2rtc* --help .\go2rtc* -version
} else { } else {
Write-Host "ARM64 architecture is not yet supported on Windows" Write-Host "ARM64 architecture is not yet supported on Windows"
} }
docker-test:
strategy:
matrix:
platform:
- amd64
- "386"
- arm/v7
- arm64/v8
continue-on-error: true
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/${{ matrix.platform }}
push: false
load: true
tags: go2rtc-${{ matrix.platform }}
- name: test run
run: |
docker run --platform=linux/${{ matrix.platform }} --rm go2rtc-${{ matrix.platform }} go2rtc -version
- name: Build and push Hardware
if: matrix.platform == 'amd64'
uses: docker/build-push-action@v3
with:
context: .
file: hardware.Dockerfile
platforms: linux/amd64
push: false
load: true
tags: go2rtc-${{ matrix.platform }}-hardware
- name: test run
if: matrix.platform == 'amd64'
run: |
docker run --platform=linux/${{ matrix.platform }} --rm go2rtc-${{ matrix.platform }}-hardware go2rtc -version
+13 -4
View File
@@ -2,16 +2,18 @@ package app
import ( import (
"flag" "flag"
"github.com/AlexxIT/go2rtc/pkg/shell" "fmt"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"gopkg.in/yaml.v3"
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
"runtime" "runtime"
"strings" "strings"
"time" "time"
"github.com/AlexxIT/go2rtc/pkg/shell"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"gopkg.in/yaml.v3"
) )
var Version = "1.2.0" var Version = "1.2.0"
@@ -24,10 +26,17 @@ var Info = map[string]interface{}{
func Init() { func Init() {
var confs Config var confs Config
var version bool
flag.Var(&confs, "config", "go2rtc config (path to file or raw text), support multiple") flag.Var(&confs, "config", "go2rtc config (path to file or raw text), support multiple")
flag.BoolVar(&version, "version", false, "Print the version of the application and exit")
flag.Parse() flag.Parse()
if version {
fmt.Println("Current version: ", Version)
os.Exit(0)
}
if confs == nil { if confs == nil {
confs = []string{"go2rtc.yaml"} confs = []string{"go2rtc.yaml"}
} }