Skip to content

Commit dafd47b

Browse files
authored
Merge pull request #10 from mortezaPRK/feature/enhance-project-infrastructure
feat: enhance project infrastructure
2 parents 55f1d64 + 27e5208 commit dafd47b

12 files changed

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