Skip to content

Commit

Permalink
Merge pull request #1 from MarnixBouhuis/feature/opensource
Browse files Browse the repository at this point in the history
Release project as open source
  • Loading branch information
marnixbouhuis authored Sep 26, 2024
2 parents d0ce084 + 97cd146 commit 4f9fcb1
Show file tree
Hide file tree
Showing 196 changed files with 17,587 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/pkg/gen/** linguist-generated
37 changes: 37 additions & 0 deletions .github/actions/setup-go-with-dependencies/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Setup go with dependencies
description: Setup go, dependencies and tooling. Speed up downloads / installs with caching support. Requires the repo to be checked out, expects a go.mod file in the root of the repo.
runs:
using: composite
steps:
- name: Setup go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: "go.mod"
cache: false
- name: Determine go paths
id: vars
shell: bash
run: |
echo "GOCACHE=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
echo "GOMODCACHE=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
echo "GOVERSION=$(go env GOVERSION)" >> "$GITHUB_OUTPUT"
- name: Make sure modcache is empty before restoring cache
shell: bash
run: go clean -modcache
- name: Restore cache
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: |
${{ steps.vars.outputs.GOCACHE }}
${{ steps.vars.outputs.GOMODCACHE }}
key: go-v1-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-${{ steps.vars.outputs.GOVERSION }}-${{ hashFiles('go.mod') }}
- name: Install tools and dependencies
shell: bash
run: make dependencies install-tools
- name: Upload cache
uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: |
${{ steps.vars.outputs.GOCACHE }}
${{ steps.vars.outputs.GOMODCACHE }}
key: go-v1-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-${{ steps.vars.outputs.GOVERSION }}-${{ hashFiles('go.mod') }}
35 changes: 35 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name-template: "v$RESOLVED_VERSION"
tag-template: "v$RESOLVED_VERSION"
categories:
- title: "🚀 Features"
labels:
- feature
- enhancement
- title: "🐛 Bug Fixes"
labels:
- fix
- bug
- title: "🧰 Maintenance"
labels:
- chore
- documentation
- title: "⬆ Dependencies"
labels:
- dependencies
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
change-title-escapes: "\\<*_&"
version-resolver:
major:
labels:
- major
minor:
labels:
- minor
patch:
labels:
- patch
default: patch
template: |
## Changelog
$CHANGES
24 changes: 24 additions & 0 deletions .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build release
on:
push:
tags: [ v* ]
permissions:
contents: write
jobs:
build_release:
name: Build release
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Setup go and tooling
uses: ./.github/actions/setup-go-with-dependencies
- name: Run GoReleaser
run: goreleaser release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101 changes: 101 additions & 0 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: CI/CD Pipeline
on:
push: {}
jobs:
lint_go:
name: Lint go code
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 1
- name: Setup go and tooling
uses: ./.github/actions/setup-go-with-dependencies
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: none
install-mode: none # golangci-lint is installed using the setup tooling step above. This ensures we use the same binary version in the CI as locally.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
lint_proto:
name: Lint proto
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0 # Fetch all history (used for breaking change detection)
- name: Setup go and tooling
uses: ./.github/actions/setup-go-with-dependencies
- name: Run buf
uses: bufbuild/buf-action@d4b43256b3a511e94e6c0d38d478e1bd39f8690e # v1.0.1
with:
lint: true
breaking: true
breaking_against: ${{ github.event.repository.clone_url }}#format=git,branch=main
format: true
push: false # Do not push to schema registry
archive: false # Do not archive releases since we do not use the BSR
- name: Make sure all proto files have been generated
run: |
buf generate
if [[ `git status --porcelain` ]]; then
git --no-pager diff
echo "Uncommitted changes in generated files. Please run \"make gen\" locally and commit the changes."
exit 1
else
echo "All proto files are correctly generated."
fi
test:
name: Test
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 1
- name: Setup go and tooling
uses: ./.github/actions/setup-go-with-dependencies
- name: Run tests
shell: bash
run: |
set -o pipefail
go test -json ./... | tee test-results.json
- name: Report test results
if: always()
uses: guyarb/golang-test-annotations@2941118d7ef622b1b3771d1ff6eae9e90659eb26 # v0.8.0
with:
test-results: test-results.json
package-name: github.com/marnixbouhuis/confpb
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Setup go and tooling
uses: ./.github/actions/setup-go-with-dependencies
- name: Build release
run: goreleaser release --clean --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifacts
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: build
path: dist/*
22 changes: 22 additions & 0 deletions .github/workflows/draft-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Draft release
on:
push:
branches: [ main ]
jobs:
update_release_draft:
name: Update draft release
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 1
- name: Update release draft
uses: release-drafter/release-drafter@3f0f87098bd6b5c5b9a36d49c41d998ea58f9348 # v6.0.0
with:
disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/increment-runtime-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Increment runtime version
on:
push:
branches: [ main ]
permissions:
contents: write
jobs:
increment_version:
name: Increment runtime version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 1
- name: Increment version
run: |
old_version=$(grep "RuntimeVersion int" internal/version/runtime.go | grep -o "[0-9]*")
new_version=$((old_version + 1))
sed -i "s/RuntimeVersion int = $old_version/RuntimeVersion int = $new_version/" internal/version/runtime.go
- name: Push changes
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
git add .
git commit -m "Increment runtime version number"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37 changes: 37 additions & 0 deletions .github/workflows/pr-labels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: PR labels
on:
pull_request:
types: [ opened, labeled, unlabeled, synchronize ]
permissions:
pull-requests: read
checks: write
jobs:
check_type_labels:
name: Check that PR has type labels
runs-on: ubuntu-latest
steps:
- if: ${{ github.base_ref == 'main' }}
name: Check PR category label
uses: danielchabr/pr-labels-checker@7145ecb81a69104f99767cb133bf856e749f7e73 # v3.3
with:
hasSome: feature,enhancement,fix,bug,chore,documentation,dependencies
githubToken: ${{ secrets.GITHUB_TOKEN }}
check_semver_labels:
name: Check that PR has release version labels
runs-on: ubuntu-latest
steps:
- if: ${{ github.base_ref == 'main' }}
name: Check PR version label
uses: danielchabr/pr-labels-checker@7145ecb81a69104f99767cb133bf856e749f7e73 # v3.3
with:
hasSome: major,minor,patch
githubToken: ${{ secrets.GITHUB_TOKEN }}
check_do_not_merge:
name: Check that PR does not have do not merge label
runs-on: ubuntu-latest
steps:
- name: Check PR version label
uses: danielchabr/pr-labels-checker@7145ecb81a69104f99767cb133bf856e749f7e73 # v3.3
with:
hasNone: do not merge
githubToken: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
dist/
98 changes: 98 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
issues:
exclude-dirs:
- ./pkg/gen/
exclude-rules:
- path: (.+)_test.go
linters:
- dupl
linters-settings:
testifylint:
disable:
- float-compare
- blank-import
linters:
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- asasalint
- asciicheck
- bidichk
- bodyclose
- canonicalheader
- containedctx
- contextcheck
- copyloopvar
- decorder
- dogsled
- dupl
- dupword
- durationcheck
- errchkjson
- errname
- errorlint
- exhaustive
- fatcontext
- forbidigo
- forcetypeassert
- gci
- ginkgolinter
- gocheckcompilerdirectives
- gochecknoinits
- gochecksumtype
- gocritic
- godot
- godox
- gofmt
- gofumpt
- goheader
- goimports
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosmopolitan
- grouper
- importas
- inamedparam
- interfacebloat
- intrange
- loggercheck
- makezero
- mirror
- misspell
- musttag
- nakedret
- nilerr
- nilnil
- noctx
- nolintlint
- nosprintfhostport
- paralleltest
- perfsprint
- prealloc
- predeclared
- promlinter
- reassign
- revive
- rowserrcheck
- sloglint
- spancheck
- sqlclosecheck
- stylecheck
- tagalign
- tagliatelle
- tenv
- testableexamples
- testifylint
- testpackage
- thelper
- tparallel
- unconvert
- usestdlibvars
- wastedassign
- whitespace
- zerologlint
Loading

0 comments on commit 4f9fcb1

Please sign in to comment.