Skip to content

Commit

Permalink
Update Makefile (#4)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha authored Oct 25, 2019
1 parent 11da7a1 commit 2e6c4c6
Show file tree
Hide file tree
Showing 170 changed files with 30,818 additions and 30,452 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
push:
branches-ignore:
- 'release-*'
tags-ignore:
- '*.*'

jobs:

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

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

- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest

- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}

- name: Run checks
run: |
sudo apt-get -qq update
sudo apt-get install -y bzr
make ci
- name: Build
env:
REGISTRY: appscodeci
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
USERNAME: 1gtm
run: |
docker login --username ${USERNAME} --password ${DOCKER_TOKEN}
make push
27 changes: 0 additions & 27 deletions .github/workflows/go.yml

This file was deleted.

5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Release

on:
create:
push:
tags:
- '*.*'
- '*.*.*'

jobs:
Expand All @@ -22,7 +23,7 @@ jobs:
- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@master
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest

Expand Down
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

112 changes: 84 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
# Copyright 2019 AppsCode Inc.
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

SHELL=/bin/bash -o pipefail

# The binary to build (just the basename).
GO_PKG := stash.appscode.dev
REPO := $(notdir $(shell pwd))
BIN := stash-percona-xtradb
COMPRESS ?= no

Expand Down Expand Up @@ -35,9 +51,10 @@ NEW_RESTIC_VER := 0.9.5
### These variables should not need tweaking.
###

SRC_DIRS := cmd pkg # directories which hold app source (not vendored)
SRC_PKGS := cmd pkg
SRC_DIRS := $(SRC_PKGS) # directories which hold app source (not vendored)

DOCKER_PLATFORMS := linux/amd64 linux/arm linux/arm64
DOCKER_PLATFORMS := linux/amd64 linux/arm64
BIN_PLATFORMS := $(DOCKER_PLATFORMS)

# Used internally. Users should pass GOOS and/or GOARCH.
Expand All @@ -54,7 +71,7 @@ TAG := $(VERSION)_$(OS)_$(ARCH)
TAG_PROD := $(TAG)
TAG_DBG := $(VERSION)-dbg_$(OS)_$(ARCH)

GO_VERSION ?= 1.12.5
GO_VERSION ?= 1.12.12
BUILD_IMAGE ?= appscode/golang-dev:$(GO_VERSION)-stretch

OUTBIN = bin/$(OS)_$(ARCH)/$(BIN)
Expand All @@ -65,7 +82,11 @@ endif
# Directories that we need created to build/test.
BUILD_DIRS := bin/$(OS)_$(ARCH) \
.go/bin/$(OS)_$(ARCH) \
.go/cache
.go/cache \
hack/config \
$(HOME)/.credentials \
$(HOME)/.kube \
$(HOME)/.minikube

DOCKERFILE_PROD = Dockerfile.in
DOCKERFILE_DBG = Dockerfile.dbg
Expand Down Expand Up @@ -111,7 +132,7 @@ version:
@echo ::set-output name=commit_timestamp::$(commit_timestamp)

gen:
./hack/codegen.sh
@true

fmt: $(BUILD_DIRS)
@docker run \
Expand All @@ -126,7 +147,10 @@ fmt: $(BUILD_DIRS)
--env HTTP_PROXY=$(HTTP_PROXY) \
--env HTTPS_PROXY=$(HTTPS_PROXY) \
$(BUILD_IMAGE) \
./hack/fmt.sh $(SRC_DIRS)
/bin/bash -c " \
REPO_PKG=$(GO_PKG) \
./hack/fmt.sh $(SRC_DIRS) \
"

build: $(OUTBIN)

Expand Down Expand Up @@ -164,9 +188,21 @@ $(OUTBIN): .go/$(OUTBIN).stamp
commit_timestamp=$(commit_timestamp) \
./hack/build.sh \
"
@if [ $(COMPRESS) = yes ] && [ $(OS) != windows ]; then \
echo "compressing $(OUTBIN)"; \
upx --brute .go/$(OUTBIN); \
@if [ $(COMPRESS) = yes ] && [ $(OS) != darwin ]; then \
echo "compressing $(OUTBIN)"; \
docker run \
-i \
--rm \
-u $$(id -u):$$(id -g) \
-v $$(pwd):/src \
-w /src \
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin \
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin/$(OS)_$(ARCH) \
-v $$(pwd)/.go/cache:/.cache \
--env HTTP_PROXY=$(HTTP_PROXY) \
--env HTTPS_PROXY=$(HTTPS_PROXY) \
$(BUILD_IMAGE) \
upx --brute /go/$(OUTBIN); \
fi
@if ! cmp -s .go/$(OUTBIN) $(OUTBIN); then \
mv .go/$(OUTBIN) $(OUTBIN); \
Expand All @@ -181,13 +217,13 @@ container: bin/.container-$(DOTFILE_IMAGE)-PROD bin/.container-$(DOTFILE_IMAGE)-
bin/.container-$(DOTFILE_IMAGE)-%: bin/$(OS)_$(ARCH)/$(BIN) $(DOCKERFILE_%)
@echo "container: $(IMAGE):$(TAG_$*)"
@sed \
-e 's|{ARG_BIN}|$(BIN)|g' \
-e 's|{ARG_ARCH}|$(ARCH)|g' \
-e 's|{ARG_OS}|$(OS)|g' \
-e 's|{ARG_FROM}|$(BASEIMAGE_$*)|g' \
-e 's|{RESTIC_VER}|$(RESTIC_VER)|g' \
-e 's|{NEW_RESTIC_VER}|$(NEW_RESTIC_VER)|g' \
$(DOCKERFILE_$*) > bin/.dockerfile-$*-$(OS)_$(ARCH)
-e 's|{ARG_BIN}|$(BIN)|g' \
-e 's|{ARG_ARCH}|$(ARCH)|g' \
-e 's|{ARG_OS}|$(OS)|g' \
-e 's|{ARG_FROM}|$(BASEIMAGE_$*)|g' \
-e 's|{RESTIC_VER}|$(RESTIC_VER)|g' \
-e 's|{NEW_RESTIC_VER}|$(NEW_RESTIC_VER)|g' \
$(DOCKERFILE_$*) > bin/.dockerfile-$*-$(OS)_$(ARCH)
@DOCKER_CLI_EXPERIMENTAL=enabled docker buildx build --platform $(OS)/$(ARCH) --load --pull -t $(IMAGE):$(TAG_$*) -f bin/.dockerfile-$*-$(OS)_$(ARCH) .
@docker images -q $(IMAGE):$(TAG_$*) > $@
@echo
Expand All @@ -204,7 +240,10 @@ docker-manifest-%:
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a $(IMAGE):$(VERSION_$*) $(foreach PLATFORM,$(DOCKER_PLATFORMS),$(IMAGE):$(VERSION_$*)_$(subst /,_,$(PLATFORM)))
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push $(IMAGE):$(VERSION_$*)

test: $(BUILD_DIRS)
.PHONY: test
test: unit-tests

unit-tests: $(BUILD_DIRS)
@docker run \
-i \
--rm \
Expand Down Expand Up @@ -243,40 +282,57 @@ lint: $(BUILD_DIRS)
--env GO111MODULE=on \
--env GOFLAGS="-mod=vendor" \
$(BUILD_IMAGE) \
golangci-lint run --enable $(ADDTL_LINTERS)
golangci-lint run --enable $(ADDTL_LINTERS) --deadline=10m --skip-files="generated.*\.go$\" --skip-dirs-use-default

$(BUILD_DIRS):
@mkdir -p $@

.PHONY: dev
dev: gen fmt push

.PHONY: verify
verify: verify-modules verify-gen

.PHONY: verify-modules
verify-modules:
GO111MODULE=on go mod tidy
GO111MODULE=on go mod vendor
@if !(git diff --exit-code HEAD); then \
echo "go module files are out of date"; exit 1; \
fi

.PHONY: verify-gen
verify-gen: gen fmt
@if !(git diff --exit-code HEAD); then \
echo "files are out of date, run make gen fmt"; exit 1; \
fi

.PHONY: ci
ci: lint test build #cover
ci: verify lint build unit-tests #cover

.PHONY: qa
qa: docker-manifest
qa:
@if [ "$$APPSCODE_ENV" = "prod" ]; then \
echo "Nothing to do in prod env. Are you trying to 'release' binaries to prod?"; \
exit 1; \
fi
@if [ "$(version_strategy)" = "git_tag" ]; then \
@if [ "$(version_strategy)" = "tag" ]; then \
echo "Are you trying to 'release' binaries to prod?"; \
exit 1; \
fi
@$(MAKE) clean all-push --no-print-directory
@$(MAKE) clean all-push docker-manifest --no-print-directory

