Skip to content

Commit 14a5138

Browse files
authored
chore(ci): login with docker (#1218)
Ultimate goal: login with docker to get higher pull limits What it involved: - Rework how the `buildkite-agent` vm is built - sourcegraph/infrastructure#6848 - sourcegraph/infrastructure#6849 - sourcegraph/infrastructure#6850 - sourcegraph/infrastructure#6851 - sourcegraph/infrastructure#6852 - sourcegraph/infrastructure#6854 - sourcegraph/infrastructure#6855 - sourcegraph/infrastructure#6856 - Transition to mise - Use a specific version of vagrant (2.4.1) otherwise the an older incompatible version of `vagrant-google` (2.2.0) gets installed, 2.7.0 is the latest and correct one - Fix vagrant issues ### Test plan CI
1 parent fd2df07 commit 14a5138

File tree

7 files changed

+37
-19
lines changed

7 files changed

+37
-19
lines changed

.buildkite/ci-checkov.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
#!/usr/bin/env bash
2-
# Set this to fail on the install
2+
# Set this to fail on the install
33
set -euxo pipefail
44

5-
# Install and run the plugin for checkov
6-
# Use the full path to run pip3.10
7-
pip3 install checkov
8-
95
# List of checks we do not want to run here
106
# This is a living list and will see additions and mostly removals over time.
117
SKIP_CHECKS="CKV_GCP_22,CKV_GCP_66,CKV_GCP_13,CKV_GCP_71,CKV_GCP_61,CKV_GCP_21,CKV_GCP_65,CKV_GCP_67,CKV_GCP_20,CKV_GCP_69,CKV_GCP_12,CKV_GCP_24,CKV_GCP_25,CKV_GCP_64,CKV_GCP_68,CKV2_AWS_5,CKV2_GCP_3,CKV2_GCP_5,CKV_AWS_23,CKV_GCP_70,CKV_GCP_62,CKV_GCP_62,CKV_GCP_62,CKV_GCP_62,CKV_GCP_29,CKV_GCP_39"
@@ -19,7 +15,7 @@ echo "==========================================================================
1915
# Set not to fail on non-zero exit code
2016
set +e
2117
# Run checkov
22-
python3 -m checkov.main --skip-check $SKIP_CHECKS --quiet --framework terraform --compact -d .
18+
checkov --skip-check $SKIP_CHECKS --quiet --framework terraform --compact -d .
2319

2420
# Options
2521
# --quiet: Only show failing tests

.buildkite/hooks/pre-command

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ trap remove_pidfile EXIT
2727
echo $$ > "$PIDFILE"
2828

2929
echo "Installing asdf dependencies as defined in '${WORKDIR}/.tool-versions':"
30-
asdf install
30+
if [ ! -f ".use_mise" ]; then
31+
asdf install
32+
else
33+
mise install
34+
eval "$(mise activate)"
35+
fi

.buildkite/vagrant-run.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,20 @@ cleanup() {
1313
}
1414

1515
echo --- ":vagrant: installing plugins"
16-
plugins=(vagrant-google vagrant-env vagrant-scp)
17-
for i in "${plugins[@]}"; do
18-
if ! vagrant plugin list --no-tty | grep "$i"; then
19-
vagrant plugin install "$i"
20-
fi
21-
done
16+
vagrant --version
17+
vagrant plugin install vagrant-google --plugin-version '2.7.0'
18+
vagrant plugin install vagrant-env
19+
vagrant plugin install vagrant-scp
2220

2321
trap cleanup EXIT
22+
23+
echo --- ":lock: builder account key"
24+
KEY_PATH="/tmp/e2e-builder.json"
25+
if [ ! -f ${KEY_PATH} ]; then
26+
gcloud secrets versions access latest --secret=e2e-builder-sa-key --quiet --project=sourcegraph-ci > "${KEY_PATH}"
27+
fi
28+
export GOOGLE_JSON_KEY_LOCATION="${KEY_PATH}"
29+
2430
echo --- ":vagrant: starting box $box"
2531
vagrant up "$box" --provider=google || exit_code=$?
2632

.tool-versions

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
nodejs 16.7.0
2-
yarn 1.22.4
3-
shellcheck 0.7.1
4-
golang 1.19.8
5-
github-cli 2.46.0
6-
python system
1+
nodejs 16.7.0
2+
yarn 1.22.4
3+
shellcheck 0.7.1
4+
golang 1.19.8
5+
github-cli 2.46.0
6+
asdf:bosmak/asdf-checkov latest

.use_mise

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Buildkite Agent CI use the presence of this file to determine whether it should install tools with mise or install them with ASDF.
2+
Thus if you delete this file, CI will use ASDF to install tools and not mise.
3+
4+
The file is only meant to be here while we transition to using mise completely.
5+
6+
For more information you can reach out to the dev-infra team on #discuss-dev-infra.

test/Vagrantfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
6262
cat << EOF >> /root/.profile
6363
export GIT_BRANCH=#{ENV['BUILDKITE_BRANCH']}
6464
export TEST_TYPE=#{ENV['TEST_TYPE']}
65+
export DOCKER_USERNAME=#{ENV['DOCKER_USERNAME']}
66+
export DOCKER_PASSWORD=#{ENV['DOCKER_PASSWORD']}
6567
EOF
6668
SHELL
6769

test/smoke-test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
set -euxfo pipefail
33

44
configure_docker() {
5+
if [ -n "${DOCKER_USERNAME}" ] && [ -n "${DOCKER_PASSWORD}" ]; then
6+
docker login -u "${DOCKER_USERNAME}" --password-stdin <<<"$DOCKER_PASSWORD"
7+
fi
58
gcloud auth configure-docker
69
gcloud auth configure-docker us-central1-docker.pkg.dev
710
}

0 commit comments

Comments
 (0)