From f8a0274f7df77608717ded88f5cae45a60e6dca3 Mon Sep 17 00:00:00 2001 From: mdr0id Date: Tue, 30 Jul 2019 10:44:10 -0700 Subject: [PATCH 1/3] creating initial CI/CD file --- .gitlab-ci.yml | 106 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..c73ec02 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,106 @@ +# /************************************************************************ + # File: .gitlab-ci.yml + # Author: mdr0id + # Date: 7/16/2019 + # Description: Used to setup runners/jobs for lightwalletd + # Usage: Commit source and the pipeline will trigger the according jobs. + # + # Known bugs/missing features: + # + # IMPORTANT NOTE: any job with preceeding '.'' is ignored in pipeline + # ************************************************************************/ + +image: golang:1.11-alpine + +stages: + - build + - test + - deploy + - monitor + +# ************************************************************************/ +# BUILD +# ************************************************************************/ +.lint-check: + stage: build + script: + - make lint + +.build-docs: + stage: build + script: + - made docs + +build-linux: + stage: build + script: + - make + +.build-windows: + stage: build + script: + - make + +.build-mac: + stage: build + script: + - make + +# Build against latest Golang +.build-latest: + stage: build + image: golang:latest-alpine + script: + - make + allow_failure: true + +# Likely don't need a nightly in always deployable model; will revisit after requirement gathering +.build-nightly: + stage: build + script: + - make + allow_failure: true + +# ************************************************************************/ +# TEST +# ************************************************************************/ +test-coverage: + stage: test + script: + - make coverage + +test-coverage-report: + stage: test + script: + - make coverage_report + +test-coverage-report-html: + stage: test + script: + - make coverage_html + +# ************************************************************************/ +# DEPLOY +# ************************************************************************/ +.release-candidate: + stage: deploy + script: + - echo "Generating v0.0.1-rc" + when: manual + +.release-production: + stage: deploy + script: + - echo "Generating v0.0.1" + when: manual + + +# ************************************************************************/ +# MONITOR +# ************************************************************************/ +.monitor-release: + stage: deploy + script: + - echo "Building docker image for v0.0.0" + - make image + when: manual From ea3b3c119fb1b4d4069c7e27fdf26254d260fa80 Mon Sep 17 00:00:00 2001 From: mdr0id Date: Tue, 30 Jul 2019 10:44:44 -0700 Subject: [PATCH 2/3] creating initial Makefile for CI/CD --- Makefile | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..20117db --- /dev/null +++ b/Makefile @@ -0,0 +1,76 @@ +# /************************************************************************ + # File: Makefile + # Author: mdr0id + # Date: 7/16/2019 + # Description: Used for local and container dev in CI deployments + # Usage: make + # + # Known bugs/missing features: + # + # ************************************************************************/ +PROJECT_NAME := "lightwalletd" +GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v '*_test.go') +GO_TEST_FILES := $(shell find . -name '*_test.go' -type f | rev | cut -d "/" -f2- | rev | sort -u) +GO_BUILD_FILES := $(shell find . -name 'main.go') + +#PKG_LIST := $(shell go list | grep -v /vendor/) +#GO_COV_REPORTS := + +.PHONY: all dep build clean test coverage coverhtml lint + +all: build + +# Lint golang files +lint: + @golint -set_exit_status + +show_tests: + @echo ${GO_TEST_FILES} + +# Run unittests +test: + @go test -v -short ${GO_TEST_FILES} + +# Run data race detector +race: dep + @go test -v -race -short ${GO_TEST_FILES} + +# Run memory sanitizer (need to ensure proper build flag is set) +msan: dep + @go test -v -msan -short ${GO_TEST_FILES} + +# Generate global code coverage report +coverage: + @go test -coverprofile=coverage.out ${GO_TEST_FILES} + +# Generate code coverage report +coverage_report: + @go tool cover -func=coverage.out + +# Generate code coverage report in HTML +coverage_html: + @go tool cover -html=coverage.out + +# Generate documents +docs: + @echo "Generating docs..." + +# Generate docker image +image: + @echo "Building lightwalletd image..." + +# Get dependencies +dep: + @go get -v -d ./... + +# Build binary +build: #dep + @go build -i -v ${GO_BUILD_FILES} + +# Install binaries into Go path +install: + go install ./... + +clean: + @echo "clean project..." + #rm -f $(PROJECT_NAME) \ No newline at end of file From 4a2d22ca3ae8f079e53b6ca63351cc6675485ec1 Mon Sep 17 00:00:00 2001 From: mdr0id Date: Thu, 5 Sep 2019 18:17:26 -0700 Subject: [PATCH 3/3] Update makefile for broken make target --- .gitlab-ci.yml | 5 ++++- Makefile | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c73ec02..4bbb3e0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -67,17 +67,20 @@ build-linux: test-coverage: stage: test script: - - make coverage + - make coverage + allow_failure: true test-coverage-report: stage: test script: - make coverage_report + allow_failure: true test-coverage-report-html: stage: test script: - make coverage_html + allow_failure: true # ************************************************************************/ # DEPLOY diff --git a/Makefile b/Makefile index 20117db..521b165 100644 --- a/Makefile +++ b/Makefile @@ -64,8 +64,9 @@ dep: @go get -v -d ./... # Build binary -build: #dep - @go build -i -v ${GO_BUILD_FILES} +build: + @go build -i -v ./cmd/ingest + @go build -i -v ./cmd/server # Install binaries into Go path install: