diff --git a/.chglog/CHANGELOG.tpl.md b/.chglog/CHANGELOG.tpl.md new file mode 100755 index 0000000..3f7457d --- /dev/null +++ b/.chglog/CHANGELOG.tpl.md @@ -0,0 +1,27 @@ +# Changelog + +{{ range .Versions -}} +## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }}) + +{{ range .CommitGroups -}} +### {{ .Title }} + +{{ $subjects := list }} +{{ range .Commits -}} +{{ if not (has .Subject $subjects) -}} +- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} +{{ $subjects = append $subjects .Subject -}} +{{ end }} +{{- end }} +{{- end -}} + +{{- if .NoteGroups -}} +{{ range .NoteGroups -}} +### {{ .Title }} + +{{ range .Notes }} +{{ .Body }} +{{ end }} +{{ end -}} +{{ end -}} +{{ end -}} diff --git a/.chglog/config.yml b/.chglog/config.yml new file mode 100755 index 0000000..6407ef7 --- /dev/null +++ b/.chglog/config.yml @@ -0,0 +1,25 @@ +style: github +template: CHANGELOG.tpl.md +info: + title: CHANGELOG + repository_url: https://github.com/thegeeklab/drone-template-lib +options: + commit_groups: + title_maps: + feat: Features + fix: Bug Fixes + perf: Performance Improvements + refactor: Code Refactoring + chore: Others + test: Testing + ci: CI Pipeline + docs: Documentation + header: + pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$" + pattern_maps: + - Type + - Scope + - Subject + notes: + keywords: + - BREAKING CHANGE diff --git a/.dictionary b/.dictionary new file mode 100644 index 0000000..e69de29 diff --git a/.drone.jsonnet b/.drone.jsonnet new file mode 100644 index 0000000..a20ad41 --- /dev/null +++ b/.drone.jsonnet @@ -0,0 +1,142 @@ +local PipelineTest(deps=[],) = { + kind: 'pipeline', + name: 'test', + platform: { + os: 'linux', + arch: 'amd64', + }, + steps: [ + { + name: 'staticcheck', + image: 'golang:1.16', + commands: [ + 'go run honnef.co/go/tools/cmd/staticcheck ./...', + ], + volumes: [ + { + name: 'gopath', + path: '/go', + }, + ], + }, + { + name: 'lint', + image: 'golang:1.16', + commands: [ + 'go run golang.org/x/lint/golint -set_exit_status ./...', + ], + volumes: [ + { + name: 'gopath', + path: '/go', + }, + ], + }, + { + name: 'vet', + image: 'golang:1.16', + commands: [ + 'go vet ./...', + ], + volumes: [ + { + name: 'gopath', + path: '/go', + }, + ], + }, + { + name: 'test', + image: 'golang:1.16', + commands: [ + 'go test -cover ./...', + ], + volumes: [ + { + name: 'gopath', + path: '/go', + }, + ], + }, + ], + volumes: [ + { + name: 'gopath', + temp: {}, + }, + ], + depends_on: deps, + trigger: { + ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'], + }, +}; + +local PipelineDocs(deps=[],) = { + kind: 'pipeline', + name: 'docs', + platform: { + os: 'linux', + arch: 'amd64', + }, + steps: [ + { + name: 'markdownlint', + image: 'thegeeklab/markdownlint-cli', + commands: [ + "markdownlint 'README.md' 'CONTRIBUTING.md'", + ], + }, + { + name: 'spellcheck', + image: 'node:lts-alpine', + commands: [ + 'npm install -g spellchecker-cli', + "spellchecker --files 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls --no-suggestions", + ], + environment: { + FORCE_COLOR: true, + NPM_CONFIG_LOGLEVEL: 'error', + }, + }, + ], + depends_on: deps, + trigger: { + ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'], + }, +}; + +local PipelineNotifications(deps=[],) = { + kind: 'pipeline', + name: 'notifications', + platform: { + os: 'linux', + arch: 'amd64', + }, + steps: [ + { + name: 'matrix', + image: 'plugins/matrix', + settings: { + homeserver: { from_secret: 'matrix_homeserver' }, + roomid: { from_secret: 'matrix_roomid' }, + template: 'Status: **{{ build.status }}**
Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}
Message: {{ build.message }}', + username: { from_secret: 'matrix_username' }, + password: { from_secret: 'matrix_password' }, + }, + when: { + status: ['success', 'failure'], + }, + }, + ], + depends_on: deps, + trigger: { + ref: ['refs/heads/main', 'refs/tags/**'], + status: ['success', 'failure'], + }, +}; + +[ + PipelineTest(), + PipelineDocs(deps=['test']), + PipelineNotifications(deps=['docs']), +] diff --git a/.drone.yml b/.drone.yml index 59f116b..ef57f0f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,56 +1,110 @@ --- +depends_on: [] kind: pipeline -type: docker -name: testing - +name: test platform: - os: linux arch: amd64 - + os: linux steps: -- name: environment - image: golang:1.15 - commands: - - go version - - go env - volumes: - - name: gopath - path: /go - -- name: staticcheck - image: golang:1.15 - commands: +- commands: - go run honnef.co/go/tools/cmd/staticcheck ./... + image: golang:1.16 + name: staticcheck volumes: - name: gopath path: /go - -- name: lint - image: golang:1.15 - commands: +- commands: - go run golang.org/x/lint/golint -set_exit_status ./... + image: golang:1.16 + name: lint volumes: - name: gopath path: /go - -- name: vet - image: golang:1.15 - commands: +- commands: - go vet ./... + image: golang:1.16 + name: vet volumes: - name: gopath path: /go - -- name: test - image: golang:1.15 - commands: - - go test -cover -v ./... +- commands: + - go test -cover ./... + image: golang:1.16 + name: test volumes: - name: gopath path: /go - +trigger: + ref: + - refs/heads/main + - refs/tags/** + - refs/pull/** volumes: - name: gopath temp: {} +--- +depends_on: +- test +kind: pipeline +name: docs +platform: + arch: amd64 + os: linux +steps: +- commands: + - markdownlint 'README.md' 'CONTRIBUTING.md' + image: thegeeklab/markdownlint-cli + name: markdownlint +- commands: + - npm install -g spellchecker-cli + - spellchecker --files 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article + syntax-urls --no-suggestions + environment: + FORCE_COLOR: true + NPM_CONFIG_LOGLEVEL: error + image: node:lts-alpine + name: spellcheck +trigger: + ref: + - refs/heads/main + - refs/tags/** + - refs/pull/** +--- +depends_on: +- docs +kind: pipeline +name: notifications +platform: + arch: amd64 + os: linux +steps: +- image: plugins/matrix + name: 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 }}) ({{ build.branch }}) by {{ build.author }}
Message: + {{ build.message }}' + username: + from_secret: matrix_username + when: + status: + - success + - failure +trigger: + ref: + - refs/heads/main + - refs/tags/** + status: + - success + - failure +--- +kind: signature +hmac: 758e035deda2239882aef0b1654916e376f5959883149f109dcb59a30faa9d96 ... diff --git a/.github/settings.yml b/.github/settings.yml new file mode 100644 index 0000000..85e2941 --- /dev/null +++ b/.github/settings.yml @@ -0,0 +1,64 @@ +repository: + name: drone-template-lib + description: Custom template library for Drone CI + topics: drone, drone-plugin + + private: false + has_issues: true + has_wiki: false + has_downloads: true + + default_branch: main + + allow_squash_merge: true + allow_merge_commit: true + allow_rebase_merge: true + +labels: + - name: bug + color: d73a4a + description: Something isn't working + - name: documentation + color: 0075ca + description: Improvements or additions to documentation + - name: duplicate + color: cfd3d7 + description: This issue or pull request already exists + - name: enhancement + color: a2eeef + description: New feature or request + - name: good first issue + color: 7057ff + description: Good for newcomers + - name: help wanted + color: 008672 + description: Extra attention is needed + - name: invalid + color: e4e669 + description: This doesn't seem right + - name: question + color: d876e3 + description: Further information is requested + - name: wontfix + color: ffffff + description: This will not be worked on + +branches: + - name: main + protection: + required_pull_request_reviews: null + required_status_checks: + strict: false + contexts: + - continuous-integration/drone/pr + enforce_admins: null + restrictions: null + - name: docs + protection: + required_pull_request_reviews: null + required_status_checks: null + enforce_admins: true + restrictions: + users: [] + teams: + - bot diff --git a/.gitignore b/.gitignore index 2d83068..3610817 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ +/release/ +/drone-template-lib* + coverage.out +CHANGELOG.md 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 new file mode 100644 index 0000000..97e0b3e --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +.drone.yml +*.tpl.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..c471f59 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,31 @@ +# Contributing + +## Security + +If you think you have found a **security issue**, please do not mention it in this repository. +Instead, send an email to security@thegeeklab.de with as many details as possible so it can be handled confidential. + +## Bug Reports and Feature Requests + +If you have found a **bug** or have a **feature request** please use the search first in case a similar issue already exists. +If not, please create an issue in this repository + +## Code + +If you would like to fix a bug or implement a feature, please fork the repository and create a Pull Request. + +Before you start any Pull Request, it is recommended that you create an issue to discuss first if you have any +doubts about requirement or implementation. That way you can be sure that the maintainer(s) agree on what to change and how, +and you can hopefully get a quick merge afterwards. + +Pull Requests can only be merged once all status checks are green. + +## Do not force push to your Pull Request branch + +Please do not force push to your Pull Requests branch after you have created your Pull Request, as doing so makes it harder for us to review your work. +Pull Requests will always be squashed by us when we merge your work. Commit as many times as you need in your Pull Request branch. + +## Re-requesting a review + +Please do not ping your reviewer(s) by mentioning them in a new comment. Instead, use the re-request review functionality. +Read more about this in the [GitHub docs, Re-requesting a review](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/incorporating-feedback-in-your-pull-request#re-requesting-a-review). diff --git a/LICENSE b/LICENSE index 8dada3e..e07ea97 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,4 @@ + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -178,7 +179,7 @@ APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" + boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a @@ -186,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright {yyyy} {name of copyright owner} + Copyright 2021 Robert Kaussow Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..45d1c03 --- /dev/null +++ b/renovate.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["github>thegeeklab/renovate-presets:golang"] +}