这是我在工作流中使用的 GitHub 操作文件。
.github/workflows/go.yml
name: Go
on:
push:
branches: [ master development ]
tags:
- '*'
pull_request:
branches:
- '*'
jobs:
test:
name: Test
runs-on: [self-hosted, linux]
services:
solr:
image: solr
ports:
- 2010:8983
options: solr:8.3.1 - cloud
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Test
run: |
mkdir build
go test ./... -v -coverprofile build/coverage.txt -coverpkg=./...
cat build/coverage.txt | grep -v '.pb.go' > build/coverage.out
go tool cover -func build/coverage.out
- uses: actions/upload-artifact@v2
with:
name: build artifacts
path: build
在我得到的工作流的结果中connection refused
,Workflow 能够拉出 Solr 容器,但是在我的测试中,我收到以下错误:
获取“http://localhost:2010/solr/customer/select?q=id%3A2+\u0026wt=json”:拨打 tcp 127.0.0.1:2010:连接:连接被拒绝”
由于 Solr 容器已被拉出,我希望我的测试能够成功命中 Solr API。