diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 7ed7b2b..5c7f16e 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -9,45 +9,38 @@ on: jobs: test: + runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - go_version: [ '1.17', '1.18' ] - os: [ 'ubuntu-latest', 'windows-latest', 'macOS-latest' ] - include: - - os: ubuntu-latest - services: - proxy: - image: abhinavsingh/proxy.py:v2.4.4 - ports: - - "8899:8899" - target: - image: nginx:1.23.2 - ports: - - "80:80" - env: - PROXY_URL: 'http://localhost:8899' - TARGET_URL: 'http://target:80' - - os: windows-latest - services: {} - env: {} - - os: macOS-latest - services: {} - env: {} - - services: ${{ matrix.services }} - runs-on: ${{ matrix.os }} + go: [ '1.25', '1.26' ] + services: + proxy: + image: abhinavsingh/proxy.py:v2.4.4 + ports: + - "8899:8899" + target: + image: nginx:1.23.2 + ports: + - "80:80" + env: + PROXY_URL: 'http://localhost:8899' + TARGET_URL: 'http://target:80' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - name: Use GO ${{ matrix.go_version }} - uses: actions/setup-go@v2 + - name: Use Go ${{ matrix.go }} + uses: actions/setup-go@v5 with: - go-version: ${{ matrix.go_version }} + go-version: ${{ matrix.go }} - - name: Test GO ${{ matrix.go_version }} + - name: Test run: go test ./... -race -coverprofile=coverage.txt -covermode=atomic - env: ${{ matrix.env }} - - name: Upload to codecov - if: ${{ matrix.os == 'ubuntu-latest' && matrix.go_version == '1.17' }} - run: bash <(curl -s https://codecov.io/bash) \ No newline at end of file + - name: Upload coverage to Codecov + if: ${{ matrix.go == '1.26' }} + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage.txt + fail_ci_if_error: false diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index acdf87c..878473b 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -1,39 +1,28 @@ name: golangci-lint + on: push: + branches: + - main tags: - v* + pull_request: branches: - - master - main - pull_request: + permissions: contents: read - # Optional: allow read access to pull request. Use with `only-new-issues` option. - # pull-requests: read + jobs: golangci: - strategy: - matrix: - go_version: [ '1.17', '1.18' ] - os: [ 'ubuntu-latest', 'windows-latest', 'macOS-latest' ] name: lint - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: - go-version: ${{ matrix.go }} - - uses: actions/checkout@v3 + go-version: '1.26' - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v7 with: - # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.42.1 - # Optional: working directory, useful for monorepos - # working-directory: somedir - - # Optional: golangci-lint command line arguments. - # args: --issues-exit-code=0 - - # Optional: show only new issues if it's a pull request. The default value is `false`. - # only-new-issues: true \ No newline at end of file + version: v2.12.2 diff --git a/errors.go b/errors.go index 27a2d42..6908c7a 100644 --- a/errors.go +++ b/errors.go @@ -3,6 +3,8 @@ package proxycheck import "errors" var ( - // FeedEnd this error happens when the feed runs out of proxies to check + // FeedEnd this error happens when the feed runs out of proxies to check. + // Named without the conventional Err* prefix to preserve the public API. + //nolint:staticcheck // ST1012: renaming would break importers of the package FeedEnd = errors.New("feed end") ) diff --git a/go.mod b/go.mod index cf0c9c2..afedcdc 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/memclutter/proxycheck -go 1.18 +go 1.25 require ( github.com/urfave/cli/v2 v2.23.4 diff --git a/utils.go b/utils.go index e385ead..cdc14ab 100644 --- a/utils.go +++ b/utils.go @@ -4,7 +4,7 @@ import ( "context" "fmt" "h12.io/socks" - "io/ioutil" + "io" "net" "net/http" "net/url" @@ -55,6 +55,6 @@ func createProxyTransport(proxyURL *url.URL, timeout time.Duration) *http.Transp } func readResponse(httpResponse *http.Response) ([]byte, error) { - defer httpResponse.Body.Close() - return ioutil.ReadAll(httpResponse.Body) + defer func() { _ = httpResponse.Body.Close() }() + return io.ReadAll(httpResponse.Body) }