Skip to content

Commit d4d8649

Browse files
committed
Update project structure
1 parent 3b58ddc commit d4d8649

File tree

11 files changed

+261
-83
lines changed

11 files changed

+261
-83
lines changed

.circleci/config.yml

Lines changed: 99 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,110 @@
1-
version: 2
1+
version: 2.1
2+
parameters:
3+
cmds:
4+
type: string
5+
default: "ssl-quality-inspector"
6+
27
jobs:
3-
backend:
8+
test_go:
9+
resource_class: medium
10+
docker:
11+
- image: cimg/go:1.20.2
12+
steps:
13+
- checkout
14+
- attach_workspace:
15+
at: .
16+
- run: go get -v -t -d ./...
17+
- run: go test -v -covermode=count -coverprofile=count.out ./...
18+
- run: go tool cover -html=count.out -o coverage.html
19+
- store_artifacts:
20+
path: coverage.html
21+
destination: coverage
22+
23+
build_go:
24+
resource_class: large
425
docker:
5-
- image: circleci/golang:1.17
26+
- image: cimg/go:1.20.2
27+
steps:
28+
- checkout
29+
- attach_workspace:
30+
at: .
31+
- run: go get -v -t -d ./...
32+
- run: |
33+
set -u
34+
version=${CIRCLE_TAG:-}
35+
for cmd in << pipeline.parameters.cmds >>; do
36+
GOOS=linux GOARCH=amd64 go build -o ./release/${cmd}_${version}_linux_amd64 ./cmd/${cmd}
37+
GOOS=linux GOARCH=arm64 go build -o ./release/${cmd}_${version}_linux_arm64 ./cmd/${cmd}
38+
GOOS=linux GOARCH=arm go build -o ./release/${cmd}_${version}_linux_arm ./cmd/${cmd}
39+
GOOS=darwin GOARCH=amd64 go build -o ./release/${cmd}_${version}_darwin_amd64 ./cmd/${cmd}
40+
GOOS=darwin GOARCH=arm64 go build -o ./release/${cmd}_${version}_darwin_arm64 ./cmd/${cmd}
41+
GOOS=windows GOARCH=amd64 go build -o ./release/${cmd}_${version}_windows_amd64.exe ./cmd/${cmd}
42+
done
43+
- persist_to_workspace:
44+
root: .
45+
paths:
46+
- release/*
647

7-
working_directory: /go/src/github.com/RoboCup-SSL/ssl-quality-inspector
48+
publish_gh:
49+
resource_class: small
50+
docker:
51+
- image: cimg/go:1.20.2
852
steps:
9-
- checkout
10-
- run: go get -v -t -d ./...
11-
- run: go test -v ./...
12-
- run:
13-
working_directory: cmd/ssl-quality-inspector
14-
command: |
15-
GOOS=linux GOARCH=amd64 go build -o ../../release/ssl-quality-inspector_linux_amd64
16-
GOOS=darwin GOARCH=amd64 go build -o ../../release/ssl-quality-inspector_darwin_amd64
17-
GOOS=windows GOARCH=amd64 go build -o ../../release/ssl-quality-inspector_windows_amd64.exe
18-
- persist_to_workspace:
19-
root: .
20-
paths:
21-
- release/*
53+
- attach_workspace:
54+
at: .
55+
- run: |
56+
set -u
57+
go install github.com/tcnksm/[email protected]
58+
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete -generatenotes ${CIRCLE_TAG} ./release
2259
23-
publish-github-release:
60+
build_docker:
61+
resource_class: small
2462
docker:
25-
- image: circleci/golang:1.17
63+
- image: cimg/base:2023.04
2664
steps:
27-
- attach_workspace:
28-
at: .
29-
- run:
30-
name: "Prepare artifacts"
31-
working_directory: release
32-
command: |
33-
mv ssl-quality-inspector_linux_amd64 ssl-quality-inspector_${CIRCLE_TAG}_linux_amd64
34-
mv ssl-quality-inspector_darwin_amd64 ssl-quality-inspector_${CIRCLE_TAG}_darwin_amd64
35-
mv ssl-quality-inspector_windows_amd64.exe ssl-quality-inspector_${CIRCLE_TAG}_windows_amd64.exe
36-
- run:
37-
name: "Publish Release on GitHub"
38-
command: |
39-
go get github.com/tcnksm/ghr
40-
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${CIRCLE_TAG} ./release/
65+
- checkout
66+
- setup_remote_docker:
67+
version: 20.10.18
68+
- run: |
69+
for cmd in << pipeline.parameters.cmds >>; do
70+
docker build --build-arg cmd=${cmd} -t robocupssl/${cmd}:latest .
71+
done
72+
73+
publish_docker:
74+
resource_class: small
75+
docker:
76+
- image: cimg/base:2023.04
77+
steps:
78+
- checkout
79+
- setup_remote_docker:
80+
version: 20.10.18
81+
- run: |
82+
# Parse version from tag (removing 'v' prefix)
83+
TAG=${CIRCLE_TAG:1}
84+
TAG=${TAG:-latest}
85+
for cmd in << pipeline.parameters.cmds >>; do
86+
docker build --build-arg cmd=${cmd} -t robocupssl/${cmd}:${TAG} .
87+
docker login -u "${DOCKER_HUB_USERNAME}" -p "${DOCKER_HUB_PASSWORD}"
88+
docker push robocupssl/${cmd}:${TAG}
89+
done
4190
4291
workflows:
4392
version: 2
44-
main:
93+
build:
94+
jobs:
95+
- test_go
96+
release:
97+
jobs:
98+
- build_go:
99+
filters: { branches: { ignore: /.*/ }, tags: { only: /^v.*/ } }
100+
- publish_gh:
101+
context: github
102+
requires: [ build_go ]
103+
filters: { branches: { ignore: /.*/ }, tags: { only: /^v.*/ } }
104+
docker:
45105
jobs:
46-
- backend:
47-
filters:
48-
tags:
49-
only: /.*/
50-
- publish-github-release:
51-
requires:
52-
- backend
53-
filters:
54-
branches:
55-
ignore: /.*/
56-
tags:
57-
only: /^v.*/
106+
- build_docker:
107+
filters: { branches: { ignore: master } }
108+
- publish_docker:
109+
context: docker hub
110+
filters: { branches: { only: master }, tags: { only: /^v.*/ } }

