Skip to content

Commit c8baa79

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 ecd3402 commit c8baa79

18 files changed

Lines changed: 1687 additions & 0 deletions

File tree

.github/workflows/go-ci.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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@v6
30+
with:
31+
go-version-file: go.mod
32+
cache: true
33+
34+
- name: Setup Just
35+
uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3
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 ./...
54+
if: matrix.runner-os != 'ubuntu-latest'
55+
56+
- name: Run Go tests with coverage
57+
run: go test -v -race -coverprofile=coverage.out ./...
58+
if: matrix.runner-os == 'ubuntu-latest'
59+
60+
- name: Generate coverage report
61+
if: matrix.runner-os == 'ubuntu-latest'
62+
run: |
63+
go tool cover -html=coverage.out -o coverage.html
64+
go tool cover -func=coverage.out
65+
66+
- name: Upload coverage artifact
67+
if: matrix.runner-os == 'ubuntu-latest'
68+
uses: actions/upload-artifact@v6
69+
with:
70+
name: go-coverage-report
71+
path: coverage.html
72+
73+
- name: Test binaries
74+
run: |
75+
./dist/gei --version
76+
./dist/ado2gh --version
77+
./dist/bbs2gh --version
78+
shell: bash
79+
80+
go-lint:
81+
name: Go Lint
82+
runs-on: ubuntu-latest
83+
84+
steps:
85+
- uses: actions/checkout@v6
86+
with:
87+
persist-credentials: false
88+
89+
- name: Setup Go
90+
uses: actions/setup-go@v6
91+
with:
92+
go-version-file: go.mod
93+
cache: true
94+
95+
- name: golangci-lint
96+
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
97+
with:
98+
version: latest
99+
args: --timeout=5m

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,3 +359,9 @@ MigrationBackup/
359359
/src/gei/Properties/launchSettings.json
360360
/src/OctoshiftCLI.IntegrationTests/Properties/launchSettings.json
361361
/src/ado2gh/Properties/launchSettings.json
362+
363+
# Go coverage reports
364+
coverage/
365+
*.out
366+
coverage.html
367+
/coverage.out

.golangci.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# golangci-lint configuration for gh-gei Go port
2+
# See https://golangci-lint.run/usage/configuration/
3+
version: "2"
4+
5+
run:
6+
timeout: 5m
7+
tests: true
8+
modules-download-mode: readonly
9+
10+
formatters:
11+
enable:
12+
- gofmt
13+
- goimports
14+
- gofumpt
15+
16+
linters:
17+
enable:
18+
- govet # Reports suspicious constructs
19+
- errcheck # Checks for unchecked errors
20+
- staticcheck # Static analysis (includes gosimple, stylecheck)
21+
- unused # Checks for unused code
22+
- ineffassign # Detects ineffectual assignments
23+
- bodyclose # Checks for HTTP response body close
24+
- noctx # Finds HTTP requests without context
25+
- misspell # Finds commonly misspelled English words
26+
- unconvert # Removes unnecessary type conversions
27+
- goconst # Finds repeated strings that could be constants
28+
- gocyclo # Computes cyclomatic complexities
29+
- revive # Fast, configurable, extensible linter
30+
- gosec # Security-focused linter
31+
- errname # Checks error naming
32+
- errorlint # Finds misuses of errors
33+
- whitespace # Detects leading/trailing whitespace
34+
35+
settings:
36+
gocyclo:
37+
min-complexity: 15
38+
goconst:
39+
min-len: 3
40+
min-occurrences: 3
41+
misspell:
42+
locale: US
43+
revive:
44+
rules:
45+
- name: exported
46+
severity: warning
47+
disabled: false
48+
- name: package-comments
49+
severity: warning
50+
disabled: false
51+
gosec:
52+
excludes:
53+
- G104 # Audit errors not checked (too noisy)
54+
55+
exclusions:
56+
presets:
57+
- comments
58+
- common-false-positives
59+
- legacy
60+
- std-error-handling
61+
rules:
62+
# Exclude some linters from running on tests files
63+
- path: _test\.go
64+
linters:
65+
- gocyclo
66+
- errcheck
67+
- gosec
68+
- revive
69+
# Exclude error checks in main.go files (handled by cobra)
70+
- path: cmd/.*/main\.go
71+
text: "Error return value"
72+
linters:
73+
- errcheck
74+
# Unused functions in skeleton main.go files will be wired up in future PRs
75+
- path: cmd/.*/main\.go
76+
linters:
77+
- unused
78+
# SA1029: context key type - will be replaced with proper type in later phases
79+
- path: cmd/.*/main\.go
80+
text: "SA1029"
81+
linters:
82+
- staticcheck
83+
84+
output:
85+
formats:
86+
text:
87+
path: stdout
88+
colors: true
89+
print-issued-lines: true
90+
print-linter-name: true

0 commit comments

Comments
 (0)