Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG committed Sep 12, 2023
1 parent 02e337c commit fcd0333
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 4 deletions.
14 changes: 13 additions & 1 deletion integration-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ LINUX=LINUX
OSX=OSX
WINDOWS=WIN32
OSFLAG :=

.DEFAULT_GOAL := abigen

COMMIT_SHA ?= $(shell git rev-parse HEAD)
VERSION = $(shell cat VERSION)
GO_LDFLAGS := $(shell tools/bin/ldflags)
GOFLAGS = -ldflags "$(GO_LDFLAGS)"

ifeq ($(OS),Windows_NT)
OSFLAG = $(WINDOWS)
else
Expand Down Expand Up @@ -212,4 +220,8 @@ run_test_with_local_image: build_docker_image
SELECTED_NETWORKS="SIMULATED,SIMULATED_1,SIMULATED_2" \
ARGS="$(args)" \
PRODUCT=$(product) \
./scripts/run_product_tests
./scripts/run_product_tests

.PHONY: operator-ui
operator-ui: ## Fetch the frontend
./operator_ui/install.sh
26 changes: 26 additions & 0 deletions integration-tests/operator_ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Operator UI

NOTE: If you're looking for the source of operator UI, it has now been moved to https://github.com/smartcontractkit/operator-ui

This directory instead now as a collection of scripts for maintaining the version of operator UI to pull in when developing and building the chainlink node.

## About

This package is responsible for rendering the UI of the chainlink node, which allows interactions with node jobs, jobs runs, configuration and any other related tasks.

## Installation

### Requirements

The `install.sh` script handles installing the specified tag of operator UI within the [tag file](./TAG). When executed, it downloads then moves the static assets of operator UI into the `core/web/assets` path. Then, when the chainlink binary is built, these assets are included into the build that gets served.

## Updates

### Requirements

- gh cli ^2.15.0 https://github.com/cli/cli/releases/tag/v2.15.0
- jq ^1.6 https://stedolan.github.io/jq/

The `update.sh` script will check for the latest release from the `smartcontractkit/operator-ui` repository, if the latest release is newer than the current tag, it'll update the [tag file](./TAG) with the corresponding latest tag. Checking for updates is automatically [handled by CI](../.github/workflows/operator-ui.yml), where any new detected updates will be pushed to a branch and have a PR opened against `develop`.

See https://docs.github.com/en/rest/releases/releases#get-the-latest-release for how a latest release is determined.
1 change: 1 addition & 0 deletions integration-tests/operator_ui/TAG
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.8.0-91e5ba4
37 changes: 37 additions & 0 deletions integration-tests/operator_ui/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
set -e

# Dependencies:
# gh cli ^2.15.0 https://github.com/cli/cli/releases/tag/v2.15.0
# jq ^1.6 https://stedolan.github.io/jq/

repo=smartcontractkit/operator-ui
gitRoot=$(git rev-parse --show-toplevel)
cd "$gitRoot/operator_ui"

tag_file=TAG
current_tag=$(cat $tag_file)
echo "Currently pinned tag for $repo is $current_tag"

echo "Getting latest release for tag for $repo"
release=$(gh release view -R $repo --json 'tagName,body')
latest_tag=$(echo "$release" | jq -r '.tagName')
body=$(echo "$release" | jq -r '.body')

if [ "$current_tag" = "$latest_tag" ]; then
echo "Tag $current_tag is up to date."
exit 0
else
echo "Tag $current_tag is out of date, updating $tag_file file to latest version..."
echo "$latest_tag" >"$tag_file"
echo "Tag updated $current_tag -> $latest_tag"
if [ "$CI" ]; then
echo "current_tag=$current_tag" >> $GITHUB_OUTPUT
echo "latest_tag=$latest_tag" >> $GITHUB_OUTPUT
# See https://github.com/peter-evans/create-pull-request/blob/main/docs/examples.md#setting-the-pull-request-body-from-a-file
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo "body=$body" >> $GITHUB_OUTPUT
fi
fi
67 changes: 67 additions & 0 deletions integration-tests/operator_ui/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
set -e

owner=smartcontractkit
repo=operator-ui
fullRepo=${owner}/${repo}

ccipPath=$GOPATH/pkg/mod/github.com/smartcontractkit/ccip
ccipV2=$(ls -1 $ccipPath | grep v2 | tail -n 1)

gitRoot=$(git rev-parse --show-toplevel || pwd)
cd "$gitRoot/operator_ui"
unpack_dir="$ccipPath/$ccipV2/core/web/assets"
tag=$(cat TAG)
# Remove the version prefix "v"
strippedTag="${tag:1}"
# Taken from https://github.com/kennyp/asdf-golang/blob/master/lib/helpers.sh
msg() {
echo -e "\033[32m$1\033[39m" >&2
}

