Skip to content

Commit 5cee18a

Browse files
committed
Avoid tag clashes when testing the release pipeline
1 parent 0271372 commit 5cee18a

File tree

8 files changed

+162
-60
lines changed

8 files changed

+162
-60
lines changed

.buildkite/pipeline.yml

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -516,24 +516,10 @@ steps:
516516
concurrency: 1
517517
concurrency_group: 'macos-e2e-tests'
518518

519-
- group: Windows Agents Setup
520-
key: windows-setup
521-
# Assumes Ruby 2.7 + resource kit is correctly installed on the target
522-
# machine
523-
steps:
524-
- label: 💎 Configure Ruby
525-
key: windows-ruby
526-
commands:
527-
- cd test\e2e
528-
- bundle install
529-
agents:
530-
system: ${windows}
531-
532519
- group: Windows Artifacts
533520
key: windows-artifacts
534521
depends_on:
535522
- linux-nix
536-
- windows-setup
537523
steps:
538524
- block: Build Windows Artifacts (windows)
539525
depends_on: []
@@ -544,6 +530,14 @@ steps:
544530
&& build.env("RELEASE_CANDIDATE") == null
545531
key: trigger-build-windows-artifacts
546532

533+
- label: 💎 Configure Ruby
534+
key: windows-ruby
535+
commands:
536+
- cd test\e2e
537+
- bundle install
538+
agents:
539+
system: ${windows}
540+
547541
- label: Build Package (windows)
548542
key: windows-package
549543
depends_on:
@@ -565,6 +559,7 @@ steps:
565559
- group: Windows Checks
566560
depends_on:
567561
- windows-artifacts
562+
if: build.env("RELEASE_CANDIDATE") == null || build.env("TEST_RC") == "FALSE"
568563
steps:
569564
- label: Windows Unit Tests
570565
command: |
@@ -587,7 +582,7 @@ steps:
587582

588583
- block: Windows E2E Tests
589584
depends_on: []
590-
if: build.env("RELEASE_CANDIDATE") == null
585+
if: build.env("RELEASE_CANDIDATE") == null || build.env("TEST_RC") == "TRUE"
591586
key: trigger-windows-e2e-tests
592587

593588
- label: ⚙️ Windows E2E Tests
@@ -630,21 +625,23 @@ steps:
630625
agents:
631626
system: x86_64-linux
632627

633-
- block: Docker Build
634-
depends_on: []
635-
if: build.env("TEST_RC") == "TRUE"
636-
key: docker-build-block
637-
638-
- label: Push Docker Image
639-
depends_on:
640-
- docker-build
641-
key: build-docker
642-
command:
643-
- "mkdir -p config && echo '{ outputs = _: { dockerHubRepoName = \"cardanofoundation/cardano-wallet\"; }; }' > config/flake.nix"
644-
- "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"
645-
- "./docker-build-push"
646-
agents:
647-
system: x86_64-linux
628+
629+
630+
# - block: Docker Build
631+
# depends_on: []
632+
# if: build.env("TEST_RC") == "TRUE"
633+
# key: docker-build-block
634+
635+
# - label: Push Docker Image
636+
# depends_on:
637+
# - docker-build
638+
# key: build-docker
639+
# command:
640+
# - "mkdir -p config && echo '{ outputs = _: { dockerHubRepoName = \"cardanofoundation/cardano-wallet\"; }; }' > config/flake.nix"
641+
# - "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"
642+
# - "./docker-build-push"
643+
# agents:
644+
# system: x86_64-linux
648645

649646
- group: Docker Checks
650647
depends_on:

.buildkite/release.yml

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ steps:
3838
key: nightly
3939
depends_on: main-pipeline-build
4040
steps:
41+
4142
- label: Push swagger nightly
4243
commands:
4344
- nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-bump.sh
@@ -76,6 +77,28 @@ steps:
7677
env:
7778
RELEASE: false
7879

80+
- label: Push image to dockerhub
81+
commands:
82+
- nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-dockerhub.sh
83+
agents:
84+
system: x86_64-linux
85+
env:
86+
RELEASE: false
87+
88+
89+
# - block: Push test image to dockerhub
90+
# key: push-dockerhub
91+
# depends_on: create-release
92+
93+
# - label: Push test image to dockerhub
94+
# depends_on: push-dockerhub
95+
# commands:
96+
# - nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-dockerhub.sh
97+
# agents:
98+
# system: x86_64-linux
99+
# env:
100+
# RELEASE: false
101+
79102
- group: Release
80103
depends_on: nightly
81104
if: build.branch == "master"
@@ -123,17 +146,22 @@ steps:
123146
env:
124147
RELEASE: true
125148

