Skip to content

Commit

Permalink
added github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
dabump committed Nov 15, 2024
1 parent 9b52111 commit 9475ba3
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/config/golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
run:
timeout: 5m
go: '1.22'
linters:
enable:
- gofmt # Gofmt checks whether code was gofmt-ed. By default, this tool runs with -s option to check for code simplification
- gci # Gci controls golang package import order and makes it always deterministic.
- errorlint # errorlint can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
- containedctx # containedctx is a linter that detects struct contained context.Context field
- dogsled # Checks assignments with too many blank identifiers (e.g. x, , , _, := f())
- nilnil # Checks that there is no simultaneous return of nil error and an invalid value.
- noctx # noctx finds sending http request without context.Context
- funlen # limit function length
- dupl # Detect code duplication

issues:
exclude-rules:
- linters:
- containedctx
- gocyclo
- gocognit
- funlen
path: _test\.go

linters-settings:
gocyclo:
min-complexity: 10
gocognit:
min-complexity: 20
funlen:
lines: 120
statements: 120

43 changes: 43 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Lint checks
on:
push:
branches:
- 'main'
- '[0-9]+.[1-9][0-9]*.x'
pull_request:
branches:
- 'main'
- '[0-9]+.[1-9][0-9]*.x'
paths:
- "**.go"
- "**/go.mod"
- "**/go.sum"
- ".golangi.yml"
- ".github/workflows/golangci-lint.yml"
- "!docs/**"
env:
# renovate: datasource=github-releases depName=golangci/golangci-lint
GOLANGCI_LINT_VERSION: "v1.57.2"
GO_VERSION: "~1.22"
jobs:
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Check out code
uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
check-latest: true

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
working-directory: ./
version: ${{ env.GOLANGCI_LINT_VERSION }}
args: --config ./.github/config/golangci.yml -v

57 changes: 57 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: ci

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
env:
DEFAULT_GO_VERSION: "~1.22"

permissions:
contents: read

jobs:
unit-test:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.DEFAULT_GO_VERSION }}

- name: Setup Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Module cache
uses: actions/cache@v4
env:
cache-name: go-mod-cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }}

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

- name: Make a build
run: make build

- name: Unit Test
run: make unit-test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unit-tests
files: ./cover.out
slug: dabump/pingreboot

0 comments on commit 9475ba3

Please sign in to comment.