Skip to content

Commit f730ebc

Browse files
committed
init
1 parent 18350f6 commit f730ebc

Some content is hidden

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

51 files changed

+3054
-5
lines changed

.github/workflows/release.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v[0-9]+.[0-9]+.[0-9]+
7+
8+
jobs:
9+
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v4
17+
with:
18+
go-version: 1.23
19+
20+
- name: Install Protoc
21+
uses: arduino/setup-protoc@v1
22+
with:
23+
version: '3.x'
24+
25+
- name: Test
26+
run: make test
27+
28+
- name: Registry login
29+
uses: docker/login-action@v2
30+
with:
31+
registry: ghcr.io
32+
username: ${{ secrets.REGISTRY_USER }}
33+
password: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
34+
35+
- name: Release
36+
run: make release

.github/workflows/staging.yaml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Staging
2+
3+
on:
4+
push:
5+
branches:
6+
- "mistress"
7+
8+
env:
9+
COMPONENT: source-websocket
10+
VERSION: latest
11+
CHART_VERSION: 0.0.0
12+
13+
jobs:
14+
15+
deploy:
16+
runs-on: ubuntu-latest
17+
steps:
18+
19+
- uses: actions/checkout@v2
20+
21+
- name: Registry login
22+
uses: docker/login-action@v2
23+
with:
24+
registry: ghcr.io
25+
username: ${{ secrets.REGISTRY_USER }}
26+
password: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
27+
28+
- name: Staging
29+
run: make staging
30+
31+
- name: Set up Helm
32+
uses: azure/setup-helm@v1
33+
with:
34+
version: v3.12.0
35+
36+
- name: Helm Lint
37+
run: |
38+
helm lint helm/${COMPONENT}
39+
40+
- name: Helm Package
41+
run: |
42+
helm dependency update helm/${COMPONENT}
43+
mkdir helm/package
44+
helm package helm/${COMPONENT} --destination helm/package
45+
cd helm/package
46+
helm repo index .
47+
48+
- name: Publish Helm Chart
49+
uses: peaceiris/actions-gh-pages@v3
50+
with:
51+
github_token: ${{ secrets.GITHUB_TOKEN }}
52+
publish_dir: helm/package/
53+
54+
- name: Google Cloud Auth
55+
uses: 'google-github-actions/auth@v1'
56+
with:
57+
credentials_json: '${{ secrets.GKE_SA_KEY }}'
58+
59+
- uses: google-github-actions/setup-gcloud@v1
60+
with:
61+
project_id: ${{ secrets.GKE_RPOJECT_ID }}
62+
63+
- name: Kubeconfig
64+
run: |
65+
gcloud components install gke-gcloud-auth-plugin
66+
gcloud container clusters get-credentials ${{ secrets.GKE_CLUSTER_NAME_DEMO }} \
67+
--region ${{ secrets.GKE_CLUSTER_REGION }} \
68+
--project ${{ secrets.GKE_PROJECT_ID }}
69+
70+
- name: Helm Upgrade
71+
run: |
72+
helm upgrade --install ${COMPONENT} helm/package/${COMPONENT}-0.0.0.tgz \
73+
--set replicaCount=2 \
74+
--set-string podAnnotations.commit=$(git rev-parse --short HEAD)

.github/workflows/testing.yaml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Testing
2+
3+
on:
4+
push:
5+
branches:
6+
- "*"
7+
- "!mistress"
8+
9+
jobs:
10+
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
15+
- uses: actions/checkout@v3
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v4
19+
with:
20+
go-version: 1.23
21+
22+
- name: Install Protoc
23+
uses: arduino/setup-protoc@v1
24+
with:
25+
# repo-token is necessary to avoid the rate limit issue
26+
repo-token: ${{ secrets.GITHUB_TOKEN }}
27+
version: "3.x"
28+
29+
- name: Build
30+
run: make build
31+
32+
test:
33+
runs-on: ubuntu-latest
34+
steps:
35+
36+
- uses: actions/checkout@v3
37+
38+
- name: Set up Go
39+
uses: actions/setup-go@v4
40+
with:
41+
go-version: 1.23
42+
43+
- name: Install Protoc
44+
uses: arduino/setup-protoc@v1
45+
with:
46+
version: "3.x"
47+
48+
- name: Test
49+
run: make test
50+
env:
51+
DB_URI_TEST_MONGO: ${{ secrets.DB_URI_TEST_MONGO }}

