Skip to content

Commit 87e3db6

Browse files
committed
chore: add GitHub Action
1 parent 93d2bb5 commit 87e3db6

File tree

3 files changed

+76
-32
lines changed

3 files changed

+76
-32
lines changed

.github/workflows/go-cross.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Go Matrix
2+
on: [push, pull_request]
3+
4+
jobs:
5+
6+
cross:
7+
name: Go
8+
runs-on: ${{ matrix.os }}
9+
env:
10+
CGO_ENABLED: 0
11+
12+
strategy:
13+
matrix:
14+
go-version: [ oldstable, stable ]
15+
os: [ubuntu-latest, macos-latest, windows-latest]
16+
17+
steps:
18+
# https://github.com/marketplace/actions/checkout
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
# https://github.com/marketplace/actions/setup-go-environment
23+
- name: Set up Go ${{ matrix.go-version }}
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version: ${{ matrix.go-version }}
27+
28+
- name: Test
29+
run: go test -v -cover ./...
30+
31+
- name: Build
32+
run: go build -v -ldflags "-s -w" -trimpath

.github/workflows/main.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
11+
main:
12+
name: Main Process
13+
runs-on: ubuntu-latest
14+
env:
15+
GO_VERSION: stable
16+
GOLANGCI_LINT_VERSION: v1.57.0
17+
CGO_ENABLED: 0
18+
19+
steps:
20+
# https://github.com/marketplace/actions/checkout
21+
- name: Check out code
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
# https://github.com/marketplace/actions/setup-go-environment
27+
- name: Set up Go ${{ env.GO_VERSION }}
28+
uses: actions/setup-go@v5
29+
with:
30+
go-version: ${{ env.GO_VERSION }}
31+
32+
- name: Check and get dependencies
33+
run: |
34+
go mod download
35+
go mod tidy
36+
git diff --exit-code go.mod
37+
git diff --exit-code go.sum
38+
39+
# https://golangci-lint.run/usage/install#other-ci
40+
- name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }}
41+
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION}
42+
43+
- name: Make
44+
run: make

contextcheck.go

-32
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"go/ast"
55
"go/types"
66
"regexp"
7-
"strconv"
87
"strings"
98
"sync"
109

@@ -216,37 +215,6 @@ func (r *runner) collectHttpTyps(pssa *buildssa.SSA) {
216215
}
217216
}
218217

219-
func (r *runner) noImportedContextAndHttp(f *ssa.Function) (ret bool) {
220-
if !f.Pos().IsValid() {
221-
return false
222-
}
223-
224-
file := analysisutil.File(r.pass, f.Pos())
225-
if file == nil {
226-
return false
227-
}
228-
229-
if skip, has := r.skipFile[file]; has {
230-
return skip
231-
}
232-
defer func() {
233-
r.skipFile[file] = ret
234-
}()
235-
236-
for _, impt := range file.Imports {
237-
path, err := strconv.Unquote(impt.Path.Value)
238-
if err != nil {
239-
continue
240-
}
241-
path = analysisutil.RemoveVendor(path)
242-
if path == ctxPkg || path == httpPkg {
243-
return false
244-
}
245-
}
246-
247-
return true
248-
}
249-
250218
func (r *runner) checkIsEntry(f *ssa.Function) (ret entryType) {
251219
// if r.noImportedContextAndHttp(f) {
252220
// return EntryNormal

0 commit comments

Comments
 (0)