diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 26fac99..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,26 +0,0 @@ -# Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference -version: 2.1 -jobs: - build: - working_directory: ~/repo - docker: - - image: cimg/go:1.20 - steps: - - checkout - - restore_cache: - keys: - - go-mod-v4-{{ checksum "go.sum" }} - - run: - name: Install Dependencies - command: go mod download - - save_cache: - key: go-mod-v4-{{ checksum "go.sum" }} - paths: - - "/go/pkg/mod" - - run: - name: Run tests - command: | - mkdir -p /tmp/test-reports - gotestsum --junitfile /tmp/test-reports/unit-tests.xml - - store_test_results: - path: /tmp/test-reports diff --git a/.github/workflows/go-cross.yml b/.github/workflows/go-cross.yml new file mode 100644 index 0000000..d284bd4 --- /dev/null +++ b/.github/workflows/go-cross.yml @@ -0,0 +1,32 @@ +name: Go Matrix +on: [push, pull_request] + +jobs: + + cross: + name: Go + runs-on: ${{ matrix.os }} + env: + CGO_ENABLED: 0 + + strategy: + matrix: + go-version: [ oldstable, stable ] + os: [ubuntu-latest, macos-latest, windows-latest] + + steps: + # https://github.com/marketplace/actions/checkout + - name: Checkout code + uses: actions/checkout@v4 + + # https://github.com/marketplace/actions/setup-go-environment + - name: Set up Go ${{ matrix.go-version }} + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go-version }} + + - name: Test + run: go test -v -cover ./... + + - name: Build + run: go build -v -ldflags "-s -w" -trimpath diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..c5affe9 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,44 @@ +name: Main + +on: + push: + branches: + - main + pull_request: + +jobs: + + main: + name: Main Process + runs-on: ubuntu-latest + env: + GO_VERSION: stable + GOLANGCI_LINT_VERSION: v1.57.0 + CGO_ENABLED: 0 + + steps: + # https://github.com/marketplace/actions/checkout + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # https://github.com/marketplace/actions/setup-go-environment + - name: Set up Go ${{ env.GO_VERSION }} + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Check and get dependencies + run: | + go mod download + go mod tidy + git diff --exit-code go.mod + git diff --exit-code go.sum + + # https://golangci-lint.run/usage/install#other-ci + - name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }} + run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION} + + - name: Make + run: make diff --git a/contextcheck.go b/contextcheck.go index 50e11f3..6269635 100644 --- a/contextcheck.go +++ b/contextcheck.go @@ -5,7 +5,6 @@ import ( "go/token" "go/types" "regexp" - "strconv" "strings" "sync" @@ -222,37 +221,6 @@ func (r *runner) collectHttpTyps(pssa *buildssa.SSA) { } } -func (r *runner) noImportedContextAndHttp(f *ssa.Function) (ret bool) { - if !f.Pos().IsValid() { - return false - } - - file := analysisutil.File(r.pass, f.Pos()) - if file == nil { - return false - } - - if skip, has := r.skipFile[file]; has { - return skip - } - defer func() { - r.skipFile[file] = ret - }() - - for _, impt := range file.Imports { - path, err := strconv.Unquote(impt.Path.Value) - if err != nil { - continue - } - path = analysisutil.RemoveVendor(path) - if path == ctxPkg || path == httpPkg { - return false - } - } - - return true -} - func (r *runner) checkIsEntry(f *ssa.Function) (ret entryType) { // if r.noImportedContextAndHttp(f) { // return EntryNormal