diff --git a/.buildkite/docker-build-push.nix b/.buildkite/docker-build-push.nix index 8a3b761c597..ccefc5a1294 100644 --- a/.buildkite/docker-build-push.nix +++ b/.buildkite/docker-build-push.nix @@ -71,16 +71,16 @@ in # Apply tagging scheme orig_tag="${image.imageName}:${image.imageTag}" - git_branch="''${BUILDKITE_BRANCH:-}" git_tag="''${BUILDKITE_TAG:-}" + git_branch="''${BUILDKITE_BRANCH:-}" tags=() if [[ "$git_tag" =~ ^v20 ]]; then tags+=( "${image.imageTag}" ) tags+=( "latest" ) - elif [[ "$git_tag" = "rc-latest" ]]; then - tags+=( "$git_tag") + elif [[ "$git_branch" =~ ^release-candidate ]]; then + tags+=( "release-candidate" ) else - echo 'Not pushing docker image because this is neither a rc-latest nor a v20* tag build.' + tags+=( "test") fi echo diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index ed2373da3ee..c0d68831424 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -220,7 +220,7 @@ steps: export BENCHMARK_CSV_FILE="`pwd`/bench-results.csv" ./scripts/buildkite/main/bench-latency.sh depends_on: trigger-benchmarks - timeout_in_minutes: 20 + timeout_in_minutes: 30 agents: system: x86_64-linux queue: adrestia-bench @@ -431,20 +431,54 @@ steps: agents: system: ${linux} - - wait: ~ - - - block: Push Docker Image - if: build.env("RELEASE_CANDIDATE") == null - key: docker-push-block - - - label: Push Docker Image - depends_on: - - linux-nix - - docker-push-block - key: build-docker - command: - - "mkdir -p config && echo '{ outputs = _: { dockerHubRepoName = \"cardanofoundation/cardano-wallet\"; }; }' > config/flake.nix" - - "nix build .#pushDockerImage --override-input hostNixpkgs \"path:$(nix eval --impure -I $NIX_PATH --expr '(import {}).path')\" --override-input customConfig path:./config -o docker-build-push" - - "./docker-build-push" - agents: - system: x86_64-linux + - group: Docker Artifacts + key: docker-artifacts + steps: + - block: Build Docker Artifacts + if: | + build.branch !~ /^gh-readonly-queue\/master/ + && build.branch != "master" + && build.env("RELEASE_CANDIDATE") == null + key: docker-artifacts-block + + - label: Build Docker Image + key: docker-build + depends_on: + - docker-artifacts-block + - linux-nix + commands: + ./scripts/buildkite/release/docker-build.sh + agents: + system: x86_64-linux + + - label: Push Docker Image + if: build.env("RELEASE_CANDIDATE") != null + depends_on: + - linux-nix + - docker-build + - docker-smoke-test + key: build-docker + command: + - "mkdir -p config && echo '{ outputs = _: { dockerHubRepoName = \"cardanofoundation/cardano-wallet\"; }; }' > config/flake.nix" + - "nix build .#pushDockerImage --override-input hostNixpkgs \"path:$(nix eval --impure -I $NIX_PATH --expr '(import {}).path')\" --override-input customConfig path:./config -o docker-build-push" + - "./docker-build-push" + agents: + system: x86_64-linux + + - group: Docker Checks + key: docker-e2e + steps: + - label: Smoke Test docker-compose + if: build.env("RELEASE_CANDIDATE") != null + key: docker-smoke-test + depends_on: + - docker-build + timeout_in_minutes: 120 + commands: + - ./scripts/buildkite/release/docker-smoke-test.sh + artifact_paths: + - "./logs/*" + env: + NODE_STATE_DIR: "${STATE_DIR?}/node/preprod" + agents: + system: x86_64-linux diff --git a/scripts/buildkite/release/docker-build.sh b/scripts/buildkite/release/docker-build.sh new file mode 100755 index 00000000000..dc0980a6ad4 --- /dev/null +++ b/scripts/buildkite/release/docker-build.sh @@ -0,0 +1,16 @@ +#! /usr/bin/env -S nix shell --command bash +# shellcheck shell=bash + +set -euox pipefail + +git fetch --all + +RELEASE_CANDIDATE_COMMIT=$(buildkite-agent meta-data get "release-candidate-commit" --default="${BUILDKITE_COMMIT}") + +git checkout "$RELEASE_CANDIDATE_COMMIT" + +mkdir -p result + +nix build .#dockerImage -o result/docker-image + +docker load < result/docker-image diff --git a/scripts/buildkite/release/docker-smoke-test.sh b/scripts/buildkite/release/docker-smoke-test.sh new file mode 100755 index 00000000000..7f812004831 --- /dev/null +++ b/scripts/buildkite/release/docker-smoke-test.sh @@ -0,0 +1,78 @@ +#! /usr/bin/env -S nix shell 'nixpkgs#docker-compose' 'nixpkgs#rsync' 'nixpkgs#jq' --command bash +# shellcheck shell=bash + +set -euox pipefail + + +NETWORK=preprod +export NETWORK + +TESTS_NODE_DB="$(pwd)/state/node_db" + +mkdir -p "$TESTS_NODE_DB" +export TESTS_NODE_DB + +rsync -a --delete "$NODE_STATE_DIR/db/" "$TESTS_NODE_DB" + +WALLET_TAG=$(buildkite-agent meta-data get "release-cabal-version") +export WALLET_TAG + +NODE_TAG="8.9.4" +export NODE_TAG + +NODE_DB="$TESTS_NODE_DB" +export NODE_DB + +WALLET_DB="$(pwd)/state/wallet_db" +mkdir -p "$WALLET_DB" +export WALLET_DB + +WALLET_PORT=$(shuf -i 2000-65000 -n 1) +export WALLET_PORT + +USER_ID=$(id -u) +export USER_ID + +tmpfile=$(mktemp -d /tmp/node-preprod.XXXXXX) + +# set the node socket path +NODE_SOCKET_DIR="$tmpfile" +export NODE_SOCKET_DIR + +NODE_SOCKET_NAME="node.socket" +export NODE_SOCKET_NAME + +COMPOSE_PROJECT_NAME="docker-smoke-test-$WALLET_PORT" +export COMPOSE_PROJECT_NAME + +docker compose down || true + +docker-compose up -d + +n=0 +while : +do + result=$(curl --connect-timeout 1 localhost:"$WALLET_PORT"/v2/network/information || echo "wait") + echo "$result" + if [ "$result" != "wait" ]; + then + echo "$result" | jq + break + else + sleep 30 + n=$((n+1)) + fi +done + + +mkdir -p logs +docker-compose logs > logs/docker-compose.log +docker-compose down + +rm -rf "$tmpfile" + +if [ "$result" == "wait" ]; + then + echo "Failed to start the wallet server" + exit 1 +fi