Skip to content

Commit b7a33e4

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 9e4f343 commit b7a33e4

18 files changed

Lines changed: 1682 additions & 0 deletions

File tree

.github/workflows/go-ci.yml

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