Skip to content

Commit 37f520b

Browse files
committed
Restructure build
1 parent 91e70c2 commit 37f520b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+24226
-8984
lines changed

.circleci/config.yml

Lines changed: 88 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,137 @@
1-
version: 2
1+
version: 2.1
2+
parameters:
3+
cmds:
4+
type: string
5+
default: "ssl-status-board"
6+
27
jobs:
3-
frontend:
8+
build_node:
9+
resource_class: medium
410
docker:
5-
- image: cimg/node:16.15
11+
- image: cimg/node:16.20
612
steps:
713
- checkout
814
- run:
915
name: "Install dependencies"
10-
command: yarn install
11-
- run:
12-
name: "Run lint"
13-
command: yarn lint
16+
working_directory: frontend
17+
command: npm install
1418
- run:
1519
name: "Build"
16-
command: yarn build
20+
working_directory: frontend
21+
command: npm run build
1722
- persist_to_workspace:
1823
root: .
1924
paths:
20-
- pkg/board/ui/dist/*
25+
- frontend/dist/*
2126

22-
backend:
27+
test_go:
28+
resource_class: medium
2329
docker:
24-
- image: cimg/go:1.18
30+
- image: cimg/go:1.20.2
2531
steps:
2632
- checkout
2733
- attach_workspace:
2834
at: .
2935
- run: go get -v -t -d ./...
3036
- run: go test -v -covermode=count -coverprofile=count.out ./...
3137
- run: go tool cover -html=count.out -o coverage.html
32-
- run:
33-
command: |
34-
GOOS=linux GOARCH=amd64 go build -o release/ssl-status-board_linux_amd64 ./cmd/ssl-status-board
35-
GOOS=linux GOARCH=arm go build -o release/ssl-status-board_linux_arm ./cmd/ssl-status-board
36-
GOOS=linux GOARCH=arm64 go build -o release/ssl-status-board_linux_arm64 ./cmd/ssl-status-board
37-
GOOS=darwin GOARCH=amd64 go build -o release/ssl-status-board_darwin_amd64 ./cmd/ssl-status-board
38-
GOOS=windows GOARCH=amd64 go build -o release/ssl-status-board_windows_amd64.exe ./cmd/ssl-status-board
39-
- run:
40-
command: |
41-
mkdir -p release
42-
cp -a rpi ssl-status-board
43-
tar czf release/bootstrap.tar.gz ssl-status-board
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
4462
- persist_to_workspace:
4563
root: .
4664
paths:
4765
- release/*
48-
- store_artifacts:
49-
path: coverage.html
50-
destination: coverage
5166

52-
publish-github-release:
67+
publish_gh:
68+
resource_class: small
5369
docker:
54-
- image: cimg/go:1.18
70+
- image: cimg/go:1.20.2
5571
steps:
5672
- attach_workspace:
5773
at: .
58-
- run:
59-
name: "Prepare artifacts"
60-
working_directory: release
61-
command: |
62-
mv ssl-status-board_linux_amd64 ssl-status-board_${CIRCLE_TAG}_linux_amd64
63-
mv ssl-status-board_linux_arm ssl-status-board_${CIRCLE_TAG}_linux_arm
64-
mv ssl-status-board_linux_arm64 ssl-status-board_${CIRCLE_TAG}_linux_arm64
65-
mv ssl-status-board_darwin_amd64 ssl-status-board_${CIRCLE_TAG}_darwin_amd64
66-
mv ssl-status-board_windows_amd64.exe ssl-status-board_${CIRCLE_TAG}_windows_amd64.exe
67-
- run:
68-
name: "Publish Release on GitHub"
69-
command: |
70-
go install github.com/tcnksm/[email protected]
71-
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${CIRCLE_TAG} ./release/
74+
- run: |
75+
mkdir -p release
76+
cp -a rpi ssl-status-board
77+
tar czf release/bootstrap.tar.gz ssl-status-board
78+
- run: |
79+
set -u
80+
go install github.com/tcnksm/[email protected]
81+
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete -generatenotes ${CIRCLE_TAG} ./release
7282
73-
docker-build:
83+
build_docker:
84+
resource_class: small
7485
docker:
75-
- image: cimg/base:2022.06
86+
- image: cimg/base:2023.04
7687
steps:
7788
- checkout
7889
- setup_remote_docker:
79-
version: 20.10.11
90+
version: 20.10.18
8091
- run: |
81-
docker build .
92+
for cmd in << pipeline.parameters.cmds >>; do
93+
docker build --build-arg cmd=${cmd} -t robocupssl/${cmd}:latest .
94+
done
8295
83-
docker-build-and-push:
96+
publish_docker:
97+
resource_class: small
8498
docker:
85-
- image: cimg/base:2022.06
99+
- image: cimg/base:2023.04
86100
steps:
87101
- checkout
88102
- setup_remote_docker:
89-
version: 20.10.11
103+
version: 20.10.18
90104
- run: |
105+
# Parse version from tag (removing 'v' prefix)
91106
TAG=${CIRCLE_TAG:1}
92107
TAG=${TAG:-latest}
93-
docker build -t robocupssl/ssl-status-board:$TAG .
94-
docker login -u "${DOCKER_HUB_USERNAME}" -p "${DOCKER_HUB_PASSWORD}"
95-
docker push robocupssl/ssl-status-board:$TAG
108+
for cmd in << pipeline.parameters.cmds >>; do
109+
docker build --build-arg cmd=${cmd} -t robocupssl/${cmd}:${TAG} .
110+
docker login -u "${DOCKER_HUB_USERNAME}" -p "${DOCKER_HUB_PASSWORD}"
111+
docker push robocupssl/${cmd}:${TAG}
112+
done
96113
97114
workflows:
98115
version: 2
99-
main:
116+
build:
100117
jobs:
101-
- frontend:
102-
filters:
103-
tags:
104-
only: /.*/
105-
- backend:
106-
requires:
107-
- frontend
108-
filters:
109-
tags:
110-
only: /.*/
111-
- publish-github-release:
118+
- build_node
119+
- test_go:
120+
requires: [ build_node ]
121+
release:
122+
jobs:
123+
- build_node:
124+
filters: { branches: { ignore: /.*/ }, tags: { only: /^v.*/ } }
125+
- build_go:
126+
requires: [ build_node ]
127+
filters: { branches: { ignore: /.*/ }, tags: { only: /^v.*/ } }
128+
- publish_gh:
112129
context: github
113-
requires:
114-
- backend
115-
filters:
116-
branches:
117-
ignore: /.*/
118-
tags:
119-
only: /^v.*/
120-
- docker-build:
121-
context: docker hub
122-
filters:
123-
branches:
124-
ignore: master
125-
- docker-build-and-push:
130+
requires: [ build_go ]
131+
filters: { branches: { ignore: /.*/ }, tags: { only: /^v.*/ } }
132+
docker:
133+
jobs:
134+
- build_docker
135+
- publish_docker:
126136
context: docker hub
127-
filters:
128-
branches:
129-
only: master
130-
tags:
131-
only: /^v.*/
137+
filters: { branches: { only: master }, tags: { only: /^v.*/ } }

