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

drone: init #797

Merged
merged 1 commit into from
Jun 24, 2019
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
51 changes: 51 additions & 0 deletions .drone.jsonnet
Original file line number Diff line number Diff line change
@@ -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'),
]
133 changes: 133 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -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

...
43 changes: 0 additions & 43 deletions .travis.yml

This file was deleted.

43 changes: 39 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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:
jzelinskie marked this conversation as resolved.
Show resolved Hide resolved
# 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.
jzelinskie marked this conversation as resolved.
Show resolved Hide resolved
# 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