Skip to content

Commit 6775729

Browse files
committed
Initial commit
0 parents  commit 6775729

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+5889
-0
lines changed

.github/workflows/ci.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Continious Integration
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
name: Test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: '1.22'
24+
cache: true
25+
26+
- name: Download dependencies
27+
run: go mod download
28+
29+
- name: Run tests
30+
run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
31+
32+
- name: Upload coverage to Codecov
33+
uses: codecov/codecov-action@v4
34+
with:
35+
files: ./coverage.out
36+
fail_ci_if_error: false
37+
continue-on-error: true
38+
39+
lint:
40+
name: Lint
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@v4
45+
46+
- name: Set up Go
47+
uses: actions/setup-go@v5
48+
with:
49+
go-version: '1.22'
50+
cache: true
51+
52+
- name: Run golangci-lint
53+
uses: golangci/golangci-lint-action@v6
54+
with:
55+
version: latest
56+
args: --timeout=5m
57+
58+
build:
59+
name: Build
60+
runs-on: ubuntu-latest
61+
needs: [test, lint]
62+
strategy:
63+
matrix:
64+
goos: [linux, darwin, windows]
65+
goarch: [amd64, arm64]
66+
exclude:
67+
- goos: windows
68+
goarch: arm64
69+
steps:
70+
- name: Checkout code
71+
uses: actions/checkout@v4
72+
73+
- name: Set up Go
74+
uses: actions/setup-go@v5
75+
with:
76+
go-version: '1.22'
77+
cache: true
78+
79+
- name: Build binary
80+
env:
81+
GOOS: ${{ matrix.goos }}
82+
GOARCH: ${{ matrix.goarch }}
83+
run: |
84+
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev")
85+
OUTPUT_NAME=opencligen-${{ matrix.goos }}-${{ matrix.goarch }}
86+
if [ "${{ matrix.goos }}" = "windows" ]; then
87+
OUTPUT_NAME="${OUTPUT_NAME}.exe"
88+
fi
89+
go build -ldflags "-X main.version=${VERSION}" -o ${OUTPUT_NAME} ./cmd/opencligen
90+
91+
- name: Upload artifact
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: opencligen-${{ matrix.goos }}-${{ matrix.goarch }}
95+
path: opencligen-*
96+
retention-days: 7

.golangci.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
run:
2+
timeout: 5m
3+
modules-download-mode: readonly
4+
5+
linters:
6+
enable:
7+
# Default linters
8+
- errcheck
9+
- gosimple
10+
- govet
11+
- ineffassign
12+
- staticcheck
13+
- unused
14+
# Additional linters
15+
- gofmt
16+
- goimports
17+
- misspell
18+
- unconvert
19+
- bodyclose
20+
- nilerr
21+
- exportloopref
22+
- gocritic
23+
- revive
24+
25+
linters-settings:
26+
gofmt:
27+
simplify: true
28+
goimports:
29+
local-prefixes: github.com/crunchloop/opencligen
30+
gocritic:
31+
enabled-tags:
32+
- diagnostic
33+
- performance
34+
disabled-checks:
35+
- hugeParam
36+
revive:
37+
rules:
38+
- name: blank-imports
39+
- name: context-as-argument
40+
- name: context-keys-type
41+
- name: error-return
42+
- name: error-strings
43+
- name: error-naming
44+
- name: exported
45+
- name: increment-decrement
46+
- name: var-naming
47+
- name: var-declaration
48+
- name: package-comments
49+
disabled: true
50+
- name: range
51+
- name: receiver-naming
52+
- name: indent-error-flow
53+
- name: empty-block
54+
- name: superfluous-else
55+
- name: unreachable-code
56+
57+
issues:
58+
exclude-rules:
59+
# Exclude some linters from running on tests files
60+
- path: _test\.go
61+
linters:
62+
- errcheck
63+
- gocritic
64+
# Exclude template files from most checks
65+
- path: \.tmpl$
66+
linters:
67+
- all
68+
max-issues-per-linter: 50
69+
max-same-issues: 10

