Skip to content

Commit 5d2db9a

Browse files
committed
Go port - phase 1
Begin porting this CLI to go - Justfile targets: `just go-build`, `go-test`, etc... `just ci-all` to run CI for both. - Conventional `pkg/` and `cmd/` layout - depends on the cobra CLI interface - linter rules - integrated go CI The eventual result will be a -beta CLI version in parallel with the C# CLI
1 parent 67a062c commit 5d2db9a

File tree

18 files changed

+1813
-0
lines changed

18 files changed

+1813
-0
lines changed

.github/workflows/go-ci.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Go CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
go-build-and-test:
15+
name: Go Build and Test
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
runner-os: [windows-latest, ubuntu-latest, macos-latest]
20+
21+
runs-on: ${{ matrix.runner-os }}
22+
23+
steps:
24+
- uses: actions/checkout@v6
25+
with:
26+
persist-credentials: false
27+
28+
- name: Setup Go
29+
uses: actions/setup-go@v5
30+
with:
31+
go-version-file: go.mod
32+
cache: true
33+
34+
- name: Setup Just
35+
uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff
36+
37+
- name: Check Go formatting
38+
if: matrix.runner-os == 'ubuntu-latest'
39+
run: |
40+
if [ -n "$(gofmt -l .)" ]; then
41+
echo "Go files need formatting:"
42+
gofmt -l .
43+
exit 1
44+
fi
45+
46+
- name: Go Vet
47+
run: go vet ./...
48+
49+
- name: Build Go binaries
50+
run: just go-build
51+
52+
- name: Run Go tests
53+
run: go test -v -race -coverprofile=coverage.out ./...
54+
55+
- name: Generate coverage report
56+
if: matrix.runner-os == 'ubuntu-latest'
57+
run: |
58+
go tool cover -html=coverage.out -o coverage.html
59+
go tool cover -func=coverage.out
60+
61+
- name: Upload coverage artifact
62+
if: matrix.runner-os == 'ubuntu-latest'
63+
uses: actions/upload-artifact@v6
64+
with:
65+
name: go-coverage-report
66+
path: coverage.html
67+
68+
- name: Test binaries
69+
run: |
70+
./dist/gei --version
71+
./dist/ado2gh --version
72+
./dist/bbs2gh --version
73+
shell: bash
74+
75+
go-lint:
76+
name: Go Lint
77+
runs-on: ubuntu-latest
78+
79+
steps:
80+
- uses: actions/checkout@v6
81+
with:
82+
persist-credentials: false
83+
84+
- name: Setup Go
85+
uses: actions/setup-go@v5
86+
with:
87+
go-version-file: go.mod
88+
cache: true
89+
90+
- name: golangci-lint
91+
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
92+
with:
93+
version: latest
94+
args: --timeout=5m

.golangci.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# golangci-lint configuration for gh-gei Go port
2+
# See https://golangci-lint.run/usage/configuration/
3+
4+
run:
5+
timeout: 5m
6+
tests: true
7+
modules-download-mode: readonly
8+
9+
linters:
10+
enable:
11+
- gofmt # Checks formatting
12+
- goimports # Checks imports
13+
- govet # Reports suspicious constructs
14+
- errcheck # Checks for unchecked errors
15+
- staticcheck # Static analysis
16+
- unused # Checks for unused code
17+
- gosimple # Simplify code
18+
- ineffassign # Detects ineffectual assignments
19+
- typecheck # Type-checks code
20+
- bodyclose # Checks for HTTP response body close
21+
- noctx # Finds HTTP requests without context
22+
- misspell # Finds commonly misspelled English words
23+
- unconvert # Removes unnecessary type conversions
24+
- goconst # Finds repeated strings that could be constants
25+
- gocyclo # Computes cyclomatic complexities
26+
- gofumpt # Stricter gofmt
27+
- revive # Fast, configurable, extensible linter
28+
- gosec # Security-focused linter
29+
- errname # Checks error naming
30+
- errorlint # Finds misuses of errors
31+
- exportloopref # Checks for pointers to enclosing loop variables
32+
- whitespace # Detects leading/trailing whitespace
33+
34+
linters-settings:
35+
gocyclo:
36+
min-complexity: 15
37+
goconst:
38+
min-len: 3
39+
min-occurrences: 3
40+
misspell:
41+
locale: US
42+
revive:
43+
rules:
44+
- name: exported
45+
severity: warning
46+
disabled: false
47+
- name: package-comments
48+
severity: warning
49+
disabled: false
50+
gosec:
51+
excludes:
52+
- G104 # Audit errors not checked (too noisy)
53+
54+
issues:
55+
exclude-use-default: false
56+
max-issues-per-linter: 0
57+
max-same-issues: 0
58+
59+
exclude-rules:
60+
# Exclude some linters from running on tests files
61+
- path: _test\.go
62+
linters:
63+
- gocyclo
64+
- errcheck
65+
- gosec
66+
67+
# Exclude error checks in main.go files (handled by cobra)
68+
- path: cmd/.*/main\.go
69+
text: "Error return value"
70+
linters:
71+
- errcheck
72+
73+
output:
74+
format: colored-line-number
75+
print-issued-lines: true
76+
print-linter-name: true

0 commit comments

Comments
 (0)