diff --git a/.drone.jsonnet b/.drone.jsonnet new file mode 100644 index 0000000000..52bc7268d5 --- /dev/null +++ b/.drone.jsonnet @@ -0,0 +1,51 @@ +local pipeline(goVersion, postgresVersion) = { + kind: 'pipeline', + name: 'go-' + goVersion + '-postgres' + postgresVersion, + workspace: { + base: '/go', + path: 'src/github.com/coreos/clair', + }, + clone: { depth: 50 }, + + services: [{ + name: 'postgres', + image: 'postgres:' + postgresVersion + '-alpine', + ports: [5432], + }], + + steps: [ + { + name: 'compile', + image: 'golang:' + goVersion + '-alpine', + commands: [ + 'apk add --no-cache build-base git rpm xz', + 'make build', + ], + }, + { + name: 'unit tests', + image: 'golang:' + goVersion + '-alpine', + commands: [ + 'apk add --no-cache build-base git rpm xz', + 'git config --global user.name "Test"', + 'git config --global user.email "test@coreos.com"', + 'make unit-test', + ], + }, + { + name: 'db tests', + image: 'golang:' + goVersion + '-alpine', + commands: [ + 'apk add --no-cache build-base git rpm xz', + 'make db-test', + ], + environment: { CLAIR_TEST_PGSQL: 'postgres@postgres:5432' }, + }, + ], +}; + +[ + pipeline('1.12', '9'), + pipeline('1.12', '10'), + pipeline('1.12', '11'), +] diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000000..7d444dea28 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,133 @@ +--- +kind: pipeline +name: go-1.12-postgres9 + +platform: + os: linux + arch: amd64 + +clone: + depth: 50 + +workspace: + base: /go + path: src/github.com/coreos/clair + +steps: +- name: compile + image: golang:1.12-alpine + commands: + - apk add --no-cache build-base git rpm xz + - make build + +- name: unit tests + image: golang:1.12-alpine + commands: + - apk add --no-cache build-base git rpm xz + - "git config --global user.name \"Test\"" + - "git config --global user.email \"test@coreos.com\"" + - make unit-test + +- name: db tests + image: golang:1.12-alpine + commands: + - apk add --no-cache build-base git rpm xz + - make db-test + environment: + CLAIR_TEST_PGSQL: "postgres@postgres:5432" + +services: +- name: postgres + image: postgres:9-alpine + ports: + - 5432 + +--- +kind: pipeline +name: go-1.12-postgres10 + +platform: + os: linux + arch: amd64 + +clone: + depth: 50 + +workspace: + base: /go + path: src/github.com/coreos/clair + +steps: +- name: compile + image: golang:1.12-alpine + commands: + - apk add --no-cache build-base git rpm xz + - make build + +- name: unit tests + image: golang:1.12-alpine + commands: + - apk add --no-cache build-base git rpm xz + - "git config --global user.name \"Test\"" + - "git config --global user.email \"test@coreos.com\"" + - make unit-test + +- name: db tests + image: golang:1.12-alpine + commands: + - apk add --no-cache build-base git rpm xz + - make db-test + environment: + CLAIR_TEST_PGSQL: "postgres@postgres:5432" + +services: +- name: postgres + image: postgres:10-alpine + ports: + - 5432 + +--- +kind: pipeline +name: go-1.12-postgres11 + +platform: + os: linux + arch: amd64 + +clone: + depth: 50 + +workspace: + base: /go + path: src/github.com/coreos/clair + +steps: +- name: compile + image: golang:1.12-alpine + commands: + - apk add --no-cache build-base git rpm xz + - make build + +- name: unit tests + image: golang:1.12-alpine + commands: + - apk add --no-cache build-base git rpm xz + - "git config --global user.name \"Test\"" + - "git config --global user.email \"test@coreos.com\"" + - make unit-test + +- name: db tests + image: golang:1.12-alpine + commands: + - apk add --no-cache build-base git rpm xz + - make db-test + environment: + CLAIR_TEST_PGSQL: "postgres@postgres:5432" + +services: +- name: postgres + image: postgres:11-alpine + ports: + - 5432 + +... diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fc2d8eb186..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,43 +0,0 @@ -language: go - -go: - - "1.11.x" - -sudo: required - -env: - global: - - PATH=$HOME/.local/bin:$PATH - -install: -- curl https://glide.sh/get | sh -- mkdir -p $HOME/.local/bin -- curl -o $HOME/.local/bin/prototool -sSL https://github.com/uber/prototool/releases/download/v0.1.0/prototool-$(uname -s)-$(uname -m) -- chmod +x $HOME/.local/bin/prototool - -script: -- diff -u <(echo -n) <(gofmt -l -s $(go list -f '{{.Dir}}') | grep -v '/vendor/') -- prototool format -d api/v3/clairpb/clair.proto -- prototool lint api/v3/clairpb/clair.proto -- go test $(glide novendor | grep -v contrib) - -dist: trusty - -services: - - postgresql - -notifications: - email: false - -matrix: - include: - - addons: - apt: - packages: - - rpm - postgresql: 9.5 - - addons: - apt: - packages: - - rpm - postgresql: 9.6 diff --git a/Makefile b/Makefile index 322a227d95..5b717acdd6 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,51 @@ -# this make target is designed to be ran idempotently. each run deploys the latest code in the repository -# requires kubernetes. both minikube and docker desktop is supported. +# Copyright 2019 clair authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +COMMIT = $(shell git describe --tag --always --dirty) + +UNIT_TEST_PACKAGES = $(shell go list ./... | grep -v 'database/') +DB_TEST_PACKAGES = $(shell go list ./... | grep 'database/') + +CLAIR_TEST_PGSQL ?= postgres@127.0.0.1:5432 + +.PHONY: build +build: + go build -v -ldflags "-X github.com/coreos/clair/pkg/version.Version=$(COMMIT)" ./cmd/clair + +.PHONY: unit-test +unit-test: + go test $(UNIT_TEST_PACKAGES) + +.PHONY: db-test +db-test: + # The following executes integration tests with a live, but empty database. + @echo 'CLAIR_TEST_PGSQL: $(CLAIR_TEST_PGSQL)' + go test $(DB_TEST_PACKAGES) + .PHONY: deploy-local deploy-local: + # This make target is designed to be ran idempotently. + # Each run deploys the latest code in the repository requires kubernetes. + # Both minikube and docker desktop is supported. ./local-dev/build.sh -helm dependency update ./local-dev/helm/clair-pg -helm install --name clair-pg ./local-dev/helm/clair-pg -helm delete --purge clair helm install --name clair ./local-dev/helm/clair -# this make target tears down local dev environment deployed by the above target .PHONY: teardown-local teardown-local: + # This target tears down the environment deployed by deploy-local. -helm delete --purge clair -helm delete --purge clair-pg -