ci: refactor build tools and ci setup (#31)

This commit is contained in:
Robert Kaussow 2022-04-25 12:55:06 +02:00 committed by GitHub
parent 72b6f2bd1a
commit 38c2f9e523
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 171 additions and 191 deletions

View File

@ -1,2 +1,2 @@
* *
!release/ !dist/

View File

@ -1,6 +1,5 @@
local PipelineTest = { local PipelineTest = {
kind: 'pipeline', kind: 'pipeline',
image_pull_secrets: ['docker_config'],
name: 'test', name: 'test',
platform: { platform: {
os: 'linux', os: 'linux',
@ -8,14 +7,14 @@ local PipelineTest = {
}, },
steps: [ steps: [
{ {
name: 'staticcheck', name: 'deps',
image: 'golang:1.18', image: 'golang:1.18',
commands: [ commands: [
'go run honnef.co/go/tools/cmd/staticcheck ./...', 'make deps',
], ],
volumes: [ volumes: [
{ {
name: 'gopath', name: 'godeps',
path: '/go', path: '/go',
}, },
], ],
@ -24,24 +23,11 @@ local PipelineTest = {
name: 'lint', name: 'lint',
image: 'golang:1.18', image: 'golang:1.18',
commands: [ commands: [
'go run golang.org/x/lint/golint -set_exit_status ./...', 'make lint',
], ],
volumes: [ volumes: [
{ {
name: 'gopath', name: 'godeps',
path: '/go',
},
],
},
{
name: 'vet',
image: 'golang:1.18',
commands: [
'go vet ./...',
],
volumes: [
{
name: 'gopath',
path: '/go', path: '/go',
}, },
], ],
@ -50,11 +36,11 @@ local PipelineTest = {
name: 'test', name: 'test',
image: 'golang:1.18', image: 'golang:1.18',
commands: [ commands: [
'go test -cover ./...', 'make test',
], ],
volumes: [ volumes: [
{ {
name: 'gopath', name: 'godeps',
path: '/go', path: '/go',
}, },
], ],
@ -62,7 +48,7 @@ local PipelineTest = {
], ],
volumes: [ volumes: [
{ {
name: 'gopath', name: 'godeps',
temp: {}, temp: {},
}, },
], ],
@ -74,7 +60,6 @@ local PipelineTest = {
local PipelineBuildBinaries = { local PipelineBuildBinaries = {
kind: 'pipeline', kind: 'pipeline',
image_pull_secrets: ['docker_config'],
name: 'build-binaries', name: 'build-binaries',
platform: { platform: {
os: 'linux', os: 'linux',
@ -85,34 +70,14 @@ local PipelineBuildBinaries = {
name: 'build', name: 'build',
image: 'techknowlogick/xgo:go-1.18.x', image: 'techknowlogick/xgo:go-1.18.x',
commands: [ commands: [
'[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}', 'make release',
'mkdir -p release/',
"cd cmd/drone-matrix && xgo -ldflags \"-s -w -X main.version=$BUILD_VERSION\" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out drone-matrix .",
'mv /build/* /drone/src/release/',
'ls -l /drone/src/release/',
], ],
}, },
{ {
name: 'executable', name: 'executable',
image: 'alpine', image: 'alpine',
commands: [ commands: [
'$(find release/ -executable -type f | grep drone-matrix-linux-amd64) --help', '$(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help',
],
},
{
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',
], ],
}, },
{ {
@ -139,7 +104,7 @@ local PipelineBuildBinaries = {
api_key: { api_key: {
from_secret: 'github_token', from_secret: 'github_token',
}, },
files: ['release/*'], files: ['dist/*'],
title: '${DRONE_TAG}', title: '${DRONE_TAG}',
note: 'CHANGELOG.md', note: 'CHANGELOG.md',
}, },
@ -160,7 +125,6 @@ local PipelineBuildBinaries = {
local PipelineBuildContainer(arch='amd64') = { local PipelineBuildContainer(arch='amd64') = {
kind: 'pipeline', kind: 'pipeline',
image_pull_secrets: ['docker_config'],
name: 'build-container-' + arch, name: 'build-container-' + arch,
platform: { platform: {
os: 'linux', os: 'linux',
@ -171,20 +135,16 @@ local PipelineBuildContainer(arch='amd64') = {
name: 'build', name: 'build',
image: 'golang:1.18', image: 'golang:1.18',
commands: [ commands: [
'[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}', 'make build',
'go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/' + arch + '/drone-matrix ./cmd/drone-matrix',
], ],
}, },
{ {
name: 'dryrun', name: 'dryrun',
image: 'thegeeklab/drone-docker:19', image: 'thegeeklab/drone-docker:19',
settings: { settings: {
config: { from_secret: 'docker_config' },
dry_run: true, dry_run: true,
dockerfile: 'docker/Dockerfile.' + arch, dockerfile: 'docker/Dockerfile.' + arch,
repo: 'thegeeklab/${DRONE_REPO_NAME}', repo: 'thegeeklab/${DRONE_REPO_NAME}',
username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' },
}, },
depends_on: ['build'], depends_on: ['build'],
when: { when: {
@ -195,7 +155,6 @@ local PipelineBuildContainer(arch='amd64') = {
name: 'publish-dockerhub', name: 'publish-dockerhub',
image: 'thegeeklab/drone-docker:19', image: 'thegeeklab/drone-docker:19',
settings: { settings: {
config: { from_secret: 'docker_config' },
auto_tag: true, auto_tag: true,
auto_tag_suffix: arch, auto_tag_suffix: arch,
dockerfile: 'docker/Dockerfile.' + arch, dockerfile: 'docker/Dockerfile.' + arch,
@ -212,7 +171,6 @@ local PipelineBuildContainer(arch='amd64') = {
name: 'publish-quay', name: 'publish-quay',
image: 'thegeeklab/drone-docker:19', image: 'thegeeklab/drone-docker:19',
settings: { settings: {
config: { from_secret: 'docker_config' },
auto_tag: true, auto_tag: true,
auto_tag_suffix: arch, auto_tag_suffix: arch,
dockerfile: 'docker/Dockerfile.' + arch, dockerfile: 'docker/Dockerfile.' + arch,
@ -292,7 +250,6 @@ local PipelineDocs = {
local PipelineNotifications = { local PipelineNotifications = {
kind: 'pipeline', kind: 'pipeline',
image_pull_secrets: ['docker_config'],
name: 'notifications', name: 'notifications',
platform: { platform: {
os: 'linux', os: 'linux',

View File

@ -7,45 +7,34 @@ platform:
arch: amd64 arch: amd64
steps: steps:
- name: staticcheck - name: deps
image: golang:1.18 image: golang:1.18
commands: commands:
- go run honnef.co/go/tools/cmd/staticcheck ./... - make deps
volumes: volumes:
- name: gopath - name: godeps
path: /go path: /go
- name: lint - name: lint
image: golang:1.18 image: golang:1.18
commands: commands:
- go run golang.org/x/lint/golint -set_exit_status ./... - make lint
volumes: volumes:
- name: gopath - name: godeps
path: /go
- name: vet
image: golang:1.18
commands:
- go vet ./...
volumes:
- name: gopath
path: /go path: /go
- name: test - name: test
image: golang:1.18 image: golang:1.18
commands: commands:
- go test -cover ./... - make test
volumes: volumes:
- name: gopath - name: godeps
path: /go path: /go
volumes: volumes:
- name: gopath - name: godeps
temp: {} temp: {}
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
@ -64,28 +53,12 @@ steps:
- name: build - name: build
image: techknowlogick/xgo:go-1.18.x image: techknowlogick/xgo:go-1.18.x
commands: commands:
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}" - make release
- mkdir -p release/
- cd cmd/drone-matrix && xgo -ldflags "-s -w -X main.version=$BUILD_VERSION" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out drone-matrix .
- mv /build/* /drone/src/release/
- ls -l /drone/src/release/
- name: executable - name: executable
image: alpine image: alpine
commands: commands:
- $(find release/ -executable -type f | grep drone-matrix-linux-amd64) --help - $(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help
- 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
- name: changelog-generate - name: changelog-generate
image: thegeeklab/git-chglog image: thegeeklab/git-chglog
@ -105,7 +78,7 @@ steps:
api_key: api_key:
from_secret: github_token from_secret: github_token
files: files:
- release/* - dist/*
note: CHANGELOG.md note: CHANGELOG.md
overwrite: true overwrite: true
title: ${DRONE_TAG} title: ${DRONE_TAG}
@ -113,9 +86,6 @@ steps:
ref: ref:
- refs/tags/** - refs/tags/**
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
@ -137,21 +107,14 @@ steps:
- name: build - name: build
image: golang:1.18 image: golang:1.18
commands: commands:
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}" - make build
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/amd64/drone-matrix ./cmd/drone-matrix
- name: dryrun - name: dryrun
image: thegeeklab/drone-docker:19 image: thegeeklab/drone-docker:19
settings: settings:
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.amd64 dockerfile: docker/Dockerfile.amd64
dry_run: true dry_run: true
password:
from_secret: docker_password
repo: thegeeklab/${DRONE_REPO_NAME} repo: thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: docker_username
when: when:
ref: ref:
- refs/pull/** - refs/pull/**
@ -163,8 +126,6 @@ steps:
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: amd64 auto_tag_suffix: amd64
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.amd64 dockerfile: docker/Dockerfile.amd64
password: password:
from_secret: docker_password from_secret: docker_password
@ -183,8 +144,6 @@ steps:
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: amd64 auto_tag_suffix: amd64
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.amd64 dockerfile: docker/Dockerfile.amd64
password: password:
from_secret: quay_password from_secret: quay_password
@ -199,9 +158,6 @@ steps:
depends_on: depends_on:
- dryrun - dryrun
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
@ -223,21 +179,14 @@ steps:
- name: build - name: build
image: golang:1.18 image: golang:1.18
commands: commands:
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}" - make build
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm64/drone-matrix ./cmd/drone-matrix
- name: dryrun - name: dryrun
image: thegeeklab/drone-docker:19 image: thegeeklab/drone-docker:19
settings: settings:
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.arm64 dockerfile: docker/Dockerfile.arm64
dry_run: true dry_run: true
password:
from_secret: docker_password
repo: thegeeklab/${DRONE_REPO_NAME} repo: thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: docker_username
when: when:
ref: ref:
- refs/pull/** - refs/pull/**
@ -249,8 +198,6 @@ steps:
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: arm64 auto_tag_suffix: arm64
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.arm64 dockerfile: docker/Dockerfile.arm64
password: password:
from_secret: docker_password from_secret: docker_password
@ -269,8 +216,6 @@ steps:
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: arm64 auto_tag_suffix: arm64
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.arm64 dockerfile: docker/Dockerfile.arm64
password: password:
from_secret: quay_password from_secret: quay_password
@ -285,9 +230,6 @@ steps:
depends_on: depends_on:
- dryrun - dryrun
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
@ -309,21 +251,14 @@ steps:
- name: build - name: build
image: golang:1.18 image: golang:1.18
commands: commands:
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}" - make build
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm/drone-matrix ./cmd/drone-matrix
- name: dryrun - name: dryrun
image: thegeeklab/drone-docker:19 image: thegeeklab/drone-docker:19
settings: settings:
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.arm dockerfile: docker/Dockerfile.arm
dry_run: true dry_run: true
password:
from_secret: docker_password
repo: thegeeklab/${DRONE_REPO_NAME} repo: thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: docker_username
when: when:
ref: ref:
- refs/pull/** - refs/pull/**
@ -335,8 +270,6 @@ steps:
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: arm auto_tag_suffix: arm
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.arm dockerfile: docker/Dockerfile.arm
password: password:
from_secret: docker_password from_secret: docker_password
@ -355,8 +288,6 @@ steps:
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: arm auto_tag_suffix: arm
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.arm dockerfile: docker/Dockerfile.arm
password: password:
from_secret: quay_password from_secret: quay_password
@ -371,9 +302,6 @@ steps:
depends_on: depends_on:
- dryrun - dryrun
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
@ -513,9 +441,6 @@ steps:
- success - success
- failure - failure
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
@ -529,6 +454,6 @@ depends_on:
--- ---
kind: signature kind: signature
hmac: c6f1ed11d885e74ecf6b70f55f4de834c69fafc48e8e28d381ee10d3fb8d9757 hmac: 08707ab293e9a34853d2568004f486b98ec758581ada47e84cadd6b4bfeb29ab
... ...

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/dist/
/release/ /release/
/drone-matrix* /drone-matrix*

31
.golangci.yml Normal file
View File

@ -0,0 +1,31 @@
linters:
enable:
- gosimple
- deadcode
- typecheck
- govet
- errcheck
- staticcheck
- unused
- structcheck
- varcheck
- dupl
- gofmt
- misspell
- gocritic
- bidichk
- ineffassign
- revive
- gofumpt
- depguard
enable-all: false
disable-all: true
fast: false
run:
timeout: 3m
linters-settings:
gofumpt:
extra-rules: true
lang-version: "1.18"

96
Makefile Normal file
View File

@ -0,0 +1,96 @@
# renovate: datasource=github-releases depName=mvdan/gofumpt
GOFUMPT_PACKAGE_VERSION := v0.3.1
# renovate: datasource=github-releases depName=golangci/golangci-lint
GOLANGCI_LINT_PACKAGE_VERSION := v1.45.2
EXECUTABLE := drone-matrix
DIST := dist
DIST_DIRS := $(DIST)
IMPORT := github.com/thegeeklab/$(EXECUTABLE)
GO ?= go
CWD ?= $(shell pwd)
PACKAGES ?= $(shell go list ./...)
SOURCES ?= $(shell find . -name "*.go" -type f)
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@$(GOFUMPT_PACKAGE_VERSION)
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_PACKAGE_VERSION)
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
GENERATE ?=
XGO_VERSION := go-1.18.x
XGO_TARGETS ?= linux/amd64,linux/arm-6,linux/arm-7,linux/arm64
TAGS ?= netgo
ifndef VERSION
ifneq ($(DRONE_TAG),)
VERSION ?= $(subst v,,$(DRONE_TAG))
else
VERSION ?= $(shell git rev-parse --short HEAD)
endif
endif
ifndef DATE
DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%S%z")
endif
LDFLAGS += -s -w -X "main.BuildVersion=$(VERSION)" -X "main.BuildDate=$(DATE)"
.PHONY: all
all: clean build
.PHONY: clean
clean:
$(GO) clean -i ./...
rm -rf $(DIST_DIRS)
.PHONY: fmt
fmt:
$(GO) run $(GOFUMPT_PACKAGE) -extra -w $(SOURCES)
.PHONY: golangci-lint
golangci-lint:
$(GO) run $(GOLANGCI_LINT_PACKAGE) run
.PHONY: lint
lint: golangci-lint
.PHONY: generate
generate:
$(GO) generate $(GENERATE)
.PHONY: test
test:
$(GO) test -v -coverprofile coverage.out $(PACKAGES)
.PHONY: build
build: $(DIST)/$(EXECUTABLE)
$(DIST)/$(EXECUTABLE): $(SOURCES)
$(GO) build -v -tags '$(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -o $@ ./cmd/$(EXECUTABLE)
$(DIST_DIRS):
mkdir -p $(DIST_DIRS)
.PHONY: xgo
xgo: | $(DIST_DIRS)
$(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -v -ldflags '-extldflags "-static" $(LDFLAGS)' -tags '$(TAGS)' -targets '$(XGO_TARGETS)' -out $(EXECUTABLE) --pkg cmd/$(EXECUTABLE) .
cp /build/* $(CWD)/$(DIST)
ls -l $(CWD)/$(DIST)
.PHONY: checksum
checksum:
cd $(DIST); $(foreach file,$(wildcard $(DIST)/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
ls -l $(CWD)/$(DIST)
.PHONY: release
release: xgo checksum
.PHONY: deps
deps:
$(GO) mod download
$(GO) install $(GOFUMPT_PACKAGE)
$(GO) install $(GOLANGCI_LINT_PACKAGE)
$(GO) install $(XGO_PACKAGE)

View File

@ -27,7 +27,7 @@ export GOARCH=amd64
export CGO_ENABLED=0 export CGO_ENABLED=0
export GO111MODULE=on export GO111MODULE=on
go build -v -a -tags netgo -o release/linux/amd64/drone-matrix make build
``` ```
Build the Docker image with the following command: Build the Docker image with the following command:

View File

@ -7,6 +7,7 @@
package main package main
import ( import (
"fmt"
"os" "os"
"github.com/drone-plugins/drone-matrix/plugin" "github.com/drone-plugins/drone-matrix/plugin"
@ -16,19 +17,26 @@ import (
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
) )
var version = "unknown" var (
BuildVersion = "devel"
BuildDate = "00000000"
)
func main() { func main() {
settings := &plugin.Settings{} settings := &plugin.Settings{}
if _, err := os.Stat("/run/drone/env"); err == nil { if _, err := os.Stat("/run/drone/env"); err == nil {
godotenv.Overload("/run/drone/env") _ = godotenv.Overload("/run/drone/env")
}
cli.VersionPrinter = func(c *cli.Context) {
fmt.Printf("%s version=%s date=%s\n", c.App.Name, c.App.Version, BuildDate)
} }
app := &cli.App{ app := &cli.App{
Name: "drone-matrix", Name: "drone-matrix",
Usage: "build notifications for matrix", Usage: "build notifications for matrix",
Version: version, Version: BuildVersion,
Flags: append(settingsFlags(settings), urfave.Flags()...), Flags: append(settingsFlags(settings), urfave.Flags()...),
Action: run(settings), Action: run(settings),
} }

View File

@ -1,8 +0,0 @@
// +build tools
package tools
import (
_ "golang.org/x/lint/golint"
_ "honnef.co/go/tools/cmd/staticcheck"
)

View File

@ -7,5 +7,5 @@ LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-matrix"
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-matrix" LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-matrix"
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-matrix" LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-matrix"
ADD release/amd64/drone-matrix /bin/ ADD dist/drone-matrix /bin/
ENTRYPOINT [ "/bin/drone-matrix" ] ENTRYPOINT [ "/bin/drone-matrix" ]

View File

@ -7,5 +7,5 @@ LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-matrix"
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-matrix" LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-matrix"
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-matrix" LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-matrix"
ADD release/arm/drone-matrix /bin/ ADD dist/drone-matrix /bin/
ENTRYPOINT [ "/bin/drone-matrix" ] ENTRYPOINT [ "/bin/drone-matrix" ]

View File

@ -7,5 +7,5 @@ LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-matrix"
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-matrix" LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-matrix"
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-matrix" LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-matrix"
ADD release/arm64/drone-matrix /bin/ ADD dist/drone-matrix /bin/
ENTRYPOINT [ "/bin/drone-matrix" ] ENTRYPOINT [ "/bin/drone-matrix" ]

7
go.mod
View File

@ -10,12 +10,9 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 github.com/russross/blackfriday/v2 v2.1.0
github.com/thegeeklab/drone-template-lib/v2 v2.1.0 github.com/thegeeklab/drone-template-lib/v2 v2.1.0
github.com/urfave/cli/v2 v2.4.0 github.com/urfave/cli/v2 v2.4.0
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616
honnef.co/go/tools v0.3.0
) )
require ( require (
github.com/BurntSushi/toml v1.0.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.1.1 // indirect github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.2 // indirect github.com/Masterminds/sprig/v3 v3.2.2 // indirect
@ -32,10 +29,6 @@ require (
github.com/sirupsen/logrus v1.8.1 // indirect github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spf13/cast v1.4.1 // indirect github.com/spf13/cast v1.4.1 // indirect
golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064 // indirect golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064 // indirect
golang.org/x/exp/typeparams v0.0.0-20220328175248-053ad81199eb // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/net v0.0.0-20220325170049-de3da57026de // indirect golang.org/x/net v0.0.0-20220325170049-de3da57026de // indirect
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f // indirect golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f // indirect
golang.org/x/tools v0.1.11-0.20220330174940-8e193c2ba95e // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
) )

19
go.sum
View File

@ -1,6 +1,4 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
@ -71,20 +69,11 @@ github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2
github.com/urfave/cli/v2 v2.4.0 h1:m2pxjjDFgDxSPtO8WSdbndj17Wu2y8vOT86wE/tjr+I= github.com/urfave/cli/v2 v2.4.0 h1:m2pxjjDFgDxSPtO8WSdbndj17Wu2y8vOT86wE/tjr+I=
github.com/urfave/cli/v2 v2.4.0/go.mod h1:NX9W0zmTvedE5oDoOMs2RTC8RvdK98NTYZE5LbaEYPg= github.com/urfave/cli/v2 v2.4.0/go.mod h1:NX9W0zmTvedE5oDoOMs2RTC8RvdK98NTYZE5LbaEYPg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064 h1:S25/rfnfsMVgORT4/J61MJ7rdyseOZOyvLIrZEZ7s6s= golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064 h1:S25/rfnfsMVgORT4/J61MJ7rdyseOZOyvLIrZEZ7s6s=
golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp/typeparams v0.0.0-20220328175248-053ad81199eb h1:fP6C8Xutcp5AlakmT/SkQot0pMicROAsEX7OfNPuG10=
golang.org/x/exp/typeparams v0.0.0-20220328175248-053ad81199eb/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220325170049-de3da57026de h1:pZB1TWnKi+o4bENlbzAgLrEbY4RMYmUIRobMcSmfeYc= golang.org/x/net v0.0.0-20220325170049-de3da57026de h1:pZB1TWnKi+o4bENlbzAgLrEbY4RMYmUIRobMcSmfeYc=
golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
@ -102,12 +91,6 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.1.11-0.20220330174940-8e193c2ba95e h1:lVQAEpHVTmp9WjosvG0WcHRqP3JZv97KkBX4YDdaDfU=
golang.org/x/tools v0.1.11-0.20220330174940-8e193c2ba95e/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
@ -115,5 +98,3 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
honnef.co/go/tools v0.3.0 h1:2LdYUZ7CIxnYgskbUZfY7FPggmqnh6shBqfWa8Tn3XU=
honnef.co/go/tools v0.3.0/go.mod h1:vlRD9XErLMGT+mDuofSr0mMMquscM/1nQqtRSsh6m70=

View File

@ -36,7 +36,6 @@ func (p *Plugin) Validate() error {
// Execute provides the implementation of the plugin. // Execute provides the implementation of the plugin.
func (p *Plugin) Execute() error { func (p *Plugin) Execute() error {
m, err := gomatrix.NewClient(p.settings.Homeserver, prepend("@", p.settings.UserID), p.settings.AccessToken) m, err := gomatrix.NewClient(p.settings.Homeserver, prepend("@", p.settings.UserID), p.settings.AccessToken)
if err != nil { if err != nil {
return fmt.Errorf("failed to initialize client: %w", err) return fmt.Errorf("failed to initialize client: %w", err)
} }
@ -48,7 +47,6 @@ func (p *Plugin) Execute() error {
Password: p.settings.Password, Password: p.settings.Password,
InitialDeviceDisplayName: "Drone", InitialDeviceDisplayName: "Drone",
}) })
if err != nil { if err != nil {
return fmt.Errorf("failed to authenticate user: %w", err) return fmt.Errorf("failed to authenticate user: %w", err)
} }
@ -57,13 +55,11 @@ func (p *Plugin) Execute() error {
} }
joined, err := m.JoinRoom(prepend("!", p.settings.RoomID), "", nil) joined, err := m.JoinRoom(prepend("!", p.settings.RoomID), "", nil)
if err != nil { if err != nil {
return fmt.Errorf("failed to join room: %w", err) return fmt.Errorf("failed to join room: %w", err)
} }
message, err := template.RenderTrim(p.settings.Template, p.pipeline) message, err := template.RenderTrim(p.settings.Template, p.pipeline)
if err != nil { if err != nil {
return fmt.Errorf("failed to render template: %w", err) return fmt.Errorf("failed to render template: %w", err)
} }