description: Ensure nothing obvious is broken, and pre-cache Go modules.
executor: go-machine
steps:
  - checkout
  # Setup Go enabling the proxy for downloading modules.
  - setup-go:
      GOPROXY: https://proxy.golang.org,direct
  - run:
      name: Install CircleCI CLI
      environment:
        ARCH: linux_amd64
        BASE: https://github.com/CircleCI-Public/circleci-cli/releases/download
      command: |
        export CCI_PATH=/tmp/circleci-cli/$CIRCLECI_CLI_VERSION
        mkdir -p $CCI_PATH
        NAME=circleci-cli_${CIRCLECI_CLI_VERSION}_${ARCH}
        URL=$BASE/v${CIRCLECI_CLI_VERSION}/${NAME}.tar.gz
        curl -sSL $URL \
          | tar --overwrite --strip-components=1 -xz -C $CCI_PATH "${NAME}/circleci"
        # Add circleci to the path for subsequent steps.
        echo "export PATH=$CCI_PATH:\$PATH" >> $BASH_ENV
        # Done, print some debug info.
        set -x
        . $BASH_ENV
        which circleci
        circleci version
  - run:
      name: Verify CircleCI
      command: |
        set -x
        . $BASH_ENV
        make ci-verify
  - configure-git
  - refresh_go_mod_cache
