Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit cf2becd

Browse files
authored
Merge pull request #7 from packethost/test-ci
Ensure CGO_ENABLED=0
2 parents 105f1fa + bb285a8 commit cf2becd

File tree

3 files changed

+37
-11
lines changed

3 files changed

+37
-11
lines changed

.drone.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,36 @@ steps:
1515
pull: always
1616
image: golang:1.12.7-alpine
1717
commands:
18-
- apk --update add make git
19-
- make ci
18+
- apk --update add make git bash jq curl
19+
- make ci-test
2020

21-
- name: publish-amd64
21+
- name: image
22+
pull: always
23+
image: plugins/docker
24+
settings:
25+
dry_run: true
26+
context: .
27+
dockerfile: Dockerfile
28+
repo: packethost/cluster-api-provider-packet
29+
tags:
30+
- latest
31+
32+
- name: publish
2233
pull: always
2334
image: plugins/docker
2435
settings:
2536
context: .
2637
dockerfile: Dockerfile
2738
password:
2839
from_secret: docker_password
29-
repo: packethost/metabot
40+
repo: packethost/cluster-api-provider-packet
3041
tags:
3142
- "${DRONE_COMMIT}"
3243
- latest
3344
username:
3445
from_secret: docker_username
3546
when:
47+
branch: master
3648
event:
37-
exclude:
38-
- pull_request
49+
- push
50+
- tag

Makefile

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
.PHONY: vendor test manager clusterctl run install deploy manifests generate fmt vet run
1+
.PHONY: vendor test manager clusterctl run install deploy manifests generate fmt vet run kubebuilder ci cd
2+
3+
KUBEBUILDER_VERSION ?= 2.0.0-beta.0
4+
KUBEBUILDER ?= /usr/local/kubebuilder/bin/kubebuilder
25

36
GIT_VERSION?=$(shell git log -1 --format="%h")
47
RELEASE_TAG ?= $(shell git tag --points-at HEAD)
@@ -41,7 +44,7 @@ CLUSTERCTL ?= bin/clusterctl-$(OS)-$(ARCH)
4144
MANAGER ?= bin/manager-$(OS)-$(ARCH)
4245
KUBECTL ?= kubectl
4346

44-
GO ?= GO111MODULE=on go
47+
GO ?= GO111MODULE=on CGO_ENABLED=0 go
4548

4649
all: test manager clusterctl
4750

@@ -50,7 +53,9 @@ vendor:
5053
$(GO) mod vendor
5154
./hack/update-vendor.sh
5255

53-
ci: fmt vet test image
56+
# 2 separate targets: ci-test does everything locally, does not need docker; ci includes ci-test and building the image
57+
ci-test: fmt vet test
58+
ci: ci-test image
5459

5560
imagetag:
5661
ifndef IMAGETAG
@@ -68,9 +73,17 @@ endif
6873
cd: confirm
6974
$(MAKE) tag-image push IMAGETAG=$(GIT_VERSION)
7075

76+
# needed kubebuilder for tests
77+
kubebuilder: $(KUBEBUILDER)
78+
$(KUBEBUILDER):
79+
curl -sL https://go.kubebuilder.io/dl/$(KUBEBUILDER_VERSION)/$(BUILDOS)/$(BUILDARCH) | tar -xz -C /tmp/
80+
# move to a long-term location and put it on your path
81+
# (you'll need to set the KUBEBUILDER_ASSETS env var if you put it somewhere else)
82+
mv /tmp/kubebuilder_$(KUBEBUILDER_VERSION)_$(BUILDOS)_$(BUILDARCH) /usr/local/kubebuilder
83+
7184

7285
# Run tests
73-
test: vendor generate fmt vet manifests
86+
test: vendor generate fmt vet manifests $(KUBEBUILDER)
7487
$(GO) test -mod=vendor ./pkg/... ./cmd/... -coverprofile cover.out
7588

7689
# Build manager binary
@@ -133,7 +146,7 @@ endif
133146

134147
# Build the docker image
135148
image: docker-build
136-
docker-build: test
149+
docker-build:
137150
docker build -t $(BUILD_IMAGE_TAG) .
138151

139152
# Push the docker image

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,4 @@ Important notes:
266266

267267
* [kubeadm yaml api](https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2)
268268

269+

0 commit comments

Comments
 (0)