url-parser/.drone.jsonnet

211 lines
4.5 KiB
Plaintext
Raw Permalink Normal View History

2020-09-21 18:24:51 +00:00
local PipelineTest = {
kind: 'pipeline',
2020-11-28 12:49:44 +00:00
image_pull_secrets: ['docker_config'],
2020-09-21 18:24:51 +00:00
name: 'test',
platform: {
os: 'linux',
arch: 'amd64',
},
steps: [
{
name: 'staticcheck',
image: 'golang:1.16',
2020-09-21 18:24:51 +00:00
commands: [
'go run honnef.co/go/tools/cmd/staticcheck ./...',
],
volumes: [
{
name: 'gopath',
path: '/go',
},
],
},
{
name: 'lint',
image: 'golang:1.16',
2020-09-21 18:24:51 +00:00
commands: [
'go run golang.org/x/lint/golint -set_exit_status ./...',
],
volumes: [
{
name: 'gopath',
path: '/go',
},
],
},
{
name: 'vet',
image: 'golang:1.16',
2020-09-21 18:24:51 +00:00
commands: [
'go vet ./...',
],
volumes: [
{
name: 'gopath',
path: '/go',
},
],
},
{
name: 'test',
image: 'golang:1.16',
2020-09-21 18:24:51 +00:00
commands: [
'go test -race -coverprofile=coverage.txt -covermode=atomic ./...',
],
volumes: [
{
name: 'gopath',
path: '/go',
},
],
},
{
name: 'coverage',
image: 'plugins/codecov',
settings: {
token: {
from_secret: 'codecov_token',
},
files: [
'coverage.txt',
],
},
},
],
volumes: [
{
name: 'gopath',
temp: {},
},
],
trigger: {
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
2020-09-21 18:24:51 +00:00
},
};
local PipelineBuildBinaries = {
kind: 'pipeline',
2020-11-28 12:49:44 +00:00
image_pull_secrets: ['docker_config'],
2020-09-21 18:24:51 +00:00
name: 'build-binaries',
platform: {
os: 'linux',
arch: 'amd64',
},
steps: [
{
name: 'build',
image: 'techknowlogick/xgo:go-1.16.x',
2020-09-21 18:24:51 +00:00
commands: [
'[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}',
'mkdir -p release/',
2021-02-15 20:20:08 +00:00
"cd cmd/url-parser && xgo -ldflags \"-s -w -X main.version=$BUILD_VERSION\" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out url-parser .",
2020-09-21 18:24:51 +00:00
'mv /build/* /drone/src/release/',
2021-02-15 20:20:08 +00:00
'ls -l /drone/src/release/',
2020-09-21 18:24:51 +00:00
],
},
{
name: 'executable',
image: 'alpine',
commands: [
2020-09-21 18:29:21 +00:00
'$(find release/ -executable -type f | grep url-parser-linux-amd64) --help',
2020-09-21 18:24:51 +00:00
],
},
{
name: 'compress',
image: 'alpine',
commands: [
'apk add upx',
'find release/ -maxdepth 1 -executable -type f -exec upx {} \\;',
'ls -lh release/',
],
},
{
name: 'checksum',
image: 'alpine',
commands: [
'cd release/ && sha256sum * > sha256sum.txt',
],
},
2021-02-15 20:18:08 +00:00
{
name: 'changelog-generate',
2021-02-15 20:18:08 +00:00
image: 'thegeeklab/git-chglog',
commands: [
'git fetch -tq',
'git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased}',
],
},
{
name: 'changelog-format',
image: 'thegeeklab/alpine-tools',
commands: [
'prettier CHANGELOG.md',
'prettier -w CHANGELOG.md',
],
},
2020-09-21 18:24:51 +00:00
{
name: 'publish',
image: 'plugins/github-release',
settings: {
overwrite: true,
api_key: {
from_secret: 'github_token',
},
files: ['release/*'],
title: '${DRONE_TAG}',
note: 'CHANGELOG.md',
},
when: {
ref: [
'refs/tags/**',
],
},
},
],
depends_on: [
'test',
],
trigger: {
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
2020-09-21 18:24:51 +00:00
},
};
local PipelineNotifications = {
kind: 'pipeline',
2020-11-28 12:49:44 +00:00
image_pull_secrets: ['docker_config'],
2020-09-21 18:24:51 +00:00
name: 'notifications',
platform: {
os: 'linux',
arch: 'amd64',
},
steps: [
{
name: 'matrix',
image: 'thegeeklab/drone-matrix',
2020-09-21 18:24:51 +00:00
settings: {
homeserver: { from_secret: 'matrix_homeserver' },
roomid: { from_secret: 'matrix_roomid' },
2021-09-22 07:57:45 +00:00
template: 'Status: **{{ build.Status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}){{#if build.Branch}} ({{ build.Branch }}){{/if}} by {{ commit.Author }}<br/> Message: {{ commit.Message.Title }}',
2020-09-21 18:24:51 +00:00
username: { from_secret: 'matrix_username' },
password: { from_secret: 'matrix_password' },
},
when: {
status: ['success', 'failure'],
},
},
],
depends_on: [
'build-binaries',
],
trigger: {
ref: ['refs/heads/main', 'refs/tags/**'],
2020-09-21 18:24:51 +00:00
status: ['success', 'failure'],
},
};
[
PipelineTest,
PipelineBuildBinaries,
PipelineNotifications,
]