Skip to content

Commit

Permalink
Draft: Add go linter tool and unit testing for Pr build process (#13)
Browse files Browse the repository at this point in the history
* Add go linter tool
* Add unit-test workflow

Signed-off-by: Nathalia <[email protected]>
  • Loading branch information
n-th authored Jul 28, 2022
1 parent c406d7d commit 2edf9ad
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
26 changes: 26 additions & 0 deletions .github/workflows/pr_build.yml
Original file line number Diff line number Diff line change
@@ -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
45 changes: 45 additions & 0 deletions .golangci-lint
Original file line number Diff line number Diff line change
@@ -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
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 2edf9ad

Please sign in to comment.