Skip to content

Commit

Permalink
Merge pull request #2 from edcdavid/add-ci
Browse files Browse the repository at this point in the history
Add CI
  • Loading branch information
edcdavid authored Aug 20, 2024
2 parents e894570 + 26f8284 commit 1fa86f6
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .checkmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[maxbodylength]
disabled = true
88 changes: 88 additions & 0 deletions .github/workflows/pre-main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Test Incoming Changes

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

permissions:
contents: read

env:
TERM: xterm-color
CM_BIN: /usr/local/bin/checkmake
CM_URL_LINUX: https://github.com/mrtazz/checkmake/releases/download/0.2.2/checkmake-0.2.2.linux.amd64 # yamllint disable-line

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true

jobs:
lint-and-test:
name: Run Linters, Vet and unit tests
runs-on: ubuntu-22.04
env:
SHELL: /bin/bash

steps:
- name: Set up Go 1.22
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: 1.22.5

- name: Disable default go problem matcher
run: echo "::remove-matcher owner=go::"

- name: Check out code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: ${{ github.sha }}

- name: Extract dependent Pull Requests
uses: depends-on/depends-on-action@9e8a61fce18b15281e831f1bba0e14c71d1e1f46 # main
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install checkmake
run: |
curl --location --output $CM_BIN --silent $CM_URL_LINUX
chmod +x $CM_BIN
- name: Install Shfmt
uses: mfinelli/setup-shfmt@031e887e39d899d773a7e9b6dd6472c2c23ff50d # v3.0.1

- name: Golangci-lint
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
with:
version: v1.59
args: --timeout 10m0s

- name: Checkmake
run: checkmake --config=.checkmake Makefile

- name: Hadolint
uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf # v3.1.0
with:
dockerfile: Dockerfile
recursive: true

- name: Shfmt
run: shfmt -d scripts

- name: ShellCheck
uses: ludeeus/action-shellcheck@00b27aa7cb85167568cb48a3838b75f4265f2bca # master

- name: Go vet
run: make vet

- name: Run Build
run: make build
env:
SHELL: /bin/bash

- name: Run Tests
run: make test
env:
SHELL: /bin/bash
53 changes: 32 additions & 21 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ linters-settings:
dupl:
threshold: 100
funlen:
lines: 50
statements: 30
gci:
local-prefixes: github.com/golangci/golangci-lint
lines: 60
statements: 45
goconst:
min-len: 4
min-occurrences: 2
Expand All @@ -19,16 +17,13 @@ linters-settings:
disabled-checks:
- whyNoLint
gocyclo:
min-complexity: 15
goimports:
local-prefixes: github.com/golangci/golangci-lint
gomnd:
min-complexity: 20
mnd:
settings:
mnd:
# don't include the "operation" and "assign"
# do not include the "operation" and "assign"
checks: argument,case,condition,return
govet:
check-shadowing: true
settings:
printf:
funcs:
Expand All @@ -43,16 +38,17 @@ linters-settings:
nolintlint:
allow-leading-space: false # disallow leading spaces. A space means the //nolint comment shows in `godoc` output.
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-explanation: false # do not require an explanation for nolint directives
require-specific: true # require nolint directives to be specific about which linter is being skipped
exhaustive:
default-signifies-exhaustive: true
linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- bodyclose
- dogsled
- dupl
- errcheck
- exhaustive
- exportloopref
Expand All @@ -62,18 +58,15 @@ linters:
- gocyclo
- gofmt
- goimports
- gomnd
- mnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- noctx
- nolintlint
- revive
- rowserrcheck
- staticcheck
- stylecheck
Expand All @@ -82,30 +75,48 @@ linters:
- unparam
- unused
- whitespace
# don't enable:
# do not enable:
# - asciicheck
# - depguard
# - dupl
# - gochecknoglobals
# - gochecknoinits
# - gocognit
# - godot
# - godox
# - goerr113
# - maligned
# - nakedret
# - nestif
# - noctx
# - prealloc
# - revive
# - exportloopref
# - structcheck
# - testpackage
# - wsl
issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
# Ignore magic numbers and inline strings in tests.
# Ignore magic numbers, inline strings and function length in tests.
- path: _test\.go
linters:
- gomnd
- mnd
- goconst
# Ignore line length for string assignments (don't try and wrap regex definitions)
- funlen
- path: config/config.go
linters:
- mnd
- path: _scaling.go
linters:
- gocritic
- path: hugepages.go
linters:
- mnd
- path: scheduling.go
linters:
- mnd
# Ignore line length for string assignments (do not try and wrap regex definitions)
- linters:
- lll
source: "^(.*= (\".*\"|`.*`))$"
Expand All @@ -119,6 +130,6 @@ issues:
# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
service:
golangci-lint-version: 1.52.x # use the fixed version to not introduce new linters unexpectedly
golangci-lint-version: 1.59.x # use the fixed version to not introduce new linters unexpectedly
prepare:
- echo "here I can run custom commands, but no preparation needed for this repo"
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
GOLANGCI_VERSION=v1.53.2

.PHONY: all clean test build

lint:
golangci-lint run
# Install golangci-lint
Expand Down

0 comments on commit 1fa86f6

Please sign in to comment.