[英]Github Actions listen on localhost
I'm trying to set up automated test coverage analysis for my go project, however I can't get it to run on github actions, as the go test command fails with this error:我正在尝试为我的 go 项目设置自动测试覆盖率分析,但是我无法让它在 github 操作上运行,因为 go test 命令失败并出现以下错误:
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.
So far I've tried to force the tests to listen on 127.0.0.1
as I thought it might be caused by a lack of IPV6 support on the github server though that didn't work.到目前为止,我已经尝试强制测试在127.0.0.1
上收听,因为我认为这可能是由于 github 服务器上缺乏 IPV6 支持造成的,尽管这不起作用。
Here's my CI pipeline for testing这是我用于测试的 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 并且它工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.