diff --git a/.github/workflows/golang-ci.yml b/.github/workflows/golang-ci.yml new file mode 100644 index 0000000..9a56170 --- /dev/null +++ b/.github/workflows/golang-ci.yml @@ -0,0 +1,40 @@ +name: golang-ci + +on: + # Trigger the workflow on push or pull request, + # but only for the main branch + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + container: + image: golangci/golangci-lint:v1.54.0 + steps: + - name: checkout + uses: actions/checkout@v4 + - name: golangci-lint + run: golangci-lint run --modules-download-mode=mod + + build: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.21 + - name: build broker + run: go build -o chat-broker ./cmd/broker + - name: build logic + run: go build -o chat-logic ./cmd/logic diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..699f062 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,25 @@ +linters: + disable-all: true + enable: + - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases + - gosimple # Linter for Go source code that specializes in simplifying a code + - govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string + - ineffassign # Detects when assignments to existing variables are not used + - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks + - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code + - unused # Checks Go code for unused constants, variables, functions and types + - exportloopref + +linters-settings: + govet: + enable-all: true + check-shadowing: true + disable: + - fieldalignment + +run: + skip-dirs: + - scripts + - test + - example + - cmd