0

这是我在工作流中使用的 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。

4

1 回答 1

0

我相信您的“选项”设置实际上是将参数传递给使服务出错的容器。至少,当我在本地尝试它们时,这似乎正在发生。以这种方式尝试您的服务设置以获得您想要的显式版本:

  services:
    solr:
      image: solr:8.3.1
      ports:
        - 2010:8983

调试服务容器启动可能有点困难。但是,如果您在操作日志中四处挖掘,您应该会找到一些线索。

于 2020-09-28T16:32:20.913 回答