.dockerignore

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
/node_modules
2-
/dist
3-
/.git
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: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1-
[*.vue]
2-
indent_size = 4
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
[*]
7+
end_of_line = lf
8+
insert_final_newline = true
39
indent_style = space
10+
indent_size = 2
11+
12+
[*.proto]
13+
indent_size = 4
14+
15+
[Makefile]
16+
indent_style = tab

.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

.github/renovate.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": [
3+
"config:base",
4+
"schedule:monthly"
5+
],
6+
"labels": [
7+
"dependencies"
8+
]
9+
}

.gitignore

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
.DS_Store
22
node_modules
3-
/dist
4-
/pkg/board/ui/dist
3+
4+
# Editor directories and files
5+
.idea
6+
.vscode
7+
*.suo
8+
*.ntvs*
9+
*.njsproj
10+
*.sln
11+
*.sw*
512

613
# local env files
714
.env.local
@@ -12,11 +19,8 @@ npm-debug.log*
1219
yarn-debug.log*
1320
yarn-error.log*
1421

15-
# Editor directories and files
16-
.idea
17-
.vscode
18-
*.suo
19-
*.ntvs*
20-
*.njsproj
21-
*.sln
22-
*.sw?
22+
# Local installations
23+
/.local
24+
25+
# Make cache
26+
/.frontend

Dockerfile

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
FROM node:16.15-alpine3.15 AS build_node
2-
WORKDIR /tmp/ssl-status-board
3-
COPY . .
4-
RUN yarn install
5-
RUN yarn build
1+
FROM node:16-alpine AS build_node
2+
COPY frontend frontend
3+
WORKDIR frontend
4+
RUN npm install
5+
RUN npm run build
66

7-
FROM golang:1.18-alpine AS build_go
8-
WORKDIR /go/src/github.com/RoboCup-SSL/ssl-status-board
7+
FROM golang:1.20-alpine AS build_go
8+
ARG cmd=ssl-status-board
9+
WORKDIR work
910
COPY . .
10-
COPY --from=build_node /tmp/ssl-status-board/pkg/board/ui/dist pkg/board/ui/dist
11-
RUN go build -o release/ssl-status-board_linux_amd64 ./cmd/ssl-status-board
11+
COPY --from=build_node frontend/dist frontend/dist
12+
RUN go install ./cmd/${cmd}
1213

1314
# Start fresh from a smaller image
14-
FROM alpine:3.16
15-
COPY --from=build_go /go/src/github.com/RoboCup-SSL/ssl-status-board/release/ssl-status-board_linux_amd64 /app/ssl-status-board
16-
EXPOSE 8082
15+
FROM alpine:3
16+
ARG cmd
17+
COPY --from=build_go /go/bin/${cmd} /app/${cmd}
18+
WORKDIR /data
19+
RUN chown 1000: /data
1720
USER 1000
18-
ENTRYPOINT ["/app/ssl-status-board"]
21+
ENV COMMAND="/app/${cmd}"
22+
ENTRYPOINT "${COMMAND}"
1923
CMD []

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
CMDS = ssl-status-board
2+
DOCKER_TARGETS = $(addprefix docker-, $(CMDS))
3+
.PHONY: all docker frontend test install proto $(DOCKER_TARGETS)
4+
5+
all: install docker
6+
7+
docker: $(DOCKER_TARGETS)
8+
9+
$(DOCKER_TARGETS): docker-%:
10+
docker build --build-arg cmd=$* -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

0 commit comments

Comments
 (0)