From 246e1006668268669cd048c116d55fd138898770 Mon Sep 17 00:00:00 2001 From: Patrick O'Grady Date: Wed, 20 Sep 2023 15:49:37 -0700 Subject: [PATCH 1/6] test build --- .../workflows/morpheusvm-static-analysis.yml | 7 ++++++- .github/workflows/tokenvm-static-analysis.yml | 13 ++++++++++++- .../tokenvm/cmd/token-wallet/scripts/build.sh | 18 ++++++++++++++++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/.github/workflows/morpheusvm-static-analysis.yml b/.github/workflows/morpheusvm-static-analysis.yml index 0c42970719..1e510d4dba 100644 --- a/.github/workflows/morpheusvm-static-analysis.yml +++ b/.github/workflows/morpheusvm-static-analysis.yml @@ -11,7 +11,8 @@ on: jobs: morpheusvm-lint: - runs-on: ubuntu-latest + runs-on: + labels: ubuntu-20.04-32 timeout-minutes: 10 steps: - name: Checkout @@ -29,6 +30,10 @@ jobs: working-directory: ./examples/morpheusvm shell: bash run: scripts/tests.lint.sh + - name: Build vm, cli + working-directory: ./examples/morpheusvm + shell: bash + run: scripts/build.sh concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} diff --git a/.github/workflows/tokenvm-static-analysis.yml b/.github/workflows/tokenvm-static-analysis.yml index fd00984152..6a7ef6002c 100644 --- a/.github/workflows/tokenvm-static-analysis.yml +++ b/.github/workflows/tokenvm-static-analysis.yml @@ -11,7 +11,8 @@ on: jobs: tokenvm-lint: - runs-on: ubuntu-latest + runs-on: + labels: ubuntu-20.04-32 timeout-minutes: 10 steps: - name: Checkout @@ -29,6 +30,16 @@ jobs: working-directory: ./examples/tokenvm shell: bash run: scripts/tests.lint.sh + - name: Build vm, cli, faucet, feed + working-directory: ./examples/tokenvm + shell: bash + run: scripts/build.sh + - name: Build wallet + working-directory: ./examples/tokenvm/cmd/token-wallet + shell: bash + run: scripts/build.sh + env: + PUBLISH: false concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} diff --git a/examples/tokenvm/cmd/token-wallet/scripts/build.sh b/examples/tokenvm/cmd/token-wallet/scripts/build.sh index 8dd3346f96..a7a32b5508 100755 --- a/examples/tokenvm/cmd/token-wallet/scripts/build.sh +++ b/examples/tokenvm/cmd/token-wallet/scripts/build.sh @@ -6,13 +6,27 @@ set -o errexit set -o nounset set -o pipefail -# Remove any previous build artifacts -rm -rf token-wallet.zip +PUBLISH=${PUBLISH:-true} + +# Install wails +go install -v github.com/wailsapp/wails/v2/cmd/wails@v2.5.1 # Build file for local arch # # Don't use upx: https://github.com/upx/upx/issues/446 wails build -clean -platform darwin/universal + +# Exit early if not publishing +if [ ${PUBLISH} == false ]; then + echo "not publishing app" + exit 0 +fi +echo "publishing app" + +# Remove any previous build artifacts +rm -rf token-wallet.zip + +# Sign code codesign -s ${APP_SIGNING_KEY_ID} --deep --timestamp -o runtime -v build/bin/Token\ Wallet.app ditto -c -k --keepParent build/bin/Token\ Wallet.app token-wallet.zip From 99162603e40f912f2d86676bf58e9b6d6afaa254 Mon Sep 17 00:00:00 2001 From: Patrick O'Grady Date: Wed, 20 Sep 2023 15:56:34 -0700 Subject: [PATCH 2/6] lint on macos --- .github/workflows/tokenvm-static-analysis.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/tokenvm-static-analysis.yml b/.github/workflows/tokenvm-static-analysis.yml index 6a7ef6002c..5ca7d9c9ad 100644 --- a/.github/workflows/tokenvm-static-analysis.yml +++ b/.github/workflows/tokenvm-static-analysis.yml @@ -34,6 +34,21 @@ jobs: working-directory: ./examples/tokenvm shell: bash run: scripts/build.sh + tokenvm-lint-macos: + runs-on: macos-latest + timeout-minutes: 10 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.20" + check-latest: true + cache: true + cache-dependency-path: | + go.sum + examples/tokenvm/go.sum - name: Build wallet working-directory: ./examples/tokenvm/cmd/token-wallet shell: bash From 7430195be78cc671050c3dd6c267fd62761536da Mon Sep 17 00:00:00 2001 From: Patrick O'Grady Date: Wed, 20 Sep 2023 16:02:33 -0700 Subject: [PATCH 3/6] provide correct cgo flags --- examples/tokenvm/cmd/token-wallet/README.md | 2 +- .../tokenvm/cmd/token-wallet/scripts/build.sh | 11 +++++++++++ .../tokenvm/cmd/token-wallet/scripts/dev.sh | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100755 examples/tokenvm/cmd/token-wallet/scripts/dev.sh diff --git a/examples/tokenvm/cmd/token-wallet/README.md b/examples/tokenvm/cmd/token-wallet/README.md index b680768c1d..cb5b5fc245 100644 --- a/examples/tokenvm/cmd/token-wallet/README.md +++ b/examples/tokenvm/cmd/token-wallet/README.md @@ -4,7 +4,7 @@ If you want to override the default configuration, place a `config.json` file at `~/.token-wallet/config.json`. ## Live Development -To run in live development mode, run `wails dev` in the project directory. This will run a Vite development +To run in live development mode, run `./scripts/dev.sh` in the project directory. This will run a Vite development server that will provide very fast hot reload of your frontend changes. If you want to develop in a browser and have access to your Go methods, there is also a dev server that runs on http://localhost:34115. Connect to this in your browser, and you can call your Go code from devtools. diff --git a/examples/tokenvm/cmd/token-wallet/scripts/build.sh b/examples/tokenvm/cmd/token-wallet/scripts/build.sh index a7a32b5508..90e213fed3 100755 --- a/examples/tokenvm/cmd/token-wallet/scripts/build.sh +++ b/examples/tokenvm/cmd/token-wallet/scripts/build.sh @@ -6,6 +6,12 @@ set -o errexit set -o nounset set -o pipefail +# Set the CGO flags to use the portable version of BLST +# +# We use "export" here instead of just setting a bash variable because we need +# to pass this flag to all child processes spawned by the shell. +export CGO_CFLAGS="-O -D__BLST_PORTABLE__" + PUBLISH=${PUBLISH:-true} # Install wails @@ -16,6 +22,11 @@ go install -v github.com/wailsapp/wails/v2/cmd/wails@v2.5.1 # Don't use upx: https://github.com/upx/upx/issues/446 wails build -clean -platform darwin/universal +OUTPUT=build/bin/Token\ Wallet.app +if [ ! -d "$OUTPUT" ]; then + exit 1 +fi + # Exit early if not publishing if [ ${PUBLISH} == false ]; then echo "not publishing app" diff --git a/examples/tokenvm/cmd/token-wallet/scripts/dev.sh b/examples/tokenvm/cmd/token-wallet/scripts/dev.sh new file mode 100755 index 0000000000..9c2f18cb8c --- /dev/null +++ b/examples/tokenvm/cmd/token-wallet/scripts/dev.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Copyright (C) 2023, Ava Labs, Inc. All rights reserved. +# See the file LICENSE for licensing terms. + +set -o errexit +set -o nounset +set -o pipefail + +# Set the CGO flags to use the portable version of BLST +# +# We use "export" here instead of just setting a bash variable because we need +# to pass this flag to all child processes spawned by the shell. +export CGO_CFLAGS="-O -D__BLST_PORTABLE__" + +# Install wails +go install -v github.com/wailsapp/wails/v2/cmd/wails@v2.5.1 + +# Start development environment +wails dev From 5bad336c60576c388b7dd8632c3f163fbb00cd7d Mon Sep 17 00:00:00 2001 From: Patrick O'Grady Date: Wed, 20 Sep 2023 16:19:34 -0700 Subject: [PATCH 4/6] move wallet build to release --- .github/workflows/tokenvm-release.yml | 27 +++++++++++++++++++ .github/workflows/tokenvm-static-analysis.yml | 21 --------------- .../tokenvm/cmd/token-wallet/scripts/build.sh | 7 ++--- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/.github/workflows/tokenvm-release.yml b/.github/workflows/tokenvm-release.yml index 48e0d4864f..d2f21c6b25 100644 --- a/.github/workflows/tokenvm-release.yml +++ b/.github/workflows/tokenvm-release.yml @@ -13,6 +13,33 @@ on: types: [labeled,synchronize,reopened] jobs: + tokenvm-wallet-release: + runs-on: macos-latest-xl + timeout-minutes: 10 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.20" + check-latest: true + cache: true + cache-dependency-path: | + go.sum + examples/tokenvm/go.sum + - name: Build wallet + working-directory: ./examples/tokenvm/cmd/token-wallet + shell: bash + run: scripts/build.sh + env: + PUBLISH: false + - name: Archive Builds + uses: actions/upload-artifact@v3 + with: + name: token-wallet + path: ./examples/tokenvm/cmd/token-wallet/token-wallet.zip + tokenvm-release: # We build with 20.04 to maintain max compatibility: https://github.com/golang/go/issues/57328 runs-on: ubuntu-20.04-32 diff --git a/.github/workflows/tokenvm-static-analysis.yml b/.github/workflows/tokenvm-static-analysis.yml index 5ca7d9c9ad..de4a1b23ea 100644 --- a/.github/workflows/tokenvm-static-analysis.yml +++ b/.github/workflows/tokenvm-static-analysis.yml @@ -34,27 +34,6 @@ jobs: working-directory: ./examples/tokenvm shell: bash run: scripts/build.sh - tokenvm-lint-macos: - runs-on: macos-latest - timeout-minutes: 10 - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: "1.20" - check-latest: true - cache: true - cache-dependency-path: | - go.sum - examples/tokenvm/go.sum - - name: Build wallet - working-directory: ./examples/tokenvm/cmd/token-wallet - shell: bash - run: scripts/build.sh - env: - PUBLISH: false concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} diff --git a/examples/tokenvm/cmd/token-wallet/scripts/build.sh b/examples/tokenvm/cmd/token-wallet/scripts/build.sh index 90e213fed3..20efb16532 100755 --- a/examples/tokenvm/cmd/token-wallet/scripts/build.sh +++ b/examples/tokenvm/cmd/token-wallet/scripts/build.sh @@ -27,16 +27,17 @@ if [ ! -d "$OUTPUT" ]; then exit 1 fi +# Remove any previous build artifacts +rm -rf token-wallet.zip + # Exit early if not publishing if [ ${PUBLISH} == false ]; then echo "not publishing app" + ditto -c -k --keepParent build/bin/Token\ Wallet.app token-wallet.zip exit 0 fi echo "publishing app" -# Remove any previous build artifacts -rm -rf token-wallet.zip - # Sign code codesign -s ${APP_SIGNING_KEY_ID} --deep --timestamp -o runtime -v build/bin/Token\ Wallet.app ditto -c -k --keepParent build/bin/Token\ Wallet.app token-wallet.zip From de4ac508e191154c2f2112ef5f1700120c96c648 Mon Sep 17 00:00:00 2001 From: Patrick O'Grady Date: Wed, 20 Sep 2023 16:26:34 -0700 Subject: [PATCH 5/6] nits --- .github/workflows/tokenvm-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tokenvm-release.yml b/.github/workflows/tokenvm-release.yml index d2f21c6b25..b89e4be2aa 100644 --- a/.github/workflows/tokenvm-release.yml +++ b/.github/workflows/tokenvm-release.yml @@ -15,7 +15,7 @@ on: jobs: tokenvm-wallet-release: runs-on: macos-latest-xl - timeout-minutes: 10 + if: ${{ github.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run release') }} steps: - name: Checkout uses: actions/checkout@v3 @@ -40,7 +40,7 @@ jobs: name: token-wallet path: ./examples/tokenvm/cmd/token-wallet/token-wallet.zip - tokenvm-release: + tokenvm-release: # We build with 20.04 to maintain max compatibility: https://github.com/golang/go/issues/57328 runs-on: ubuntu-20.04-32 if: ${{ github.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run release') }} From 3d4a9b6b3210bf614fe1fc7729ddc05b3d7acdef Mon Sep 17 00:00:00 2001 From: Patrick O'Grady Date: Wed, 20 Sep 2023 16:34:07 -0700 Subject: [PATCH 6/6] naming nits --- .github/workflows/tokenvm-release.yml | 2 +- examples/tokenvm/.goreleaser.yml | 56 +++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tokenvm-release.yml b/.github/workflows/tokenvm-release.yml index b89e4be2aa..4af74372a6 100644 --- a/.github/workflows/tokenvm-release.yml +++ b/.github/workflows/tokenvm-release.yml @@ -13,7 +13,7 @@ on: types: [labeled,synchronize,reopened] jobs: - tokenvm-wallet-release: + token-wallet-release: runs-on: macos-latest-xl if: ${{ github.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run release') }} steps: diff --git a/examples/tokenvm/.goreleaser.yml b/examples/tokenvm/.goreleaser.yml index 283e44447c..21aa157163 100644 --- a/examples/tokenvm/.goreleaser.yml +++ b/examples/tokenvm/.goreleaser.yml @@ -59,6 +59,62 @@ builds: goamd64: v1 env: - CC=o64-clang + - id: token-faucet + main: ./cmd/token-faucet + binary: token-faucet + flags: + - -v + goos: + - linux + - darwin + goarch: + - amd64 + - arm64 + env: + - CGO_ENABLED=1 + - CGO_CFLAGS=-O -D__BLST_PORTABLE__ # Set the CGO flags to use the portable version of BLST + overrides: + - goos: linux + goarch: arm64 + env: + - CC=aarch64-linux-gnu-gcc + - goos: darwin + goarch: arm64 + env: + - CC=oa64-clang + - goos: darwin + goarch: amd64 + goamd64: v1 + env: + - CC=o64-clang + - id: token-feed + main: ./cmd/token-feed + binary: token-feed + flags: + - -v + goos: + - linux + - darwin + goarch: + - amd64 + - arm64 + env: + - CGO_ENABLED=1 + - CGO_CFLAGS=-O -D__BLST_PORTABLE__ # Set the CGO flags to use the portable version of BLST + overrides: + - goos: linux + goarch: arm64 + env: + - CC=aarch64-linux-gnu-gcc + - goos: darwin + goarch: arm64 + env: + - CC=oa64-clang + - goos: darwin + goarch: amd64 + goamd64: v1 + env: + - CC=o64-clang checksum: name_template: "tokenvm_checksums.txt"