Skip to content

Commit

Permalink
release: enable bincheck for tag pushes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rail committed Feb 25, 2022
1 parent 763611f commit 9ec3464
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ name: bincheck

on:
push:
branches: [ master, release-* ]
pull_request:
branches: [ master, release-* ]
tags: [ v* ]

jobs:

Expand All @@ -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 }}
22 changes: 5 additions & 17 deletions build/release/bincheck/README.md
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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":**

<img width="550" src="https://user-images.githubusercontent.com/3051672/105749155-0b15e880-5f11-11eb-97a7-308cec768df3.png">

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

Expand Down Expand Up @@ -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
Expand All @@ -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
18 changes: 0 additions & 18 deletions build/release/bincheck/VERSION

This file was deleted.

49 changes: 16 additions & 33 deletions build/release/bincheck/download_binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
14 changes: 11 additions & 3 deletions build/release/bincheck/test-linux
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
14 changes: 11 additions & 3 deletions build/release/bincheck/test-macos
Original file line number Diff line number Diff line change
@@ -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"
13 changes: 10 additions & 3 deletions build/release/bincheck/test-windows
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 9ec3464

Please sign in to comment.