From 4f2fcc522b05fbdaf82c7b7487c4f248ef62a28c Mon Sep 17 00:00:00 2001 From: Richard Patel Date: Thu, 3 Mar 2022 22:54:56 +0100 Subject: [PATCH] .github: add golangci-lint and test --- .github/workflows/golangci-lint.yml | 24 ++++++++++++++++++++++++ .github/workflows/test.yml | 22 ++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 .github/workflows/golangci-lint.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..b51ee24 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,24 @@ +name: golangci-lint +on: + push: + tags: + - v* + branches: + - main + pull_request: +permissions: + contents: read +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v2 + - uses: actions/checkout@v2 + with: + go-version: 1.17.x + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + version: v1.44.2 + only-new-issues: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..96dc895 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,22 @@ +on: [ pull_request ] +name: unit tests +jobs: + unit_tests: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: 1.17.x + - uses: actions/cache@v2 + with: + path: | + ~/go/pkg/mod # Module download cache + ~/.cache/go-build # Build cache (Linux) + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Test + run: go test ./... -v + - name: Check Format + run: '[ "$(gofmt -l ./ | wc -l)" -eq 0 ]'