Skip to content

Commit

Permalink
Avoid tag clashes when testing the release pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
paolino committed Jan 10, 2025
1 parent 0271372 commit 5cee18a
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 60 deletions.
57 changes: 27 additions & 30 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -516,24 +516,10 @@ steps:
concurrency: 1
concurrency_group: 'macos-e2e-tests'

- group: Windows Agents Setup
key: windows-setup
# Assumes Ruby 2.7 + resource kit is correctly installed on the target
# machine
steps:
- label: 💎 Configure Ruby
key: windows-ruby
commands:
- cd test\e2e
- bundle install
agents:
system: ${windows}

- group: Windows Artifacts
key: windows-artifacts
depends_on:
- linux-nix
- windows-setup
steps:
- block: Build Windows Artifacts (windows)
depends_on: []
Expand All @@ -544,6 +530,14 @@ steps:
&& build.env("RELEASE_CANDIDATE") == null
key: trigger-build-windows-artifacts

- label: 💎 Configure Ruby
key: windows-ruby
commands:
- cd test\e2e
- bundle install
agents:
system: ${windows}

- label: Build Package (windows)
key: windows-package
depends_on:
Expand All @@ -565,6 +559,7 @@ steps:
- group: Windows Checks
depends_on:
- windows-artifacts
if: build.env("RELEASE_CANDIDATE") == null || build.env("TEST_RC") == "FALSE"
steps:
- label: Windows Unit Tests
command: |
Expand All @@ -587,7 +582,7 @@ steps:

- block: Windows E2E Tests
depends_on: []
if: build.env("RELEASE_CANDIDATE") == null
if: build.env("RELEASE_CANDIDATE") == null || build.env("TEST_RC") == "TRUE"
key: trigger-windows-e2e-tests

- label: ⚙️ Windows E2E Tests
Expand Down Expand Up @@ -630,21 +625,23 @@ steps:
agents:
system: x86_64-linux

- block: Docker Build
depends_on: []
if: build.env("TEST_RC") == "TRUE"
key: docker-build-block

- label: Push Docker Image
depends_on:
- docker-build
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 <nixpkgs> {}).path')\" --override-input customConfig path:./config -o docker-build-push"
- "./docker-build-push"
agents:
system: x86_64-linux


# - block: Docker Build
# depends_on: []
# if: build.env("TEST_RC") == "TRUE"
# key: docker-build-block

# - label: Push Docker Image
# depends_on:
# - docker-build
# 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 <nixpkgs> {}).path')\" --override-input customConfig path:./config -o docker-build-push"
# - "./docker-build-push"
# agents:
# system: x86_64-linux

- group: Docker Checks
depends_on:
Expand Down
48 changes: 38 additions & 10 deletions .buildkite/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ steps:
key: nightly
depends_on: main-pipeline-build
steps:

- label: Push swagger nightly
commands:
- nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-bump.sh
Expand Down Expand Up @@ -76,6 +77,28 @@ steps:
env:
RELEASE: false

- label: Push image to dockerhub
commands:
- nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-dockerhub.sh
agents:
system: x86_64-linux
env:
RELEASE: false


# - block: Push test image to dockerhub
# key: push-dockerhub
# depends_on: create-release

# - label: Push test image to dockerhub
# depends_on: push-dockerhub
# commands:
# - nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-dockerhub.sh
# agents:
# system: x86_64-linux
# env:
# RELEASE: false

- group: Release
depends_on: nightly
if: build.branch == "master"
Expand Down Expand Up @@ -123,17 +146,22 @@ steps:
env:
RELEASE: true

- label: Push Docker Image
depends_on:
- create-release
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 <nixpkgs> {}).path')\" --override-input customConfig path:./config -o docker-build-push"
- "./docker-build-push"
agents:
system: x86_64-linux

- label: Update Documentation Links
depends_on: create-release
commands:
- nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/update-documentation-links.sh

- block: Push to dockerhub
key: push-dockerhub
depends_on: create-release

