Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 committed Sep 4, 2023
2 parents 6fc7fc9 + 66094d9 commit e6598ac
Show file tree
Hide file tree
Showing 49 changed files with 4,440 additions and 579 deletions.
43 changes: 35 additions & 8 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go 1.21
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21.x'

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
args: --build-tags integration -p bugs -p unused --timeout=3m
go-version-file: 'go.mod'

- name: Make tag
run: |
Expand All @@ -49,11 +44,43 @@ jobs:
- name: Build
run:
make all
make build

- name: Build and push image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.tag }}

integration:
name: Integration Test
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
cache: false

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
args: --build-tags integration -p bugs -p unused --timeout=3m

- name: Test
run: |
make test
- name: Create k8s Kind Cluster
uses: helm/[email protected]
with:
install_only: true

- name: Test
run: |
make test-integration
28 changes: 19 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,39 @@ LINKMODE := -extldflags '-static -s -w' \
-X 'github.com/metal-stack/v.GitSHA1=$(SHA)' \
-X 'github.com/metal-stack/v.BuildDate=$(BUILDDATE)'

.PHONY: all
all:
KUBECONFIG := $(shell pwd)/.kubeconfig
GO_RUN := $(or $(GO_RUN),)
ifneq ($(GO_RUN),)
GO_RUN_ARG := -run $(GO_RUN)
endif

.PHONY: build
build:
go mod tidy
go build -ldflags "$(LINKMODE)" -tags 'osusergo netgo static_build' -o bin/backup-restore-sidecar github.com/metal-stack/backup-restore-sidecar/cmd
strip bin/backup-restore-sidecar

.PHONY: test
test: build
go test -cover ./...

.PHONY: test-integration
test-integration: kind-cluster-create
kind --name backup-restore-sidecar load docker-image ghcr.io/metal-stack/backup-restore-sidecar:latest
KUBECONFIG=$(KUBECONFIG) go test $(GO_RUN_ARG) -tags=integration -count 1 -v -p 1 -timeout 10m ./...

.PHONY: proto
proto:
make -C proto protoc

.PHONY: dockerimage
dockerimage: all
dockerimage: build
docker build -t ghcr.io/metal-stack/backup-restore-sidecar:${DOCKER_TAG} .

.PHONY: dockerpush
dockerpush:
docker push ghcr.io/metal-stack/backup-restore-sidecar:${DOCKER_TAG}

# # #
# the following tasks can be used to set up a development environment
# # #

KUBECONFIG := $(shell pwd)/.kubeconfig

.PHONY: start-postgres
start-postgres:
$(MAKE) start DB=postgres
Expand Down Expand Up @@ -70,6 +79,7 @@ kind-cluster-create: dockerimage
@if ! kind get clusters | grep backup-restore-sidecar > /dev/null; then \
kind create cluster \
--name backup-restore-sidecar \
--config kind.yaml \
--kubeconfig $(KUBECONFIG); fi

.PHONY: cleanup
Expand Down
Loading

0 comments on commit e6598ac

Please sign in to comment.