3
0

Fix, update & refresh build, test & CI tools

This commit is contained in:
Denis Arh
2019-05-24 12:47:37 +02:00
parent b732894109
commit 53308a2d33
14 changed files with 159 additions and 185 deletions
+25 -26
View File
@@ -1,13 +1,13 @@
workspace:
base: /go/src
path: github.com/crusttech/crust
path: github.com/cortezaproject/corteza-server
kind: pipeline
name: docker image build
steps:
- name: unit-tests
image: crusttech/crust-builder:latest
image: cortezaproject/corteza-server-builder:latest
pull: always
environment:
CGO_ENABLED: 0
@@ -17,51 +17,51 @@ steps:
commands:
- make test
- name: api-system
- name: corteza-server-system
image: plugins/docker
depends_on: [ 'unit-tests' ]
settings:
repo: crusttech/api-system
repo: cortezaproject/corteza-server-system
auto_tag: true # generate tag names automatically based on git branch and git tag
dockerfile: Dockerfile.api-system
dockerfile: Dockerfile.corteza-server-system
username:
from_secret: docker_hub_username
password:
from_secret: docker_hub_password
- name: api-compose
- name: corteza-server-compose
image: plugins/docker
depends_on: [ 'unit-tests' ]
settings:
repo: crusttech/api-compose
repo: cortezaproject/corteza-server-compose
auto_tag: true # generate tag names automatically based on git branch and git tag
dockerfile: Dockerfile.api-compose
dockerfile: Dockerfile.corteza-server-compose
username:
from_secret: docker_hub_username
password:
from_secret: docker_hub_password
- name: api-messaging
- name: corteza-server-messaging
depends_on: [ 'unit-tests' ]
image: plugins/docker
settings:
repo: crusttech/api-messaging
repo: cortezaproject/corteza-server-messaging
auto_tag: true # generate tag names automatically based on git branch and git tag
dockerfile: Dockerfile.api-messaging
dockerfile: Dockerfile.corteza-server-messaging
username:
from_secret: docker_hub_username
password:
from_secret: docker_hub_password
- name: crust
- name: corteza-server
image: plugins/docker
depends_on: [ 'unit-tests' ]
settings:
repo: crusttech/crust
repo: cortezaproject/corteza
auto_tag: true # generate tag names automatically based on git branch and git tag
dockerfile: Dockerfile.crust
dockerfile: Dockerfile.corteza-server
username:
from_secret: docker_hub_username
password:
@@ -78,14 +78,14 @@ trigger:
---
workspace:
base: /go/src
path: github.com/crusttech/crust
path: github.com/cortezaproject/corteza-server
kind: pipeline
name: integration
steps:
- name: test
image: crusttech/crust-builder:latest
image: cortezaproject/corteza-server-builder:latest
pull: always
environment:
CGO_ENABLED: 0
@@ -93,14 +93,13 @@ steps:
GOARCH: amd64
CI: circleci
AUTH_OIDC_ENABLED: 0
AUTH_JWT_SECRET: bRxJ37sJ6Qu4
DB_DSN: crust:crust@tcp(crust-db:3306)/crust?collation=utf8mb4_general_ci
SYSTEM_DB_DSN: crust:crust@tcp(crust-db:3306)/crust?collation=utf8mb4_general_ci
COMPOSE_DB_DSN: crust:crust@tcp(crust-db:3306)/crust?collation=utf8mb4_general_ci
MESSAGING_DB_DSN: crust:crust@tcp(crust-db:3306)/crust?collation=utf8mb4_general_ci
AUTH_JWT_SECRET: FBjddkvwQib0d4usifnEGVr1bncuVeD7
SYSTEM_DB_DSN: corteza:corteza-pwd@tcp(corteza-db:3306)/corteza?collation=utf8mb4_general_ci
COMPOSE_DB_DSN: corteza:corteza-pwd@tcp(corteza-db:3306)/corteza?collation=utf8mb4_general_ci
MESSAGING_DB_DSN: corteza:corteza-pwd@tcp(corteza-db:3306)/corteza?collation=utf8mb4_general_ci
commands:
- go build ./cmd/...
- wait-for-it.sh -t 60 --strict crust-db:3306 -- echo "Crust DB1 is up"
- wait-for-it.sh -t 60 --strict corteza-db:3306 -- echo "corteza-db is up"
- gotest -v --tags="migrations" ./system/db/...
- gotest -v --tags="migrations" ./compose/db/...
- gotest -v --tags="migrations" ./messaging/db/...
@@ -115,15 +114,15 @@ steps:
- coverage.txt
services:
- name: crust-db
- name: corteza-db
pull: always
image: percona:8.0
ports:
- 3306
environment:
MYSQL_ROOT_PASSWORD: bRxJ37sJ6Qu4
MYSQL_DATABASE: crust
MYSQL_USER: crust
MYSQL_PASSWORD: crust
MYSQL_DATABASE: corteza
MYSQL_USER: corteza
MYSQL_PASSWORD: corteza-pwd
trigger:
+12 -9
View File
@@ -30,14 +30,15 @@ schema:
run:
status: true
args:
- api
- serve-api
watcher:
paths:
- .
- ../../system
- ../../messaging
- ../../pkg
- ../../internal
extensions:
- go
- go
ignored_paths:
- ../../vendor
- ../../.git
@@ -53,17 +54,18 @@ schema:
run:
status: true
args:
- api
- serve-api
watcher:
paths:
- .
- ../../messaging
- ../../pkg
- ../../internal
extensions:
- go
- go
ignored_paths:
- ../../vendor
- ../../.git
- ../../vendor
- ../../.git
# ######################################################################################################################
- name: cmp
@@ -76,14 +78,15 @@ schema:
run:
status: true
args:
- api
- serve-api
watcher:
paths:
- .
- ../../compose
- ../../pkg
- ../../internal
extensions:
- go
- go
ignored_paths:
- ../../vendor
- ../../.git
+2 -2
View File
@@ -1,6 +1,6 @@
# How to Contribute
Crust projects are [Apache 2.0 licensed](LICENSE) and accept contributions via
Corteza projects are [Apache 2.0 licensed](LICENSE) and accept contributions via
GitHub pull requests. This document outlines some of the conventions on
development workflow, commit message formatting, contact points and other
resources to make it easier to get your contribution accepted.
@@ -15,7 +15,7 @@ contribution. See the [DCO](DCO) file for details.
# Getting Started
- Fork the repository on GitHub
- Read the [Wiki](https://github.com/crusttech/crust/wiki) for build and test instructions
- Read the [Wiki](https://github.com/cortezaproject/corteza-server/wiki) for build and test instructions
- Play with the project, submit bugs, submit patches!
## Contribution Flow
-26
View File
@@ -1,26 +0,0 @@
## builder image
FROM crusttech/crust-builder AS builder
WORKDIR /go/src/github.com/crusttech/crust
COPY . .
RUN mkdir /build; \
go build \
-ldflags "-X github.com/crusttech/crust/internal/version.BuildTime="`date +%FT%T%z`" -X github.com/crusttech/crust/internal/version.Version="`git describe --always --tags` \
-o /build/compose cmd/compose/*.go
## == target image ==
FROM alpine:3.7
RUN apk add --no-cache ca-certificates
COPY --from=builder /build /crust
WORKDIR /crust
EXPOSE 80
ENTRYPOINT /crust/compose
-26
View File
@@ -1,26 +0,0 @@
## builder image
FROM crusttech/crust-builder AS builder
WORKDIR /go/src/github.com/crusttech/crust
COPY . .
RUN mkdir /build; \
go build \
-ldflags "-X github.com/crusttech/crust/internal/version.BuildTime="`date +%FT%T%z`" -X github.com/crusttech/crust/internal/version.Version="`git describe --always --tags` \
-o /build/messaging cmd/messaging/*.go
## == target image ==
FROM alpine:3.7
RUN apk add --no-cache ca-certificates
COPY --from=builder /build /crust
WORKDIR /crust
EXPOSE 80
ENTRYPOINT /crust/messaging
-29
View File
@@ -1,29 +0,0 @@
## builder image
FROM crusttech/crust-builder AS builder
WORKDIR /go/src/github.com/crusttech/crust
COPY . .
RUN mkdir /build; \
go build \
-ldflags "-X github.com/crusttech/crust/internal/version.BuildTime="`date +%FT%T%z`" -X github.com/crusttech/crust/internal/version.Version="`git describe --always --tags` \
-o /build/system cmd/system/*.go; \
go build \
-ldflags "-X github.com/crusttech/crust/internal/version.BuildTime="`date +%FT%T%z`" -X github.com/crusttech/crust/internal/version.Version="`git describe --always --tags` \
-o /build/cli cmd/system-cli/*.go
## == target image ==
FROM alpine:3.7
RUN apk add --no-cache ca-certificates
COPY --from=builder /build /crust
WORKDIR /crust
EXPOSE 80
ENTRYPOINT /crust/system
+20
View File
@@ -0,0 +1,20 @@
## builder image
FROM cortezaproject/corteza-server-builder:latest AS builder
WORKDIR /go/src/github.com/cortezaproject/corteza-server
COPY . .
RUN scripts/builder-make-bin.sh monolith /tmp/corteza-server
## == target image ==
FROM alpine:3.7
RUN apk add --no-cache ca-certificates
COPY --from=builder /tmp/corteza-server /bin
EXPOSE 80
ENTRYPOINT ["/bin/corteza-server"]
CMD ["serve-api"]
+20
View File
@@ -0,0 +1,20 @@
## builder image
FROM cortezaproject/corteza-server-builder:latest AS builder
WORKDIR /go/src/github.com/cortezaproject/corteza-server
COPY . .
RUN scripts/builder-make-bin.sh compose /tmp/corteza-server-compose
## == target image ==
FROM alpine:3.7
RUN apk add --no-cache ca-certificates
COPY --from=builder /tmp/corteza-server-compose /bin
EXPOSE 80
ENTRYPOINT ["/bin/corteza-server-compose"]
CMD ["serve-api"]
+20
View File
@@ -0,0 +1,20 @@
## builder image
FROM cortezaproject/corteza-server-builder:latest AS builder
WORKDIR /go/src/github.com/cortezaproject/corteza-server
COPY . .
RUN scripts/builder-make-bin.sh messaging /tmp/corteza-server-messaging
## == target image ==
FROM alpine:3.7
RUN apk add --no-cache ca-certificates
COPY --from=builder /tmp/corteza-server-messaging /bin
EXPOSE 80
ENTRYPOINT ["/bin/corteza-server-messaging"]
CMD ["serve-api"]
+20
View File
@@ -0,0 +1,20 @@
## builder image
FROM cortezaproject/corteza-server-builder:latest AS builder
WORKDIR /go/src/github.com/cortezaproject/corteza-server
COPY . .
RUN scripts/builder-make-bin.sh system /tmp/corteza-server-system
## == target image ==
FROM alpine:3.7
RUN apk add --no-cache ca-certificates
COPY --from=builder /tmp/corteza-server-system /bin
EXPOSE 80
ENTRYPOINT ["/bin/corteza-server-system"]
CMD ["serve-api"]
-40
View File
@@ -1,40 +0,0 @@
## == builder image ==
FROM crusttech/crust-builder AS builder
WORKDIR /go/src/github.com/crusttech/crust
COPY . .
RUN mkdir /build; \
go build \
-ldflags "-X github.com/crusttech/crust/internal/version.BuildTime="`date +%FT%T%z`" -X github.com/crusttech/crust/internal/version.Version="`git describe --always --tags` \
-o /build/crust cmd/crust/*.go && \
go build \
-ldflags "-X github.com/crusttech/crust/internal/version.BuildTime="`date +%FT%T%z`" -X github.com/crusttech/crust/internal/version.Version="`git describe --always --tags` \
-o /build/cli cmd/system-cli/*.go
## == webapp image ==
FROM crusttech/webapp:latest as webapp
## == target image ==
FROM alpine:3.7
RUN apk add --no-cache ca-certificates
COPY --from=builder /build /crust
COPY --from=webapp /crust/webapp /crust/webapp
COPY --from=webapp /start.d /start.d
COPY --from=webapp /entrypoint.sh /entrypoint.sh
WORKDIR /crust
EXPOSE 80
ENTRYPOINT ["/entrypoint.sh", "/crust/crust"]
-11
View File
@@ -1,11 +0,0 @@
FROM golang:1.12-alpine
ENV CGO_ENABLED=0
RUN apk add --no-cache git make bash && \
echo "installing overalls" && go get -u github.com/go-playground/overalls && \
echo "installing gomock" && go get -u github.com/golang/mock/gomock && \
echo "installing mockgen" && go get -u github.com/golang/mock/mockgen && \
echo "installing gotest" && go get -u github.com/rakyll/gotest && \
echo "installing goware/statik" && go get -u github.com/goware/statik && \
cd /usr/local/bin && wget https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh && chmod a+x wait-for-it.sh
+23 -16
View File
@@ -6,22 +6,23 @@ GO = go
GOGET = $(GO) get -u
BASEPKGS = system compose messaging
IMAGES = system compose messaging
IMAGES = corteza-server-system corteza-server-compose corteza-server-messaging corteza-server
########################################################################################################################
# Tool bins
DEP = $(GOPATH)/bin/dep
REALIZE = ${GOPATH}/bin/realize
GOTEST = ${GOPATH}/bin/gotest
GOCRITIC = ${GOPATH}/bin/gocritic
MOCKGEN = ${GOPATH}/bin/mockgen
DEP = $(GOPATH)/bin/dep
REALIZE = ${GOPATH}/bin/realize
GOTEST = ${GOPATH}/bin/gotest
GOCRITIC = ${GOPATH}/bin/gocritic
MOCKGEN = ${GOPATH}/bin/mockgen
STATICCHECK = ${GOPATH}/bin/staticcheck
help:
@echo
@echo Usage: make [target]
@echo
@echo - docker: builds docker images locally
@echo - docker-push: push built images
@echo - docker-images: builds docker images locally
@echo - docker-push: push built images
@echo
@echo - vet - run go vet on all code
@echo - critic - run go critic on all code
@@ -32,15 +33,15 @@ help:
@echo
docker: $(IMAGES:%=docker-image.%)
docker-images: $(IMAGES:%=docker-image.%)
docker-image.%: Dockerfile.%
@ docker build --no-cache --rm -f Dockerfile.$* -t crusttech/$*:latest .
@ docker build --no-cache --rm -f Dockerfile.$* -t cortezaproject/$*:latest .
docker-push: $(IMAGES:%=docker-push.%)
docker-push.%: Dockerfile.%
@ docker push crusttech/$*:latest
@ docker push cortezaproject/$*:latest
########################################################################################################################
@@ -66,10 +67,10 @@ mailhog.up:
test:
# Run basic unit tests
$(GO) test ./cmd/... ./internal/... ./compose/... ./messaging/... ./system/...
$(GO) test ./opt/... ./internal/... ./compose/... ./messaging/... ./system/...
test-coverage:
overalls -project=github.com/crusttech/crust -covermode=count -debug -- -coverpkg=./... --tags=integration
overalls -project=github.com/cortezaproject/corteza-server -covermode=count -debug -- -coverpkg=./... --tags=integration
mv overalls.coverprofile coverage.txt
test.internal: $(GOTEST)
@@ -108,9 +109,9 @@ test.store: $(GOTEST)
test.cross-dep:
# Outputs cross-package imports that should not be there.
grep -rE "crust/(compose|messaging)/" system || exit 0
grep -rE "crust/(system|messaging)/" compose || exit 0
grep -rE "crust/(system|compose)/" messaging || exit 0
grep -rE "corteza/(compose|messaging)/" system || exit 0
grep -rE "corteza/(system|messaging)/" compose || exit 0
grep -rE "corteza/(system|compose)/" messaging || exit 0
integration:
# Run drone's integration pipeline
@@ -124,6 +125,9 @@ vet:
critic: $(GOCRITIC)
$(GOCRITIC) check-project .
staticcheck: $(STATICCHECK)
$(STATICCHECK) ./pkg/... ./internal/... ./system/... ./messaging/... ./compose/...
qa: vet critic test
mocks: $(GOMOCK)
@@ -157,5 +161,8 @@ $(MOCKGEN):
$(GOGET) github.com/golang/mock/gomock
$(GOGET) github.com/golang/mock/mockgen
$(STATICCHECK):
$(GOGET) honnef.co/go/tools/cmd/staticcheck
clean:
rm -f $(REALIZE) $(GOCRITIC) $(GOTEST)
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env sh
# This file is intended to be used from Dockerfile,
# presumably from cortezaproject/corteza-server-builder.
set -eu
BUILD_TIME=${BUILD_TIME:-$(date +%FT%T%z)}
GIT_TAG=${GIT_TAG:-$(git describe --always --tags)}
APP=${1}
DST=${2:-"/bin/corteza-server-${APP}"}
LDFLAGS=""
LDFLAGS="${LDFLAGS} -X github.com/cortezaproject/corteza-server/internal/version.BuildTime=${BUILD_TIME}"
LDFLAGS="${LDFLAGS} -X github.com/cortezaproject/corteza-server/internal/version.Version=${GIT_TAG}"
go build -ldflags "${LDFLAGS}" -o $DST ./cmd/$APP/*.go