Skip to content

Commit

Permalink
CI Using binaries from EVMC release
Browse files Browse the repository at this point in the history
  • Loading branch information
finiteops committed Feb 23, 2024
1 parent bd50b20 commit df7d3d3
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 507 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ jobs:
EVM_DEPLOYER: ${{ secrets.EVM_DEPLOYER }}
GH_PKG_LOGIN: ${{ secrets.GH_PKG_LOGIN }}
GH_PKG_TOKEN: ${{ secrets.GH_PKG_TOKEN }}
GH_TMP_TOKEN: ${{ secrets.GH_TEMP_RO_TOKEN }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
34 changes: 33 additions & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,34 @@ on:
required: true
GH_PKG_TOKEN:
required: true
GH_TMP_TOKEN:
required: true
SLACK_BOT_TOKEN:
required: true

env:
EVM_DEPLOYER: ${{ secrets.EVM_DEPLOYER }}
GH_API_TOKEN: ${{ secrets.GH_TMP_TOKEN }}

jobs:

prepare:
runs-on: ubuntu-latest
outputs:
gh_api_token: ${{ steps.tokens.outputs.gh_api_token }}

steps:
- id: tokens
run: |
ENCRYPTED=$(echo $GH_API_TOKEN | base64)
#echo "::add-mask::$ENCRYPTED"
echo "gh_api_token=$ENCRYPTED" >> $GITHUB_OUTPUT
#cat "$GITHUB_OUTPUT"
build-test:
needs: ['prepare']
name: "Build and Test"
uses: bitfinity-network/ci-wf/.github/workflows/build-n-test.yml@main
with:
Expand All @@ -54,9 +74,20 @@ jobs:
cargo-clippy-extra-args: "-- -D warnings"
output-artifact: artifact-evm
init-script: |
echo ${{ secrets.GH_TMP_TOKEN }} | wc -cm
echo "Debug count chars"
echo ${{ needs.prepare.outputs.gh_api_token }} | wc -cm
./scripts/build_solidity.sh
artifact-pre-script: |
export ETHEREUM_GENESIS_ACCOUNTS=${{ inputs.ethereum_genesis_accounts }}
export GH_TOKEN=$(echo ${{ needs.prepare.outputs.gh_api_token }} | base64 -d)
echo "Debug count chars"
echo ${{ needs.prepare.outputs.gh_api_token }} | wc -cm
./scripts/evmc-get-release.sh "v0.2.0-2207-g78d7fc4a" "evm-v0.2.0-2207-g78d7fc4a.tar.gz"
./scripts/build.sh
test-script: |
export WASMS_DIR="`pwd`/.artifact"
Expand All @@ -66,4 +97,5 @@ jobs:
disable-cache: ${{ github.event.pull_request.base.ref == 'main' || github.ref_name == 'main' }}
secrets:
gh_token: ${{ secrets.GH_PKG_TOKEN }}
gh_login: ${{ secrets.GH_PKG_LOGIN }}
gh_login: ${{ secrets.GH_PKG_LOGIN }}

6 changes: 0 additions & 6 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,6 @@ build_requested_canisters() {
script_dir=$(dirname $0)
project_dir=$(realpath "${script_dir}/..")

cp "$project_dir/src/integration-tests/evm_testnet.did" "$WASM_DIR/evm_testnet.did"
cp "$project_dir/src/integration-tests/evm_testnet.wasm.gz" "$WASM_DIR/evm_testnet.wasm.gz"

cp "$project_dir/src/integration-tests/signature_verification.did" "$WASM_DIR/signature_verification.did"
cp "$project_dir/src/integration-tests/signature_verification.wasm.gz" "$WASM_DIR/signature_verification.wasm.gz"

build_canister "spender_canister" "export-api" "spender.wasm" "spender"
build_canister "minter_canister" "export-api" "minter.wasm" "minter"
build_canister "evm-minter" "export-api" "evm-minter.wasm" "evm-minter"
Expand Down
62 changes: 62 additions & 0 deletions scripts/evmc-get-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env sh
VERSION="$1"
FILE="$2"

if [ -z "${GH_API_TOKEN}" ]; then
echo "Required GH_API_TOKEN env variable with appropriate GitHub API token"
exit 1
fi

REPO="bitfinity-network/evm-canister"
WASM_DIR=".artifact"

script_dir=$(dirname $0)
assets_dir=$(realpath "${script_dir}/../$WASM_DIR")

if [ -f "$assets_dir/$FILE" ]; then
echo "File aready downloaded $assets_dir/$FILE"
echo "Skip download and unpacking"
exit 0
fi

set -e

mkdir -p "$assets_dir"

assets=$( curl -fL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_API_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$REPO/releases/tags/$VERSION )


# echo "https://api.github.com/repos/$REPO/releases/tags/$VERSION"
echo "$assets"

echo "Release assets acqured"

for row in $(echo "${assets}" | jq -c '.assets[]'); do
name=$( jq -r '.name' <<< "${row}" )
echo ${name}

if [ "$FILE" = "$name" ]; then
asset_id=$( jq -r '.id' <<< "${row}" )

echo "https://api.github.com/repos/$REPO/releases/assets/$asset_id"

curl -L \
-H "Accept: application/octet-stream" \
-H "Authorization: Bearer $GH_API_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/$REPO/releases/assets/$asset_id" \
-o "$assets_dir/$FILE"
fi
done

if [ ! -f "$assets_dir/$FILE" ]; then
echo "Release asset not found: $FILE"
exit 33
fi

cd $assets_dir
tar -xzf "$FILE"
Loading

0 comments on commit df7d3d3

Please sign in to comment.