.gitignore

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
*.out
1616

1717
# Dependency directories (remove the comment below to include it)
18-
# vendor/
18+
vendor/
1919

2020
# Go workspace file
2121
go.work
22-
go.work.sum
2322

24-
# env file
25-
.env
23+
**/*.pb.go
24+
cover.tmp

Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM golang:1.23.2-alpine3.20 AS builder
2+
WORKDIR /go/src/source-websocket
3+
COPY . .
4+
RUN \
5+
apk add protoc protobuf-dev make git && \
6+
make build
7+
8+
FROM alpine:3.20
9+
RUN apk --no-cache add ca-certificates \
10+
&& update-ca-certificates
11+
COPY --from=builder /go/src/source-websocket/source-websocket /bin/source-websocket
12+
ENTRYPOINT ["/bin/source-websocket"]

Makefile

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.PHONY: test clean
2+
default: build
3+
4+
BINARY_FILE_NAME=source-websocket
5+
COVERAGE_FILE_NAME=cover.out
6+
COVERAGE_TMP_FILE_NAME=cover.tmp
7+
8+
proto:
9+
go install github.com/golang/protobuf/protoc-gen-go@latest
10+
go install google.golang.org/grpc/cmd/[email protected]
11+
PATH=${PATH}:~/go/bin protoc --go_out=plugins=grpc:. --go_opt=paths=source_relative \
12+
api/grpc/*.proto
13+
14+
vet: proto
15+
go vet
16+
17+
test: vet
18+
go test -race -cover -coverprofile=${COVERAGE_FILE_NAME} ./...
19+
cat ${COVERAGE_FILE_NAME} | grep -v _mock.go | grep -v logging.go | grep -v .pb.go > ${COVERAGE_FILE_NAME}.tmp
20+
mv -f ${COVERAGE_FILE_NAME}.tmp ${COVERAGE_FILE_NAME}
21+
go tool cover -func=${COVERAGE_FILE_NAME} | grep -Po '^total\:\h+\(statements\)\h+\K.+(?=\.\d+%)' > ${COVERAGE_TMP_FILE_NAME}
22+
./scripts/cover.sh
23+
rm -f ${COVERAGE_TMP_FILE_NAME}
24+
25+
build: proto
26+
CGO_ENABLED=0 GOOS=linux GOARCH= GOARM= go build -o ${BINARY_FILE_NAME} main.go
27+
chmod ugo+x ${BINARY_FILE_NAME}
28+
29+
docker:
30+
docker build -t awakari/source-websocket .
31+
32+
33+
staging: docker
34+
./scripts/staging.sh
35+
36+
release: docker
37+
./scripts/release.sh
38+
39+
clean:
40+
go clean
41+
rm -f ${BINARY_FILE_NAME} ${COVERAGE_FILE_NAME}

README.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
11
# source-websocket
2-
WebSocket source implementation for Awakari
2+
Server-sent events source type
3+
4+
```shell
5+
grpcurl \
6+
-plaintext \
7+
-proto api/grpc/service.proto \
8+
-d @ \
9+
localhost:50051 \
10+
awakari.source.websocket.Service/Create
11+
```
12+
13+
```json
14+
{
15+
"url": "wss://www.seismicportal.eu/standing_order/websocket",
16+
"groupId": "default"
17+
}
18+
```

0 commit comments

Comments
 (0)