Skip to content

Commit

Permalink
Initial CI workflow (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
pantrif authored Jul 24, 2024
1 parent bb43a2c commit 30fb858
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

make lint
44 changes: 44 additions & 0 deletions .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Go CI

on:
pull_request:

env:
GO_VERSION: '1.22.5'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.59

unit_test:
needs: [lint]
name: Run Unit Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: execute tests
run: make test
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*.exe
*.exe~
*.dll
*.so
*.dylib
*.test
*.out
go.work
go.work.sum
.env
.idea/
.vscode/
coverage.txt
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
all: help

.PHONY: help
help: Makefile
@echo "Available commands:"
@echo
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo

.PHONY: lint
## lint: Runs golangci-lint run
lint:
golangci-lint run

.PHONY: test
## test: Runs `go test` on project test files.
test:
go test ./... -race

## install-hooks: Install git-hooks from .githooks directory.
.PHONY: install-hooks
install-hooks:
git config core.hooksPath .githooks

0 comments on commit 30fb858

Please sign in to comment.