Skip to content

Commit

Permalink
chore(packaging): drone.io check stage
Browse files Browse the repository at this point in the history
Adds a check stage to the drone pipeline to lint and test
  • Loading branch information
sh0rez committed Sep 9, 2019
1 parent 74ff290 commit 9e2f2c5
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 3 deletions.
28 changes: 26 additions & 2 deletions .drone/drone.jsonnet
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
local apps = ['loki', 'loki-canary', 'promtail'];
local archs = ['amd64', 'arm64', 'arm'];

local build_image_version = std.extVar('__build-image-version');

local condition(verb) = {
tagMaster: {
ref: {
Expand All @@ -19,6 +21,16 @@ local pipeline(name) = {
steps: [],
};

local run(name, commands) = {
name: name,
image: 'grafana/loki-build-image:%s' % build_image_version,
commands: commands,
};

local make(target, container=true) = run(target, [
'make ' + (if !container then 'BUILD_IN_CONTAINER=false ' else '') + target,
]);

local docker(arch, app) = {
name: '%s-image' % if $.settings.dry_run then 'build-' + app else 'publish-' + app,
image: 'plugins/docker',
Expand Down Expand Up @@ -60,6 +72,7 @@ local multiarch_image(arch) = pipeline('docker-' + arch) {
}
for app in apps
],
depends_on: ['check'],
};

local manifest(apps) = pipeline('manifest') {
Expand All @@ -80,14 +93,25 @@ local manifest(apps) = pipeline('manifest') {
}
for app in apps
],
} + {
depends_on: [
'docker-%s' % arch
for arch in archs
],
] + ['check'],
};

local drone = [
pipeline('check') {
workspace: {
base: "/go",
path: "src/github.com/grafana/loki"
},
steps: [
make('test', container=false) { depends_on: ['clone'] },
make('lint', container=false) { depends_on: ['clone'] },
make('check-generated-files', container=false) { depends_on: ['clone'] },
],
},
] + [
multiarch_image(arch)
for arch in archs
] + [
Expand Down
32 changes: 32 additions & 0 deletions .drone/drone.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
kind: pipeline
name: check
steps:
- commands:
- make BUILD_IN_CONTAINER=false test
depends_on:
- clone
image: grafana/loki-build-image:0.5.0
name: test
- commands:
- make BUILD_IN_CONTAINER=false lint
depends_on:
- clone
image: grafana/loki-build-image:0.5.0
name: lint
- commands:
- make BUILD_IN_CONTAINER=false check-generated-files
depends_on:
- clone
image: grafana/loki-build-image:0.5.0
name: check-generated-files
workspace:
base: /go
path: src/github.com/grafana/loki
---
depends_on:
- check
kind: pipeline
name: docker-amd64
platform:
arch: amd64
Expand Down Expand Up @@ -113,6 +140,8 @@ steps:
- refs/heads/master
- refs/tags/v*
---
depends_on:
- check
kind: pipeline
name: docker-arm64
platform:
Expand Down Expand Up @@ -228,6 +257,8 @@ steps:
- refs/heads/master
- refs/tags/v*
---
depends_on:
- check
kind: pipeline
name: docker-arm
platform:
Expand Down Expand Up @@ -347,6 +378,7 @@ depends_on:
- docker-amd64
- docker-arm64
- docker-arm
- check
kind: pipeline
name: manifest
steps:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -441,4 +441,4 @@ benchmark-store:

# regenerate drone yaml
drone:
jsonnet .drone/drone.jsonnet | jq .drone -r | yq -y . > .drone/drone.yml
jsonnet -V __build-image-version=$(BUILD_IMAGE_VERSION) .drone/drone.jsonnet | jq .drone -r | yq -y . > .drone/drone.yml

0 comments on commit 9e2f2c5

Please sign in to comment.