Skip to content

Commit 249d483

Browse files
committed
Update project structure
1 parent 52398a9 commit 249d483

File tree

14 files changed

+213
-142
lines changed

14 files changed

+213
-142
lines changed

.circleci/config.yml

Lines changed: 85 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
version: 2
1+
version: 2.1
2+
parameters:
3+
cmds:
4+
type: string
5+
default: "ssl-vision-client ssl-vision-cli"
6+
27
jobs:
3-
frontend:
8+
build_node:
9+
resource_class: medium
410
docker:
511
- image: cimg/node:lts
612
steps:
@@ -18,99 +24,110 @@ jobs:
1824
paths:
1925
- frontend/dist/*
2026

21-
backend:
27+
test_go:
28+
resource_class: medium
2229
docker:
23-
- image: cimg/go:1.20
30+
- image: cimg/go:1.20.2
2431
steps:
2532
- checkout
2633
- attach_workspace:
2734
at: .
2835
- run: go get -v -t -d ./...
29-
- run: go test -v ./...
30-
- run:
31-
working_directory: cmd/ssl-vision-client
32-
command: |
33-
GOOS=linux GOARCH=amd64 go build -o ../../release/ssl-vision-client_linux_amd64
34-
GOOS=darwin GOARCH=amd64 go build -o ../../release/ssl-vision-client_darwin_amd64
35-
GOOS=windows GOARCH=amd64 go build -o ../../release/ssl-vision-client_windows_amd64.exe
36-
- run:
37-
working_directory: cmd/ssl-vision-cli
38-
command: |
39-
GOOS=linux GOARCH=amd64 go build -o ../../release/ssl-vision-cli_linux_amd64
40-
GOOS=darwin GOARCH=amd64 go build -o ../../release/ssl-vision-cli_darwin_amd64
41-
GOOS=windows GOARCH=amd64 go build -o ../../release/ssl-vision-cli_windows_amd64.exe
36+
- run: go test -v -covermode=count -coverprofile=count.out ./...
37+
- run: go tool cover -html=count.out -o coverage.html
38+
- store_artifacts:
39+
path: coverage.html
40+
destination: coverage
41+
42+
build_go:
43+
resource_class: large
44+
docker:
45+
- image: cimg/go:1.20.2
46+
steps:
47+
- checkout
48+
- attach_workspace:
49+
at: .
50+
- run: go get -v -t -d ./...
51+
- run: |
52+
set -u
53+
version=${CIRCLE_TAG:-}
54+
for cmd in << pipeline.parameters.cmds >>; do
55+
GOOS=linux GOARCH=amd64 go build -o ./release/${cmd}_${version}_linux_amd64 ./cmd/${cmd}
56+
GOOS=linux GOARCH=arm64 go build -o ./release/${cmd}_${version}_linux_arm64 ./cmd/${cmd}
57+
GOOS=linux GOARCH=arm go build -o ./release/${cmd}_${version}_linux_arm ./cmd/${cmd}
58+
GOOS=darwin GOARCH=amd64 go build -o ./release/${cmd}_${version}_darwin_amd64 ./cmd/${cmd}
59+
GOOS=darwin GOARCH=arm64 go build -o ./release/${cmd}_${version}_darwin_arm64 ./cmd/${cmd}
60+
GOOS=windows GOARCH=amd64 go build -o ./release/${cmd}_${version}_windows_amd64.exe ./cmd/${cmd}
61+
done
4262
- persist_to_workspace:
4363
root: .
4464
paths:
4565
- release/*
4666

47-
publish-github-release:
67+
publish_gh:
68+
resource_class: small
4869
docker:
49-
- image: cimg/go:1.20
70+
- image: cimg/go:1.20.2
5071
steps:
5172
- attach_workspace:
5273
at: .
53-
- run:
54-
name: "Prepare artifacts"
55-
working_directory: release
56-
command: |
57-
mkdir gh
58-
mv ssl-vision-client_linux_amd64 gh/ssl-vision-client_${CIRCLE_TAG}_linux_amd64
59-
mv ssl-vision-client_darwin_amd64 gh/ssl-vision-client_${CIRCLE_TAG}_darwin_amd64
60-
mv ssl-vision-client_windows_amd64.exe gh/ssl-vision-client_${CIRCLE_TAG}_windows_amd64.exe
61-
mv ssl-vision-cli_linux_amd64 gh/ssl-vision-cli_${CIRCLE_TAG}_linux_amd64
62-
mv ssl-vision-cli_darwin_amd64 gh/ssl-vision-cli_${CIRCLE_TAG}_darwin_amd64
63-
mv ssl-vision-cli_windows_amd64.exe gh/ssl-vision-cli_${CIRCLE_TAG}_windows_amd64.exe
64-
- run:
65-
name: "Publish Release on GitHub"
66-
command: |
67-
go install github.com/tcnksm/[email protected]
68-
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${CIRCLE_TAG} ./release/gh/
74+
- run: |
75+
set -u
76+
go install github.com/tcnksm/[email protected]
77+
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete -generatenotes ${CIRCLE_TAG} ./release
6978
70-
docker:
79+
build_docker:
80+
resource_class: small
81+
docker:
82+
- image: cimg/base:2023.04
83+
steps:
84+
- checkout
85+
- setup_remote_docker:
86+
version: 20.10.18
87+
- run: |
88+
for cmd in << pipeline.parameters.cmds >>; do
89+
docker build -f ./cmd/${cmd}/Dockerfile -t robocupssl/${cmd}:latest .
90+
done
91+
92+
publish_docker:
93+
resource_class: small
7194
docker:
72-
- image: cimg/base:2023.02
95+
- image: cimg/base:2023.04
7396
steps:
7497
- checkout
7598
- setup_remote_docker:
7699
version: 20.10.18
77100
- run: |
101+
# Parse version from tag (removing 'v' prefix)
78102
TAG=${CIRCLE_TAG:1}
79103
TAG=${TAG:-latest}
80-
docker build -t robocupssl/ssl-vision-client:$TAG .
81-
docker login -u "${DOCKER_HUB_USERNAME}" -p "${DOCKER_HUB_PASSWORD}"
82-
docker push robocupssl/ssl-vision-client:$TAG
83-
docker build -t robocupssl/ssl-vision-cli:$TAG .
84-
docker login -u "${DOCKER_HUB_USERNAME}" -p "${DOCKER_HUB_PASSWORD}"
85-
docker push robocupssl/ssl-vision-cli:$TAG
104+
for cmd in << pipeline.parameters.cmds >>; do
105+
docker build -f ./cmd/${cmd}/Dockerfile -t robocupssl/${cmd}:${TAG} .
106+
docker login -u "${DOCKER_HUB_USERNAME}" -p "${DOCKER_HUB_PASSWORD}"
107+
docker push robocupssl/${cmd}:${TAG}
108+
done
86109
87110
workflows:
88111
version: 2
89-
main:
112+
build:
90113
jobs:
91-
- frontend:
92-
filters:
93-
tags:
94-
only: /.*/
95-
- backend:
96-
requires:
97-
- frontend
98-
filters:
99-
tags:
100-
only: /.*/
101-
- publish-github-release:
114+
- build_node
115+
- test_go:
116+
requires: [ build_node ]
117+
release:
118+
jobs:
119+
- build_node:
120+
filters: { branches: { ignore: /.*/ }, tags: { only: /^v.*/ } }
121+
- build_go:
122+
requires: [ build_node ]
123+
filters: { branches: { ignore: /.*/ }, tags: { only: /^v.*/ } }
124+
- publish_gh:
102125
context: github
103-
requires:
104-
- backend
105-
filters:
106-
branches:
107-
ignore: /.*/
108-
tags:
109-
only: /^v.*/
110-
- docker:
126+
requires: [ build_go ]
127+
filters: { branches: { ignore: /.*/ }, tags: { only: /^v.*/ } }
128+
docker:
129+
jobs:
130+
- build_docker
131+
- publish_docker:
111132
context: docker hub
112-
filters:
113-
branches:
114-
only: master
115-
tags:
116-
only: /^v.*/
133+
filters: { branches: { only: master }, tags: { only: /^v.*/ } }