126-
- label: Push Docker Image
127-
depends_on:
128-
- create-release
129-
command:
130-
- "mkdir -p config && echo '{ outputs = _: { dockerHubRepoName = \"cardanofoundation/cardano-wallet\"; }; }' > config/flake.nix"
131-
- "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"
132-
- "./docker-build-push"
133-
agents:
134-
system: x86_64-linux
135-
136149
- label: Update Documentation Links
137150
depends_on: create-release
138151
commands:
139152
- nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/update-documentation-links.sh
153+
154+
- block: Push to dockerhub
155+
key: push-dockerhub
156+
depends_on: create-release
157+
158+
- label: Push to dockerhub
159+
depends_on: push-dockerhub
160+
artifact_paths:
161+
- ./artifacts/*.tgz
162+
commands:
163+
- nix develop path:$RELEASE_SCRIPTS_DIR -c $RELEASE_SCRIPTS_DIR/push-to-dockerhub.sh
164+
agents:
165+
system: x86_64-linux
166+
env:
167+
RELEASE: true

scripts/buildkite/release/push-artifacts.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ set -euox pipefail
44

55
base_build=$(buildkite-agent meta-data get base-build)
66
NEW_GIT_TAG=$(buildkite-agent meta-data get release-version)
7+
TEST_RC=$(buildkite-agent meta-data get test-rc)
78

89
if [ "$RELEASE" == "false" ]; then
9-
TAG=nightly
10+
if [ "$TEST_RC" == "TRUE" ]; then
11+
TAG="test"
12+
else
13+
TAG="nightly"
14+
fi
1015
else
1116
TAG=$NEW_GIT_TAG
1217
fi
@@ -20,6 +25,7 @@ mkdir -p artifacts
2025

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

34-
artifact "cardano-wallet-$NEW_GIT_TAG-linux64.tar.gz"
35-
artifact "cardano-wallet.exe-$NEW_GIT_TAG-win64.zip"
36-
artifact "cardano-wallet-$NEW_GIT_TAG-macos-silicon.tar.gz"
37-
artifact "cardano-wallet-$NEW_GIT_TAG-macos-intel.tar.gz"
38-
artifact "cardano-wallet-$NEW_GIT_TAG-docker-image.tgz"
41+
artifact "cardano-wallet-$NEW_GIT_TAG-linux64.tar.gz" "cardano-wallet-$TAG-linux64.tar.gz"
42+
artifact "cardano-wallet.exe-$NEW_GIT_TAG-win64.zip" "cardano-wallet.exe-$TAG-win64.zip"
43+
artifact "cardano-wallet-$NEW_GIT_TAG-macos-silicon.tar.gz" "cardano-wallet-$TAG-macos-silicon.tar.gz"
44+
artifact "cardano-wallet-$NEW_GIT_TAG-macos-intel.tar.gz" "cardano-wallet-$TAG-macos-intel.tar.gz"
45+
artifact "cardano-wallet-$NEW_GIT_TAG-docker-image.tgz" "cardano-wallet-$TAG-docker-image.tgz"

scripts/buildkite/release/push-release.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@
33
set -euox pipefail
44

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

78
if [ "$RELEASE" == "false" ]; then
8-
TAG=nightly
9-
title="Nightly $NEW_GIT_TAG"
9+
if [ "$TEST_RC" == "FALSE" ]; then
10+
TAG=nightly
11+
title="Nightly $NEW_GIT_TAG"
12+
else
13+
TAG="test"
14+
title="Test $NEW_GIT_TAG"
15+
fi
16+
1017
else
1118
TAG=$NEW_GIT_TAG
1219
title="Release $TAG"

scripts/buildkite/release/push-tag.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@
33
set -euox pipefail
44

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

78
git tag -l | xargs git tag -d
89
git fetch --tags
910

1011
if [ "$RELEASE" == "false" ]; then
11-
git tag -d nightly || true
12-
TAG=nightly
12+
if [ "$TEST_RC" == "TRUE" ]; then
13+
git tag -d nightly || true
14+
TAG=nightly
15+
else
16+
git tag -d test || true
17+
TAG="test"
18+
fi
1319
else
1420
TAG=$(buildkite-agent meta-data get release-version)
1521
exists=$(git tag -l "$TAG")

scripts/buildkite/release/push-to-bump.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
set -euox pipefail
44

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

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

15-
1616
npm install [email protected]
1717

1818
export PATH=$PWD/node_modules/.bin:$PATH
@@ -25,8 +25,13 @@ if [[ "$RELEASE" == "true" ]]; then
2525
TOKEN="$BUMP_RELEASE_TOKEN"
2626
REPO=cardano-wallet-backend
2727
else
28-
TOKEN="$BUMP_DAILY_TOKEN"
29-
REPO=cardano-wallet-backend-daily
28+
if [[ "$TEST_RC" == "TRUE" ]]; then
29+
TOKEN="$BUMP_TEST_TOKEN"
30+
REPO=cardano-wallet-backend-test
31+
else
32+
TOKEN="$BUMP_DAILY_TOKEN"
33+
REPO=cardano-wallet-backend-daily
34+
fi
3035
fi
3136

3237
bump diff \
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
set -euox pipefail
4+
5+
TRIGGERED_BY=$(buildkite-agent meta-data get base-build)
6+
NEW_GIT_TAG=$(buildkite-agent meta-data get release-version)
7+
TEST_RC=$(buildkite-agent meta-data get test-rc)
8+
9+
if [ "$RELEASE" == "false" ]; then
10+
if [ "$TEST_RC" == "TRUE" ]; then
11+
TAG="test"
12+
else
13+
TAG="nightly"
14+
fi
15+
else
16+
TAG=$NEW_GIT_TAG
17+
fi
18+
19+
main_build=$(curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
20+
-X GET "https://api.buildkite.com/v2/builds" \
21+
| jq ".[] | select(.meta_data.\"triggered-by\" == \"$TRIGGERED_BY\")" \
22+
| jq .number)
23+
24+
mkdir -p artifacts
25+
26+
artifact() {
27+
local artifact_name=$1
28+
# shellcheck disable=SC2155
29+
local artifact_value=$(curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
30+
-X GET "https://api.buildkite.com/v2/organizations/cardano-foundation/pipelines/cardano-wallet/builds/$main_build/artifacts?per_page=100" \
31+
| jq -r " [.[] | select(.filename == \"$artifact_name\")][0] \
32+
| .download_url")
33+
curl -H "Authorization: Bearer $BUILDKITE_API_TOKEN" -L \
34+
-o "artifacts/$artifact_name" \
35+
"$artifact_value"
36+
local image_name="cardanofoundation/cardano-wallet:$TAG"
37+
docker login -u cfhal -p "$DOCKER_HUB_TOKEN"
38+
docker load -i "artifacts/$artifact_name"
39+
# docker push "$image_name"
40+
echo "$image_name"
41+
}
42+
43+
artifact "cardano-wallet-$NEW_GIT_TAG-docker-image.tgz"

scripts/buildkite/release/release-candidate.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,29 @@
33

44
set -euox pipefail
55

6+
if [ "$BUILDKITE_BRANCH" == "master" ]; then
7+
TEST_RC="FALSE"
8+
else
9+
TEST_RC="TRUE"
10+
fi
11+
612
# date from git tag
713
# example v2023-04-04 -> 2023-04-04
814
tag_date() {
915
echo "${1##v}"
1016
}
17+
18+
tag_today() {
19+
sed -e 's/-0/-/g' -e 's/-/./g' <<< "$1"
20+
}
21+
1122
# cabal version from git tag
1223
# example v2023-04-04 -> 2023.4.4
1324
tag_cabal_ver() {
14-
tag_date "$1" | sed -e s/-0/-/g -e s/-/./g
25+
tag_today "$(tag_date "$1")"
1526
}
1627

28+
1729
git tag -l | xargs git tag -d
1830
git fetch --tags
1931

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

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

26-
NEW_GIT_TAG=v$today
27-
28-
NEW_CABAL_VERSION=$(tag_cabal_ver "$NEW_GIT_TAG")
38+
NEW_GIT_TAG="v$today"
39+
NEW_CABAL_VERSION=$(tag_today "$today")
2940

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

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

4859
if [ "$BUILDKITE_BRANCH" == "master" ]; then
4960
RELEASE_CANDIDATE_BRANCH="release-candidate/$NEW_GIT_TAG"
50-
TEST_RC="FALSE"
5161
else
5262
RELEASE_CANDIDATE_BRANCH="test-rc/$BUILDKITE_BRANCH"
53-
TEST_RC="TRUE"
5463
fi
5564

5665
git config --global user.email "[email protected]"

0 commit comments

Comments
 (0)