- label: Push to dockerhub
depends_on: push-dockerhub
artifact_paths:
- ./artifacts/*.tgz
commands:
- nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-dockerhub.sh
agents:
system: x86_64-linux
env:
RELEASE: true
21 changes: 14 additions & 7 deletions scripts/buildkite/release/push-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ set -euox pipefail

base_build=$(buildkite-agent meta-data get base-build)
NEW_GIT_TAG=$(buildkite-agent meta-data get release-version)
TEST_RC=$(buildkite-agent meta-data get test-rc)

if [ "$RELEASE" == "false" ]; then
TAG=nightly
if [ "$TEST_RC" == "TRUE" ]; then
TAG="test"
else
TAG="nightly"
fi
else
TAG=$NEW_GIT_TAG
fi
Expand All @@ -20,6 +25,7 @@ mkdir -p artifacts

artifact() {
local artifact_name=$1
local new_artifact_name=$2
# shellcheck disable=SC2155
local artifact_value=$(curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
-X GET "https://api.buildkite.com/v2/organizations/cardano-foundation/pipelines/cardano-wallet/builds/$main_build/artifacts?per_page=100" \
Expand All @@ -28,11 +34,12 @@ artifact() {
curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" -L \
-o "artifacts/$artifact_name" \
"$artifact_value"
gh release upload "$TAG" "artifacts/$artifact_name"
mv "artifacts/$artifact_name" "artifacts/$new_artifact_name"
gh release upload "$TAG" "artifacts/$new_artifact_name"
}

artifact "cardano-wallet-$NEW_GIT_TAG-linux64.tar.gz"
artifact "cardano-wallet.exe-$NEW_GIT_TAG-win64.zip"
artifact "cardano-wallet-$NEW_GIT_TAG-macos-silicon.tar.gz"
artifact "cardano-wallet-$NEW_GIT_TAG-macos-intel.tar.gz"
artifact "cardano-wallet-$NEW_GIT_TAG-docker-image.tgz"
artifact "cardano-wallet-$NEW_GIT_TAG-linux64.tar.gz" "cardano-wallet-$TAG-linux64.tar.gz"
artifact "cardano-wallet.exe-$NEW_GIT_TAG-win64.zip" "cardano-wallet.exe-$TAG-win64.zip"
artifact "cardano-wallet-$NEW_GIT_TAG-macos-silicon.tar.gz" "cardano-wallet-$TAG-macos-silicon.tar.gz"
artifact "cardano-wallet-$NEW_GIT_TAG-macos-intel.tar.gz" "cardano-wallet-$TAG-macos-intel.tar.gz"
artifact "cardano-wallet-$NEW_GIT_TAG-docker-image.tgz" "cardano-wallet-$TAG-docker-image.tgz"
11 changes: 9 additions & 2 deletions scripts/buildkite/release/push-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
set -euox pipefail

NEW_GIT_TAG=$(buildkite-agent meta-data get release-version)
TEST_RC=$(buildkite-agent meta-data get test-rc)

if [ "$RELEASE" == "false" ]; then
TAG=nightly
title="Nightly $NEW_GIT_TAG"
if [ "$TEST_RC" == "FALSE" ]; then
TAG=nightly
title="Nightly $NEW_GIT_TAG"
else
TAG="test"
title="Test $NEW_GIT_TAG"
fi

else
TAG=$NEW_GIT_TAG
title="Release $TAG"
Expand Down
10 changes: 8 additions & 2 deletions scripts/buildkite/release/push-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
set -euox pipefail

RELEASE_GIT_COMMIT=$(buildkite-agent meta-data get release-candidate-commit)
TEST_RC=$(buildkite-agent meta-data get test-rc)

git tag -l | xargs git tag -d
git fetch --tags

if [ "$RELEASE" == "false" ]; then
git tag -d nightly || true
TAG=nightly
if [ "$TEST_RC" == "TRUE" ]; then
git tag -d nightly || true
TAG=nightly
else
git tag -d test || true
TAG="test"
fi
else
TAG=$(buildkite-agent meta-data get release-version)
exists=$(git tag -l "$TAG")
Expand Down
11 changes: 8 additions & 3 deletions scripts/buildkite/release/push-to-bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

set -euox pipefail

TEST_RC=$(buildkite-agent meta-data get test-rc --default "FALSE")

if [[ -n "${BUILDKITE-}" ]]; then
RELEASE_CANDIDATE_COMMIT=$(buildkite-agent meta-data get release-candidate-commit --default "")
Expand All @@ -12,7 +13,6 @@ else
RELEASE_CANDIDATE_COMMIT=""
fi


npm install [email protected]

export PATH=$PWD/node_modules/.bin:$PATH
Expand All @@ -25,8 +25,13 @@ if [[ "$RELEASE" == "true" ]]; then
TOKEN="$BUMP_RELEASE_TOKEN"
REPO=cardano-wallet-backend
else
TOKEN="$BUMP_DAILY_TOKEN"
REPO=cardano-wallet-backend-daily
if [[ "$TEST_RC" == "TRUE" ]]; then
TOKEN="$BUMP_TEST_TOKEN"
REPO=cardano-wallet-backend-test
else
TOKEN="$BUMP_DAILY_TOKEN"
REPO=cardano-wallet-backend-daily
fi
fi

bump diff \
Expand Down
43 changes: 43 additions & 0 deletions scripts/buildkite/release/push-to-dockerhub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash

set -euox pipefail

TRIGGERED_BY=$(buildkite-agent meta-data get base-build)
NEW_GIT_TAG=$(buildkite-agent meta-data get release-version)
TEST_RC=$(buildkite-agent meta-data get test-rc)

if [ "$RELEASE" == "false" ]; then
if [ "$TEST_RC" == "TRUE" ]; then
TAG="test"
else
TAG="nightly"
fi
else
TAG=$NEW_GIT_TAG
fi

main_build=$(curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
-X GET "https://api.buildkite.com/v2/builds" \
| jq ".[] | select(.meta_data.\"triggered-by\" == \"$TRIGGERED_BY\")" \
| jq .number)

mkdir -p artifacts

artifact() {
local artifact_name=$1
# shellcheck disable=SC2155
local artifact_value=$(curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
-X GET "https://api.buildkite.com/v2/organizations/cardano-foundation/pipelines/cardano-wallet/builds/$main_build/artifacts?per_page=100" \
| jq -r " [.[] | select(.filename == \"$artifact_name\")][0] \
| .download_url")
curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" -L \
-o "artifacts/$artifact_name" \
"$artifact_value"
local image_name="cardanofoundation/cardano-wallet:$TAG"
docker login -u cfhal -p "$DOCKER_HUB_TOKEN"
docker load -i "artifacts/$artifact_name"
# docker push "$image_name"
echo "$image_name"
}

artifact "cardano-wallet-$NEW_GIT_TAG-docker-image.tgz"
21 changes: 15 additions & 6 deletions scripts/buildkite/release/release-candidate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,29 @@

set -euox pipefail

if [ "$BUILDKITE_BRANCH" == "master" ]; then
TEST_RC="FALSE"
else
TEST_RC="TRUE"
fi

# date from git tag
# example v2023-04-04 -> 2023-04-04
tag_date() {
echo "${1##v}"
}

tag_today() {
sed -e 's/-0/-/g' -e 's/-/./g' <<< "$1"
}

# cabal version from git tag
# example v2023-04-04 -> 2023.4.4
tag_cabal_ver() {
tag_date "$1" | sed -e s/-0/-/g -e s/-/./g
tag_today "$(tag_date "$1")"
}


git tag -l | xargs git tag -d
git fetch --tags

Expand All @@ -23,9 +35,8 @@ git checkout "$BASE_COMMIT"

today=$(date +%Y-%m-%d)

NEW_GIT_TAG=v$today

NEW_CABAL_VERSION=$(tag_cabal_ver "$NEW_GIT_TAG")
NEW_GIT_TAG="v$today"
NEW_CABAL_VERSION=$(tag_today "$today")

OLD_GIT_TAG=$( git tag -l "v2*-*-*" | sort | tail -n1)

Expand All @@ -47,10 +58,8 @@ CARDANO_NODE_TAG=$(cardano-node version | head -n1 | awk '{print $2}')

if [ "$BUILDKITE_BRANCH" == "master" ]; then
RELEASE_CANDIDATE_BRANCH="release-candidate/$NEW_GIT_TAG"
TEST_RC="FALSE"
else
RELEASE_CANDIDATE_BRANCH="test-rc/$BUILDKITE_BRANCH"
TEST_RC="TRUE"
fi

git config --global user.email "[email protected]"
Expand Down

0 comments on commit 5cee18a

Please sign in to comment.