From d3b2b8fdae76876053f42c59e73c7c481dc5996f Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Tue, 21 Feb 2023 18:11:15 +0300 Subject: [PATCH] add docker testing --- .github/workflows/test.yml | 55 +++++++++++++++++++++++++++++++++----- cmd/app/app.go | 17 +++++++++--- 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3db871eb..6a8fea0f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ on: workflow_dispatch: jobs: - test: + build-test: strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest] @@ -35,18 +35,18 @@ jobs: if: matrix.os == 'ubuntu-latest' run: | if [ "${{ matrix.arch }}" = "amd64" ]; then - ./go2rtc --help + ./go2rtc -version else sudo apt-get update && sudo apt-get install -y qemu-user-static sudo cp /usr/bin/qemu-aarch64-static . sudo chown $USER:$USER ./qemu-aarch64-static - qemu-aarch64-static ./go2rtc --help + qemu-aarch64-static ./go2rtc -version fi - name: Test Go binary on macos if: matrix.os == 'macos-latest' run: | if [ "${{ matrix.arch }}" = "amd64" ]; then - ./go2rtc --help + ./go2rtc -version else echo "ARM64 architecture is not yet supported on macOS" fi @@ -54,7 +54,50 @@ jobs: if: matrix.os == 'windows-latest' run: | if ("${{ matrix.arch }}" -eq "amd64") { - .\go2rtc* --help + .\go2rtc* -version } else { Write-Host "ARM64 architecture is not yet supported on Windows" - } \ No newline at end of file + } + 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 \ No newline at end of file diff --git a/cmd/app/app.go b/cmd/app/app.go index 40d85dd3..5f5007e0 100644 --- a/cmd/app/app.go +++ b/cmd/app/app.go @@ -2,16 +2,18 @@ package app import ( "flag" - "github.com/AlexxIT/go2rtc/pkg/shell" - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" - "gopkg.in/yaml.v3" + "fmt" "io" "os" "path/filepath" "runtime" "strings" "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" @@ -24,10 +26,17 @@ var Info = map[string]interface{}{ func Init() { var confs Config + var version bool 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() + if version { + fmt.Println("Current version: ", Version) + os.Exit(0) + } + if confs == nil { confs = []string{"go2rtc.yaml"} }