Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failed when run go test in GitHub actions CI #29

Open
ghost opened this issue Aug 25, 2020 · 1 comment
Open

Test failed when run go test in GitHub actions CI #29

ghost opened this issue Aug 25, 2020 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 25, 2020

Everything works fine on local enviroment, but can not run go test in GitHub actions CI.

My GitHub action config:

name: Build and test Go
on: [ push, pull_request ]
jobs:
  test:
    strategy:
      matrix:
        go-version: [ 1.15.x ]
        os: [ ubuntu-latest ]
        mongodb-version: [4.2]
    runs-on: ${{ matrix.os }}
    steps:
      - name: setup env
        shell: bash
        run: |
          echo "::set-env name=GOPATH::${{ github.workspace }}/go"
          echo "::add-path::${{ github.workspace }}/go/bin"

      - name: Install Go
        uses: actions/setup-go@v2
        with:
          go-version: ${{ matrix.go-version }}

      - name: Start MongoDB
        uses: supercharge/[email protected]
        with:
          mongodb-version: ${{ matrix.mongodb-version }}

      - name: Checkout code
        uses: actions/checkout@v2

      - name: Build
        env:
          GOPROXY: "https://proxy.golang.org"
        run: go build .

      - name: Test
        run: go test ./...

Some GitHub action logs:

ok  	github.com/klauspost/compress/zstd	30.515s
ok  	github.com/klauspost/compress/zstd/internal/xxhash	0.016s
--- FAIL: TestFormatNew (0.00s)
    format_test.go:38: test 3: line 3: fmt.Sprintf("%+v", err):
         got: "error\ngithub.com/pkg/errors.TestFormatNew\n\t/home/runner/work/coinsmart-api/coinsmart-api/go/pkg/mod/github.com/pkg/[email protected]/format_test.go:26\ntesting.tRunner\n\t/opt/hostedtoolcache/go/1.15.0/x64/src/testing/testing.go:1108\nruntime.goexit\n\t/opt/hostedtoolcache/go/1.15.0/x64/src/runtime/asm_amd64.s:1374"
        want: "error\ngithub.com/pkg/errors.TestFormatNew\n\t.+/github.com/pkg/errors/format_test.go:26"
--- FAIL: TestFormatErrorf (0.00s)
    format_test.go:64: test 3: line 3: fmt.Sprintf("%+v", err):
         got: "error\ngithub.com/pkg/errors.TestFormatErrorf\n\t/home/runner/work/coinsmart-api/coinsmart-api/go/pkg/mod/github.com/pkg/[email protected]/format_test.go:56\ntesting.tRunner\n\t/opt/hostedtoolcache/go/1.15.0/x64/src/testing/testing.go:1108\nruntime.goexit\n\t/opt/hostedtoolcache/go/1.15.0/x64/src/runtime/asm_amd64.s:1374"
        want: "error\ngithub.com/pkg/errors.TestFormatErrorf\n\t.+/github.com/pkg/errors/format_test.go:56"

It seems errors can not pass the tests. But I don't know why.

@titouanfreville
Copy link
Collaborator

@zmrenwu are you using go mod vendor on your local environment ?
Your issue seems to be linked to the go mod installation witch add an @VERSION for each downloaded package while your test does not expect the versioning element. If you use a vendor directory on your local, the test will pass cause the vendored installation does not use the @Version packaging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant