Skip to content

Commit

Permalink
feat: added workflow for lint and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmoysrt committed Nov 10, 2023
1 parent e2365ae commit 0621b7e
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/go-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Golang Lint CI
on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read
pull-requests: read

jobs:
gofmt-unix:
strategy:
matrix:
go: ["1.21.3"]
os: [macos-latest, ubuntu-latest]
name: gofmt
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
cache: true
- name: Run format checks
run: |
if [ $(gofmt -d -l -e . | wc -l) -eq 0 ]; then
printf 'Format Checks Have Passed!!!'
else
printf 'Format Checks Have Failed!\nPlease use gofmt in your system to format your code.'
gofmt -l -e -d .
exit 1
fi
golangci:
strategy:
matrix:
go: ["1.21.3"]
os: [macos-latest, ubuntu-latest]
name: lint
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
args: --timeout 10m
- name: Verify dependencies
run: go mod verify

- name: Build
run: go build -v ./...

- name: Run go vet
run: go vet ./...

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest

- name: Run staticcheck
run: staticcheck ./...
29 changes: 29 additions & 0 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Golang Test CI
on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read
pull-requests: read

jobs:
test:
strategy:
matrix:
go: ["1.21.3"]
os: [macos-latest, ubuntu-latest]
name: lint
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
cache: true
- name: go-test
run: go test -v ./...

0 comments on commit 0621b7e

Please sign in to comment.