CONTRIBUTING.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Contributing to opencligen
2+
3+
Thank you for your interest in contributing to opencligen! This document provides guidelines and instructions for contributing.
4+
5+
## Development Setup
6+
7+
### Prerequisites
8+
9+
- Go 1.22 or later
10+
- Make (optional, but recommended)
11+
- golangci-lint (for linting)
12+
13+
### Getting Started
14+
15+
1. Clone the repository:
16+
```bash
17+
git clone https://github.com/crunchloop/opencligen.git
18+
cd opencligen
19+
```
20+
21+
2. Install dependencies:
22+
```bash
23+
go mod download
24+
```
25+
26+
3. Run tests:
27+
```bash
28+
make test
29+
# or
30+
go test ./...
31+
```
32+
33+
4. Run linting:
34+
```bash
35+
make lint
36+
# or
37+
golangci-lint run
38+
```
39+
40+
5. Build the binary:
41+
```bash
42+
make build
43+
# or
44+
go build -o bin/opencligen ./cmd/opencligen
45+
```
46+
47+
## Making Changes
48+
49+
### Code Style
50+
51+
- Follow standard Go conventions and idioms
52+
- Run `make fmt` before committing to format code
53+
- Ensure all linting checks pass with `make lint`
54+
- Add tests for new functionality
55+
56+
### Testing
57+
58+
- Write tests for any new functionality
59+
- Ensure all existing tests pass before submitting a PR
60+
- Aim for at least 80% test coverage for new code
61+
- Run `make coverage` to check coverage
62+
63+
### Commit Messages
64+
65+
- Use clear, concise commit messages
66+
- Start with a verb in imperative mood (e.g., "Add", "Fix", "Update")
67+
- Reference related issues when applicable
68+
69+
## Pull Request Process
70+
71+
1. Fork the repository and create a feature branch
72+
2. Make your changes and ensure all tests pass
73+
3. Update documentation if needed
74+
4. Submit a pull request with a clear description of the changes
75+
76+
## Project Structure
77+
78+
```
79+
opencligen/
80+
├── cmd/opencligen/ # CLI entry point
81+
├── internal/
82+
│ ├── spec/ # OpenAPI spec parsing
83+
│ ├── plan/ # CLI command planning
84+
│ ├── gen/ # Code generation
85+
│ └── runtime_skel/ # Runtime library skeleton
86+
├── .github/workflows/ # CI/CD configuration
87+
└── Makefile # Build automation
88+
```
89+
90+
## Questions?
91+
92+
If you have questions or need help, please open an issue on GitHub.

Makefile

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
.PHONY: build test lint coverage clean install help
2+
3+
# Build variables
4+
BINARY_NAME := opencligen
5+
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
6+
BUILD_TIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
7+
LDFLAGS := -ldflags "-X main.version=$(VERSION) -X main.buildTime=$(BUILD_TIME)"
8+
9+
# Default target
10+
all: lint test build
11+
12+
## build: Build the binary
13+
build:
14+
go build $(LDFLAGS) -o bin/$(BINARY_NAME) ./cmd/opencligen
15+
16+
## test: Run all tests
17+
test:
18+
go test -race ./...
19+
20+
## lint: Run golangci-lint
21+
lint:
22+
golangci-lint run
23+
24+
## coverage: Run tests with coverage report
25+
coverage:
26+
go test -race -coverprofile=coverage.out -covermode=atomic ./...
27+
go tool cover -func=coverage.out
28+
@echo ""
29+
@echo "To view HTML coverage report, run: go tool cover -html=coverage.out"
30+
31+
## coverage-html: Generate and open HTML coverage report
32+
coverage-html: coverage
33+
go tool cover -html=coverage.out -o coverage.html
34+
@echo "Coverage report generated: coverage.html"
35+
36+
## clean: Remove build artifacts
37+
clean:
38+
rm -rf bin/
39+
rm -f coverage.out coverage.html
40+
41+
## install: Install the binary to GOPATH/bin
42+
install:
43+
go install $(LDFLAGS) ./cmd/opencligen
44+
45+
## fmt: Format code
46+
fmt:
47+
go fmt ./...
48+
goimports -w -local github.com/crunchloop/opencligen .
49+
50+
## vet: Run go vet
51+
vet:
52+
go vet ./...
53+
54+
## mod-tidy: Tidy go modules
55+
mod-tidy:
56+
go mod tidy
57+
58+
## check: Run all checks (fmt, vet, lint, test)
59+
check: fmt vet lint test
60+
61+
## help: Show this help message
62+
help:
63+
@echo "Usage: make [target]"
64+
@echo ""
65+
@echo "Targets:"
66+
@sed -n 's/^## //p' $(MAKEFILE_LIST) | column -t -s ':' | sed 's/^/ /'

0 commit comments

Comments
 (0)