Skip to content

Commit e310945

Browse files
committed
build: add Makefile for dev workflow
1 parent 3265ab7 commit e310945

File tree

3 files changed

+55
-41
lines changed

3 files changed

+55
-41
lines changed

.github/workflows/go.yml

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,54 +11,24 @@ permissions:
1111
contents: read
1212

1313
jobs:
14-
golangci-lint:
14+
lint-test:
15+
name: Lint and Unit Test
1516
runs-on: ubuntu-latest
1617
steps:
1718
- uses: actions/checkout@v4
1819
with:
1920
fetch-depth: 0
20-
- uses: actions/setup-go@v5
21-
with:
22-
go-version: "1.24.4"
23-
- run: go mod tidy
24-
- name: golangci-lint
25-
uses: golangci/golangci-lint-action@v8
26-
with:
27-
version: latest
28-
args: --tests=false
29-
continue-on-error: true
30-
31-
gosec:
32-
runs-on: ubuntu-latest
33-
env:
34-
GO111MODULE: on
35-
steps:
36-
- uses: actions/checkout@v4
37-
with:
38-
fetch-depth: 0
39-
- uses: actions/setup-go@v5
40-
with:
41-
go-version: "1.24.4"
42-
- run: go mod tidy
43-
- name: Run Gosec Security Scanner
44-
uses: securego/gosec@master
45-
with:
46-
args: ./...
47-
continue-on-error: true
4821

49-
gotestsum:
50-
runs-on: ubuntu-latest
51-
steps:
52-
- uses: actions/checkout@v4
53-
with:
54-
fetch-depth: 0
5522
- uses: actions/setup-go@v5
5623
with:
5724
go-version: "1.24.4"
5825
- run: go mod tidy
5926
- run: go install gotest.tools/gotestsum@latest
60-
- run: gotestsum --junitfile unit-tests.xml -- -coverprofile=coverage.out -covermode=atomic ./...
61-
- uses: codecov/codecov-action@v5
62-
with:
63-
files: coverage.out
64-
token: ${{ secrets.CODECOV_TOKEN }}
27+
- run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
28+
- run: go install github.com/securego/gosec/v2/cmd/gosec@latest
29+
30+
- name: Lint
31+
run: make lint
32+
33+
- name: Unit-Test
34+
run: make test

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,5 @@ unit-tests.xml
6464
coverage.out
6565
.scannerwork/
6666
*-report*
67-
.sonarlint/
67+
.sonarlint/
68+
dependency-check/

Makefile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Define the Go binary and output directory
2+
GO ?= go
3+
OUTPUT_DIR ?= ./bin
4+
PROJECT_NAME ?= gitlab-sync
5+
MAIN_FILE ?= cmd/main.go
6+
DOCKERFILE ?= Containerfile
7+
DOCKER_ENGINE ?= podman
8+
9+
# Default target
10+
.DEFAULT_GOAL := build
11+
12+
# Build target
13+
build:
14+
@echo "Running go mod tidy..."
15+
$(GO) mod tidy
16+
@echo "Building the binary..."
17+
$(GO) build -o $(OUTPUT_DIR)/$(PROJECT_NAME) $(MAIN_FILE)
18+
19+
# Lint target
20+
lint:
21+
@echo "Running go mod tidy..."
22+
$(GO) mod tidy
23+
@echo "Running golangci-lint..."
24+
golangci-lint run --tests=false --fix --issues-exit-code 0
25+
@echo "Running gosec..."
26+
gosec -enable-audit -no-fail -quiet ./...
27+
28+
dependency-check:
29+
@echo "Running dependency-check..."
30+
dependency-check --nvdApiKey $(NVD_API_KEY) --scan ./ --format ALL --out dependency-check/ --enableExperimental
31+
32+
# Test target
33+
test:
34+
@echo "Running tests with coverage..."
35+
gotestsum --format-icons octicons -- -covermode=atomic ./...
36+
37+
# Docker target
38+
package:
39+
@echo "Building Docker image..."
40+
$(DOCKER_ENGINE) build -t $(PROJECT_NAME):dev -f $(DOCKERFILE) .
41+
42+
# Phony targets
43+
.PHONY: build lint dependency-check test package

0 commit comments

Comments
 (0)