.dockerignore

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
/node_modules
2-
/dist
3-
/.git
4-
/Dockerfile
5-
/.idea
6-
/.vscode
1+
*
2+
!cmd
3+
!frontend
4+
!internal
5+
!pkg
6+
!go.mod
7+
!go.sum
8+
9+
frontend/node_modules
10+
frontend/dist

.editorconfig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ root = true
77
end_of_line = lf
88
insert_final_newline = true
99
indent_style = space
10+
indent_size = 2
11+
12+
[*.proto]
1013
indent_size = 4
1114

12-
[*.go]
15+
[Makefile]
1316
indent_style = tab
14-
15-
[*.{vue,yml,json}]
16-
indent_size = 2

.github/release.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
changelog:
2+
categories:
3+
- title: 🏕 Features
4+
labels:
5+
- '*'
6+
exclude:
7+
labels:
8+
- dependencies
9+
- title: 👒 Dependencies
10+
labels:
11+
- dependencies

.gitignore

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
.DS_Store
22
node_modules
3-
/dist
3+
/config/
4+
5+
# Editor directories and files
6+
.idea/*
7+
.vscode
8+
*.suo
9+
*.ntvs*
10+
*.njsproj
11+
*.sln
12+
*.sw*
13+
!.idea/runConfigurations
414

515
# local env files
616
.env.local
@@ -11,11 +21,11 @@ npm-debug.log*
1121
yarn-debug.log*
1222
yarn-error.log*
1323

14-
# Editor directories and files
15-
.idea
16-
.vscode
17-
*.suo
18-
*.ntvs*
19-
*.njsproj
20-
*.sln
21-
*.sw*
24+
# app-specific ignores
25+
/*.json.stream
26+
27+
# Local installations
28+
/.local
29+
30+
# Make cache
31+
/.frontend

Dockerfile

Lines changed: 0 additions & 23 deletions
This file was deleted.

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
CMDS = ssl-vision-client ssl-vision-cli
2+
DOCKER_TARGETS = $(addprefix docker-, $(CMDS))
3+
.PHONY: all docker frontend install test run proto $(DOCKER_TARGETS)
4+
5+
all: install docker
6+
7+
docker: $(DOCKER_TARGETS)
8+
9+
$(DOCKER_TARGETS): docker-%:
10+
docker build -f ./cmd/$*/Dockerfile -t $*:latest .
11+
12+
.frontend: $(shell find frontend/ -type f -not -path "frontend/node_modules/*")
13+
cd frontend && \
14+
npm install && \
15+
npm run build && \
16+
touch ../.frontend
17+
18+
frontend: .frontend
19+
20+
install: frontend
21+
go install -v ./...
22+
23+
test: frontend
24+
go test ./...
25+
26+
run: frontend
27+
go run ./cmd/$(word 1,$(CMDS))
28+
29+
proto:
30+
tools/generateProto.sh

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,27 @@ By default, the UI is available at http://localhost:8082
2222

2323
## Development
2424

25+
### Requirements
26+
2527
You need to install following dependencies first:
2628

2729
* Go
2830
* Node
2931

30-
See [.circleci/config.yml](.circleci/config.yml) for required versions.
32+
See [.circleci/config.yml](.circleci/config.yml) for compatible versions.
3133

3234
### Frontend
3335

3436
See [frontend/README.md](frontend/README.md)
3537

38+
### Build
39+
40+
Build and install all binaries:
41+
42+
```bash
43+
make install
44+
```
45+
3646
### Run
3747

3848
Run the backend:
@@ -41,8 +51,10 @@ Run the backend:
4151
go run cmd/ssl-vision-client/main.go
4252
```
4353

44-
### Build self-contained release binary
54+
### Update generated protobuf code
4555

46-
```bash
47-
./install.sh
56+
Generate the code for the `.proto` files after you've changed anything in a `.proto` file with:
57+
58+
```shell
59+
make proto
4860
```

cli.Dockerfile

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)