From a657a74383f9077500e1708d6fac85dfe72a2b81 Mon Sep 17 00:00:00 2001 From: Phil Cluff <578330+GeneticGenesis@users.noreply.github.com> Date: Sat, 25 Apr 2020 00:28:03 +0100 Subject: [PATCH] Run Video and Data Integration tests in CI (#12) * First pass of github actions * Match starter workflow, which I think is broken * There will be a lot of debug commits coming * Create gobin * dep ensure * Workaround path issues * Nightmare * Debug all the things * Hopefully * Rebuild paths under the limited directory structure github allows * Try and run a test maybe * no-op * Pull creds * Run all tests. Will likely fail, concerningly. * First pass at cleaning up workflow * Move GOPATH to the top level * Remove empty env statements * A little more cleanup and some commenting * Try cleaning up using variables liberally * 1 is the default fetch depth anyway * Cleanup, commenting, correct triggers * Badge it! * Cleanup tests to use Safari as per synthetic views --- .github/workflows/ci.yaml | 43 +++++++++++++++++++ README.md | 2 + examples/data/errors/exercise-errors.go | 6 +-- examples/data/filters/exercise-filters.go | 4 +- .../data/video-views/exercise-video-views.go | 6 +-- test.sh | 28 ++++++++++++ 6 files changed, 81 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/ci.yaml create mode 100755 test.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..7799d52 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,43 @@ +name: Integration Test + +on: + push: + branches: + - master + pull_request: + +# I appreciate this isn't the cleanest workflow, but it's the neatest I can get it while we're +# still using dep to manage dependencies. If we move to go modules this can be cleaned up a lot. +# I'd love to use a nicer checkout path, but GitHub actions won't let you use anything above +# /home/runner/work/mux-go/mux-go/, so /home/runner/work/mux-go/mux-go/go it is! + +jobs: + build: + name: Integration Test + runs-on: ubuntu-latest + env: + GOPATH: /home/runner/work/mux-go/mux-go/go + CHECKOUT_LOCATION: /home/runner/work/mux-go/mux-go/go/src/github.com/muxinc/mux-go + steps: + - name: Check out code + uses: actions/checkout@v2 + with: + path: ${{env.CHECKOUT_LOCATION}} + - name: Install Go + uses: actions/setup-go@v2 + - name: Install Dep + run: | + mkdir -p $GOPATH/bin + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + - name: Install Go Dependencies + run: | + cd $CHECKOUT_LOCATION + export PATH=$PATH:$(go env GOPATH)/bin + dep ensure + - name: Run Integration Tests + run: | + cd $CHECKOUT_LOCATION + bash test.sh + env: + MUX_TOKEN_ID: ${{ secrets.MUX_TOKEN_ID }} + MUX_TOKEN_SECRET: ${{ secrets.MUX_TOKEN_SECRET }} diff --git a/README.md b/README.md index 8496be3..550287d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ ![Mux Go Banner](https://banner.mux.dev/?image=go) +![](https://github.com/muxinc/mux-go/workflows/Integration%20Test/badge.svg) + # Mux Go Official Mux API wrapper for golang projects, supporting both Mux Data and Mux Video. diff --git a/examples/data/errors/exercise-errors.go b/examples/data/errors/exercise-errors.go index 2f672bf..8b47d45 100644 --- a/examples/data/errors/exercise-errors.go +++ b/examples/data/errors/exercise-errors.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "github.com/muxinc/mux-go" + muxgo "github.com/muxinc/mux-go" "github.com/muxinc/mux-go/examples/common" ) @@ -20,7 +20,7 @@ func main() { )) // ========== list-errors ========== - lep := muxgo.ListErrorsParams{Filters: []string{"browser:Chrome"}, Timeframe: []string{"7:days"}} + lep := muxgo.ListErrorsParams{Filters: []string{"browser:Safari"}, Timeframe: []string{"7:days"}} e, err := client.ErrorsApi.ListErrors(muxgo.WithParams(&lep)) common.AssertNoError(err) common.AssertNotNil(e.Data) @@ -29,4 +29,4 @@ func main() { os.Exit(255) } fmt.Println("list-errors ✅") -} \ No newline at end of file +} diff --git a/examples/data/filters/exercise-filters.go b/examples/data/filters/exercise-filters.go index d5ee1e9..428b149 100644 --- a/examples/data/filters/exercise-filters.go +++ b/examples/data/filters/exercise-filters.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "github.com/muxinc/mux-go" + muxgo "github.com/muxinc/mux-go" "github.com/muxinc/mux-go/examples/common" ) @@ -34,4 +34,4 @@ func main() { common.AssertNoError(err) common.AssertNotNil(fv.Data) fmt.Println("list-filter-values ✅") -} \ No newline at end of file +} diff --git a/examples/data/video-views/exercise-video-views.go b/examples/data/video-views/exercise-video-views.go index f2524c2..c953c72 100644 --- a/examples/data/video-views/exercise-video-views.go +++ b/examples/data/video-views/exercise-video-views.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "github.com/muxinc/mux-go" + muxgo "github.com/muxinc/mux-go" "github.com/muxinc/mux-go/examples/common" ) @@ -21,7 +21,7 @@ func main() { )) // ========== list-video-views ========== - p := muxgo.ListVideoViewsParams{Filters: []string{"country:GB", "browser:Chrome"}, Timeframe: []string{"7:days"}} + p := muxgo.ListVideoViewsParams{Filters: []string{"country:US", "browser:Safari"}, Timeframe: []string{"7:days"}} vs, err := client.VideoViewsApi.ListVideoViews(muxgo.WithParams(&p)) common.AssertNoError(err) common.AssertNotNil(vs.Data) @@ -36,4 +36,4 @@ func main() { common.AssertNoError(err) common.AssertNotNil(v.Data) fmt.Println("get-video-view ✅") -} \ No newline at end of file +} diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..8e3fc34 --- /dev/null +++ b/test.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -euo pipefail + +if [ -z "${MUX_TOKEN_ID:-}" ] +then + echo "MUX_TOKEN_ID not set" + exit 255 +fi + +if [ -z "${MUX_TOKEN_SECRET:-}" ] +then + echo "MUX_TOKEN_SECRET not set" + exit 255 +fi + +VIDEO_TESTS=./examples/video/*/exercise*.go +for f in $VIDEO_TESTS +do + echo "========== Running $f ==========" + go run $f +done + +DATA_TESTS=./examples/data/*/exercise*.go +for f in $DATA_TESTS +do + echo "========== Running $f ==========" + go run $f +done