Skip to content

Commit

Permalink
grpc service (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 committed Jul 26, 2022
1 parent 9d82af9 commit 56e109e
Show file tree
Hide file tree
Showing 31 changed files with 3,347 additions and 127 deletions.
30 changes: 30 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'

template: |
## General Changes
$CHANGES
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'

version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
64 changes: 64 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Docker Build Action
on:
pull_request:
branches:
- master
release:
types:
- published
push:
branches:
- master

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.18
uses: actions/setup-go@v2
with:
go-version: 1.18
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Lint
uses: golangci/golangci-lint-action@v2
with:
args: -p bugs -p unused --timeout=3m

- name: build and test
run: |
make test
make bench
- name: Publish Codecoverage report
run: bash <(curl -s https://codecov.io/bash)

- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Make tag
run: |
[ "${GITHUB_EVENT_NAME}" == 'pull_request' ] && echo "tag=${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV || true
[ "${GITHUB_EVENT_NAME}" == 'release' ] && echo "tag=${GITHUB_REF##*/}" >> $GITHUB_ENV || true
[ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "tag=latest" >> $GITHUB_ENV || true
- name: Build and push image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.tag }}
33 changes: 0 additions & 33 deletions .github/workflows/main.yml

This file was deleted.

33 changes: 0 additions & 33 deletions .github/workflows/pr.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/release-drafter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Release Drafter Action

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode
.idea
coverage.out
bin
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM bufbuild/buf:1.6.0 as buf
FROM golang:1.18-alpine as builder

RUN apk add \
binutils \
gcc \
git \
libc-dev \
make

WORKDIR /work
COPY --from=buf /usr/local/bin/buf /usr/local/bin/buf
COPY . .
RUN make server client

FROM alpine:3.16
COPY --from=builder /work/bin/* /
ENTRYPOINT [ "/server" ]
45 changes: 42 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
.ONESHELL:
SHA := $(shell git rev-parse --short=8 HEAD)
GITVERSION := $(shell git describe --long --all)
BUILDDATE := $(shell date -Iseconds)
VERSION := $(or ${VERSION},devel)

CGO_ENABLED := $(or ${CGO_ENABLED},0)
GO := go
GO111MODULE := on
PG_VERSION := $(or ${PG_VERSION},14-alpine)
COCKROACH_VERSION := $(or ${COCKROACH_VERSION},v22.1.0)
COCKROACH_VERSION := $(or ${COCKROACH_VERSION},latest-v22.1)
LINKMODE := -extldflags '-static -s -w'


.EXPORT_ALL_VARIABLES:

all: test bench
all: proto server client test bench

.PHONY: bench
bench:
CGO_ENABLED=1 $(GO) test -bench . -run=- -count 5 -benchmem -timeout 20m
CGO_ENABLED=1 $(GO) test -bench ./... -run=- -benchmem -timeout 20m

.PHONY: benchstat
benchstat:
Expand All @@ -33,6 +40,30 @@ golangcicheck:
lint: golangcicheck
golangci-lint run -p bugs -p unused

.PHONY: proto
proto:
$(MAKE) -C proto protoc

.PHONY: server
server:
go build -tags netgo,osusergo,urfave_cli_no_docs \
-ldflags "$(LINKMODE) -X 'github.com/metal-stack/v.Version=$(VERSION)' \
-X 'github.com/metal-stack/v.Revision=$(GITVERSION)' \
-X 'github.com/metal-stack/v.GitSHA1=$(SHA)' \
-X 'github.com/metal-stack/v.BuildDate=$(BUILDDATE)'" \
-o bin/server github.com/metal-stack/go-ipam/cmd/server
strip bin/server

.PHONY: client
client:
go build -tags netgo,osusergo,urfave_cli_no_docs \
-ldflags "$(LINKMODE) -X 'github.com/metal-stack/v.Version=$(VERSION)' \
-X 'github.com/metal-stack/v.Revision=$(GITVERSION)' \
-X 'github.com/metal-stack/v.GitSHA1=$(SHA)' \
-X 'github.com/metal-stack/v.BuildDate=$(BUILDDATE)'" \
-o bin/cli github.com/metal-stack/go-ipam/cmd/client
strip bin/cli

.PHONY: postgres-up
postgres-up: postgres-rm
docker run -d --name ipamdb -p 5433:5432 -e POSTGRES_PASSWORD="password" postgres:$(PG_VERSION) -c 'max_connections=200'
Expand Down Expand Up @@ -60,3 +91,11 @@ cockroach-up-cluster: cockroach-rm
cockroach-rm:
docker rm -f roach1 roach2 roach3 || true
docker network rm roachnet || true

.PHONY: redis-up
redis-up: redis-rm
docker run -d --name ipamredis -p 6379:6379 redis

.PHONY: redis-rm
redis-rm:
docker rm -f ipamredis || true
Loading

0 comments on commit 56e109e

Please sign in to comment.