Skip to content

Commit 99ecc32

Browse files
committed
chore: enhance project infrastructure
- Pin GitHub Actions to tag SHAs instead of commit SHAs - Use make targets in CI workflows instead of raw commands - Add vulncheck to Makefile and CI - Simplify golangci-lint config for v2 compatibility - Fix README hallucinations (remove non-existent file references) - Add Dependabot configuration for GitHub Actions and Go modules
1 parent 2f9f789 commit 99ecc32

12 files changed

Lines changed: 800 additions & 28 deletions

File tree

.github/dependabot.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
version: 2
22
updates:
3+
# Maintain dependencies for GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
groups:
10+
github-actions:
11+
patterns:
12+
- "*"
13+
labels:
14+
- "dependencies"
15+
- "github-actions"
16+
17+
# Maintain dependencies for Go modules
318
- package-ecosystem: "gomod"
419
directory: "/"
520
schedule:
621
interval: "weekly"
7-
open-pull-requests-limit: 1
22+
day: "monday"
823
groups:
924
go-dependencies:
1025
patterns:
1126
- "*"
12-
update-types:
13-
- "major"
14-
- "minor"
15-
- "patch"
27+
labels:
28+
- "dependencies"
29+
- "go"

.github/workflows/ci.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint:
11+
name: Lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
19+
with:
20+
go-version: '1.24'
21+
cache: true
22+
cache-dependency-path: go.sum
23+
24+
- name: Install golangci-lint
25+
uses: golangci/golangci-lint-action@8564da7cb3c6866ed1da648ca8f00a258ef0c802 # v6.5.2
26+
with:
27+
version: v2.11.4
28+
skip-install: true
29+
30+
- name: Run linter
31+
run: make lint
32+
33+
vulncheck:
34+
name: Vulnerability Check
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
39+
40+
- name: Set up Go
41+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
42+
with:
43+
go-version: '1.24'
44+
cache: true
45+
cache-dependency-path: go.sum
46+
47+
- name: Run vulnerability check
48+
run: make vulncheck
49+
50+
test:
51+
name: Test
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Checkout code
55+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
56+
57+
- name: Set up Go
58+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
59+
with:
60+
go-version: '1.24'
61+
cache: true
62+
cache-dependency-path: go.sum
63+
64+
- name: Run tests
65+
run: make test
66+
67+
- name: Upload coverage to artifacts
68+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
69+
with:
70+
name: coverage-report
71+
path: |
72+
coverage.out
73+
coverage.html
74+
75+
- name: Display coverage summary
76+
run: make coverage-func

.github/workflows/publish.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ jobs:
1515
contents: write
1616
steps:
1717
- name: Checkout repository
18-
uses: actions/checkout@v4
18+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
1919

2020
- name: Set up QEMU
21-
uses: docker/setup-qemu-action@v3
21+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
2222

2323
- name: Set up Docker Buildx
24-
uses: docker/setup-buildx-action@v3
24+
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca # v3.9.0
2525

2626
- name: Login to Docker Hub
27-
uses: docker/login-action@v3
27+
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
2828
with:
2929
username: ${{ secrets.DOCKER_USERNAME }}
3030
password: ${{ secrets.DOCKER_PASSWORD }}
3131

