Skip to content

Commit

Permalink
Added github lint and test actions
Browse files Browse the repository at this point in the history
  • Loading branch information
thrawn01 committed Nov 3, 2024
1 parent 4345f08 commit 0893aaf
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 1 deletion.
36 changes: 36 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Lint

on:
push:
branches: [ master ]
pull_request:

env:
GOLANGCI_LINT_VERSION: v1.61.0

jobs:
lint:
name: lint
strategy:
matrix:
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: ./go.mod
cache: true # caching and restoring go modules and build outputs

- name: Check that 'go mod tidy' was called before commit
run: go mod tidy && git diff --exit-code

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
skip-cache: true # cache/restore is done by actions/setup-go@v3 step
args: -v
46 changes: 46 additions & 0 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: On Pull Request

on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

jobs:
test:
name: test
strategy:
matrix:
go-version:
- 1.23.x
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Fetch git tags
run: git fetch --tags

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Cache deps
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install deps
run: go mod download

- name: Test
run: go test -timeout 10m -v -p=1 -count=1 -race -tags clock_mutex
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DEFAULT_GOAL := build
LINT = $(GOPATH)/bin/golangci-lint
LINT_VERSION = 1.56.2
LINT_VERSION = v1.61.0

$(LINT): ## Download Go linter
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin $(LINT_VERSION)
Expand Down

0 comments on commit 0893aaf

Please sign in to comment.