Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support local tap #60

Merged
merged 6 commits into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions .ci/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# homebrew-eosio
The [homebrew-eosio](https://buildkite.com/EOSIO/homebrew-eosio) pipeline runs on the `master` branch of the [homebrew-eosio](https://github.com/EOSIO/homebrew-eosio) repo to verify that the [EOSIO](https://github.com/EOSIO/eos) packages we are providing via the [Homebrew](https://brew.sh) package manager on macOS are functional.
The [homebrew-eosio](https://buildkite.com/EOSIO/homebrew-eosio) pipeline verifies that [EOSIO](https://github.com/EOSIO/eos) [Homebrew](https://brew.sh) packages for macOS are functional.

<details>
<summary>See More</summary>
Expand All @@ -16,9 +16,15 @@ The [homebrew-eosio](https://buildkite.com/EOSIO/homebrew-eosio) pipeline runs o
This pipeline will parse the [eosio.rb](https://github.com/EOSIO/homebrew-eosio/blob/master/eosio.rb) ruby file in the root of this repo and generate a pipeline step to run a clean Anka VM for each macOS version found. Each step performs the following:
1. Verify the SHA-256 of the bottle attached to the release on GitHub at `root_url` in the ruby file matches the hash defined in the ruby file
1. Tap EOSIO
```bash
brew tap EOSIO/eosio
```
1. On master branch:
```bash
brew tap EOSIO/eosio
```
1. On any non-master branch:
```bash
<configure local tap>
brew tap <local repo>
```
1. Install EOSIO
```bash
brew install eosio
Expand All @@ -27,21 +33,16 @@ This pipeline will parse the [eosio.rb](https://github.com/EOSIO/homebrew-eosio/
```bash
which nodeos
```
1. Invoke the [full-version-label.sh](https://github.com/EOSIO/eos/blob/master/tests/full-version-label.sh) test on that binary
1. Invoke the [full-version-label.sh](https://github.com/EOSIO/eos/blob/master/tests/full-version-label.sh) test on that binary.

All of these must pass for the Buildkite job step to pass.

# Configuration
There are no user-configurable options for this pipeline at this time. The functionality of this pipeline is based entirely on the `eosio.rb` ruby file in the root of [homebrew-eosio](https://github.com/EOSIO/homebrew-eosio) on the `master` branch.
There are no user-configurable options for this pipeline at this time.

## Variables
There are no configurable variables intended for the end-user at this time.

Because this pipeline runs against published release packages, it doesn't make sense to run it on feature branches. If you try, the pipeline fails with a useful error message. We did create a flag to bypass this so engineers can test changes to the CI code on feature branches.
```bash
DEBUG='true|false' # run this pipeline on feature branches, for testing CI changes
```

# See Also
- Buildkite
- [DevDocs](https://github.com/EOSIO/devdocs/wiki/Buildkite)
Expand Down
6 changes: 3 additions & 3 deletions .ci/anka.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- label: ":darwin: macOS ${OS_STYLIZED} - ${LABEL}"
command:
- "git clone --recursive --single-branch --branch '${BUILDKITE_BRANCH}' '${BUILDKITE_REPO}'"
- "./${BUILDKITE_PIPELINE_SLUG}/.ci/test.sh"
command: |
git clone --recursive --single-branch --branch '${BUILDKITE_BRANCH}' '${BUILDKITE_REPO}'
if [[ "${BUILDKITE_BRANCH}" == 'master' ]] ; then ./${BUILDKITE_PIPELINE_SLUG}/.ci/test-prod-tap.sh ; else ./${BUILDKITE_PIPELINE_SLUG}/.ci/test-local-tap.sh ; fi
env:
BIN: "${BIN}"
BOTTLE: "${BOTTLE}"
Expand Down
68 changes: 68 additions & 0 deletions .ci/libfunctions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash

function perform {
echo "$ $1"
eval $1
}

function test_bottle {
echo '+++ :hash: Verify Package Hash - SHA-256'
pushd "$BUILDKITE_PIPELINE_SLUG" # same as repo name
perform "curl -fsSL -o './$BOTTLE' '$ROOT_URL/$BOTTLE'"
FILE_HASH="openssl dgst -sha256 '$BOTTLE'"
echo "$ $FILE_HASH"
BOTTLE_HASH="$(eval $FILE_HASH | tee >(cat - >&9) | awk '{print $2}')"
RUBY_LINE="cat '$RUBY_FILE' | grep 'sha256' | grep '$OS'"
echo "$ $RUBY_LINE"
RUBY_HASH="$(eval $RUBY_LINE | tee >(cat - >&9) | awk '{print $3}' | tr -d '"')"
if [[ "$BOTTLE_HASH" == "$RUBY_HASH" ]]; then
echo "Pass: $BOTTLE_HASH = $RUBY_HASH"
else
echo "+++ :x: Failed to Verify Bottle Hash"
FAIL_MSG="$BOTTLE hash $BOTTLE_HASH ≠ $RUBY_FILE::$OS hash $RUBY_HASH"'!'
echo "FAILURE: $FAIL_MSG"
[[ "$BUILDKITE" == 'true' ]] && echo "**FAILURE:** $FAIL_MSG" | buildkite-agent annotate --style 'error' --context "wrong-hash-$OS"
exit 2
fi
mv $BOTTLE ..
popd
}

function test_binary_exists {
WHICH_BIN="which '$BIN'"
echo "$ $WHICH_BIN"
export BUILD_ROOT="$(eval $WHICH_BIN | tee >(cat - >&9) | sed "s_/bin/${BIN}__g")"
if [[ -z "$BUILD_ROOT" ]]; then
FAIL_MSG="'$BIN' binary not found after homebrew installation on $OS_STYLIZED"'!'
echo "FAILURE: $FAIL_MSG"
[[ "$BUILDKITE" == 'true' ]] && echo "**FAILURE:** $FAIL_MSG" | tr "'" '`' | buildkite-agent annotate --style 'error' --context "no-binary-$OS"
exit 3
else
echo "Found '$BIN' at \"$BUILD_ROOT/bin/$BIN\"."
fi
}

function test_full_version_matches {
echo "Using git tag '$REPO_UNDER_TEST:$GIT_TAG'."
perform "git clone --quiet --recursive --single-branch --branch '${GIT_TAG}' '${REPO_UNDER_TEST}' > /dev/null"
pushd $(echo ${REPO_UNDER_TEST} | sed 's/.*\/\(.*\)\.git/\1/')

export BUILDKITE_COMMIT="$(git rev-parse HEAD)" # override homebrew-eosio commit with eos tag commit
echo "Found git commit '$REPO_UNDER_TEST:$BUILDKITE_COMMIT'."
unset BUILDKITE_TAG
export CMAKE_SOURCE_DIR="$(pwd)"
echo "Set CMAKE_SOURCE_DIR to \"$CMAKE_SOURCE_DIR\"."
TEST="./tests/full-version-label.sh '$GIT_TAG'"
echo "$ $TEST"
set +e
eval $TEST
EXIT_STATUS="$?"
set -e
if [[ "$EXIT_STATUS" != '0' ]]; then
FAIL_MSG="Version label test failed on $OS_STYLIZED"'!'
echo "FAILURE: $FAIL_MSG"
[[ "$BUILDKITE" == 'true' ]] && echo "**FAILURE:** $FAIL_MSG" | buildkite-agent annotate --style 'error' --context "test-failure-$OS"
exit "$EXIT_STATUS"
fi
popd
}
11 changes: 0 additions & 11 deletions .ci/pipeline-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ if [[ "$BUILDKITE" == 'true' && "$RETRY" == '0' ]]; then
elif [[ "$BUILDKITE" == 'true' ]]; then
printf "Skipping \033]1339;url=$DOCS_URL;content=documentation\a upload for job retry number $RETRY.\n" >&2
fi
# only run on master
if [[ "$BUILDKITE_BRANCH" != 'master' && "$DEBUG" != 'true' ]]; then
ERROR_MSG='This pipeline currently does nothing on branches besides `master`!'
echo "ERROR: $ERROR_MSG" | tr -d '`' | cat >&2
[[ "$BUILDKITE" == 'true' && "$RETRY" == '0' ]] && echo "**ERROR:** $ERROR_MSG" | buildkite-agent annotate --style 'error' --context 'not-master'
exit 1
elif [[ "$DEBUG" == 'true' ]]; then
WARNING_MSG='Running on non-`master` branch because `DEBUG` is set to "true".'
echo "WARNING: $WARNING_MSG" | tr -d '`' | cat >&2
[[ "$BUILDKITE" == 'true' && "$RETRY" == '0' ]] && echo "**WARNING:** $WARNING_MSG" | tr '"' '`' | buildkite-agent annotate --style 'warning' --context 'not-master'
fi
echo '+++ :yaml: Generating Pipeline Steps' >&2
# yaml header
cat <<EOF
Expand Down
20 changes: 20 additions & 0 deletions .ci/test-local-tap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -eo pipefail

. "${0%/*}/libfunctions.sh"

echo '--- :evergreen_tree: Configuring Environment'
exec 9>&1 # enable tee to write to STDOUT as a file
[[ -n "$BOTTLE" ]] && test_bottle

echo '+++ :beer: Homebrew Tap and Install'
perform 'brew update'
perform "brew tap eosio/eosio ${BUILDKITE_PIPELINE_SLUG}"
perform "brew install '$PACKAGE'"

echo '+++ :label: Full Version Label Test'
test_binary_exists
test_full_version_matches

echo '--- :white_check_mark: Done!'
echo 'Done.'
19 changes: 19 additions & 0 deletions .ci/test-prod-tap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -eo pipefail
. "${0%/*}/libfunctions.sh"

echo '--- :evergreen_tree: Configuring Environment'
exec 9>&1 # enable tee to write to STDOUT as a file
[[ -n "$BOTTLE" ]] && test_bottle
kj4ezj marked this conversation as resolved.
Show resolved Hide resolved

echo '+++ :beer: Homebrew Tap and Install'
perform 'brew update'
perform "brew tap '$TAP'"
perform "brew install '$PACKAGE'"

echo '+++ :label: Full Version Label Test'
test_binary_exists
test_full_version_matches

echo '--- :white_check_mark: Done!'
echo 'Done.'
73 changes: 0 additions & 73 deletions .ci/test.sh

This file was deleted.