3232
- name: Build and push Docker image
33-
uses: docker/build-push-action@v6
33+
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
3434
with:
3535
context: .
3636
push: true
@@ -49,12 +49,12 @@ jobs:
4949
done
5050
5151
- name: Upload Release Assets
52-
uses: softprops/action-gh-release@v2
52+
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2
5353
with:
5454
files: built/*
55-
55+
5656
- name: Update repo description
57-
uses: peter-evans/dockerhub-description@v4
57+
uses: peter-evans/dockerhub-description@432a30c9e07499fd01da9f8a49f0faf9e0ca5b77 # v4.0.2
5858
with:
5959
username: ${{ secrets.DOCKER_USERNAME }}
6060
password: ${{ secrets.DOCKER_PASSWORD }}

.golangci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: "2"
2+
3+
run:
4+
timeout: 5m
5+
tests: true
6+
modules-download-mode: readonly
7+
8+
linters:
9+
enable:
10+
- govet
11+
- staticcheck
12+
- errcheck
13+
- ineffassign
14+
- unused
15+
- misspell
16+
- gocritic
17+
- gosec
18+
- revive
19+
20+
formatters:
21+
enable:
22+
- gofmt
23+
- goimports

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Morteza Pourseif
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
.PHONY: lint fix clean vulncheck ci deps deps-update run help
2+
3+
# Variables
4+
BINARY_NAME=kmir
5+
GO=go
6+
GOFLAGS=-v
7+
LINTER=golangci-lint
8+
9+
help: ## Show this help message
10+
@echo 'Usage: make [target]'
11+
@echo ''
12+
@echo 'Available targets:'
13+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
14+
15+
build: ## Build the binary
16+
@echo "Building $(BINARY_NAME)..."
17+
$(GO) build $(GOFLAGS) -o $(BINARY_NAME) .
18+
19+
test: ## Run tests
20+
@echo "Running tests..."
21+
$(GO) test -v -race -coverprofile=coverage.out -covermode=atomic ./...
22+
23+
test-short: ## Run short tests only
24+
@echo "Running short tests..."
25+
$(GO) test -v -short ./...
26+
27+
lint: ## Run linters
28+
@echo "Running linters..."
29+
$(LINTER) run --timeout 5m ./...; \
30+
31+
fix: ## Auto-fix linting issues
32+
@echo "Fixing linting issues..."
33+
$(LINTER) run --fix --timeout 5m ./...; \
34+
35+
coverage: ## Generate coverage report
36+
@echo "Generating coverage report..."
37+
$(GO) test -coverprofile=coverage.out -covermode=atomic ./...
38+
$(GO) tool cover -html=coverage.out -o coverage.html
39+
@echo "Coverage report generated: coverage.html"
40+
41+
coverage-func: ## Show coverage by function
42+
@echo "Coverage by function:"
43+
$(GO) test -coverprofile=coverage.out -covermode=atomic ./...
44+
$(GO) tool cover -func=coverage.out
45+
46+
clean: ## Clean build artifacts
47+
@echo "Cleaning..."
48+
rm -f $(BINARY_NAME)
49+
rm -f coverage.out coverage.html
50+
rm -f *.test
51+
52+
vulncheck: ## Check for security vulnerabilities
53+
@echo "Checking for vulnerabilities..."
54+
$(GO) tool govulncheck ./...
55+
56+
ci: lint vulncheck test ## Run CI checks (lint + vulncheck + test)
57+
58+
deps: ## Download dependencies
59+
@echo "Downloading dependencies..."
60+
$(GO) mod download
61+
$(GO) mod tidy
62+
63+
deps-update: ## Update dependencies
64+
@echo "Updating dependencies..."
65+
$(GO) get -u ./...
66+
$(GO) mod tidy
67+
68+
run: build ## Build and run the binary
69+
@echo "Running $(BINARY_NAME)..."
70+
./$(BINARY_NAME)

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,64 @@ The positional arguments, which specify the topic information, can be in any of
6868
```sh
6969
kmir --source-brokers=localhost:9092 --sink-brokers=localhost:9093 --client-id=my-client --kafka-version=2.7.0 topic1 topic2@-1 topic3@0:100,1:200
7070
```
71+
72+
## Development
73+
74+
### Prerequisites
75+
76+
- Go 1.24 or later
77+
- golangci-lint v2.11.4 or later
78+
79+
### Setup
80+
81+
```bash
82+
# Clone the repository
83+
git clone https://github.com/mortezaPRK/kmir.git
84+
cd kmir
85+
86+
# Install dependencies
87+
make deps
88+
```
89+
90+
### Building
91+
92+
```bash
93+
# Build the binary
94+
make build
95+
```
96+
97+
### Testing
98+
99+
```bash
100+
# Run all tests
101+
make test
102+
103+
# Run short tests only
104+
make test-short
105+
106+
# Generate coverage report
107+
make coverage
108+
109+
# Run all CI checks
110+
make ci
111+
```
112+
113+
### Available Make Commands
114+
115+
| Command | Description |
116+
|---------|-------------|
117+
| `make build` | Build the binary |
118+
| `make test` | Run tests with race detection |
119+
| `make test-short` | Run short tests only |
120+
| `make lint` | Run linters (golangci-lint) |
121+
| `make fix` | Auto-fix formatting issues |
122+
| `make coverage` | Generate coverage report |
123+
| `make clean` | Clean build artifacts |
124+
| `make ci` | Run full CI checks (lint, vulncheck, test) |
125+
| `make deps` | Download dependencies |
126+
| `make deps-update` | Update dependencies |
127+
| `make vulncheck` | Check for security vulnerabilities |
128+
129+
## License
130+
131+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)