mirror of
https://github.com/thegeeklab/wp-github-comment.git
synced 2024-11-21 13:50:40 +00:00
ci: refactor build tools and ci setup (#95)
This commit is contained in:
parent
124a518772
commit
c7937fd44e
@ -1,2 +1,2 @@
|
||||
*
|
||||
!release/
|
||||
!dist/
|
||||
|
@ -1,6 +1,5 @@
|
||||
local PipelineTest = {
|
||||
kind: 'pipeline',
|
||||
image_pull_secrets: ['docker_config'],
|
||||
name: 'test',
|
||||
platform: {
|
||||
os: 'linux',
|
||||
@ -8,14 +7,14 @@ local PipelineTest = {
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: 'staticcheck',
|
||||
name: 'deps',
|
||||
image: 'golang:1.18',
|
||||
commands: [
|
||||
'go run honnef.co/go/tools/cmd/staticcheck ./...',
|
||||
'make deps',
|
||||
],
|
||||
volumes: [
|
||||
{
|
||||
name: 'gopath',
|
||||
name: 'godeps',
|
||||
path: '/go',
|
||||
},
|
||||
],
|
||||
@ -24,24 +23,11 @@ local PipelineTest = {
|
||||
name: 'lint',
|
||||
image: 'golang:1.18',
|
||||
commands: [
|
||||
'go run golang.org/x/lint/golint -set_exit_status ./...',
|
||||
'make lint',
|
||||
],
|
||||
volumes: [
|
||||
{
|
||||
name: 'gopath',
|
||||
path: '/go',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'vet',
|
||||
image: 'golang:1.18',
|
||||
commands: [
|
||||
'go vet ./...',
|
||||
],
|
||||
volumes: [
|
||||
{
|
||||
name: 'gopath',
|
||||
name: 'godeps',
|
||||
path: '/go',
|
||||
},
|
||||
],
|
||||
@ -50,11 +36,11 @@ local PipelineTest = {
|
||||
name: 'test',
|
||||
image: 'golang:1.18',
|
||||
commands: [
|
||||
'go test -cover ./...',
|
||||
'make test',
|
||||
],
|
||||
volumes: [
|
||||
{
|
||||
name: 'gopath',
|
||||
name: 'godeps',
|
||||
path: '/go',
|
||||
},
|
||||
],
|
||||
@ -62,7 +48,7 @@ local PipelineTest = {
|
||||
],
|
||||
volumes: [
|
||||
{
|
||||
name: 'gopath',
|
||||
name: 'godeps',
|
||||
temp: {},
|
||||
},
|
||||
],
|
||||
@ -74,7 +60,6 @@ local PipelineTest = {
|
||||
|
||||
local PipelineBuildBinaries = {
|
||||
kind: 'pipeline',
|
||||
image_pull_secrets: ['docker_config'],
|
||||
name: 'build-binaries',
|
||||
platform: {
|
||||
os: 'linux',
|
||||
@ -85,34 +70,14 @@ local PipelineBuildBinaries = {
|
||||
name: 'build',
|
||||
image: 'techknowlogick/xgo:go-1.18.x',
|
||||
commands: [
|
||||
'[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}',
|
||||
'mkdir -p release/',
|
||||
"cd cmd/drone-github-comment && xgo -ldflags \"-s -w -X main.version=$BUILD_VERSION\" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out drone-github-comment .",
|
||||
'mv /build/* /drone/src/release/',
|
||||
'ls -l /drone/src/release/',
|
||||
'make release',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'executable',
|
||||
image: 'alpine',
|
||||
commands: [
|
||||
'$(find release/ -executable -type f | grep drone-github-comment-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',
|
||||
'$(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help',
|
||||
],
|
||||
},
|
||||
{
|
||||
@ -139,7 +104,7 @@ local PipelineBuildBinaries = {
|
||||
api_key: {
|
||||
from_secret: 'github_token',
|
||||
},
|
||||
files: ['release/*'],
|
||||
files: ['dist/*'],
|
||||
title: '${DRONE_TAG}',
|
||||
note: 'CHANGELOG.md',
|
||||
},
|
||||
@ -160,7 +125,6 @@ local PipelineBuildBinaries = {
|
||||
|
||||
local PipelineBuildContainer(arch='amd64') = {
|
||||
kind: 'pipeline',
|
||||
image_pull_secrets: ['docker_config'],
|
||||
name: 'build-container-' + arch,
|
||||
platform: {
|
||||
os: 'linux',
|
||||
@ -171,20 +135,17 @@ local PipelineBuildContainer(arch='amd64') = {
|
||||
name: 'build',
|
||||
image: 'golang:1.18',
|
||||
commands: [
|
||||
'[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}',
|
||||
'go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/' + arch + '/drone-github-comment ./cmd/drone-github-comment',
|
||||
'make build',
|
||||
'ls -l dist/drone-github-comment',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'dryrun',
|
||||
image: 'thegeeklab/drone-docker:19',
|
||||
settings: {
|
||||
config: { from_secret: 'docker_config' },
|
||||
dry_run: true,
|
||||
dockerfile: 'docker/Dockerfile.' + arch,
|
||||
repo: 'thegeeklab/${DRONE_REPO_NAME}',
|
||||
username: { from_secret: 'docker_username' },
|
||||
password: { from_secret: 'docker_password' },
|
||||
},
|
||||
depends_on: ['build'],
|
||||
when: {
|
||||
@ -195,7 +156,6 @@ local PipelineBuildContainer(arch='amd64') = {
|
||||
name: 'publish-dockerhub',
|
||||
image: 'thegeeklab/drone-docker:19',
|
||||
settings: {
|
||||
config: { from_secret: 'docker_config' },
|
||||
auto_tag: true,
|
||||
auto_tag_suffix: arch,
|
||||
dockerfile: 'docker/Dockerfile.' + arch,
|
||||
@ -212,7 +172,6 @@ local PipelineBuildContainer(arch='amd64') = {
|
||||
name: 'publish-quay',
|
||||
image: 'thegeeklab/drone-docker:19',
|
||||
settings: {
|
||||
config: { from_secret: 'docker_config' },
|
||||
auto_tag: true,
|
||||
auto_tag_suffix: arch,
|
||||
dockerfile: 'docker/Dockerfile.' + arch,
|
||||
@ -292,7 +251,6 @@ local PipelineDocs = {
|
||||
|
||||
local PipelineNotifications = {
|
||||
kind: 'pipeline',
|
||||
image_pull_secrets: ['docker_config'],
|
||||
name: 'notifications',
|
||||
platform: {
|
||||
os: 'linux',
|
||||
|
108
.drone.yml
108
.drone.yml
@ -7,45 +7,34 @@ platform:
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: staticcheck
|
||||
- name: deps
|
||||
image: golang:1.18
|
||||
commands:
|
||||
- go run honnef.co/go/tools/cmd/staticcheck ./...
|
||||
- make deps
|
||||
volumes:
|
||||
- name: gopath
|
||||
- name: godeps
|
||||
path: /go
|
||||
|
||||
- name: lint
|
||||
image: golang:1.18
|
||||
commands:
|
||||
- go run golang.org/x/lint/golint -set_exit_status ./...
|
||||
- make lint
|
||||
volumes:
|
||||
- name: gopath
|
||||
path: /go
|
||||
|
||||
- name: vet
|
||||
image: golang:1.18
|
||||
commands:
|
||||
- go vet ./...
|
||||
volumes:
|
||||
- name: gopath
|
||||
- name: godeps
|
||||
path: /go
|
||||
|
||||
- name: test
|
||||
image: golang:1.18
|
||||
commands:
|
||||
- go test -cover ./...
|
||||
- make test
|
||||
volumes:
|
||||
- name: gopath
|
||||
- name: godeps
|
||||
path: /go
|
||||
|
||||
volumes:
|
||||
- name: gopath
|
||||
- name: godeps
|
||||
temp: {}
|
||||
|
||||
image_pull_secrets:
|
||||
- docker_config
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/main
|
||||
@ -64,28 +53,12 @@ steps:
|
||||
- name: build
|
||||
image: techknowlogick/xgo:go-1.18.x
|
||||
commands:
|
||||
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
|
||||
- mkdir -p release/
|
||||
- cd cmd/drone-github-comment && xgo -ldflags "-s -w -X main.version=$BUILD_VERSION" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out drone-github-comment .
|
||||
- mv /build/* /drone/src/release/
|
||||
- ls -l /drone/src/release/
|
||||
- make release
|
||||
|
||||
- name: executable
|
||||
image: alpine
|
||||
commands:
|
||||
- $(find release/ -executable -type f | grep drone-github-comment-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
|
||||
- $(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help
|
||||
|
||||
- name: changelog-generate
|
||||
image: thegeeklab/git-chglog
|
||||
@ -105,7 +78,7 @@ steps:
|
||||
api_key:
|
||||
from_secret: github_token
|
||||
files:
|
||||
- release/*
|
||||
- dist/*
|
||||
note: CHANGELOG.md
|
||||
overwrite: true
|
||||
title: ${DRONE_TAG}
|
||||
@ -113,9 +86,6 @@ steps:
|
||||
ref:
|
||||
- refs/tags/**
|
||||
|
||||
image_pull_secrets:
|
||||
- docker_config
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/main
|
||||
@ -137,21 +107,15 @@ steps:
|
||||
- name: build
|
||||
image: golang:1.18
|
||||
commands:
|
||||
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
|
||||
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/amd64/drone-github-comment ./cmd/drone-github-comment
|
||||
- make build
|
||||
- ls -l dist/drone-github-comment
|
||||
|
||||
- name: dryrun
|
||||
image: thegeeklab/drone-docker:19
|
||||
settings:
|
||||
config:
|
||||
from_secret: docker_config
|
||||
dockerfile: docker/Dockerfile.amd64
|
||||
dry_run: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||
username:
|
||||
from_secret: docker_username
|
||||
when:
|
||||
ref:
|
||||
- refs/pull/**
|
||||
@ -163,8 +127,6 @@ steps:
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: amd64
|
||||
config:
|
||||
from_secret: docker_config
|
||||
dockerfile: docker/Dockerfile.amd64
|
||||
password:
|
||||
from_secret: docker_password
|
||||
@ -183,8 +145,6 @@ steps:
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: amd64
|
||||
config:
|
||||
from_secret: docker_config
|
||||
dockerfile: docker/Dockerfile.amd64
|
||||
password:
|
||||
from_secret: quay_password
|
||||
@ -199,9 +159,6 @@ steps:
|
||||
depends_on:
|
||||
- dryrun
|
||||
|
||||
image_pull_secrets:
|
||||
- docker_config
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/main
|
||||
@ -223,21 +180,15 @@ steps:
|
||||
- name: build
|
||||
image: golang:1.18
|
||||
commands:
|
||||
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
|
||||
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm64/drone-github-comment ./cmd/drone-github-comment
|
||||
- make build
|
||||
- ls -l dist/drone-github-comment
|
||||
|
||||
- name: dryrun
|
||||
image: thegeeklab/drone-docker:19
|
||||
settings:
|
||||
config:
|
||||
from_secret: docker_config
|
||||
dockerfile: docker/Dockerfile.arm64
|
||||
dry_run: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||
username:
|
||||
from_secret: docker_username
|
||||
when:
|
||||
ref:
|
||||
- refs/pull/**
|
||||
@ -249,8 +200,6 @@ steps:
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: arm64
|
||||
config:
|
||||
from_secret: docker_config
|
||||
dockerfile: docker/Dockerfile.arm64
|
||||
password:
|
||||
from_secret: docker_password
|
||||
@ -269,8 +218,6 @@ steps:
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: arm64
|
||||
config:
|
||||
from_secret: docker_config
|
||||
dockerfile: docker/Dockerfile.arm64
|
||||
password:
|
||||
from_secret: quay_password
|
||||
@ -285,9 +232,6 @@ steps:
|
||||
depends_on:
|
||||
- dryrun
|
||||
|
||||
image_pull_secrets:
|
||||
- docker_config
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/main
|
||||
@ -309,21 +253,15 @@ steps:
|
||||
- name: build
|
||||
image: golang:1.18
|
||||
commands:
|
||||
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
|
||||
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm/drone-github-comment ./cmd/drone-github-comment
|
||||
- make build
|
||||
- ls -l dist/drone-github-comment
|
||||
|
||||
- name: dryrun
|
||||
image: thegeeklab/drone-docker:19
|
||||
settings:
|
||||
config:
|
||||
from_secret: docker_config
|
||||
dockerfile: docker/Dockerfile.arm
|
||||
dry_run: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||
username:
|
||||
from_secret: docker_username
|
||||
when:
|
||||
ref:
|
||||
- refs/pull/**
|
||||
@ -335,8 +273,6 @@ steps:
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: arm
|
||||
config:
|
||||
from_secret: docker_config
|
||||
dockerfile: docker/Dockerfile.arm
|
||||
password:
|
||||
from_secret: docker_password
|
||||
@ -355,8 +291,6 @@ steps:
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: arm
|
||||
config:
|
||||
from_secret: docker_config
|
||||
dockerfile: docker/Dockerfile.arm
|
||||
password:
|
||||
from_secret: quay_password
|
||||
@ -371,9 +305,6 @@ steps:
|
||||
depends_on:
|
||||
- dryrun
|
||||
|
||||
image_pull_secrets:
|
||||
- docker_config
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/main
|
||||
@ -513,9 +444,6 @@ steps:
|
||||
- success
|
||||
- failure
|
||||
|
||||
image_pull_secrets:
|
||||
- docker_config
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/main
|
||||
@ -529,6 +457,6 @@ depends_on:
|
||||
|
||||
---
|
||||
kind: signature
|
||||
hmac: 5cd21b17a502582e619fecbb7a09fcd895279018dca98c7a25f7ae7b5ac76358
|
||||
hmac: 437f7ee83558c821e40d26af06e99e1e1a7d805cbf8c7b409747711dd696f193
|
||||
|
||||
...
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
/dist/
|
||||
/release/
|
||||
/drone-github-comment*
|
||||
|
||||
|
31
.golangci.yml
Normal file
31
.golangci.yml
Normal 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
96
Makefile
Normal 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-github-comment
|
||||
|
||||
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)
|
@ -27,7 +27,7 @@ export GOARCH=amd64
|
||||
export CGO_ENABLED=0
|
||||
export GO111MODULE=on
|
||||
|
||||
go build -v -a -tags netgo -o release/drone-github-comment
|
||||
make build
|
||||
```
|
||||
|
||||
Build the Docker image with the following command:
|
||||
|
@ -1,28 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/drone-plugins/drone-plugin-lib/errors"
|
||||
"github.com/drone-plugins/drone-plugin-lib/urfave"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/thegeeklab/drone-github-comment/plugin"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var version = "unknown"
|
||||
var (
|
||||
BuildVersion = "devel"
|
||||
BuildDate = "00000000"
|
||||
)
|
||||
|
||||
func main() {
|
||||
settings := &plugin.Settings{}
|
||||
|
||||
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{
|
||||
Name: "drone-github-comment",
|
||||
Usage: "handle comments to github issues or pull requests",
|
||||
Version: version,
|
||||
Version: BuildVersion,
|
||||
Flags: append(settingsFlags(settings), urfave.Flags()...),
|
||||
Action: run(settings),
|
||||
}
|
||||
|
@ -1,8 +0,0 @@
|
||||
// +build tools
|
||||
|
||||
package tools
|
||||
|
||||
import (
|
||||
_ "golang.org/x/lint/golint"
|
||||
_ "honnef.co/go/tools/cmd/staticcheck"
|
||||
)
|
@ -7,5 +7,6 @@ LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-github-c
|
||||
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-github-comment"
|
||||
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-github-comment"
|
||||
|
||||
ADD release/amd64/drone-github-comment /bin/
|
||||
ENTRYPOINT [ "/bin/drone-github-comment" ]
|
||||
ADD dist/drone-github-comment /bin/
|
||||
|
||||
ENTRYPOINT ["/bin/drone-github-comment"]
|
||||
|
@ -7,5 +7,6 @@ LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-github-c
|
||||
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-github-comment"
|
||||
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-github-comment"
|
||||
|
||||
ADD release/arm/drone-github-comment /bin/
|
||||
ENTRYPOINT [ "/bin/drone-github-comment" ]
|
||||
ADD dist/drone-github-comment /bin/
|
||||
|
||||
ENTRYPOINT ["/bin/drone-github-comment"]
|
||||
|
@ -7,5 +7,6 @@ LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-github-c
|
||||
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-github-comment"
|
||||
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-github-comment"
|
||||
|
||||
ADD release/arm64/drone-github-comment /bin/
|
||||
ENTRYPOINT [ "/bin/drone-github-comment" ]
|
||||
ADD dist/drone-github-comment /bin/
|
||||
|
||||
ENTRYPOINT ["/bin/drone-github-comment"]
|
||||
|
7
go.mod
7
go.mod
@ -8,24 +8,17 @@ require (
|
||||
github.com/joho/godotenv v1.4.0
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/urfave/cli/v2 v2.4.0
|
||||
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616
|
||||
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a
|
||||
honnef.co/go/tools v0.3.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.0.0 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // 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/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
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/protobuf v1.28.0 // indirect
|
||||
)
|
||||
|
12
go.sum
12
go.sum
@ -32,8 +32,6 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
|
||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
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/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
@ -170,8 +168,6 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
|
||||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
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/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
@ -184,8 +180,6 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl
|
||||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
|
||||
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
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/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
@ -194,8 +188,6 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
|
||||
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
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-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@ -325,8 +317,6 @@ golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roY
|
||||
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
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-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@ -425,8 +415,6 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.3.0 h1:2LdYUZ7CIxnYgskbUZfY7FPggmqnh6shBqfWa8Tn3XU=
|
||||
honnef.co/go/tools v0.3.0/go.mod h1:vlRD9XErLMGT+mDuofSr0mMMquscM/1nQqtRSsh6m70=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||
|
@ -64,7 +64,7 @@ func (cc *commentClient) comment() (*github.IssueComment, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
allComments = append(comments, comments...)
|
||||
allComments = append(allComments, comments...)
|
||||
if resp.NextPage == 0 {
|
||||
break
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ func (p *Plugin) Validate() error {
|
||||
}
|
||||
|
||||
if !strings.HasSuffix(p.settings.BaseURL, "/") {
|
||||
p.settings.BaseURL = p.settings.BaseURL + "/"
|
||||
p.settings.BaseURL += "/"
|
||||
}
|
||||
p.settings.baseURL, err = url.Parse(p.settings.BaseURL)
|
||||
if err != nil {
|
||||
@ -95,7 +95,6 @@ func (p *Plugin) Execute() error {
|
||||
}
|
||||
|
||||
err := cc.issueComment()
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create or update comment: %w", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user