adds drone yaml

This commit is contained in:
Marvin Steadfast 2021-01-20 15:24:38 +01:00
parent e736942f01
commit d9764025be
4 changed files with 66 additions and 49 deletions

64
.drone.yml Normal file
View File

@ -0,0 +1,64 @@
---
kind: pipeline
name: default
steps:
- name: fetch
image: docker:git
commands:
- git fetch --tags
- name: lint
image: golangci/golangci-lint:latest
commands:
- make lint
- name: test
image: golang:latest
commands:
- make lint
- name: build
image: goreleaser/goreleaser:latest
volumes:
- name: dockersock
path: /var/run
environment:
commands:
- make build
when:
event:
exclude:
- tag
depends_on:
- lint
- test
- name: release
image: goreleaser/goreleaser:latest
volumes:
- name: dockersock
path: /var/run
environment:
GITEA_TOKEN:
from_secret: gitea_token
commands:
- make release
when:
event:
- tag
depends_on:
- lint
- test
services:
- name: docker
image: docker:dind
privileged: true
volumes:
- name: dockersock
path: /var/run
volumes:
- name: dockersock
temp: {}

View File

@ -1,25 +0,0 @@
stages:
- build
go_build:
stage: build
image: golang:1.12
variables:
CGO_ENABLED: 0
script:
- mkdir -p .cache/cache || true
- mkdir -p .cache/go || true
- export GOCACHE="$CI_PROJECT_DIR/.cache/cache"
- export GOPATH="$CI_PROJECT_DIR/.cache/go"
- CGO_ENABLED=1 go test -race ./...
- mkdir -p build || true
- go env
- GOOS=linux GOARCH=amd64 go build -a -ldflags '-extldflags "-static"' -o build/${CI_PROJECT_NAME}-amd64 ./cmd/wg-quick
- GOOS=linux GOARCH=arm GOARM=7 go build -a -ldflags '-extldflags "-static"' -o build/${CI_PROJECT_NAME}-arm32v7 ./cmd/wg-quick
- GOOS=linux GOARCH=arm64 go build -a -ldflags '-extldflags "-static"' -o build/${CI_PROJECT_NAME}-arm64v8 ./cmd/wg-quick
artifacts:
paths:
- build/
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .cache

View File

@ -1,22 +0,0 @@
exclude: ".vscode/*"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: end-of-file-fixer
- id: pretty-format-json
args:
- --autofix
- id: requirements-txt-fixer
- id: trailing-whitespace
- id: detect-private-key
- repo: git://github.com/dnephin/pre-commit-golang
rev: v0.3.2
hooks:
- id: go-fmt

4
wg.go
View File

@ -202,10 +202,10 @@ func SyncLink(cfg *Config, iface string, log logrus.FieldLogger) (netlink.Link,
LinkType: "wireguard", LinkType: "wireguard",
} }
if err := netlink.LinkAdd(wgLink); err != nil { if err := netlink.LinkAdd(wgLink); err != nil {
log.WithError(err).Errorf("cannot create link: %w", err) log.WithError(err).Errorf("cannot create link: %s", err.Error())
log.Info("trying to use embedded wireguard-go...") log.Info("trying to use embedded wireguard-go...")
if err := wgGo(iface); err != nil { if err := wgGo(iface); err != nil {
log.WithError(err).Errorf("cannot create link through wireguard-go: %w", err) log.WithError(err).Errorf("cannot create link through wireguard-go: %s", err.Error())
return nil, fmt.Errorf("cannot create link") return nil, fmt.Errorf("cannot create link")
} }
} }