From 9ec34640cd891972be5cd6785e241efa027d326b Mon Sep 17 00:00:00 2001 From: Rail Aliiev Date: Thu, 24 Feb 2022 22:28:04 -0500 Subject: [PATCH] release: enable bincheck for tag pushes Previously, in order to run `bincheck` as part of the release process, we would need to follow hands-on instructions at https://github.com/cockroachdb/bincheck/blob/master/README.md. This process requires some time and error prone. This patch enables GitHub actions on tag push events and automates the task. Release note: None --- .../ci.yaml => .github/workflows/bincheck.yml | 10 ++-- build/release/bincheck/README.md | 22 ++------- build/release/bincheck/VERSION | 18 ------- build/release/bincheck/download_binary.sh | 49 ++++++------------- build/release/bincheck/test-linux | 14 ++++-- build/release/bincheck/test-macos | 14 ++++-- build/release/bincheck/test-windows | 13 +++-- 7 files changed, 57 insertions(+), 83 deletions(-) rename build/release/bincheck/.github/workflows/ci.yaml => .github/workflows/bincheck.yml (53%) delete mode 100644 build/release/bincheck/VERSION diff --git a/build/release/bincheck/.github/workflows/ci.yaml b/.github/workflows/bincheck.yml similarity index 53% rename from build/release/bincheck/.github/workflows/ci.yaml rename to .github/workflows/bincheck.yml index b18b65fbd268..45f85c07b2c5 100644 --- a/build/release/bincheck/.github/workflows/ci.yaml +++ b/.github/workflows/bincheck.yml @@ -2,9 +2,7 @@ name: bincheck on: push: - branches: [ master, release-* ] - pull_request: - branches: [ master, release-* ] + tags: [ v* ] jobs: @@ -13,16 +11,16 @@ jobs: steps: - uses: actions/checkout@v2 - run: sudo apt-get update && sudo apt-get install -y qemu-system-x86 - - run: ./test-linux + - run: cd build/release/bincheck && ./test-linux ${{ github.ref_name }} ${{ github.sha }} darwin: runs-on: macos-latest steps: - uses: actions/checkout@v2 - - run: ./test-macos + - run: cd build/release/bincheck && ./test-macos ${{ github.ref_name }} ${{ github.sha }} windows: runs-on: windows-latest steps: - uses: actions/checkout@v2 - - run: bash test-windows + - run: cd build/release/bincheck && bash test-windows ${{ github.ref_name }} ${{ github.sha }} diff --git a/build/release/bincheck/README.md b/build/release/bincheck/README.md index 57afd7a00c91..775ca7a3bb23 100644 --- a/build/release/bincheck/README.md +++ b/build/release/bincheck/README.md @@ -1,6 +1,4 @@ -# cockroachdb/bincheck - -[![Build Status](https://github.com/cockroachdb/bincheck/actions/workflows/ci.yaml/badge.svg)](https://github.com/cockroachdb/bincheck/actions/workflows/ci.yaml) +# bincheck bincheck verifies the sanity of CockroachDB release binaries. At present, the sanity checks are: @@ -10,18 +8,9 @@ sanity checks are: ## Testing a new release -Open a PR that updates the version in [VERSION] on the appropriate branch (eg: `release-2.0` for 2.0 builds). -You can use the little pencil button to edit the file directly through the GitHub UI (no need to -fork the repo): - -**Important: make sure to select the "start a pull request" option before clicking "Propose changes":** - - - +bincheck action is triggered when a new tag with `v` prefix is created. Check +https://github.com/cockroachdb/cockroach/actions after a release is published. -The PR will automatically kick off checks to verify the release using GitHub -Actions. If the checks complete successfully, you can merge the PR and you're -done! ## The nitty-gritty @@ -58,10 +47,10 @@ implementations at runtime [has proven difficult][issue-15589]. After [installing Buildroot][buildroot-install]: ```shell -$ make qemu_x86_64_glibc_defconfig BR2_EXTERNAL=${BINCHECK-REPO}/buildroot +$ make qemu_x86_64_glibc_defconfig BR2_EXTERNAL=buildroot $ make menuconfig # Only if configuration changes are necessary. $ make -$ cp output/images/bzImage ${BINCHECK-REPO}/images/qemu_x86_64_glibc_bzImage +$ cp output/images/bzImage images/qemu_x86_64_glibc_bzImage ``` At the time of writing, `qemu_x86_64_glibc_defconfig` instructed Buildroot to @@ -76,4 +65,3 @@ it's a FAT volume. [Buildroot]: https://buildroot.org [CRC32C]: http://www.evanjones.ca/crc32c.html [QEMU]: http://qemu.org -[VERSION]: ./VERSION diff --git a/build/release/bincheck/VERSION b/build/release/bincheck/VERSION deleted file mode 100644 index 969186e2b8ce..000000000000 --- a/build/release/bincheck/VERSION +++ /dev/null @@ -1,18 +0,0 @@ -# WARNING: ARE YOU MAKING A PULL REQUEST AGAINST THE RIGHT BRANCH? -# Use the release-X.Y branch that corresponds to the version of CockroachDB -# you're checking. To check v2.0.4, for example, make your pull request against -# the release-2.0 branch. -# -# The version can take one of two formats: -# -# - v: release binary from https://binaries.cockroachdb.com -# e.g.: v2.0.2 -# -# - test:v: test release binary from https://binaries-test.cockroachdb.com -# e.g.: test:vx.y.z[-extensions] -# -# Be sure to list the expected SHA, in full, on the line following the version. -# - -v20.2.19 -09707aabb12e50f6e7345b5c9664c0745bb7d742 diff --git a/build/release/bincheck/download_binary.sh b/build/release/bincheck/download_binary.sh index 5fe3959c4c6d..c0b08c44e921 100755 --- a/build/release/bincheck/download_binary.sh +++ b/build/release/bincheck/download_binary.sh @@ -2,39 +2,22 @@ set -euo pipefail -binary_suffix=$1 -binary_source="" -cockroach_version="" -while read line; do - # Trailing \r on Windows sneaks into the variables, let's nuke it - line=$(echo $line | tr -d '\r') - case "$line" in - \#*|"") continue ;; - test:*) - binary_source="https://binaries-test.cockroachdb.com" - parts=(${line//:/ }) - export COCKROACH_VERSION=${parts[1]} - ;; - v*) - binary_source="https://binaries.cockroachdb.com" - export COCKROACH_VERSION=$line - ;; - *) - export COCKROACH_SHA=$line - esac -done < VERSION +download_and_extract() { + cockroach_version=$1 + binary_suffix=$2 + binary_source="https://binaries.cockroachdb.com" + binary_url="${binary_source}/cockroach-${cockroach_version}.${binary_suffix}" -binary_url="${binary_source}/cockroach-$COCKROACH_VERSION.${binary_suffix}" + mkdir -p mnt -mkdir -p mnt + # Check if this is a tarball or zip. + if [[ "${binary_suffix}" == *.tgz ]]; then + curl -sSfL "${binary_url}" > cockroach.tar.gz + tar zxf cockroach.tar.gz -C mnt --strip-components=1 + else + curl -sSfL "${binary_url}" > cockroach.zip + 7z e -omnt cockroach.zip + fi -# Check if this is a tarball or zip. -if [[ "${binary_suffix}" == *.tgz ]]; then - curl -sSfL "${binary_url}" > cockroach.tar.gz - tar zxf cockroach.tar.gz -C mnt --strip-components=1 -else - curl -sSfL "${binary_url}" > cockroach.zip - 7z e -omnt cockroach.zip -fi - -echo "Downloaded ${binary_url}" + echo "Downloaded ${binary_url}" +} diff --git a/build/release/bincheck/test-linux b/build/release/bincheck/test-linux index 4ca41c5e6fdf..1415c83befe3 100755 --- a/build/release/bincheck/test-linux +++ b/build/release/bincheck/test-linux @@ -1,10 +1,18 @@ #!/usr/bin/env bash set -euo pipefail +source ./download_binary.sh -# Download the binary based on the VERSION file. This sets the COCKROACH_VERSION env variable -# and downloads the binary in ./mnt/ -. download_binary.sh "linux-amd64.tgz" +if [[ $# -ne 2 ]] +then + echo "usage: $0 EXPECTED-VERSION EXPECTED-SHA" >&2 + exit 1 +fi + +COCKROACH_VERSION=$1 +COCKROACH_SHA=$2 + +download_and_extract "$COCKROACH_VERSION" "linux-amd64.tgz" ssh() { command ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ diff --git a/build/release/bincheck/test-macos b/build/release/bincheck/test-macos index 4177f9692dd5..a1469ea61c2e 100755 --- a/build/release/bincheck/test-macos +++ b/build/release/bincheck/test-macos @@ -1,9 +1,17 @@ #!/usr/bin/env bash set -euo pipefail +source ./download_binary.sh -# Download the binary based on the VERSION file. This sets the COCKROACH_VERSION env variable -# and downloads the binary in ./mnt/ -. download_binary.sh "darwin-10.9-amd64.tgz" +# Verify arguments. +if [[ $# -ne 2 ]] +then + echo "usage: $0 EXPECTED-VERSION EXPECTED-SHA" >&2 + exit 1 +fi +COCKROACH_VERSION=$1 +COCKROACH_SHA=$2 + +download_and_extract "$COCKROACH_VERSION" "darwin-10.9-amd64.tgz" ./bincheck ./mnt/cockroach "$COCKROACH_VERSION" "$COCKROACH_SHA" diff --git a/build/release/bincheck/test-windows b/build/release/bincheck/test-windows index c74fa4c6ebbd..5a219182c90e 100644 --- a/build/release/bincheck/test-windows +++ b/build/release/bincheck/test-windows @@ -1,9 +1,16 @@ #!/usr/bin/env bash set -euo pipefail +source ./download_binary.sh -# Download the binary based on the VERSION file. This sets the COCKROACH_VERSION env variable -# and downloads the binary in ./mnt/ -. download_binary.sh "windows-6.2-amd64.zip" +if [[ $# -ne 2 ]] +then + echo "usage: $0 EXPECTED-VERSION EXPECTED-SHA" >&2 + exit 1 +fi +COCKROACH_VERSION=$1 +COCKROACH_SHA=$2 + +download_and_extract "$COCKROACH_VERSION" "windows-6.2-amd64.zip" ./bincheck ./mnt/cockroach.exe "$COCKROACH_VERSION" "$COCKROACH_SHA"