github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/build/teamcity-check.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  # Set this to 1 to require a "release justification" note in the commit message
     4  # or the PR description.
     5  require_justification=0
     6  
     7  set -euo pipefail
     8  
     9  source "$(dirname "${0}")/teamcity-support.sh"
    10  
    11  tc_prepare
    12  
    13  if [ "$require_justification" = 1 ]; then
    14    tc_start_block "Ensure commit message contains a release justification"
    15    # Ensure master branch commits have a release justification.
    16    if [[ $(git log -n1 | grep -ci "Release justification: \S\+") == 0 ]]; then
    17      echo "Build Failed. No Release justification in the commit message or in the PR description." >&2
    18      echo "Commits must have a Release justification of the form:" >&2
    19      echo "Release justification: <some description of why this commit is safe to add to the release branch.>" >&2
    20      exit 1
    21    fi
    22    tc_end_block "Ensure commit message contains a release justification"
    23  fi
    24  
    25  tc_start_block "Ensure dependencies are up-to-date"
    26  run build/builder.sh go install ./vendor/github.com/golang/dep/cmd/dep ./pkg/cmd/github-pull-request-make
    27  run build/builder.sh env GITHUB_API_TOKEN="$GITHUB_API_TOKEN" BUILD_VCS_NUMBER="$BUILD_VCS_NUMBER" TARGET=checkdeps github-pull-request-make
    28  tc_end_block "Ensure dependencies are up-to-date"
    29  
    30  tc_start_block "Ensure generated code is up-to-date"
    31  # Buffer noisy output and only print it on failure.
    32  run build/builder.sh make generate buildshort &> artifacts/generate.log || (cat artifacts/generate.log && false)
    33  rm artifacts/generate.log
    34  # The workspace is clean iff `git status --porcelain` produces no output. Any
    35  # output is either an error message or a listing of an untracked/dirty file.
    36  if [[ "$(git status --porcelain 2>&1)" != "" ]]; then
    37    git status >&2 || true
    38    git diff -a >&2 || true
    39    exit 1
    40  fi
    41  tc_end_block "Ensure generated code is up-to-date"
    42  
    43  tc_start_block "Lint"
    44  # Disable ccache so that Go doesn't try to install dependencies into GOROOT,
    45  # where it doesn't have write permissions. (Using ccache busts the Go package
    46  # cache because it appears to the Go toolchain as a different C compiler than
    47  # the toolchain was compiled with.) We've already built the C dependencies
    48  # above, so we're not losing anything by turning it off.
    49  #
    50  # TODO(benesch): once GOPATH/pkg goes away because Go static analysis tools can
    51  # rebuild on demand, remove this. Upstream issue: golang/go#25650.
    52  run_json_test env COCKROACH_BUILDER_CCACHE= \
    53    build/builder.sh stdbuf -eL -oL make GOTESTFLAGS=-json lint
    54  tc_end_block "Lint"
    55  
    56  tc_start_block "Test web UI"
    57  # Run the UI tests. This logically belongs in teamcity-test.sh, but we do it
    58  # here to minimize total build time since this build has already generated the
    59  # UI.
    60  run build/builder.sh make -C pkg/ui
    61  tc_end_block "Test web UI"