Skip to content

Commit

Permalink
chore(ci/cd): breaking the circle (#990)
Browse files Browse the repository at this point in the history
* chore(ci/cd): breaking the circle

As the trial period for drone.io went really well (not a single failed build,
apart from merge-failures), I think it is time to make the switch to the new,
native ARM and much more performant platform.

This should fix all kinds of issues and be a solid architecture for the future
to level up our CI/CD in terms of performance and reliability.

* chore(packaging): drone.io check stage

Adds a check stage to the drone pipeline to lint and test
  • Loading branch information
sh0rez authored Sep 9, 2019
1 parent f6468f1 commit db8880e
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 179 deletions.
107 changes: 0 additions & 107 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,8 @@ workflows:
- lint: {filters: {<<: *tags}}
- test: {filters: {<<: *tags}}

- build/loki:
requires: [ lint, test ]
filters: {<<: *no-master}
- publish/loki:
requires: [ lint, test ]
filters: { <<: *tag-or-master }

- build/canary:
requires: [ lint, test ]
filters: {<<: *no-master}
- publish/canary:
requires: [ lint, test ]
filters: { <<: *tag-or-master }

- build/promtail:
requires: [ lint, test ]
filters: {<<: *no-master}
- build/promtail-windows:
requires: [ lint, test ]
- publish/promtail:
requires: [ lint, test ]
filters: { <<: *tag-or-master }

- build/docker-driver:
requires: [ lint, test ]
Expand All @@ -58,11 +38,6 @@ workflows:
filters: { <<: *only-tags }

- deploy:
requires:
- publish/loki
- publish/promtail
- publish/canary
- publish/docker-driver
filters: {<<: *tag-or-master}

- test-helm:
Expand All @@ -79,56 +54,6 @@ workflows:
- image: grafana/loki-build-image:0.5.0
working_directory: /go/src/github.com/grafana/loki

.machine: &machine
machine:
image: ubuntu-1604:201903-01
working_directory: ~/go/src/github.com/grafana/loki
environment:
APP: to-be-set
GOPATH: /home/circleci/go

.rootless: &rootless
run:
name: rootless
command: |
sudo apt-get update && \
sudo apt-get install -qy uidmap libseccomp-dev binfmt-support go-bindata
sudo docker run --privileged linuxkit/binfmt:v0.6
.img: &img
run:
name: img
# TODO: switch to https://github.com/genuinetools/img once 5a8119fb4ce7d712ca2ed589a345213fdf576268 is released
command: |
sudo curl -fSL "https://github.com/sh0rez/img/releases/download/v0.5.8/img-linux-amd64" -o "/usr/local/bin/img"
sudo chmod a+x "/usr/local/bin/img"
# builds a container
.container: &container
<<: *machine
steps:
- checkout
- <<: *rootless
- <<: *img
- run:
name: container
command: |
make $APP-image-cross
# builds and pushes a container
.publish: &publish
<<: *machine
steps:
- checkout
- <<: *rootless
- <<: *img
- run:
name: login
command: img login -u "$DOCKER_USER" -p "$DOCKER_PASS"
- run:
name: push image
command: make $APP-push

jobs:
test:
<<: *defaults
Expand All @@ -149,34 +74,7 @@ jobs:
name: Check Generated Files
command: make BUILD_IN_CONTAINER=false check-generated-files

# Loki
build/loki:
<<: *container
environment:
APP: loki

publish/loki:
<<: *publish
environment:
APP: loki

# Loki
build/canary:
<<: *container
environment:
APP: loki-canary

publish/canary:
<<: *publish
environment:
APP: loki-canary

# Promtail
build/promtail:
<<: *container
environment:
APP: promtail

build/promtail-windows:
<<: *defaults
steps:
Expand All @@ -185,11 +83,6 @@ jobs:
name: build
command: make GOOS=windows promtail

publish/promtail:
<<: *publish
environment:
APP: promtail

# Docker driver
build/docker-driver:
<<: *defaults
Expand Down
8 changes: 4 additions & 4 deletions .drone/docker-manifest.tmpl
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
image: grafanasaur/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}
image: grafana/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
- image: grafanasaur/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}-amd64
- image: grafana/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}-amd64
platform:
architecture: amd64
os: linux
- image: grafanasaur/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}-arm64
- image: grafana/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}-arm64
platform:
architecture: arm64
os: linux
variant: v8
- image: grafanasaur/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}-arm
- image: grafana/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}-arm
platform:
architecture: arm
os: linux
Expand Down
38 changes: 31 additions & 7 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,14 +21,24 @@ 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',
settings: {
repo: 'grafanasaur/%s' % app,
repo: 'grafana/%s' % app,
dockerfile: 'cmd/%s/Dockerfile' % app,
username: { from_secret: 'saur_username' },
password: { from_secret: 'saur_password' },
username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' },
dry_run: false,
},
};
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 @@ -73,21 +86,32 @@ local manifest(apps) = pipeline('manifest') {
target: app,
spec: '.drone/docker-manifest.tmpl',
ignore_missing: true,
username: { from_secret: 'saur_username' },
password: { from_secret: 'saur_password' },
username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' },
},
depends_on: ['clone'],
}
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
Loading

0 comments on commit db8880e

Please sign in to comment.