我试图为我的go项目设置自动测试覆盖率分析,但是我不能让它在github上运行,因为go测试命令失败,出现此错误:
Run go test -race -coverprofile=coverage.txt -covermode=atomic ./...
go: downloading github.com/alyu/configparser v0.0.0-20191103060215-744e9a66e7bc
go: downloading gorm.io/driver/mysql v1.1.2
go: downloading gorm.io/driver/postgres v1.1.1
go: downloading gorm.io/driver/sqlite v1.1.5
go: downloading gorm.io/gorm v1.21.15
go: downloading gopkg.in/guregu/null.v4 v4.0.0
go: downloading github.com/gorilla/mux v1.8.0
go: downloading github.com/go-sql-driver/mysql v1.6.0
go: downloading github.com/jackc/pgx/v4 v4.13.0
go: downloading github.com/mattn/go-sqlite3 v1.14.8
go: downloading github.com/jinzhu/inflection v1.0.0
go: downloading github.com/jinzhu/now v1.1.2
go: downloading github.com/jackc/pgconn v1.10.0
go: downloading github.com/jackc/pgio v1.0.0
go: downloading github.com/jackc/pgproto3/v2 v2.1.1
go: downloading github.com/jackc/pgtype v1.8.1
go: downloading github.com/jackc/chunkreader/v2 v2.0.1
go: downloading github.com/jackc/pgpassfile v1.0.0
go: downloading github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b
go: downloading golang.org/x/crypto v0.0.0-20210817164053-32db794688a5
go: downloading golang.org/x/text v0.3.7
? github.com/Zaprit/Reflow [no test files]
? github.com/Zaprit/Reflow/config [no test files]
? github.com/Zaprit/Reflow/database [no test files]
? github.com/Zaprit/Reflow/internal [no test files]
? github.com/Zaprit/Reflow/models [no test files]
2021/10/24 21:59:38 Get "http://127.0.0.1:8069/api": dial tcp 127.0.0.1:8069: connect: connection refused
FAIL github.com/Zaprit/Reflow/technicapi 0.049s
? github.com/Zaprit/Reflow/utils [no test files]
FAIL
Error: Process completed with exit code 1.
到目前为止,我试图强迫测试监听127.0.0.1
,因为我认为这可能是由于github服务器上缺乏IPV6支持造成的,尽管这不起作用。
这是我用于测试的CI管道
# This lints the Reflow project
name: Lint
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Go environment
uses: actions/setup-go@v2.1.3
with:
go-version: 1.17.1
stable: true
token: ${{ github.token }}
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2.5.2
我修复了它,我想这是端口的权限问题,因为我切换到使用服务器的net/http/httptest,它的工作。