From 90072d2d43bcd3d37396bc5e3dc037f7d37c8cb8 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 21 Aug 2023 16:06:34 +0200 Subject: [PATCH] ci: migrate to woodpecker (#69) --- .dictionary | 5 ++ .drone.yml | 148 ----------------------------------- .github/settings.yml | 6 +- .golangci.yml | 2 +- .markdownlint.yml | 6 ++ .prettierignore | 1 - .woodpecker/build-binary.yml | 46 +++++++++++ .woodpecker/docs.yml | 71 +++++++++++++++++ .woodpecker/notify.yml | 26 ++++++ .woodpecker/test.yml | 25 ++++++ Makefile | 6 +- README.md | 4 +- go.mod | 2 +- 13 files changed, 190 insertions(+), 158 deletions(-) create mode 100644 .dictionary delete mode 100644 .drone.yml create mode 100644 .markdownlint.yml create mode 100644 .woodpecker/build-binary.yml create mode 100644 .woodpecker/docs.yml create mode 100644 .woodpecker/notify.yml create mode 100644 .woodpecker/test.yml diff --git a/.dictionary b/.dictionary new file mode 100644 index 0000000..cbe55b2 --- /dev/null +++ b/.dictionary @@ -0,0 +1,5 @@ +url-parser +Codecov +herloct +multiarch +(P|p)rebuilt diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index d0d8386..0000000 --- a/.drone.yml +++ /dev/null @@ -1,148 +0,0 @@ ---- -kind: pipeline -name: test - -platform: - os: linux - arch: amd64 - -steps: - - name: deps - image: golang:1.20 - commands: - - make deps - volumes: - - name: godeps - path: /go - - - name: lint - image: golang:1.20 - commands: - - make lint - volumes: - - name: godeps - path: /go - - - name: test - image: golang:1.20 - commands: - - make test - volumes: - - name: godeps - path: /go - - - name: coverage - image: plugins/codecov - settings: - files: - - coverage.out - token: - from_secret: codecov_token - -volumes: - - name: godeps - temp: {} - -trigger: - ref: - - refs/heads/main - - refs/tags/** - - refs/pull/** - ---- -kind: pipeline -name: build-binaries - -platform: - os: linux - arch: amd64 - -steps: - - name: build - image: techknowlogick/xgo:go-1.20.x - commands: - - ln -s /drone/src /source - - make release - - - name: executable - image: alpine - commands: - - $(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help - - - name: changelog-generate - 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 - - - name: publish - image: plugins/github-release - settings: - api_key: - from_secret: github_token - files: - - dist/* - note: CHANGELOG.md - overwrite: true - title: ${DRONE_TAG} - when: - ref: - - refs/tags/** - -trigger: - ref: - - refs/heads/main - - refs/tags/** - - refs/pull/** - -depends_on: - - test - ---- -kind: pipeline -name: notifications - -platform: - os: linux - arch: amd64 - -steps: - - name: matrix - image: thegeeklab/drone-matrix - settings: - homeserver: - from_secret: matrix_homeserver - password: - from_secret: matrix_password - roomid: - from_secret: matrix_roomid - template: "Status: **{{ .Build.Status }}**
Build: [{{ .Repo.Owner }}/{{ .Repo.Name }}]({{ .Build.Link }}){{ if .Build.Branch }} ({{ .Build.Branch }}){{ end }} by {{ .Commit.Author }}
Message: {{ .Commit.Message.Title }}" - username: - from_secret: matrix_username - when: - status: - - success - - failure - -trigger: - ref: - - refs/heads/main - - refs/tags/** - status: - - success - - failure - -depends_on: - - build-binaries - ---- -kind: signature -hmac: cd330bcce6c40fde659949ebbe13e9d501bfecda755e8f4b8e758a9db2f0a9ba - -... diff --git a/.github/settings.yml b/.github/settings.yml index 9fd1fe3..a8addd1 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -50,7 +50,9 @@ branches: required_status_checks: strict: false contexts: - - continuous-integration/drone/pr - enforce_admins: true + - ci/woodpecker/pr/test + - ci/woodpecker/pr/build-binary + - ci/woodpecker/pr/docs + enforce_admins: false required_linear_history: true restrictions: null diff --git a/.golangci.yml b/.golangci.yml index 342bde5..7e7ed7d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -94,4 +94,4 @@ run: linters-settings: gofumpt: extra-rules: true - lang-version: "1.20" + lang-version: "1.21" diff --git a/.markdownlint.yml b/.markdownlint.yml new file mode 100644 index 0000000..b59a114 --- /dev/null +++ b/.markdownlint.yml @@ -0,0 +1,6 @@ +--- +default: True +MD013: False +MD041: False +MD004: + style: dash diff --git a/.prettierignore b/.prettierignore index 23a4f05..135c35d 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,2 @@ -.drone.yml *.tpl.md LICENSE diff --git a/.woodpecker/build-binary.yml b/.woodpecker/build-binary.yml new file mode 100644 index 0000000..f6de3f2 --- /dev/null +++ b/.woodpecker/build-binary.yml @@ -0,0 +1,46 @@ +--- +when: + - event: [pull_request, tag] + - event: [push, manual] + branch: + - ${CI_REPO_DEFAULT_BRANCH} + +steps: + build: + image: docker.io/techknowlogick/xgo:go-1.21.x + commands: + - ln -s $(pwd) /source + - make release + + executable: + image: quay.io/thegeeklab/alpine-tools + commands: + - $(find dist/ -executable -type f -iname ${CI_REPO_NAME}-linux-amd64) --help + + changelog-generate: + image: quay.io/thegeeklab/git-chglog + commands: + - git fetch -tq + - git-chglog --no-color --no-emoji -o CHANGELOG.md ${CI_COMMIT_TAG:---next-tag unreleased unreleased} + + changelog-format: + image: quay.io/thegeeklab/alpine-tools + commands: + - prettier CHANGELOG.md + - prettier -w CHANGELOG.md + + publish-github: + image: docker.io/plugins/github-release + settings: + api_key: + from_secret: github_token + files: + - dist/* + note: CHANGELOG.md + overwrite: true + title: ${CI_COMMIT_TAG} + when: + - event: [tag] + +depends_on: + - test diff --git a/.woodpecker/docs.yml b/.woodpecker/docs.yml new file mode 100644 index 0000000..8862e1d --- /dev/null +++ b/.woodpecker/docs.yml @@ -0,0 +1,71 @@ +--- +when: + - event: [pull_request, tag] + - event: [push, manual] + branch: + - ${CI_REPO_DEFAULT_BRANCH} + +steps: + markdownlint: + image: quay.io/thegeeklab/markdownlint-cli + commands: + - markdownlint 'README.md' 'CONTRIBUTING.md' + + spellcheck: + image: quay.io/thegeeklab/alpine-tools + commands: + - spellchecker --files '_docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls --no-suggestions + environment: + FORCE_COLOR: "true" + NPM_CONFIG_LOGLEVEL: "error" + + publish: + image: quay.io/thegeeklab/wp-git-action + settings: + action: + - pages + author_email: bot@thegeeklab.de + author_name: thegeeklab-bot + branch: docs + message: "[skip ci] auto-update documentation" + netrc_password: + from_secret: github_token + pages_directory: _docs/ + when: + - event: [push, manual] + branch: + - ${CI_REPO_DEFAULT_BRANCH} + + pushrm-dockerhub: + image: docker.io/chko/docker-pushrm:1 + secrets: + - source: docker_password + target: DOCKER_PASS + - source: docker_username + target: DOCKER_USER + environment: + PUSHRM_FILE: README.md + PUSHRM_SHORT: Woodpecker CI plugin to build multiarch OCI images with buildx + PUSHRM_TARGET: ${CI_REPO} + when: + - event: [push, manual] + branch: + - ${CI_REPO_DEFAULT_BRANCH} + status: [success] + + pushrm-quay: + image: docker.io/chko/docker-pushrm:1 + secrets: + - source: quay_token + target: APIKEY__QUAY_IO + environment: + PUSHRM_FILE: README.md + PUSHRM_TARGET: quay.io/${CI_REPO} + when: + - event: [push, manual] + branch: + - ${CI_REPO_DEFAULT_BRANCH} + status: [success] + +depends_on: + - build-binary diff --git a/.woodpecker/notify.yml b/.woodpecker/notify.yml new file mode 100644 index 0000000..a851904 --- /dev/null +++ b/.woodpecker/notify.yml @@ -0,0 +1,26 @@ +--- +when: + - event: [tag] + - event: [push, manual] + branch: + - ${CI_REPO_DEFAULT_BRANCH} + +runs_on: [success, failure] + +steps: + matrix: + image: quay.io/thegeeklab/wp-matrix + settings: + homeserver: + from_secret: matrix_homeserver + password: + from_secret: matrix_password + roomid: + from_secret: matrix_roomid + username: + from_secret: matrix_username + when: + - status: [success, failure] + +depends_on: + - docs diff --git a/.woodpecker/test.yml b/.woodpecker/test.yml new file mode 100644 index 0000000..6c78aa4 --- /dev/null +++ b/.woodpecker/test.yml @@ -0,0 +1,25 @@ +--- +when: + - event: [pull_request, tag] + - event: [push, manual] + branch: + - ${CI_REPO_DEFAULT_BRANCH} + +steps: + lint: + image: docker.io/library/golang:1.21 + commands: + - make lint + + test: + image: docker.io/library/golang:1.21 + commands: + - make test + + coverage: + image: docker.io/plugins/codecov + settings: + files: + - coverage.out + token: + from_secret: codecov_token diff --git a/Makefile b/Makefile index bfadbfc..9048bfb 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@$(G XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest GENERATE ?= -XGO_VERSION := go-1.20.x +XGO_VERSION := go-1.21.x XGO_TARGETS ?= linux/amd64,linux/arm-6,linux/arm-7,linux/arm64 TARGETOS ?= linux @@ -30,8 +30,8 @@ endif TAGS ?= netgo ifndef VERSION - ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) + ifneq ($(CI_COMMIT_TAG),) + VERSION ?= $(subst v,,$(CI_COMMIT_TAG)) else VERSION ?= $(shell git rev-parse --short HEAD) endif diff --git a/README.md b/README.md index 60c6334..4f4cf15 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # url-parser -[![Build Status](https://img.shields.io/drone/build/thegeeklab/url-parser?logo=drone&server=https%3A%2F%2Fdrone.thegeeklab.de)](https://drone.thegeeklab.de/thegeeklab/url-parser) +[![Build Status](https://ci.thegeeklab.de/api/badges/thegeeklab/url-parser/status.svg)](https://ci.thegeeklab.de/repos/thegeeklab/url-parser) [![Go Report Card](https://goreportcard.com/badge/github.com/thegeeklab/url-parser)](https://goreportcard.com/report/github.com/thegeeklab/url-parser) [![Codecov](https://img.shields.io/codecov/c/github/thegeeklab/url-parser)](https://codecov.io/gh/thegeeklab/url-parser) [![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/url-parser)](https://github.com/thegeeklab/url-parser/graphs/contributors) @@ -10,7 +10,7 @@ Inspired by [herloct/url-parser](https://github.com/herloct/url-parser), a simpl ## Installation -Prebuild multiarch binaries are availabe for Linux only: +Prebuilt multiarch binaries are available for Linux only. ```Shell curl -L https://github.com/thegeeklab/url-parser/releases/download/v0.1.0/url-parser-0.1.0-linux-amd64 > /usr/local/bin/url-parser diff --git a/go.mod b/go.mod index 70784de..8982c6f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/thegeeklab/url-parser -go 1.20 +go 1.21 require ( github.com/sirupsen/logrus v1.9.3