Skip to content

Commit 85ddc37

Browse files
committed
Tests, ci, docs, Makefile, ...
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
1 parent fce1d62 commit 85ddc37

31 files changed

+611
-91
lines changed

.ci/script.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
if [ -z ${GOPATH} ]; then
4+
export PATH="${HOME}/go/bin:${PATH}"
5+
else
6+
export PATH="${GOPATH}/bin:${PATH}"
7+
fi
8+
9+
BUILD_IMAGE="quay.io/jpkroehling/opentelemetry-operator" make ci
10+
RT=$?
11+
if [ ${RT} != 0 ]; then
12+
echo "Failed to build the operator."
13+
exit ${RT}
14+
fi

.codecov.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ignore:
2+
- "./pkg/apis/opentelemetry/v1alpha1/zz_generated.deepcopy.go"
3+
- "./pkg/apis/opentelemetry/v1alpha1/zz_generated.openapi.go"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: "Continuous Integration"
2+
on: [push, pull_request]
3+
4+
jobs:
5+
unit-tests:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v1
9+
- uses: jpkrohling/setup-operator-sdk@v1-release
10+
with:
11+
operator-sdk-version: v0.10.0
12+
13+
- name: "basic checks"
14+
run: ./.ci/script.sh

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Once minikube has finished starting, get the Operator running:
3838
make run
3939
```
4040

41-
At this point, a Jaeger instance can be installed:
41+
At this point, an OpenTelemetry Service instance can be installed:
4242

4343
```
4444
kubectl apply -f deploy/examples/simplest.yaml
@@ -58,4 +58,4 @@ The Operator SDK generates the `pkg/apis/opentelemetry/v1alpha1//zz_generated.*.
5858

5959
#### Tests
6060

61-
Right now, there are no tests on this repo yet. This will change really soon.
61+
Right now, there are only unit tests in this repository. They can be executed via `make unit-tests`. End-to-end tests are planned, and should be executed via `make e2e-tests`. All tests, including unit and end-to-end, will be executed when `make test` is called.

Makefile

+15-20
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ OUTPUT_BINARY ?= "$(BIN_DIR)/$(OPERATOR_NAME)"
1313
VERSION_PKG ?= "github.com/open-telemetry/opentelemetry-operator/version"
1414
LD_FLAGS ?= "-X=$(VERSION_PKG).Version=$(OPERATOR_VERSION)"
1515

16-
PACKAGES := $(shell go list ./cmd/... ./pkg/...)
16+
PACKAGES := $(shell go list ./cmd/... ./pkg/... ./version/...)
1717

1818
.DEFAULT_GOAL := build
1919

2020
.PHONY: check
21-
check:
21+
check: format ensure-generate-is-noop
2222
@echo Checking...
23-
@go fmt $(PACKAGES) > $(FMT_LOG)
23+
@git diff -s --exit-code . || (echo "Build failed: one or more source files aren't properly formatted. Run 'make format' and update your PR." && exit 1)
2424

2525
.PHONY: ensure-generate-is-noop
2626
ensure-generate-is-noop: generate
@@ -29,17 +29,12 @@ ensure-generate-is-noop: generate
2929
.PHONY: format
3030
format:
3131
@echo Formatting code...
32-
@go fmt $(PACKAGES)
33-
34-
.PHONY: lint
35-
lint:
36-
@echo Linting...
37-
@$(GOPATH)/bin/golint -set_exit_status=1 $(PACKAGES)
32+
@goimports -w -local "github.com/open-telemetry/opentelemetry-operator" .
3833

3934
.PHONY: security
4035
security:
4136
@echo Security...
42-
@$(GOPATH)/bin/gosec -quiet $(PACKAGES) 2>/dev/null
37+
@gosec -quiet $(PACKAGES) 2>/dev/null
4338

4439
.PHONY: build
4540
build: format
@@ -68,21 +63,21 @@ generate:
6863
@operator-sdk generate openapi
6964

7065
.PHONY: test
71-
test:
72-
@echo Running tests...
66+
test: unit-tests
67+
68+
.PHONY: unit-tests
69+
unit-tests:
70+
@echo Running unit tests...
71+
@go test $(PACKAGES) -cover -coverprofile=cover.out
7372

7473
.PHONY: all
75-
all: check format lint security build test
74+
all: check format security build test
7675

7776
.PHONY: ci
78-
ci: ensure-generate-is-noop all
79-
80-
.PHONY: scorecard
81-
scorecard:
82-
@operator-sdk scorecard --cr-manifest deploy/examples/simplest.yaml --csv-path deploy/olm-catalog/jaeger.clusterserviceversion.yaml --init-timeout 30
77+
ci: install-tools ensure-generate-is-noop all
8378

8479
.PHONY: install-tools
8580
install-tools:
8681
@go get -u \
87-
golang.org/x/lint/golint \
88-
github.com/securego/gosec/cmd/gosec
82+
github.com/securego/gosec/cmd/gosec \
83+
golang.org/x/tools/cmd/goimports

cmd/manager/empty_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// this file exists to force the coverage tool to count this directory
2+
package main

deploy/crds/opentelemetry_v1alpha1_opentelemetryservice_crd.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ spec:
3535
type: object
3636
spec:
3737
properties:
38+
args:
39+
additionalProperties:
40+
type: string
41+
type: object
3842
config:
3943
description: +required
4044
type: string

go.mod

+14
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,23 @@ module github.com/open-telemetry/opentelemetry-operator
22

33
require (
44
github.com/NYTimes/gziphandler v1.0.1 // indirect
5+
github.com/go-logr/logr v0.1.0
56
github.com/go-openapi/spec v0.19.0
7+
github.com/golang/protobuf v1.3.2 // indirect
8+
github.com/kr/pty v1.1.8 // indirect
9+
github.com/lib/pq v1.2.0 // indirect
10+
github.com/onsi/ginkgo v1.9.0 // indirect
11+
github.com/onsi/gomega v1.7.0 // indirect
612
github.com/operator-framework/operator-sdk v0.10.1-0.20190827134739-8e55eb7da610
13+
github.com/securego/gosec v0.0.0-20190709033609-4b59c948083c // indirect
714
github.com/spf13/pflag v1.0.3
15+
github.com/stretchr/objx v0.2.0 // indirect
16+
github.com/stretchr/testify v1.4.0
17+
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 // indirect
18+
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect
19+
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456 // indirect
20+
golang.org/x/text v0.3.2 // indirect
21+
golang.org/x/tools v0.0.0-20190829051458-42f498d34c4d // indirect
822
gopkg.in/yaml.v2 v2.2.2
923
k8s.io/api v0.0.0-20190612125737-db0771252981
1024
k8s.io/apimachinery v0.0.0-20190612125636-6a5db36e93ad

0 commit comments

Comments
 (0)