Skip to content

Commit

Permalink
Set up GitHub Actions
Browse files Browse the repository at this point in the history
Signed-off-by: Russell <[email protected]>
  • Loading branch information
rtrox committed Dec 1, 2023
1 parent ecf12bf commit 579ba1b
Show file tree
Hide file tree
Showing 23 changed files with 454 additions and 168 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @rtrox
22 changes: 22 additions & 0 deletions .github/goreleaser-dist.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
project_name: "lybbrio"
archives:
- id: main
wrap_in_directory: true
files:
- "README.md"
builds:
- main: ./cmd/lybbrio/main.go
binary: lybbrio
ldflags:
- -s -w -X main.version={{.Version}} -X main.revision={{.Commit}} -X main.buildTime={{.CommitTimestamp}}
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm64
mod_timestamp: '{{ .CommitTimestamp }}'
changelog:
use: github-native
18 changes: 18 additions & 0 deletions .github/lint/golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
run:
timeout: 3m
linters:
# https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
# - wsl
# - dupl
# - errorlint
# - gofmt
# - goconst
# - revive
15 changes: 15 additions & 0 deletions .github/lint/precommit-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v0.7.1
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/adrienverge/yamllint
rev: v1.28.0
hooks:
- args:
- --config-file
- .github/lint/yamllint.yaml
id: yamllint
14 changes: 14 additions & 0 deletions .github/lint/yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
extends: default
rules:
truthy:
allowed-values: ["true", "false", "on"]
comments:
min-spaces-from-content: 1
line-length: disable
braces:
min-spaces-inside: 0
max-spaces-inside: 1
brackets:
min-spaces-inside: 0
max-spaces-inside: 0
indentation: enable
19 changes: 19 additions & 0 deletions .github/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# .github/release.yml
changelog:
exclude:
labels:
- ignore-for-release
authors:
- rtrox
categories:
- title: Breaking Changes 🛠
labels:
- Semver-Major
- breaking-change
- title: Exciting New Features 🎉
labels:
- Semver-Minor
- enhancement
- title: Other Changes
labels:
- "*"
58 changes: 58 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"extends": [
"config:base"
],
"enabled": true,
"timezone": "America/Los_Angeles",
"semanticCommits": "enabled",
"dependencyDashboard": true,
"dependencyDashboardTitle": "Renovate Dashboard 🤖",
"commitBody": "Signed-off-by: Russell Troxel <[email protected]>",
"suppressNotifications": ["prIgnoreNotification"],
"rebaseWhen": "conflicted",
"commitMessageTopic": "{{depName}}",
"commitMessageExtra": "to {{newVersion}}",
"commitMessageSuffix": "",
"git-submodules": {
"enabled": true
},
"enabledManagers": [
"dockerfile",
"gomod",
"git-submodules",
"pre-commit",
"github-actions"
],
"assignees": ["rtrox"],
"assignAutomerge": true,
"labels": ["dependencies"],
"packageRules": [
// add labels according to package and update types
{
"matchDepTypes": ["optionalDependencies"],
"addLabels": ["optional"]
},
{
"matchUpdateTypes": ["major"],
"addLabels": ["dep/major"]
},
{
"matchUpdateTypes": ["minor"],
"addLabels": ["dep/minor"],
},
{
"matchUpdateTypes": ["patch"],
"addLabels": ["dep/patch"],
},
{
"matchDatasources": ["docker"],
"addLabels": ["dep/docker"],
},
{
"matchDatasources": ["git-refs"],
"addLabels": ["dep/git-ref"],
},
// enable auto-merge
{ "updateTypes": ["minor", "patch", "pin", "digest"], "automerge": true }
]
}
10 changes: 10 additions & 0 deletions .github/workflows/on-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Handle Push to Main Branch
# https://dev.to/koddr/github-action-for-release-your-go-projects-as-fast-and-easily-as-possible-20a2
# https://github.com/orgs/community/discussions/25244
on:
push:
branches:
- main
jobs:
tests:
uses: ./.github/workflows/tests.yaml
53 changes: 53 additions & 0 deletions .github/workflows/on-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Create Release
# https://dev.to/koddr/github-action-for-release-your-go-projects-as-fast-and-easily-as-possible-20a2
# https://github.com/orgs/community/discussions/25244
on:
push:
tags:
- "v*.*.*"
jobs:
tests:
uses: ./.github/workflows/tests.yaml
main-branch-check:
runs-on: ubuntu-latest
needs: tests
outputs:
on_main_branch: ${{ steps.register_tag.outputs.on_main_branch }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git fetch --force --tags
- uses: rickstaa/action-contains-tag@v1
id: contains_tag
with:
reference: "main"
tag: "${{ github.ref }}"
- name: register output
id: register_tag
run: |
echo "retval: ${{ steps.contains_tag.outputs.retval }}"
echo "::set-output name=on_main_branch::${{ steps.contains_tag.outputs.retval }}"
release-tag:
runs-on: ubuntu-latest
needs: main-branch-check
if: ${{ needs.main-branch-check.outputs.on_main_branch }} == true
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git fetch --force --tags
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.21.4
id: go
- name: Create Release
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --rm-dist --config .github/goreleaser-dist.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60 changes: 60 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Run Tests
on:
workflow_call:
jobs:
pre-commit-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: pre-commit/[email protected]
with:
extra_args: --config .github/lint/precommit-ci.yaml
golangci-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ">=1.21.4"
- name: Check Go Fmt
run: |
go version
go fmt ./...
git diff --exit-code
- name: Check Go mod
run: |
go version
go mod tidy
git diff --exit-code
- uses: golangci/golangci-lint-action@v2
with:
version: v1.51.2
args: --timeout 5m --config .github/lint/golangci.yaml
go-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ">=1.21.4"
- name: Tidy
run: |
go version
go mod tidy
git diff --exit-code
- name: Run Unit tests
run: |
go version
go test -v -race -covermode atomic -coverprofile=covprofile ./...
# - name: Install goveralls
# run: |
# go version
# go install github.com/mattn/goveralls@latest

# - name: Send coverage
# env:
# COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: goveralls -coverprofile=covprofile -service=github
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v0.7.1
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/adrienverge/yamllint
rev: v1.28.0
hooks:
- args:
- --config-file
- .github/lint/yamllint.yaml
id: yamllint
- repo: https://github.com/golangci/golangci-lint
rev: v1.51.2
hooks:
- id: golangci-lint
args:
- --config
- .github/lint/golangci.yaml
2 changes: 1 addition & 1 deletion docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1137,4 +1137,4 @@
}
}
}
}
}
Loading

0 comments on commit 579ba1b

Please sign in to comment.