Skip to content

Commit

Permalink
Add color to release-sop (#3419)
Browse files Browse the repository at this point in the history
# Motivation

It can be used to find specific values such as the commit hash or the RC
URL in the output of the release SOP script.

# Changes

1. Output newly recorded values in green.
2. Output previously recorded values in magenta.
3. Update tests.

# Tests

updated

# Todos

- [ ] Add entry to changelog (if necessary).
not necessary
  • Loading branch information
dskloetd authored Sep 29, 2023
1 parent 2894133 commit e1216ac
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 154 deletions.
8 changes: 6 additions & 2 deletions scripts/nns-dapp/release-sop
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ fi
TOP_DIR=$(execute git rev-parse --show-toplevel)
execute cd "$TOP_DIR"

GREEN_COLOR="\033[32m"
MAGENTA_COLOR="\033[35m"
RESET_COLOR="\033[0m"

checklist_get() {
local name
name="$1"
Expand All @@ -150,7 +154,7 @@ checklist_add() {
temp_file="$CHECKLIST_FILE.tmp"
jq --arg name "$name" --arg value "$value" '. + [{name: $name, value: $value}]' "$CHECKLIST_FILE" >"$temp_file"
mv "$temp_file" "$CHECKLIST_FILE"
echo "$name: $value"
echo -e "$name: ${GREEN_COLOR}$value${RESET_COLOR}"
}

# This script is designed to be run multiple times. Steps that have been
Expand Down Expand Up @@ -202,7 +206,7 @@ record() {
shift
value="$(checklist_get "$label")"
if [ "$value" ]; then
echo "$label: Was already: $value"
echo -e "$label: Was already: ${MAGENTA_COLOR}$value${RESET_COLOR}"
return
fi
if ! value="$(execute "$@")"; then
Expand Down
26 changes: 13 additions & 13 deletions scripts/nns-dapp/release-sop-test-continue-after-success.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,36 +54,36 @@
],
"expectedOutput": [
"Checklist file: scripts/nns-dapp/Release-2001-02-29.json",
"Start time: Was already: 2001-02-29 14:15:16",
"Start time: Was already: \u001b[35m2001-02-29 14:15:16\u001b[0m",
"git fetch --tags --force: Was already done. Skipping.",
"Release SOP script is newest version: Was already: yes",
"Release SOP script is newest version: Was already: \u001b[35myes\u001b[0m",
"git checkout -b Release-2001-02-29 --no-track origin/main: Was already done. Skipping.",
"Release branch: Was already: Release-2001-02-29",
"Release branch: Was already: \u001b[35mRelease-2001-02-29\u001b[0m",
"Current branch: Release-2001-02-29",
"git push origin Release-2001-02-29: Was already done. Skipping.",
"Release branch URL: Was already: https://github.com/dfinity/nns-dapp/tree/Release-2001-02-29",
"Release branch URL: Was already: \u001b[35mhttps://github.com/dfinity/nns-dapp/tree/Release-2001-02-29\u001b[0m",
"git tag -f release-candidate: Was already done. Skipping.",
"Release commit: Was already: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3",
"Release commit: Was already: \u001b[35ma1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3\u001b[0m",
"tags/release-candidate commit: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3",
"git push origin -f tags/release-candidate: Was already done. Skipping.",
"Security test: npm audit: Was already: found 0 vulnerabilities",
"Security test: npm audit: Was already: \u001b[35mfound 0 vulnerabilities\u001b[0m",
"Expected npm audit: found 0 vulnerabilities",
"Security test: cargo audit: Was already: RUSTSEC-2020-0071,RUSTSEC-2020-0159",
"Security test: cargo audit: Was already: \u001b[35mRUSTSEC-2020-0071,RUSTSEC-2020-0159\u001b[0m",
"Expected cargo audit: RUSTSEC-2020-0071,RUSTSEC-2020-0159",
"Security test: no HTML in templates: Was already: Checked",
"Security test: no HTML in templates: Was already: \u001b[35mChecked\u001b[0m",
"scripts/nns-dapp/download-ci-wasm --commit tags/release-candidate --dir /home/runner/work/nns-dapp/release/ci --wasm-filename nns-dapp.wasm.gz: Was already done. Skipping.",
"CI NNS-dapp WASM hash: Was already: 6fbaddd1b8fde76de97ca1b03a356f01741878d6210cd9b7c6753ae80ae374a4",
"CI NNS-dapp WASM hash: Was already: \u001b[35m6fbaddd1b8fde76de97ca1b03a356f01741878d6210cd9b7c6753ae80ae374a4\u001b[0m",
"Local WASM hash: 6fbaddd1b8fde76de97ca1b03a356f01741878d6210cd9b7c6753ae80ae374a4",
"scripts/canister_ids --remove --network staging --canister nns-dapp: Was already done. Skipping.",
"dfx identity: Was already: default: s2dw5-fmktb-knrnq-772tr-ca3g7-me224-st35j-f3eli-xx2vf-aoesd-2qe",
"dfx identity: Was already: \u001b[35mdefault: s2dw5-fmktb-knrnq-772tr-ca3g7-me224-st35j-f3eli-xx2vf-aoesd-2qe\u001b[0m",
"dfx canister create nns-dapp --network staging --no-wallet: Was already done. Skipping.",
"NNS-dapp staging canister ID: Was already: jefp3-bqaaa-aaaaa-aacyq-cai",
"NNS-dapp staging canister ID: Was already: \u001b[35mjefp3-bqaaa-aaaaa-aacyq-cai\u001b[0m",
"Current NNS-dapp staging canister ID: jefp3-bqaaa-aaaaa-aacyq-cai",
"DFX_NETWORK=staging ./config.sh: Was already done. Skipping.",
"dfx canister install nns-dapp --argument \\(record\\{\\}\\) --network staging --wasm ./release/ci/nns-dapp.wasm.gz: Was already done. Skipping.",
"Staging URL: Was already: https://jefp3-bqaaa-aaaaa-aacyq-cai.nnsdapp.dfinity.network/",
"Staging URL: Was already: \u001b[35mhttps://jefp3-bqaaa-aaaaa-aacyq-cai.nnsdapp.dfinity.network/\u001b[0m",
"Staging WASM hash: 6fbaddd1b8fde76de97ca1b03a356f01741878d6210cd9b7c6753ae80ae374a4",
"Post on Slack: Was already: https://dfinity.slack.com/archives/C03HZERHBT3/p1687962898467509"
"Post on Slack: Was already: \u001b[35mhttps://dfinity.slack.com/archives/C03HZERHBT3/p1687962898467509\u001b[0m"
],
"expectedExitCode": 0
}
10 changes: 5 additions & 5 deletions scripts/nns-dapp/release-sop-test-continue-different-commit.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@
],
"expectedOutput": [
"Checklist file: scripts/nns-dapp/Release-2001-02-29.json",
"Start time: Was already: 2001-02-29 14:15:16",
"Start time: Was already: \u001b[35m2001-02-29 14:15:16\u001b[0m",
"git fetch --tags --force: Was already done. Skipping.",
"Release SOP script is newest version: Was already: yes",
"Release SOP script is newest version: Was already: \u001b[35myes\u001b[0m",
"git checkout -b Release-2001-02-29 --no-track origin/main: Was already done. Skipping.",
"Release branch: Was already: Release-2001-02-29",
"Release branch: Was already: \u001b[35mRelease-2001-02-29\u001b[0m",
"Current branch: Release-2001-02-29",
"git push origin Release-2001-02-29: Was already done. Skipping.",
"Release branch URL: Was already: https://github.com/dfinity/nns-dapp/tree/Release-2001-02-29",
"Release branch URL: Was already: \u001b[35mhttps://github.com/dfinity/nns-dapp/tree/Release-2001-02-29\u001b[0m",
"git tag -f release-candidate: Was already done. Skipping.",
"Release commit: Was already: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3",
"Release commit: Was already: \u001b[35ma1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3\u001b[0m",
"Values don't match!",
"Release commit: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3",
"tags/release-candidate commit: ffffffffffffffffffffffffffffffffffffffffff"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,30 @@
],
"expectedOutput": [
"Checklist file: scripts/nns-dapp/Release-2001-02-29.json",
"Start time: Was already: 2001-02-29 14:15:16",
"Start time: Was already: \u001b[35m2001-02-29 14:15:16\u001b[0m",
"git fetch --tags --force: Was already done. Skipping.",
"Release SOP script is newest version: Was already: yes",
"Release SOP script is newest version: Was already: \u001b[35myes\u001b[0m",
"git checkout -b Release-2001-02-29 --no-track origin/main: Was already done. Skipping.",
"Release branch: Was already: Release-2001-02-29",
"Release branch: Was already: \u001b[35mRelease-2001-02-29\u001b[0m",
"Current branch: Release-2001-02-29",
"git push origin Release-2001-02-29: Was already done. Skipping.",
"Release branch URL: Was already: https://github.com/dfinity/nns-dapp/tree/Release-2001-02-29",
"Release branch URL: Was already: \u001b[35mhttps://github.com/dfinity/nns-dapp/tree/Release-2001-02-29\u001b[0m",
"git tag -f release-candidate: Was already done. Skipping.",
"Release commit: Was already: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3",
"Release commit: Was already: \u001b[35ma1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3\u001b[0m",
"tags/release-candidate commit: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3",
"git push origin -f tags/release-candidate: Was already done. Skipping.",
"Security test: npm audit: Was already: found 0 vulnerabilities",
"Security test: npm audit: Was already: \u001b[35mfound 0 vulnerabilities\u001b[0m",
"Expected npm audit: found 0 vulnerabilities",
"Security test: cargo audit: Was already: RUSTSEC-2020-0071,RUSTSEC-2020-0159",
"Security test: cargo audit: Was already: \u001b[35mRUSTSEC-2020-0071,RUSTSEC-2020-0159\u001b[0m",
"Expected cargo audit: RUSTSEC-2020-0071,RUSTSEC-2020-0159",
"Security test: no HTML in templates: Was already: Checked",
"Security test: no HTML in templates: Was already: \u001b[35mChecked\u001b[0m",
"scripts/nns-dapp/download-ci-wasm --commit tags/release-candidate --dir /home/runner/work/nns-dapp/release/ci --wasm-filename nns-dapp.wasm.gz: Was already done. Skipping.",
"CI NNS-dapp WASM hash: Was already: 6fbaddd1b8fde76de97ca1b03a356f01741878d6210cd9b7c6753ae80ae374a4",
"CI NNS-dapp WASM hash: Was already: \u001b[35m6fbaddd1b8fde76de97ca1b03a356f01741878d6210cd9b7c6753ae80ae374a4\u001b[0m",
"Local WASM hash: 6fbaddd1b8fde76de97ca1b03a356f01741878d6210cd9b7c6753ae80ae374a4",
"scripts/canister_ids --remove --network staging --canister nns-dapp: Was already done. Skipping.",
"dfx identity: Was already: default: s2dw5-fmktb-knrnq-772tr-ca3g7-me224-st35j-f3eli-xx2vf-aoesd-2qe",
"dfx identity: Was already: \u001b[35mdefault: s2dw5-fmktb-knrnq-772tr-ca3g7-me224-st35j-f3eli-xx2vf-aoesd-2qe\u001b[0m",
"dfx canister create nns-dapp --network staging --no-wallet: Was already done. Skipping.",
"NNS-dapp staging canister ID: Was already: jefp3-bqaaa-aaaaa-aacyq-cai",
"NNS-dapp staging canister ID: Was already: \u001b[35mjefp3-bqaaa-aaaaa-aacyq-cai\u001b[0m",
"Values don't match!",
"NNS-dapp staging canister ID: jefp3-bqaaa-aaaaa-aacyq-cai",
"Current NNS-dapp staging canister ID: aaaaa-aa"
Expand Down
30 changes: 15 additions & 15 deletions scripts/nns-dapp/release-sop-test-different-cargo-audit.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,41 +66,41 @@
],
"expectedOutput": [
"Checklist file: scripts/nns-dapp/Release-2001-02-29.json",
"Start time: 2001-02-29 14:15:16",
"Start time: \u001b[32m2001-02-29 14:15:16\u001b[0m",
"👇 Press enter to run the following command:",
"",
"git fetch --tags --force",
"",
"git fetch --tags --force: Done",
"Release SOP script is newest version: yes",
"git fetch --tags --force: \u001b[32mDone\u001b[0m",
"Release SOP script is newest version: \u001b[32myes\u001b[0m",
"👇 Press enter to run the following command:",
"",
"git checkout -b Release-2001-02-29 --no-track origin/main",
"",
"git checkout -b Release-2001-02-29 --no-track origin/main: Done",
"Release branch: Release-2001-02-29",
"Current branch: Release-2001-02-29",
"git checkout -b Release-2001-02-29 --no-track origin/main: \u001b[32mDone\u001b[0m",
"Release branch: \u001b[32mRelease-2001-02-29\u001b[0m",
"Current branch: \u001b[32mRelease-2001-02-29\u001b[0m",
"👇 Press enter to run the following command:",
"",
"git push origin Release-2001-02-29",
"",
"git push origin Release-2001-02-29: Done",
"Release branch URL: https://github.com/dfinity/nns-dapp/tree/Release-2001-02-29",
"git push origin Release-2001-02-29: \u001b[32mDone\u001b[0m",
"Release branch URL: \u001b[32mhttps://github.com/dfinity/nns-dapp/tree/Release-2001-02-29\u001b[0m",
"👇 Press enter to run the following command:",
"",
"git tag -f release-candidate",
"",
"git tag -f release-candidate: Done",
"Release commit: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3",
"tags/release-candidate commit: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3",
"git tag -f release-candidate: \u001b[32mDone\u001b[0m",
"Release commit: \u001b[32ma1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3\u001b[0m",
"tags/release-candidate commit: \u001b[32ma1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3\u001b[0m",
"👇 Press enter to run the following command:",
"",
"git push origin -f tags/release-candidate",
"",
"git push origin -f tags/release-candidate: Done",
"Security test: npm audit: found 0 vulnerabilities",
"Expected npm audit: found 0 vulnerabilities",
"Security test: cargo audit: RUSTSEC-1999-0001",
"git push origin -f tags/release-candidate: \u001b[32mDone\u001b[0m",
"Security test: npm audit: \u001b[32mfound 0 vulnerabilities\u001b[0m",
"Expected npm audit: \u001b[32mfound 0 vulnerabilities\u001b[0m",
"Security test: cargo audit: \u001b[32mRUSTSEC-1999-0001\u001b[0m",
"Values don't match!",
"Security test: cargo audit: RUSTSEC-1999-0001",
"Expected cargo audit: RUSTSEC-2020-0071,RUSTSEC-2020-0159"
Expand Down
26 changes: 13 additions & 13 deletions scripts/nns-dapp/release-sop-test-different-npm-audit.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,39 +60,39 @@
],
"expectedOutput": [
"Checklist file: scripts/nns-dapp/Release-2001-02-29.json",
"Start time: 2001-02-29 14:15:16",
"Start time: \u001b[32m2001-02-29 14:15:16\u001b[0m",
"👇 Press enter to run the following command:",
"",
"git fetch --tags --force",
"",
"git fetch --tags --force: Done",
"Release SOP script is newest version: yes",
"git fetch --tags --force: \u001b[32mDone\u001b[0m",
"Release SOP script is newest version: \u001b[32myes\u001b[0m",
"👇 Press enter to run the following command:",
"",
"git checkout -b Release-2001-02-29 --no-track origin/main",
"",
"git checkout -b Release-2001-02-29 --no-track origin/main: Done",
"Release branch: Release-2001-02-29",
"Current branch: Release-2001-02-29",
"git checkout -b Release-2001-02-29 --no-track origin/main: \u001b[32mDone\u001b[0m",
"Release branch: \u001b[32mRelease-2001-02-29\u001b[0m",
"Current branch: \u001b[32mRelease-2001-02-29\u001b[0m",
"👇 Press enter to run the following command:",
"",
"git push origin Release-2001-02-29",
"",
"git push origin Release-2001-02-29: Done",
"Release branch URL: https://github.com/dfinity/nns-dapp/tree/Release-2001-02-29",
"git push origin Release-2001-02-29: \u001b[32mDone\u001b[0m",
"Release branch URL: \u001b[32mhttps://github.com/dfinity/nns-dapp/tree/Release-2001-02-29\u001b[0m",
"👇 Press enter to run the following command:",
"",
"git tag -f release-candidate",
"",
"git tag -f release-candidate: Done",
"Release commit: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3",
"tags/release-candidate commit: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3",
"git tag -f release-candidate: \u001b[32mDone\u001b[0m",
"Release commit: \u001b[32ma1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3\u001b[0m",
"tags/release-candidate commit: \u001b[32ma1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3\u001b[0m",
"👇 Press enter to run the following command:",
"",
"git push origin -f tags/release-candidate",
"",
"git push origin -f tags/release-candidate: Done",
"Security test: npm audit: https://github.com/advisories/XXXX-xxxx-xxxx-xxxx",
"git push origin -f tags/release-candidate: \u001b[32mDone\u001b[0m",
"Security test: npm audit: \u001b[32mhttps://github.com/advisories/XXXX-xxxx-xxxx-xxxx\u001b[0m",
"Values don't match!",
"Security test: npm audit: https://github.com/advisories/XXXX-xxxx-xxxx-xxxx",
"Expected npm audit: found 0 vulnerabilities"
Expand Down
Loading

0 comments on commit e1216ac

Please sign in to comment.