diff --git a/.checkmake b/.checkmake new file mode 100644 index 0000000..90fc7b3 --- /dev/null +++ b/.checkmake @@ -0,0 +1,2 @@ +[maxbodylength] +disabled = true diff --git a/.github/workflows/pre-main.yaml b/.github/workflows/pre-main.yaml new file mode 100644 index 0000000..fb74a10 --- /dev/null +++ b/.github/workflows/pre-main.yaml @@ -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 diff --git a/.golangci.yml b/.golangci.yml index dadff10..160a0dd 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -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 @@ -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: @@ -43,8 +38,10 @@ 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 @@ -52,7 +49,6 @@ linters: enable: - bodyclose - dogsled - - dupl - errcheck - exhaustive - exportloopref @@ -62,7 +58,7 @@ linters: - gocyclo - gofmt - goimports - - gomnd + - mnd - goprintffuncname - gosec - gosimple @@ -70,10 +66,7 @@ linters: - ineffassign - lll - misspell - - nakedret - - noctx - nolintlint - - revive - rowserrcheck - staticcheck - stylecheck @@ -82,8 +75,10 @@ linters: - unparam - unused - whitespace - # don't enable: + # do not enable: # - asciicheck + # - depguard + # - dupl # - gochecknoglobals # - gochecknoinits # - gocognit @@ -91,8 +86,11 @@ linters: # - godox # - goerr113 # - maligned + # - nakedret # - nestif + # - noctx # - prealloc + # - revive # - exportloopref # - structcheck # - testpackage @@ -100,12 +98,25 @@ linters: 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: "^(.*= (\".*\"|`.*`))$" @@ -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" diff --git a/Makefile b/Makefile index ed39668..307d64d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ GOLANGCI_VERSION=v1.53.2 +.PHONY: all clean test build + lint: golangci-lint run # Install golangci-lint