From 683572409435c694e4f5f8a305a629f3b13b7482 Mon Sep 17 00:00:00 2001 From: redowan Date: Mon, 4 Mar 2024 21:38:43 +0100 Subject: [PATCH] Better makefile --- .github/workflows/build.yml | 12 ------------ Makefile | 22 ++++++++-------------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ae4c186..bbfde6a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,20 +22,8 @@ jobs: go-version: "1.22" cache: true - - name: Install dependencies - run: make init - - name: Lint run: make lint-check - - name: check-is-dirty - run: | - if [[ -n $(git status --porcelain) ]]; then - echo "Detected uncommitted changes." - git status - git diff - exit 1 - fi - - name: Run tests run: make test diff --git a/Makefile b/Makefile index df1cbcf..0b9b2d0 100644 --- a/Makefile +++ b/Makefile @@ -1,38 +1,32 @@ -.PHONY: all build clean test lint ci +.PHONY: all build clean test lint lint-check ci + -# Binary name for the output binary BINARY_NAME=fork-sweeper -# Default command to run when no arguments are provided to make all: build -# Builds the binary build: @echo "Building..." go build -C cmd/fork-sweeper -o ../../${BINARY_NAME} -# Cleans our project: deletes binaries clean: @echo "Cleaning..." go clean rm -f ${BINARY_NAME} -# Runs tests test: @echo "Running tests..." go test ./... -cover -# Lints the project lint: @echo "Linting..." go fmt ./... go vet ./... go mod tidy -# Command for Continuous Integration -ci: lint test - @echo "CI steps..." - # Add commands specific to your CI setup - # e.g., integration testing, deployment commands, etc. - -# Additional commands can be added below for database migrations, Docker operations, etc. +lint-check: + @echo "Checking lint..." + @if [ -n "$$(gofmt -l .)" ]; then \ + echo "Some files are not formatted. Please run 'gofmt -w .' on your code."; \ + exit 1; \ + fi