Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests #55

Merged
merged 24 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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