From ed589b91645725158294b258156475950bb3416c Mon Sep 17 00:00:00 2001 From: Sam Therapy Date: Sat, 17 Sep 2022 01:20:59 +0200 Subject: [PATCH] [SKIP CI] ci: add caching Signed-off-by: Sam Therapy --- .drone.jsonnet | 142 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 97 insertions(+), 45 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 95a30fb..e692f51 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,92 +1,144 @@ // SPDX-License-Identifier: BSD-3-Clause local testing(version, arch) = { - kind: "pipeline", - type: "docker", - name: version + "-" + arch , + kind: 'pipeline', + type: 'docker', + name: version + '-' + arch, platform: { - arch: arch + arch: arch, }, steps: [ { - name: "lint", - image: "rancher/drone-golangci-lint:latest", + name: 'lint', + image: 'rancher/drone-golangci-lint:latest', }, { - name: "test", - image: "golang:" + version, + name: 'cache', + image: 'golang:' + version, commands: [ - "make test-ci" + 'go mod tidy' ], depends_on: [ - "lint", + 'lint', + ], + volumes: [ + { + name: 'cache', + path: '/go', + }, ], }, { - name: "fuzz", - image: "golang:" + version, + name: 'test', + image: 'golang:' + version, commands: [ - "make fuzz-ci", + 'make test-ci', ], depends_on: [ - "lint", + 'cache', + ], + volumes: [ + { + name: 'cache', + path: '/go', + }, + ], + }, + { + name: 'fuzz', + image: 'golang:' + version, + commands: [ + 'make fuzz-ci', + ], + depends_on: [ + 'cache', + ], + volumes: [ + { + name: 'cache', + path: '/go', + }, ], }, ], trigger: { event: { exclude: [ - "tag" + 'tag', ], - } + }, }, + volumes: [ + { + name: 'cache', + temp: {}, + }, + ], }; // "Inspired by" https://goreleaser.com/ci/drone/ local release() = { - kind: "pipeline", - type: "docker", - name: "release", + kind: 'pipeline', + type: 'docker', + name: 'release', trigger: { event: [ - "tag" + 'tag', ], }, steps: [ { - name: "fetch", - image: "alpine/git", - commands : [ - "git fetch --tags", - ] - }, - { - name: "test", - image: "golang", + name: 'fetch', + image: 'alpine/git', commands: [ - "make test-ci" - ] + 'git fetch --tags', + ], }, { - name: "release", - image: "goreleaser/goreleaser", + name: 'test', + image: 'golang', + commands: [ + 'make test-ci', + ], + volumes: [ + { + name: 'cache', + path: '/go', + }, + ], + }, + { + name: 'release', + image: 'goreleaser/goreleaser', environment: { - "GITEA_TOKEN": { - from_secret: "GITEA_TOKEN" - } + GITEA_TOKEN: { + from_secret: 'GITEA_TOKEN', + }, }, commands: [ - "goreleaser release" + 'goreleaser release', ], - } - ] + volumes: [ + { + name: 'cache', + path: '/go', + }, + ], + }, + ], + volumes: [ + { + name: 'cache', + temp: {}, + }, + ], }; [ - testing("1.19", "amd64"), - testing("1.19", "arm64"), - testing("1.18", "amd64"), - testing("1.18", "arm64"), + testing('1.19', 'amd64'), + testing('1.19', 'arm64'), + testing('1.18', 'amd64'), + testing('1.18', 'arm64'), - release() -] \ No newline at end of file + release(), +]