diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml new file mode 100644 index 00000000..4f207d7e --- /dev/null +++ b/.github/workflows/pr_build.yml @@ -0,0 +1,26 @@ +name: PR Build + +on: + pull_request: {} + +jobs: + analysis: + name: PR Build + runs-on: ubuntu-latest + + steps: + - name: "Checkout code" + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 + + - name: "Setup Go" + uses: actions/setup-go@b22fbbc2921299758641fab08929b4ac52b32923 # v3.2.0 + with: + go-version-file: 'go.mod' + + - name: "Lint" + uses: golangci/golangci-lint-action@537aa1903e5d359d0b27dbc19ddd22c5087f3fbc # v3.2.0 + with: + version: v1.47.2 + + - name: "Unit test" + run: make test diff --git a/.golangci-lint b/.golangci-lint new file mode 100644 index 00000000..28e72197 --- /dev/null +++ b/.golangci-lint @@ -0,0 +1,45 @@ +[output] +format = "colored-line-number" + +[linters] +enable = [ + # Visit https://golangci-lint.run/usage/linters/ + # for the full, current list of available linters. + + # Default linters + "deadcode", # Finds unused code + "errcheck", # Detect unchecked errors + "gosimple", # Suggest code simplifications + "govet", # Reports suspicious constructs + "ineffassign", # Detects unused variable assignments + "staticcheck", # go vet on steroids + # "structcheck", # Find unused struct fields + "typecheck", # Standard Go type checks + "unused", # Detect unused constants, variables, functions and types + "varcheck", # Find unused global variables and constants + + # Suggested additional linters + "gocyclo", # or "cyclop", # Detect cyclomatic complexity + "goconst", # Detect repeated values that can be made constants + "gofumpt", # Or "gofmt", # Enforce standard formatting + "goimports", # Ensure standard import formatting/ordering + "misspell", # Fix spelling errors + "revive", # General purpose linter + "unconvert", # Detect unnecessary type conversions + "unparam", # Detect unused function parameters + + # Optional + "bodyclose", # Check whether HTTP response bodies are closed + # "goerr113", # Enforce standard error handling practices + # "depguard", # Forbid certain package imports + # "dupl", # Detect duplicate code + # "errchkjson", # some JSON-specific checks + # "gomnd", # Magic number detection + "nakedret", # Detect naked returns + # "rowserrcheck", # Check whether Err of rows is checked + # "sqlclosecheck", # Ensure sql.Rows and sql.Stmt are closed + "tparallel", # Detects inappropriate use of t.Parallel() +] + +[issues] +exclude-use-default = false diff --git a/README.md b/README.md index b537bcbf..c4e32d09 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,9 @@ -# spire-bridge +# Galadriel + +[![CodeQL](https://github.com/HewlettPackard/Galadriel/actions/workflows/codeql.yml/badge.svg)](https://github.com/HewlettPackard/Galadriel/actions/workflows/codeql.yml) +[![PR Build](https://github.com/HewlettPackard/Galadriel/actions/workflows/linter.yml/badge.svg)](https://github.com/HewlettPackard/Galadriel/actions/workflows/linter.yml) +[![Scorecards supply-chain security](https://github.com/HewlettPackard/Galadriel/actions/workflows/scorecards.yml/badge.svg)](https://github.com/HewlettPackard/Galadriel/actions/workflows/scorecards.yml) +[![trivy](https://github.com/HewlettPackard/Galadriel/actions/workflows/trivy.yml/badge.svg)](https://github.com/HewlettPackard/Galadriel/actions/workflows/trivy.yml) ## Development