Skip to content

Commit f30e156

Browse files
committed
Put UI into Go binary
1 parent aad544d commit f30e156

File tree

4 files changed

+138
-0
lines changed

4 files changed

+138
-0
lines changed

.circleci/config.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
version: 2
2+
jobs:
3+
frontend:
4+
docker:
5+
- image: circleci/node:10.8.0
6+
steps:
7+
- checkout
8+
- run:
9+
name: "Install dependencies"
10+
command: yarn install
11+
- run:
12+
name: "Build"
13+
command: yarn run build
14+
- persist_to_workspace:
15+
root: .
16+
paths:
17+
- dist/*
18+
19+
backend:
20+
docker:
21+
- image: circleci/golang:1.10
22+
working_directory: /go/src/github.com/RoboCup-SSL/ssl-status-board
23+
steps:
24+
- checkout
25+
- attach_workspace:
26+
at: .
27+
- run: go get -v -t -d ./...
28+
- run: go test -v -covermode=count -coverprofile=count.out ./...
29+
- run: go tool cover -html=count.out -o coverage.html
30+
- run:
31+
working_directory: cmd/ssl-status-borad
32+
command: |
33+
go get -v github.com/gobuffalo/packr/packr
34+
GOOS=linux GOARCH=amd64 packr build -o ../../release/ssl-status-board_linux_amd64
35+
GOOS=linux GOARCH=arm packr build -o ../../release/ssl-status-board_linux_arm
36+
GOOS=darwin GOARCH=amd64 packr build -o ../../release/ssl-status-board_darwin_amd64
37+
GOOS=windows GOARCH=amd64 packr build -o ../../release/ssl-status-board_windows_amd64.exe
38+
- persist_to_workspace:
39+
root: .
40+
paths:
41+
- release/*
42+
- store_artifacts:
43+
path: coverage.html
44+
destination: coverage
45+
46+
publish-github-release:
47+
docker:
48+
- image: circleci/golang:1.10
49+
steps:
50+
- attach_workspace:
51+
at: .
52+
- run:
53+
name: "Prepare artifacts"
54+
working_directory: release
55+
command: |
56+
mv ssl-status-board_linux_amd64 ssl-status-board_${CIRCLE_TAG}_linux_amd64
57+
mv ssl-status-board_linux_arm ssl-status-board_${CIRCLE_TAG}_linux_arm
58+
mv ssl-status-board_darwin_amd64 ssl-status-board_${CIRCLE_TAG}_darwin_amd64
59+
mv ssl-status-board_windows_amd64.exe ssl-status-board_${CIRCLE_TAG}_windows_amd64.exe
60+
- run:
61+
name: "Publish Release on GitHub"
62+
command: |
63+
go get github.com/tcnksm/ghr
64+
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${CIRCLE_TAG} ./release/
65+
66+
workflows:
67+
version: 2
68+
main:
69+
jobs:
70+
- frontend:
71+
filters:
72+
tags:
73+
only: /.*/
74+
- backend:
75+
requires:
76+
- frontend
77+
filters:
78+
tags:
79+
only: /.*/
80+
- publish-github-release:
81+
requires:
82+
- backend
83+
filters:
84+
branches:
85+
ignore: /.*/
86+
tags:
87+
only: /^v.*/

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# ssl-status-board
22

3+
A Status Board for the Small Size League, optimized to show the current game state on a large screen.
4+
35
## Project setup
46
```
57
yarn install
@@ -19,3 +21,8 @@ yarn run build
1921
```
2022
yarn run lint
2123
```
24+
25+
### Rebuild Protobuf code
26+
```
27+
yarn run genProto
28+
```

cmd/ssl-status-board/main.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"github.com/gobuffalo/packr"
6+
"log"
7+
"net/http"
8+
)
9+
10+
var address = flag.String("address", "localhost:8082", "The address on which the UI and API is served")
11+
12+
func main() {
13+
flag.Parse()
14+
15+
setupUi()
16+
17+
err := http.ListenAndServe(*address, nil)
18+
if err != nil {
19+
log.Fatal(err)
20+
}
21+
}
22+
23+
func setupUi() {
24+
box := packr.NewBox("../../dist")
25+
http.Handle("/", http.FileServer(box))
26+
if box.Has("index.html") {
27+
log.Printf("UI is available at http://%v", *address)
28+
} else {
29+
log.Print("Backend-only version started. Run the UI separately or get a binary that has the UI included")
30+
}
31+
}

install.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# UI
6+
yarn install
7+
yarn run build
8+
9+
# backend
10+
go get -v -d ./...
11+
cd cmd/ssl-status-board
12+
go get -u -v github.com/gobuffalo/packr/packr
13+
packr install

0 commit comments

Comments
 (0)