-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add workflow, golangci, update module * upgrade arca deps * start linting * more lint * remove some linters * remove revive * check errors * cover internal files * fix implicit memory aliasing in for loop * fix lint * remove generate from ci * add newline * remove line from config * pin ci golang lint version * nolint * nolint all * optimize * add a comment about the issue * gofmt
- Loading branch information
Showing
9 changed files
with
214 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Build | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
env: | ||
go_version: 1.21.6 | ||
jobs: | ||
golangci-lint: | ||
name: golangci-lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Pin Golang version for linting | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ env.go_version }} | ||
- name: Run golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v1.55.2 | ||
test: | ||
name: go test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ env.go_version }} | ||
- name: Set up gotestfmt | ||
uses: GoTestTools/gotestfmt-action@v2 | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/go/pkg/mod | ||
~/.cache/go-build | ||
key: go-test-${{ hashFiles('**/go.sum') }} | ||
restore-keys: go-test- | ||
- name: Run go test | ||
run: | | ||
set -euo pipefail | ||
go generate | ||
go test -coverprofile /tmp/coverage.out -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt | ||
echo "# Code coverage summary" > /tmp/coverage.md | ||
echo "|File|Type|Coverage|" >> /tmp/coverage.md | ||
echo "|----|----|--------|" >> /tmp/coverage.md | ||
go tool cover -func /tmp/coverage.out | sed -e 's/\s\s*/|/g' -e 's/^/|/g' -e 's/$/|/g' >> /tmp/coverage.md | ||
cat /tmp/coverage.md >> $GITHUB_STEP_SUMMARY | ||
echo "::group::Code coverage summary" | ||
go tool cover -func /tmp/coverage.out | ||
echo "::endgroup::" | ||
- name: Upload test log | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: test-results | ||
path: | | ||
/tmp/gotest.log | ||
/tmp/coverage.out | ||
/tmp/coverage.md | ||
if-no-files-found: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
run: | ||
timeout: 5m | ||
linters: | ||
enable: | ||
# region General | ||
|
||
# Add depguard to prevent adding additional dependencies. This is a client library, we really don't want | ||
# additional dependencies. | ||
- depguard | ||
# Prevent improper directives in go.mod. | ||
- gomoddirectives | ||
# Prevent improper nolint directives. | ||
- nolintlint | ||
|
||
# endregion | ||
|
||
|
||
# region Code Quality and Comments | ||
|
||
# Inspect source code for potential security problems. This check has a fairly high false positive rate, | ||
# comment with // nolint:gosec where not relevant. | ||
- gosec | ||
# Complain about deeply nested if cases. | ||
- nestif | ||
# Prevent naked returns in long functions. | ||
- nakedret | ||
# Make Go code more readable. | ||
- gocritic | ||
# Check if comments end in a period. This helps prevent incomplete comment lines, such as half-written sentences. | ||
- godot | ||
# Complain about comments as these indicate incomplete code. | ||
- godox | ||
# Keep the cyclomatic complexity of functions to a reasonable level. | ||
- gocyclo | ||
# Find repeated strings that could be converted into constants. | ||
- goconst | ||
# Complain about unnecessary type conversions. | ||
- unconvert | ||
# Complain about unused parameters. These should be replaced with underscores. | ||
- unparam | ||
# Check for non-ASCII identifiers. | ||
- asciicheck | ||
# Check for HTTP response body being closed. Sometimes, you may need to disable this using // nolint:bodyclose. | ||
- bodyclose | ||
# Check for duplicate code. You may want to disable this with // nolint:dupl if the source code is the same, but | ||
# legitimately exists for different reasons. | ||
- dupl | ||
# Check for pointers in loops. This is a typical bug source. | ||
- exportloopref | ||
# Prevent dogsledding (mass-ignoring return values). This typically indicates missing error handling. | ||
- dogsled | ||
# Enforce consistent import aliases across all files. | ||
- importas | ||
# Make code properly formatted. | ||
- gofmt | ||
# Prevent faulty error checks. | ||
- nilerr | ||
# Prevent direct error checks that won't work with wrapped errors. | ||
- errorlint | ||
# Find slice usage that could potentially be preallocated. | ||
- prealloc | ||
# Check for improper duration handling. | ||
- durationcheck | ||
|
||
# endregion | ||
linters-settings: | ||
depguard: | ||
rules: | ||
main: | ||
list-mode: strict | ||
files: | ||
- "**/internal/*.go" | ||
allow: | ||
- $gostd | ||
- go.flow.arcalot.io/ | ||
- go.arcalot.io/ | ||
- github.com/docker/ | ||
- github.com/opencontainers/ | ||
- gopkg.in/yaml.v3 | ||
- github.com/fxamacker/cbor | ||
- k8s.io/ | ||
- sigs.k8s.io/ | ||
- golang.org/ | ||
- github.com/stretchr/testify | ||
govet: | ||
enable-all: true | ||
check-shadowing: false | ||
disable: | ||
# We don't care about variable shadowing. | ||
- shadow | ||
- fieldalignment | ||
stylecheck: | ||
checks: | ||
- all | ||
issues: | ||
exclude-use-default: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
package arcaflow_lib_kubernetes | ||
package arcaflow_lib_kubernetes_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.