From 6a9557a1e005eb346376170a2596950f2a10c188 Mon Sep 17 00:00:00 2001 From: Julien Duchesne Date: Mon, 27 Jun 2022 09:53:18 -0400 Subject: [PATCH] Add Drone pipeline to test packaging (#6482) * Add Drone pipeline to test packaging Currently, the packaging process only happens on tags, which could lead to surprises Especially considering I'm working on deb and RPM packaging (lots more steps than now) I also moved the publishing from Circle to Drone because: 1. I'll need some new secrets from Vault 2. It should be faster * Fix make target * Remove `-parallel` arg for `gox` --- .circleci/config.yml | 11 ----------- .drone/drone.jsonnet | 24 +++++++++++++++++++++--- .drone/drone.yml | 30 +++++++++++++++++++++++++++++- Makefile | 5 ++--- tools/nfpm.yaml | 2 +- tools/release | 8 ++++---- tools/release-note.md | 8 ++++---- 7 files changed, 61 insertions(+), 27 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 715bbb3ed52f1..18655765e8e6f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -32,10 +32,6 @@ workflows: requires: [test] filters: { <<: *tag-or-main } - - publish/binaries: - requires: [test] - filters: { <<: *only-tags } - # https://circleci.com/blog/circleci-hacks-reuse-yaml-in-your-circleci-config-with-yaml/ .defaults: &defaults @@ -81,10 +77,3 @@ jobs: name: docker-driver command: make docker-driver-push - publish/binaries: - <<: *defaults - steps: - - checkout - - run: - name: github release - command: make BUILD_IN_CONTAINER=false publish diff --git a/.drone/drone.jsonnet b/.drone/drone.jsonnet index 165ae41385ff8..f5e2d3ff529d5 100644 --- a/.drone/drone.jsonnet +++ b/.drone/drone.jsonnet @@ -496,13 +496,11 @@ local manifest_ecr(apps, archs) = pipeline('manifest-ecr') { fluentd(), logstash(), querytee(), -] + [ manifest(['promtail', 'loki', 'loki-canary']) { trigger: condition('include').tagMain { event: ['push', 'tag'], }, }, -] + [ pipeline('deploy') { trigger: condition('include').tagMain { event: ['push', 'tag'], @@ -533,7 +531,27 @@ local manifest_ecr(apps, archs) = pipeline('manifest-ecr') { }, ], }, -] + [promtail_win()] + promtail_win(), + pipeline('release') { + trigger: { + event: ['pull_request', 'tag'], + }, + image_pull_secrets: [pull_secret.name], + steps: [ + run( + 'test packaging', + commands=['make BUILD_IN_CONTAINER=false packages'] + ) { when: { event: ['pull_request'] } }, + run( + 'publish', + commands=['make BUILD_IN_CONTAINER=false publish'], + env={ + GITHUB_TOKEN: { from_secret: github_secret.name }, + } + ) { when: { event: ['tag'] } }, + ], + }, +] + [ lambda_promtail(arch) for arch in ['amd64', 'arm64'] diff --git a/.drone/drone.yml b/.drone/drone.yml index eaf10e6d3ff1e..5abb27ea0515b 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -1072,6 +1072,34 @@ trigger: - pull_request - tag --- +image_pull_secrets: +- dockerconfigjson +kind: pipeline +name: release +steps: +- commands: + - make BUILD_IN_CONTAINER=false packages + environment: {} + image: grafana/loki-build-image:0.21.0 + name: test packaging + when: + event: + - pull_request +- commands: + - make BUILD_IN_CONTAINER=false publish + environment: + GITHUB_TOKEN: + from_secret: github_token + image: grafana/loki-build-image:0.21.0 + name: publish + when: + event: + - tag +trigger: + event: + - pull_request + - tag +--- depends_on: - check kind: pipeline @@ -1285,6 +1313,6 @@ kind: secret name: deploy_config --- kind: signature -hmac: 8335495d285498f513bb265cf90079175c25f5b6c5717deab7abfae65341726a +hmac: e56633097c3edb68fc784f2059f5c773f02ac485750610aaff59b43eb1417c5b ... diff --git a/Makefile b/Makefile index c44ad2971ca0c..533ef4f125e38 100644 --- a/Makefile +++ b/Makefile @@ -245,9 +245,8 @@ cmd/migrate/migrate: ############# # Releasing # ############# -# concurrency is limited to 2 to prevent CircleCI from OOMing. Sorry -GOX = gox $(GO_FLAGS) -parallel=2 -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" -CGO_GOX = gox $(DYN_GO_FLAGS) -cgo -parallel=2 -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" +GOX = gox $(GO_FLAGS) -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" +CGO_GOX = gox $(DYN_GO_FLAGS) -cgo -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" dist: clean CGO_ENABLED=0 $(GOX) -osarch="linux/amd64 linux/arm64 linux/arm darwin/amd64 darwin/arm64 windows/amd64 freebsd/amd64" ./cmd/loki CGO_ENABLED=0 $(GOX) -osarch="linux/amd64 linux/arm64 linux/arm darwin/amd64 darwin/arm64 windows/amd64 freebsd/amd64" ./cmd/logcli diff --git a/tools/nfpm.yaml b/tools/nfpm.yaml index 09d18e4be2f34..4d3ed3d93fef0 100644 --- a/tools/nfpm.yaml +++ b/tools/nfpm.yaml @@ -2,7 +2,7 @@ name: "logcli" arch: "amd64" platform: "linux" -version: ${CIRCLE_TAG} +version: ${DRONE_TAG} section: "default" provides: - logcli diff --git a/tools/release b/tools/release index 180778a53b113..6f3c201263685 100755 --- a/tools/release +++ b/tools/release @@ -1,9 +1,9 @@ #!/usr/bin/env bash ghr \ -t "${GITHUB_TOKEN}" \ - -u "${CIRCLE_PROJECT_USERNAME}" \ - -r "${CIRCLE_PROJECT_REPONAME}" \ - -c "${CIRCLE_SHA1}" \ + -u "${DRONE_REPO_OWNER}" \ + -r "${DRONE_REPO_NAME}" \ + -c "${DRONE_COMMIT}" \ -b="$(cat ./tools/release-note.md | envsubst)" \ -delete -draft \ - "${CIRCLE_TAG}" ./dist/ + "${DRONE_TAG}" ./dist/ diff --git a/tools/release-note.md b/tools/release-note.md index e80ec837f17f5..4772246fcea00 100644 --- a/tools/release-note.md +++ b/tools/release-note.md @@ -1,4 +1,4 @@ -This is release `${CIRCLE_TAG}` of Loki. +This is release `${DRONE_TAG}` of Loki. ### Notable changes: :warning: **ADD RELEASE NOTES HERE** :warning: @@ -11,8 +11,8 @@ The components of Loki are currently distributed in plain binary form and as Doc * https://hub.docker.com/r/grafana/loki * https://hub.docker.com/r/grafana/promtail ```bash -$ docker pull "grafana/loki:${CIRCLE_TAG}" -$ docker pull "grafana/promtail:${CIRCLE_TAG}" +$ docker pull "grafana/loki:${DRONE_TAG}" +$ docker pull "grafana/promtail:${DRONE_TAG}" ``` #### Binary @@ -21,7 +21,7 @@ Choose from the assets below for the application and architecture matching your Example for `Loki` on the `linux` operating system and `amd64` architecture: ```bash -$ curl -O -L "https://github.com/grafana/loki/releases/download/${CIRCLE_TAG}/loki-linux-amd64.zip" +$ curl -O -L "https://github.com/grafana/loki/releases/download/${DRONE_TAG}/loki-linux-amd64.zip" # extract the binary $ unzip "loki-linux-amd64.zip" # make sure it is executable