Skip to content

Commit 7cb6a6a

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 7cb6a6a

19 files changed

Lines changed: 1690 additions & 1 deletion

File tree

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
runner-os: [windows-latest, ubuntu-latest, macos-latest]
27-
language: [ csharp, actions ]
27+
language: [csharp, actions]
2828

2929
runs-on: ${{ matrix.runner-os }}
3030

.github/workflows/go-ci.yml

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