Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-2834

Ensure `build` task fails on broken import.

    • Type: Icon: Improvement Improvement
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Scope

      • Ensure build task fails on broken import.

      Background & Motivation

      The 1.11.5 release had a failure on `go mod tidy`:

      ❯ go get go.mongodb.org/mongo-driver@latest
      go: downloading go.mongodb.org/mongo-driver v1.11.5
      go: upgraded go.mongodb.org/mongo-driver v1.10.3 => v1.11.5
      ❯ go mod tidy
      go: finding module for package go.mongodb.org/mongo-driver/internal/assert
      loadtest imports
              go.mongodb.org/mongo-driver/mongo/options tested by
              go.mongodb.org/mongo-driver/mongo/options.test imports
              go.mongodb.org/mongo-driver/internal/assert: module go.mongodb.org/mongo-driver@latest found (v1.11.5), but does not contain package go.mongodb.org/mongo-driver/internal/assert
      

      The last build task passed, despite commands in the task failing:

      [2023/05/02 21:21:00.912] can't load test package: mongo/options/changestreamoptions_test.go:6:2: cannot find module providing package go.mongodb.org/mongo-driver/internal/assert: import lookup disabled by -mod=readonly
      [2023/05/02 21:21:00.912]     (Go version in go.mod is 1.13, so vendor directory was not used.)
      

      To reproduce: check out the commit e01fa5c76ee2cc9ba9f30ddcd79d046e503a0423, which included the broken test build that impacted 1.11.5. Run this script:

      function assert_eq () {
          a="$1"
          b="$2"
          if [[ "$a" != "$b" ]]; then
              echo "Assertion failed: $a != $b"
              # Print caller
              caller
              exit 1
          fi
      }
      
      go test -c ./mongo/options > /dev/null 2>&1
      # Expect `go test` to exit with error code.
      assert_eq $? 1
      
      make build-tests > /dev/null 2>&1
      # Expect `make build-tests` to exit with error code.
      assert_eq $? 1
      # Results in: `Assertion failed: 0 != 1`
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: