Skip to content

Commit a657a74

Browse files
authored
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
1 parent 90f78c5 commit a657a74

File tree

6 files changed

+81
-8
lines changed

6 files changed

+81
-8
lines changed

.github/workflows/ci.yaml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Integration Test
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
# I appreciate this isn't the cleanest workflow, but it's the neatest I can get it while we're
10+
# still using dep to manage dependencies. If we move to go modules this can be cleaned up a lot.
11+
# I'd love to use a nicer checkout path, but GitHub actions won't let you use anything above
12+
# /home/runner/work/mux-go/mux-go/, so /home/runner/work/mux-go/mux-go/go it is!
13+
14+
jobs:
15+
build:
16+
name: Integration Test
17+
runs-on: ubuntu-latest
18+
env:
19+
GOPATH: /home/runner/work/mux-go/mux-go/go
20+
CHECKOUT_LOCATION: /home/runner/work/mux-go/mux-go/go/src/github.com/muxinc/mux-go
21+
steps:
22+
- name: Check out code
23+
uses: actions/checkout@v2
24+
with:
25+
path: ${{env.CHECKOUT_LOCATION}}
26+
- name: Install Go
27+
uses: actions/setup-go@v2
28+
- name: Install Dep
29+
run: |
30+
mkdir -p $GOPATH/bin
31+
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
32+
- name: Install Go Dependencies
33+
run: |
34+
cd $CHECKOUT_LOCATION
35+
export PATH=$PATH:$(go env GOPATH)/bin
36+
dep ensure
37+
- name: Run Integration Tests
38+
run: |
39+
cd $CHECKOUT_LOCATION
40+
bash test.sh
41+
env:
42+
MUX_TOKEN_ID: ${{ secrets.MUX_TOKEN_ID }}
43+
MUX_TOKEN_SECRET: ${{ secrets.MUX_TOKEN_SECRET }}

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
![Mux Go Banner](https://banner.mux.dev/?image=go)
22

3+
![](https://github.com/muxinc/mux-go/workflows/Integration%20Test/badge.svg)
4+
35
# Mux Go
46

57
Official Mux API wrapper for golang projects, supporting both Mux Data and Mux Video.

examples/data/errors/exercise-errors.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"os"
66

7-
"github.com/muxinc/mux-go"
7+
muxgo "github.com/muxinc/mux-go"
88
"github.com/muxinc/mux-go/examples/common"
99
)
1010

@@ -20,7 +20,7 @@ func main() {
2020
))
2121

2222
// ========== list-errors ==========
23-
lep := muxgo.ListErrorsParams{Filters: []string{"browser:Chrome"}, Timeframe: []string{"7:days"}}
23+
lep := muxgo.ListErrorsParams{Filters: []string{"browser:Safari"}, Timeframe: []string{"7:days"}}
2424
e, err := client.ErrorsApi.ListErrors(muxgo.WithParams(&lep))
2525
common.AssertNoError(err)
2626
common.AssertNotNil(e.Data)
@@ -29,4 +29,4 @@ func main() {
2929
os.Exit(255)
3030
}
3131
fmt.Println("list-errors ✅")
32-
}
32+
}

examples/data/filters/exercise-filters.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"os"
66

7-
"github.com/muxinc/mux-go"
7+
muxgo "github.com/muxinc/mux-go"
88
"github.com/muxinc/mux-go/examples/common"
99
)
1010

@@ -34,4 +34,4 @@ func main() {
3434
common.AssertNoError(err)
3535
common.AssertNotNil(fv.Data)
3636
fmt.Println("list-filter-values ✅")
37-
}
37+
}

examples/data/video-views/exercise-video-views.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"os"
66

7-
"github.com/muxinc/mux-go"
7+
muxgo "github.com/muxinc/mux-go"
88
"github.com/muxinc/mux-go/examples/common"
99
)
1010

@@ -21,7 +21,7 @@ func main() {
2121
))
2222

2323
// ========== list-video-views ==========
24-
p := muxgo.ListVideoViewsParams{Filters: []string{"country:GB", "browser:Chrome"}, Timeframe: []string{"7:days"}}
24+
p := muxgo.ListVideoViewsParams{Filters: []string{"country:US", "browser:Safari"}, Timeframe: []string{"7:days"}}
2525
vs, err := client.VideoViewsApi.ListVideoViews(muxgo.WithParams(&p))
2626
common.AssertNoError(err)
2727
common.AssertNotNil(vs.Data)
@@ -36,4 +36,4 @@ func main() {
3636
common.AssertNoError(err)
3737
common.AssertNotNil(v.Data)
3838
fmt.Println("get-video-view ✅")
39-
}
39+
}

test.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
if [ -z "${MUX_TOKEN_ID:-}" ]
5+
then
6+
echo "MUX_TOKEN_ID not set"
7+
exit 255
8+
fi
9+
10+
if [ -z "${MUX_TOKEN_SECRET:-}" ]
11+
then
12+
echo "MUX_TOKEN_SECRET not set"
13+
exit 255
14+
fi
15+
16+
VIDEO_TESTS=./examples/video/*/exercise*.go
17+
for f in $VIDEO_TESTS
18+
do
19+
echo "========== Running $f =========="
20+
go run $f
21+
done
22+
23+
DATA_TESTS=./examples/data/*/exercise*.go
24+
for f in $DATA_TESTS
25+
do
26+
echo "========== Running $f =========="
27+
go run $f
28+
done

0 commit comments

Comments
 (0)