Skip to content

Commit

Permalink
ci: add workflows (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZigBalthazar authored Sep 8, 2024
1 parent 2e478bb commit e10acff
Show file tree
Hide file tree
Showing 7 changed files with 273 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*/ @ZigBalthazar
*/ @kehiy
7 changes: 7 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Description
<!-- Explain the changes you've made and the reason for this pull request. Provide enough context for reviewers to understand your changes. -->

## Related Issue
<!-- If your pull request is related to an existing GitHub issue, link it here. -->

- Fixes #(issue number)
25 changes: 25 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Lint and format check

on:
push:
branches:
- main

pull_request:
branches:
- main

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22.5'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60
56 changes: 56 additions & 0 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Create and publish a Docker image

# This workflow is wrote based on this document: https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions

on:
push:
tags:
- 'v*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}


jobs:
build-and-push-image:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
17 changes: 17 additions & 0 deletions .github/workflows/semantic-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Semantic PR

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Run Tests

on:
push:
branches:
- main

pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '1.22.5'

- name: Unit tests
run: make unit_test

- name: Race tests
run: make test_race
137 changes: 137 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
linters:
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- asasalint
- asciicheck
- bidichk
- bodyclose
- contextcheck
- decorder
- dogsled
- dupword
- durationcheck
- errchkjson
- errname
- errorlint
- exhaustive
- exportloopref
- forbidigo
- gci
- ginkgolinter
- gocheckcompilerdirectives
- gocognit
- gocritic
- gocyclo
- godot
- gofmt
- gofumpt
- goheader
- goimports
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosmopolitan
- grouper
- importas
- lll
- loggercheck
- maintidx
- makezero
- mirror
- misspell
- musttag
- nakedret
- nestif
- nilerr
- nilnil
- nlreturn
- noctx
- nolintlint
- nosprintfhostport
- prealloc
- predeclared
- promlinter
- reassign
- revive
- rowserrcheck
- sqlclosecheck
- stylecheck
- tagalign
- tagliatelle
- tenv
- testableexamples
- thelper
- tparallel
- unconvert
- unparam
- usestdlibvars
- wastedassign
- whitespace
# - wrapcheck
- zerologlint
- nonamedreturns

linters-settings:
gosimple:
checks: ["all"]

govet:
enable-all: true
disable: fieldalignment
shadow:
strict: true

predeclared:
# Comma-separated list of predeclared identifiers to not report on.
# Default: ""
ignore: "len"
# Include method names and field names (i.e., qualified names) in checks.
# Default: false
q: true

tagliatelle:
# Check the struct tag name case.
case:
use-field-name: false
rules:
json: snake
yaml: snake

nonamedreturns:
# Report named error if it is assigned inside defer.
# Default: false
report-error-in-defer: false

gocritic:
disabled-checks:
- ifElseChain
- unnamedResult
enabled-tags:
- diagnostic
- style
- performance

nestif:
# Minimal complexity of if statements to report.
# Default: 5
min-complexity: 6

issues:
exclude-rules:
- path: _test.go
linters:
- maintidx
- nestif
- gocognit
- forbidigo

- linters:
- govet
text: "shadow: declaration of \"err\" shadows"

0 comments on commit e10acff

Please sign in to comment.