Skip to content

Commit fb092a5

Browse files
committed
setup azure pipeline and add e2e
1 parent a161123 commit fb092a5

File tree

11 files changed

+144
-221
lines changed

11 files changed

+144
-221
lines changed

.circleci/config.yml

-67
This file was deleted.

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ setenv.sh
1616
kubernetes-kms
1717
vendor
1818
azure.json
19+
*.env

.pipelines/pr.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
trigger: none
2+
3+
pr:
4+
branches:
5+
include:
6+
- master
7+
paths:
8+
exclude:
9+
- docs/*
10+
11+
pool:
12+
vmImage: ubuntu-latest
13+
14+
jobs:
15+
- template: unit-tests-template.yml

.pipelines/unit-tests-template.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
jobs:
2+
- job: unit_tests
3+
timeoutInMinutes: 20
4+
cancelTimeoutInMinutes: 5
5+
workspace:
6+
clean: all
7+
variables:
8+
- group: kubernetes-kms
9+
- name: GOPATH
10+
value: '$(system.defaultWorkingDirectory)/gopath'
11+
12+
steps:
13+
- task: GoTool@0
14+
inputs:
15+
version: 1.14.2
16+
- script: V=1 make build
17+
displayName: Build
18+
- script: make unit-test
19+
displayName: Run unit tests
20+
- script: |
21+
sudo mkdir /etc/kubernetes
22+
echo -e '{\n "tenantId": "'$TENANT_ID'",\n "subscriptionId": "'$SUBSCRIPTION_ID'",\n "aadClientId": "'$CLIENT_ID'",\n "aadClientSecret": "'$CLIENT_SECRET'",\n "resourceGroup": "'$KV_RESOURCE_GROUP'",\n "location": "'$AZURE_LOCATION'",\n "providerVaultName": "'$KV_NAME'",\n "providerKeyName": "'$KV_KEY'",\n "providerKeyVersion": "'$KV_KEY_VERSION'"\n}' | sudo tee --append /etc/kubernetes/azure.json > /dev/null
23+
displayName: Setup azure.json on host
24+
env:
25+
CLIENT_ID: $(AZURE_CLIENT_ID)
26+
CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
27+
- script: |
28+
sudo ./kubernetes-kms > /dev/null &
29+
echo Waiting 2 seconds for the server to start
30+
sleep 2
31+
make integration-test

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"go.inferGopath": false
3+
}

Gopkg.lock

-93
This file was deleted.

Gopkg.toml

-50
This file was deleted.

Makefile

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
binary := kubernetes-kms
22
REGISTRY_NAME ?= upstreamk8sci
33
REGISTRY ?= $(REGISTRY_NAME).azurecr.io
4-
DOCKER_IMAGE := $(REGISTRY)/public/k8s/kms/keyvault
5-
VERSION := v0.0.9
4+
REPO_PREFIX ?= k8s/kms
5+
DOCKER_IMAGE := $(REGISTRY)/$(REPO_PREFIX)/keyvault
6+
VERSION ?= v0.0.9
67
CGO_ENABLED_FLAG := 0
78

89
ifeq ($(OS),Windows_NT)
@@ -18,7 +19,7 @@ else
1819
endif
1920

2021
.PHONY: build
21-
build: authors deps
22+
build: authors
2223
@echo "Building..."
2324
$Q GOOS=${GOOS_FLAG} CGO_ENABLED=${CGO_ENABLED_FLAG} go build .
2425

@@ -31,12 +32,11 @@ build-image: authors deps
3132
push: build-image
3233
$Q docker push $(DOCKER_IMAGE):$(VERSION)
3334

34-
.PHONY: clean deps test testint
35+
.PHONY: clean deps unit-test integration-test
3536

3637
deps: setup
3738
@echo "Ensuring Dependencies..."
3839
$Q go env
39-
$Q dep ensure
4040

4141
clean:
4242
@echo "Clean..."
@@ -53,18 +53,21 @@ authors:
5353
$Q rm -f NEWAUTHORS
5454
$Q rm -f GITAUTHORS
5555

56-
testint:
56+
integration-test:
5757
@echo "Running Integration tests..."
5858
$Q sudo GOPATH=$(GOPATH) go test -v -count=1 github.com/Azure/kubernetes-kms/tests/client
5959

60-
test:
60+
unit-test:
6161
@echo "Running Unit Tests..."
6262
ifndef CI
6363
@echo "Running Unit Tests outside CI..."
6464
$Q go env
65-
$Q dep ensure
66-
go test -v -count=1 `go list ./... | grep -v client`
65+
go test -race -v -count=1 `go list ./... | grep -v client`
6766
else
6867
@echo "Running Unit Tests inside CI..."
69-
go test -v `go list ./... | grep -v client`
70-
endif
68+
go test -race $(shell go list ./... | grep -v /test/e2e) -v
69+
endif
70+
71+
.PHONY: mod
72+
mod:
73+
@go mod tidy

go.mod

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module github.com/Azure/kubernetes-kms
2+
3+
go 1.14
4+
5+
require (
6+
github.com/Azure/azure-sdk-for-go v11.3.0-beta+incompatible
7+
github.com/Azure/go-autorest v10.15.5+incompatible
8+
github.com/dgrijalva/jwt-go v3.1.0+incompatible // indirect
9+
github.com/dnaeon/go-vcr v1.0.1 // indirect
10+
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
11+
github.com/golang/mock v1.1.1
12+
github.com/golang/protobuf v1.0.0
13+
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
14+
github.com/satori/go.uuid v1.2.0 // indirect
15+
github.com/satori/uuid v1.2.0 // indirect
16+
github.com/stretchr/testify v1.6.1 // indirect
17+
golang.org/x/crypto v0.0.0-20180211211603-9de5f2eaf759
18+
golang.org/x/net v0.0.0-20180208041118-f5dfe339be1d
19+
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 // indirect
20+
golang.org/x/sys v0.0.0-20180202135801-37707fdb30a5
21+
golang.org/x/text v0.3.1-0.20180208041248-4e4a3210bb54 // indirect
22+
google.golang.org/genproto v0.0.0-20180206005123-2b5a72b8730b // indirect
23+
google.golang.org/grpc v1.9.2
24+
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
25+
gopkg.in/yaml.v2 v2.3.0 // indirect
26+
)

0 commit comments

Comments
 (0)