.dockerignore

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

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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
9+
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: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,32 @@
1+
.DS_Store
2+
3+
# Editor directories and files
14
.idea
2-
*.iml
5+
.vscode
6+
*.suo
7+
*.ntvs*
8+
*.njsproj
9+
*.sln
10+
*.sw*
11+
12+
# local env files
13+
.env.local
14+
.env.*.local
15+
16+
# Log files
17+
npm-debug.log*
18+
yarn-debug.log*
19+
yarn-error.log*
20+
21+
# app-specific ignores
22+
/*.json.stream
23+
24+
# Local installations
25+
/.local
26+
27+
# Local log files
28+
*.log
29+
*.log.gz
30+
31+
# distribution folder
32+
dist/

Dockerfile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
FROM golang:1.18-alpine AS build
2-
WORKDIR /go/src/github.com/RoboCup-SSL/ssl-quality-inspector
3-
COPY go.mod go.mod
4-
COPY cmd cmd
5-
COPY pkg pkg
6-
RUN go install ./...
1+
FROM golang:1.20-alpine AS build_go
2+
ARG cmd
3+
WORKDIR work
4+
COPY . .
5+
RUN go install ./cmd/${cmd}
76

87
# Start fresh from a smaller image
9-
FROM alpine:3.15
10-
COPY --from=build /go/bin/ssl-quality-inspector /app/ssl-quality-inspector
11-
ENTRYPOINT ["/app/ssl-quality-inspector"]
8+
FROM alpine:3
9+
ARG cmd
10+
COPY --from=build_go /go/bin/${cmd} /app/${cmd}
11+
WORKDIR /data
12+
RUN chown 1000: /data
13+
USER 1000
14+
ENV COMMAND="/app/${cmd}"
15+
ENTRYPOINT "${COMMAND}"
1216
CMD []

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CMDS = ssl-quality-inspector
2+
DOCKER_TARGETS = $(addprefix docker-, $(CMDS))
3+
.PHONY: all docker 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+
test:
13+
go test ./...
14+
15+
install:
16+
go install -v ./...
17+
18+
proto:
19+
tools/generateProto.sh

generateProto.sh

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

renovate.json

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

0 commit comments

Comments
 (0)