Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Makefile to allow running the tests locally #54

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/golangci/golangci-lint
rev: v1.60.3
hooks:
- id: golangci-lint
entry: golangci-lint run
args: [--timeout=5m]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.38.0
hooks:
- id: markdownlint
args: [--disable, MD013, MD002]
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: shellcheck
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-json
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.PHONY: lint test unittest help all

UNITTEST_PKG ?= "./..."

all: test

help:
@echo "Make targets:"
@echo
@echo 'Usage:'
@echo ' make lint Execute pre-commit linters'
@echo ' make unittest Execute unittest'
@echo ' make help Show this message'

test: lint unittest

unittest:
ginkgo -r --randomize-all --randomize-suites --fail-on-pending --cover --trace --v --coverprofile=coverage.out ${UNITTEST_PKG}

lint:
@echo "Executing pre-commit for all files"
pre-commit run --all-files
@echo "pre-commit executed."
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,15 @@

[![codecov](https://codecov.io/github/cloud-bulldozer/go-commons/branch/main/graph/badge.svg?token=CFPW1UV7FO)](https://codecov.io/github/cloud-bulldozer/go-commons)
[![Go Report Card](https://goreportcard.com/badge/github.com/cloud-bulldozer/go-commons)](https://goreportcard.com/report/github.com/cloud-bulldozer/go-commons)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

## Running test locally
Use `make` to run lint and unittest locally. See `make help` for details

### `lint`
The `lint` tests are executed using [pre-commit](https://pre-commit.com/).
Make sure to install it before running.

### `unittest`
The `unittest` tests are executed using [ginkgo](https://onsi.github.io/ginkgo/).
Make sure to install it locally before running.
Loading