Skip to content

Commit

Permalink
Add ci tests
Browse files Browse the repository at this point in the history
Signed-off-by: asakiz <asakizin@gmail.com>
  • Loading branch information
Asakiz authored and otavio committed Sep 23, 2020
1 parent 53f5755 commit 0b7ad6a
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,63 @@
name: CI

on:
push:
branches:
- master
- topic/test_ci
pull_request:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.15' ]
name: Go ${{ matrix.go }} sample
steps:
- uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

- name: Install Dependencies
run: |
sudo apt-get update; sudo apt-get install socat
- name: Run API test
run: |
wget https://raw.githubusercontent.com/UpdateHub/updatehub/master/doc/agent-http.yaml \
-O agent-http.yaml
docker run \
--rm \
--detach=true \
--name agent-sdk-go-mock \
-p 8080:8000 \
-v $PWD/agent-http.yaml:/api.yaml \
danielgtaylor/apisprout@sha256:6c07143937e57095d8478efc8ab7eab52b44e67c7673285f8c0a2bf4a7b137ad \
/api.yaml --validate-request
go run examples/api/main.go
- name: Run listener test
run: |
export UH_LISTENER_TEST=updatehub-statechange.sock
go build examples/listener/main.go; ./main &
while [ ! -S "$UH_LISTENER_TEST" ]; do
sleep 1
done
if [[ "$(echo "entry_point" | socat - UNIX-CONNECT:updatehub-statechange.sock)" != "" ]]; then
echo "Unexpected entry_point response"
exit 1
fi
if [[ "$(echo "download" | socat - UNIX-CONNECT:updatehub-statechange.sock)" != "cancel" ]]; then
echo "Unexpected download response"
exit 2
fi
if [[ "$(echo "error" | socat - UNIX-CONNECT:updatehub-statechange.sock)" != "" ]]; then
echo "Unexpected error response"
exit 3
fi
if [[ "$(echo "reboot" | socat - UNIX-CONNECT:updatehub-statechange.sock)" != "" ]]; then
echo "Unexpected reboot response"
exit 4
fi
5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@
*~
**/*
!**/*.go
!**/
agent-http.yaml

0 comments on commit 0b7ad6a

Please sign in to comment.