summaryrefslogtreecommitdiffhomepage
path: root/.buildkite/hooks/pre-command
blob: b6d1ef2707201933bc2c7c377cbddfb6185fa72e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Install packages we need. Docker must be installed and configured,
# as should Go itself. We just install some extra bits and pieces.
function install_pkgs() {
  while true; do
    if sudo apt-get update && sudo apt-get install -y "$@"; then
      break
    fi
  done
}
install_pkgs make "linux-headers-$(uname -r)" linux-libc-dev \
  graphviz jq curl binutils gnupg gnupg-agent gcc \
  apt-transport-https ca-certificates software-properties-common

# Install Go 1.16, as only 1.13 is available via apt.
declare -r go_archive=go1.16.6.linux-amd64.tar.gz
wget "https://golang.org/dl/${go_archive}"
sudo tar -xzf "${go_archive}" -C /usr/local
sudo ln -s /usr/local/go/bin/go /usr/bin/go
rm "${go_archive}"

# Setup for parallelization with PARTITION and TOTAL_PARTITIONS.
export PARTITION=${BUILDKITE_PARALLEL_JOB:-0}
PARTITION=$((${PARTITION}+1)) # 1-indexed, but PARALLEL_JOB is 0-indexed.
export TOTAL_PARTITIONS=${BUILDKITE_PARALLEL_JOB_COUNT:-1}

# Ensure Docker has experimental enabled.
EXPERIMENTAL=$(sudo docker version --format='{{.Server.Experimental}}')
if test "${EXPERIMENTAL}" != "true"; then
  make sudo TARGETS=//runsc:runsc ARGS="install --experimental=true"
  sudo systemctl restart docker
fi

# Helper for benchmarks, based on the branch.
if test "${BUILDKITE_BRANCH}" = "master"; then
  export BENCHMARKS_OFFICIAL=true
else
  export BENCHMARKS_OFFICIAL=false
fi

# Clear existing profiles.
sudo rm -rf /tmp/profile