err() {
echo -e "\033[31m$1\033[39m" >&2
}

fail() {
err "$1"
exit 1
}

msg "Getting release $tag for $fullRepo"
# https://docs.github.com/en/rest/releases/releases#get-a-release-by-tag-name
asset_name=${owner}-${repo}-${strippedTag}.tgz
download_url=https://github.com/${fullRepo}/releases/download/${tag}/${asset_name}

# Inspired from https://github.com/kennyp/asdf-golang/blob/master/bin/download#L29
msg "Download URL: ${download_url}"
# Check if we're able to download first
http_code=$(curl -LIs -w '%{http_code}' -o /dev/null "$download_url")
if [ "$http_code" -eq 404 ] || [ "$http_code" -eq 403 ]; then
fail "URL: ${download_url} returned status ${http_code}"
fi
# Then go ahead if we get a success code
msg "Downloading ${fullRepo}:${tag} asset: $asset_name..."
msg ""
curl -L -o "$asset_name" "$download_url"

msg "Unpacking asset $asset_name"
tar -xvzf "$asset_name"

msg ""
msg "Removing old contents of $unpack_dir"
rm -rf "$unpack_dir"

if [ ! -d "$unpack_dir" ]
then
echo "$unpack_dir folder path not present, creating $ccipPath/$ccipV2/core/web"
chmod u+rwx $ccipPath/$ccipV2/core/web
mkdir -p $unpack_dir
fi

msg "Copying contents of package/artifacts to $unpack_dir"
cp -rf package/artifacts/. "$unpack_dir" || true

msg "Cleaning up"
rm -r package
rm "$asset_name"
2 changes: 1 addition & 1 deletion integration-tests/scripts/buildTests
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ set -ex
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)

cd "$SCRIPT_DIR"/../../ || exit 1
make operator-ui
cd ./integration-tests
make operator-ui

helm repo update

Expand Down
2 changes: 0 additions & 2 deletions integration-tests/test.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ FROM ${BASE_IMAGE}:${IMAGE_VERSION}
ARG SUITES=chaos migration performance reorg smoke soak benchmark

COPY . testdir/
COPY ../operator_ui testdir/operator_ui
COPY ../tools/bin testdir/tools/bin
WORKDIR /go/testdir
RUN /go/testdir/integration-tests/scripts/buildTests "${SUITES}"
ENTRYPOINT ["/go/testdir/integration-tests/scripts/entrypoint"]
42 changes: 42 additions & 0 deletions integration-tests/tools/bin/build_abigen
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

# Checks that the correct abigen is installed in this directory, and installs it
# if not.

set -e

# Version of abigen to install. Must be run within chainlink project
GETH_VERSION=$(go list -json -m github.com/ethereum/go-ethereum | jq -r .Version)
GETH_REPO_URL="https://github.com/ethereum/go-ethereum"

function realpath { echo $(cd $(dirname $1); pwd)/$(basename $1); }
THIS_DIR="$(realpath "$(dirname $0)")"

NATIVE_ABIGEN_VERSION=v"$(
"$THIS_DIR/abigen" --version 2> /dev/null | \
grep -E -o '([0-9]+\.[0-9]+\.[0-9]+)'
)" || true

if [ "$NATIVE_ABIGEN_VERSION" == "$GETH_VERSION" ]; then
echo "Correct abigen version already installed."
exit 0
fi

function cleanup() {
rm -rf "$TMPDIR"
}

trap cleanup EXIT

TMPDIR="$(mktemp -d)"

pushd "$TMPDIR"

git clone --depth=1 --single-branch --branch "$GETH_VERSION" "$GETH_REPO_URL"
cd go-ethereum/cmd/abigen
go build
rm -f "$THIS_DIR/abigen" # necessary on MacOS for code signing
cp ./abigen "$THIS_DIR"

popd

8 changes: 8 additions & 0 deletions integration-tests/tools/bin/ldflags
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

cd "$(dirname "$0")"

COMMIT_SHA=${COMMIT_SHA:-$(git rev-parse HEAD)}
VERSION=${VERSION:-$(cat "../../VERSION")}

echo "-X github.com/smartcontractkit/chainlink/v2/core/static.Version=$VERSION -X github.com/smartcontractkit/chainlink/v2/core/static.Sha=$COMMIT_SHA"

0 comments on commit fcd0333

Please sign in to comment.