forked from Gitlink/gitlink-cli
Merge pull request 'chore: fix CI workflow, golangci-lint config, and minor lint/format issues' (#92) from muel/gitlink-cli:chore/test-coverage-and-lint into master
This commit is contained in:
commit
687633d22f
|
|
@ -8,23 +8,23 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
check:
|
||||||
name: Build, Test, Vet
|
name: Build, Lint, Test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.22'
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: go build ./...
|
run: go build ./...
|
||||||
|
|
||||||
- name: Test
|
- name: Lint
|
||||||
run: go test -race ./...
|
run: make lint
|
||||||
|
|
||||||
- name: Vet
|
- name: Test
|
||||||
run: go vet ./...
|
run: make test
|
||||||
|
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: |
|
run: make fmt
|
||||||
unformatted=$(gofmt -s -l .)
|
|
||||||
if [ -n "$unformatted" ]; then
|
|
||||||
echo "Files not formatted:"
|
|
||||||
echo "$unformatted"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,9 @@ linters:
|
||||||
# Best-effort output rendering
|
# Best-effort output rendering
|
||||||
- linters: [errcheck]
|
- linters: [errcheck]
|
||||||
path: render\.go$
|
path: render\.go$
|
||||||
|
# errcheck: test helpers intentionally ignore return values
|
||||||
|
- linters: [errcheck]
|
||||||
|
path: _test\.go$
|
||||||
# errorlint: type assertions are fine in tests
|
# errorlint: type assertions are fine in tests
|
||||||
- linters: [errorlint]
|
- linters: [errorlint]
|
||||||
path: _test\.go$
|
path: _test\.go$
|
||||||
|
|
|
||||||
|
|
@ -179,13 +179,13 @@ func TestRepoCreate(t *testing.T) {
|
||||||
func TestRepoCreateWithOptions(t *testing.T) {
|
func TestRepoCreateWithOptions(t *testing.T) {
|
||||||
var body map[string]interface{}
|
var body map[string]interface{}
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
switch {
|
switch r.URL.Path {
|
||||||
case r.URL.Path == "/users/me.json":
|
case "/users/me.json":
|
||||||
writeJSON(w, map[string]interface{}{
|
writeJSON(w, map[string]interface{}{
|
||||||
"login": "creator",
|
"login": "creator",
|
||||||
"user_id": float64(42),
|
"user_id": float64(42),
|
||||||
})
|
})
|
||||||
case r.URL.Path == "/creator/my-repo.json":
|
case "/creator/my-repo.json":
|
||||||
json.NewDecoder(r.Body).Decode(&body)
|
json.NewDecoder(r.Body).Decode(&body)
|
||||||
writeJSON(w, map[string]interface{}{"name": "my-repo"})
|
writeJSON(w, map[string]interface{}{"name": "my-repo"})
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -156,4 +156,3 @@ func TestRecommendedAction(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue