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 1fad81b
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 34 deletions.
36 changes: 19 additions & 17 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ steps:
build.branch !~ /^gh-readonly-queue\/master/
&& build.branch != "master"
&& build.branch != "rc-latest"
&& build.env("RELEASE_CANDIDATE") == null
&& (build.env("RELEASE_CANDIDATE") == null || build.env("TEST_RC") == "TRUE")
key: trigger-build-windows-artifacts

- label: Build Package (windows)
Expand Down Expand Up @@ -587,7 +587,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 +630,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
49 changes: 39 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,29 @@ steps:
env:
RELEASE: false

- label: Push image to dockerhub
depends_on: define-tag
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 +147,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
13 changes: 12 additions & 1 deletion scripts/buildkite/main/linux-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,15 @@ git fetch --all
git checkout "$RELEASE_CANDIDATE_COMMIT"

rm -rf ./result/*
nix build -o result/linux .#ci.artifacts.linux64.release
nix build -o result/linux .#ci.artifacts.linux64.release

TEST_RC_OR_FALSE=${TEST_RC:-FALSE}
OLD_GIT_TAG=$( git tag -l "v2*-*-*" | sort | tail -n1)
GIT_TAG=$(buildkite-agent meta-data get "release-version" --default="${OLD_GIT_TAG}")

# intercept test artifacts and rename them
if [ "$TEST_RC_OR_FALSE" == "TRUE" ]; then
right="cardano-wallet-$GIT_TAG-test-linux64.tar.gz"
wrong="cardano-wallet-$GIT_TAG.1-linux64.tar.gz"
mv "./result/$wrong" "./result/$right"
fi
8 changes: 8 additions & 0 deletions scripts/buildkite/main/macos-intel-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ git checkout "$RELEASE_CANDIDATE_COMMIT"

rm -rf ./result/*
nix build -o result/macos-intel .#packages.x86_64-darwin.ci.artifacts.macos-intel.release

TEST_RC_OR_FALSE=${TEST_RC:-FALSE}

if [ "$TEST_RC_OR_FALSE" == "TRUE" ]; then
right="cardano-wallet-$NEW_GIT_TAG-test-macos-intel.tar.gz"
wrong="cardano-wallet-$NEW_GIT_TAG.1-macos-intel.tar.gz"
mv "./result/$wrong" "./result/$right"
fi
9 changes: 9 additions & 0 deletions scripts/buildkite/main/macos-silicon-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ git checkout "$RELEASE_CANDIDATE_COMMIT"

rm -rf ./result/*
nix build -o result/macos-silicon .#packages.aarch64-darwin.ci.artifacts.macos-silicon.release

# interpret '.1' as '-test'
TEST_RC_OR_FALSE=${TEST_RC:-FALSE}

if [ "$TEST_RC_OR_FALSE" == "TRUE" ]; then
right="cardano-wallet-$NEW_GIT_TAG-test-macos-silicon.tar.gz"
wrong="cardano-wallet-$NEW_GIT_TAG.1-macos-silicon.tar.gz"
mv "./result/$wrong" "./result/$right"
fi
42 changes: 42 additions & 0 deletions scripts/buildkite/release/push-to-dockerhub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/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)

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"
26 changes: 20 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,13 @@ git checkout "$BASE_COMMIT"

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

NEW_GIT_TAG=v$today

NEW_CABAL_VERSION=$(tag_cabal_ver "$NEW_GIT_TAG")
if [ $TEST_RC == "TRUE" ]; then
NEW_GIT_TAG="v$today"
NEW_CABAL_VERSION=$(tag_today "$today").1
else
NEW_GIT_TAG="v$today"
NEW_CABAL_VERSION=$(tag_today "$today")
fi

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

Expand All @@ -47,10 +63,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 "gha@cardanofoundation.org"
Expand Down

0 comments on commit 1fad81b

Please sign in to comment.