.PHONY: release
release: docker-manifest
release:
@if [ "$$APPSCODE_ENV" != "prod" ]; then \
echo "'release' only works in PROD env."; \
exit 1; \
fi
@if [ "$(version_strategy)" != "git_tag" ]; then \
echo "'apply_tag' to release binaries and/or docker images."; \
exit 1; \
@if [ "$(version_strategy)" != "tag" ]; then \
echo "apply tag to release binaries and/or docker images."; \
exit 1; \
fi
@$(MAKE) clean all-push --no-print-directory
@$(MAKE) clean all-push docker-manifest --no-print-directory

.PHONY: clean
clean:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[![Go Report Card](https://goreportcard.com/badge/stash.appscode.dev/percona-xtradb)](https://goreportcard.com/report/stash.appscode.dev/percona-xtradb)
[![Build Status](https://travis-ci.org/stashed/xtradb.svg?branch=master)](https://travis-ci.org/stashed/xtradb)
[![Build Status](https://github.com/stashed/percona-xtradb/workflows/CI/badge.svg)](https://github.com/stashed/percona-xtradb/actions?workflow=CI)
[![Docker Pulls](https://img.shields.io/docker/pulls/appscode/xtradb-stash.svg)](https://hub.docker.com/r/appscode/xtradb-stash/)
[![Slack](https://slack.appscode.com/badge.svg)](https://slack.appscode.com)
[![Twitter](https://img.shields.io/twitter/follow/appscodehq.svg?style=social&logo=twitter&label=Follow)](https://twitter.com/intent/follow?screen_name=AppsCodeHQ)

# XtraDB
# Percona XtraDB
Percona XtraDB backup and restore plugin for [Stash by AppsCode](https://appscode.com/products/stash).

---
Expand Down
5 changes: 3 additions & 2 deletions cmd/stash-percona-xtradb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"os"
"runtime"

"stash.appscode.dev/percona-xtradb/pkg"
_ "stash.appscode.dev/stash/client/clientset/versioned/fake"

"github.com/appscode/go/log"
_ "k8s.io/client-go/kubernetes/fake"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"kmodules.xyz/client-go/logs"
"stash.appscode.dev/percona-xtradb/pkg"
_ "stash.appscode.dev/stash/client/clientset/versioned/fake"
)

func main() {
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module stash.appscode.dev/percona-xtradb
go 1.12

require (
github.com/appscode/go v0.0.0-20190808133642-1d4ef1f1c1e0
github.com/appscode/go v0.0.0-20191016085057-e186b6c94a3b
github.com/spf13/cobra v0.0.5
k8s.io/apimachinery v0.0.0-20190508063446-a3da69d3723c
k8s.io/client-go v11.0.0+incompatible
kmodules.xyz/client-go v0.0.0-20190808141354-bbb9e14f60ab
kmodules.xyz/custom-resources v0.0.0-20190808144301-114abf10dfe2
kubedb.dev/apimachinery v0.13.0-rc.0.0.20190830121921-d28870c9d73a
stash.appscode.dev/stash v0.9.0-rc.0.0.20190910104640-5f49f5d214aa
kmodules.xyz/client-go v0.0.0-20191023042933-b12d1ccfaf57
kmodules.xyz/custom-resources v0.0.0-20190927035424-65fe358bb045
kubedb.dev/apimachinery v0.13.0-rc.2
stash.appscode.dev/stash v0.9.0-rc.2
)

replace (
Expand All @@ -28,6 +28,6 @@ replace (
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30
k8s.io/kubernetes => k8s.io/kubernetes v1.14.0
k8s.io/metrics => k8s.io/metrics v0.0.0-20190314001731-1bd6a4002213
k8s.io/utils => k8s.io/utils v0.0.0-20190221042446-c2654d5206da
k8s.io/utils => k8s.io/utils v0.0.0-20190514214443-0a167cbac756
sigs.k8s.io/structured-merge-diff => sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2
)
Loading

0 comments on commit 2e6c4c6

Please sign in to comment.