Skip to content

Commit

Permalink
- test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
iulianpascalau committed Aug 30, 2024
1 parent f6f0fed commit e84bf05
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 155 deletions.
201 changes: 49 additions & 152 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,157 +14,54 @@ permissions:
jobs:
build:
runs-on: ubuntu-latest
container:
image: compile.Dockerfile
volumes:
- multiversx:/multiversx
steps:
- name: list files
- name: Create artifacts files
run: |
cd ${GITHUB_WORKSPACE}/multiversx
ls
#
# build:
# strategy:
# matrix:
# runs-on: [ubuntu-latest]
# runs-on: ${{ matrix.runs-on }}
# name: Build
# steps:
# - name: builder
#
#
#
#
# - name: Get dependencies
# run: |
# go get -v -t -d ./...
# if [ -f Gopkg.toml ]; then
# curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
# dep ensure
# fi
#
# # https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
# - name: Set environment variables
# run: |
# APP_VER_SHORT=$(git describe --tags)
# GOOS=$(go env GOOS)
# GOARCH=$(go env GOARCH)
# GOPATH=$(go env GOPATH)
# ARCHIVE="multiversx_""$APP_VER_SHORT""_""$GOOS""_""$GOARCH"".zip"
# BUILD_DIR=${GITHUB_WORKSPACE}/build
# VM_GO_VERSION=$(cat go.mod | grep mx-chain-vm-go | sort -n | tail -n -1| awk -F '/' '{print$3}'| sed 's/ /@/g')
# VM_GO_DIR=${GOPATH}/pkg/mod/github.com/multiversx/${VM_GO_VERSION}
#
# echo "GOOS=${GOOS}" >> $GITHUB_ENV
# echo "GOARCH=${GOARCH}" >> $GITHUB_ENV
# echo "ARCHIVE=${ARCHIVE}" >> $GITHUB_ENV
# echo "BUILD_DIR=${BUILD_DIR}" >> $GITHUB_ENV
# echo "VM_GO_VERSION=${VM_GO_VERSION}" >> $GITHUB_ENV
# echo "VM_GO_DIR=${VM_GO_DIR}" >> $GITHUB_ENV
#
# - name: Build
# run: |
# mkdir -p ${BUILD_DIR}
# cd ${GITHUB_WORKSPACE}/cmd/node && go build -o "${BUILD_DIR}/node" -a -ldflags="-X main.appVersion=${APP_VER}"
# cd ${GITHUB_WORKSPACE}/cmd/seednode && go build -o "${BUILD_DIR}/seednode" -a -ldflags="-X main.appVersion=${APP_VER}"
# cd ${GITHUB_WORKSPACE}/cmd/keygenerator && go build -o "${BUILD_DIR}/keygenerator" -a -ldflags="-X main.appVersion=${APP_VER}"
# cd ${GITHUB_WORKSPACE}/cmd/logviewer && go build -o "${BUILD_DIR}/logviewer" -a -ldflags="-X main.appVersion=${APP_VER}"
# cd ${GITHUB_WORKSPACE}/cmd/termui && go build -o "${BUILD_DIR}/termui" -a -ldflags="-X main.appVersion=${APP_VER}"
#
# - name: Package
# run: |
# cd ${GITHUB_WORKSPACE}
#
# if [[ "$GOOS" == linux && "$GOARCH" == amd64 ]]; then
# cp --verbose --no-preserve=mode,ownership ${VM_GO_DIR}/wasmer2/libvmexeccapi.so ${BUILD_DIR}/libvmexeccapi.so
# cp --verbose --no-preserve=mode,ownership ${VM_GO_DIR}/wasmer/libwasmer_linux_amd64.so ${BUILD_DIR}/libwasmer_linux_amd64.so
# fi
#
# # Actually, there's no runner for this combination (as of March 2024).
# if [[ "$GOOS" == linux && "$GOARCH" == arm64 ]]; then
# cp --verbose --no-preserve=mode,ownership ${VM_GO_DIR}/wasmer2/libvmexeccapi_arm.so ${BUILD_DIR}/libvmexeccapi_arm.so
# cp --verbose --no-preserve=mode,ownership ${VM_GO_DIR}/wasmer/libwasmer_linux_arm64_shim.so ${BUILD_DIR}/libwasmer_linux_arm64_shim.so
# fi
#
# if [[ "$GOOS" == darwin && "$GOARCH" == amd64 ]]; then
# cp -v ${VM_GO_DIR}/wasmer2/libvmexeccapi.dylib ${BUILD_DIR}/libvmexeccapi.dylib
# cp -v ${VM_GO_DIR}/wasmer/libwasmer_darwin_amd64.dylib ${BUILD_DIR}/libwasmer_darwin_amd64.dylib
# fi
#
# if [[ "$GOOS" == darwin && "$GOARCH" == arm64 ]]; then
# cp -v ${VM_GO_DIR}/wasmer2/libvmexeccapi_arm.dylib ${BUILD_DIR}/libvmexeccapi_arm.dylib
# cp -v ${VM_GO_DIR}/wasmer/libwasmer_darwin_arm64_shim.dylib ${BUILD_DIR}/libwasmer_darwin_arm64_shim.dylib
# fi
#
# if [[ "$GOOS" == linux ]]; then
# patchelf --set-rpath "\$ORIGIN" ${BUILD_DIR}/node
# patchelf --set-rpath "\$ORIGIN" ${BUILD_DIR}/seednode
#
# ldd ${BUILD_DIR}/node
# ldd ${BUILD_DIR}/seednode
# fi
#
# if [[ "$GOOS" == darwin ]]; then
# install_name_tool -add_rpath "@loader_path" ${BUILD_DIR}/node
# install_name_tool -add_rpath "@loader_path" ${BUILD_DIR}/seednode
#
# otool -L ${BUILD_DIR}/node
# otool -L ${BUILD_DIR}/seednode
# fi
#
# - name: Smoke test
# run: |
# # Remove all downloaded Go packages, so that we can test the binary's independence from them (think of Wasmer libraries).
# sudo rm -rf ${GOPATH}/pkg/mod
#
# # Test binaries in different current directories.
# cd ${BUILD_DIR} && ./node --version
# cd ${GITHUB_WORKSPACE} && ${BUILD_DIR}/node --version
# cd / && ${BUILD_DIR}/node --version
#
# cd ${BUILD_DIR} && ./seednode --version
# cd ${GITHUB_WORKSPACE} && ${BUILD_DIR}/seednode --version
# cd / && ${BUILD_DIR}/seednode --version
#
# - name: Package build output
# run: |
# sudo chown -R $USER: ${BUILD_DIR}
# chmod -R 755 ${BUILD_DIR}
# ls -al ${BUILD_DIR}
# zip -r -j ${ARCHIVE} ${BUILD_DIR}
#
# - name: Save artifacts
# uses: actions/upload-artifact@v3
# with:
# name: ${{ env.ARCHIVE }}
# path: ${{ env.ARCHIVE }}
# if-no-files-found: error
#
# release:
# needs: [build]
# runs-on: ubuntu-latest
# steps:
# - name: Check out code
# uses: actions/checkout@v2
#
# # https://docs.github.com/en/free-pro-team@latest/actions/guides/storing-workflow-data-as-artifacts#downloading-or-deleting-artifacts
# # A directory for each artifact is created using its name
# - name: Download all workflow run artifacts
# uses: actions/download-artifact@v2
# with:
# path: assets
#
# - name: Display structure of downloaded files
# run: ls -R
# working-directory: assets
#
# - name: Create release
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# gh release create --draft --notes="Release draft from Github Actions" vNext
# sleep 10
# for i in $(find ./assets -name '*.zip' -type f); do
# gh release upload vNext ${i}
# done
docker compose -f docker-compose.yml build
docker compose -f docker-compose.yml up
docker compose -f docker-compose.yml down -v
- name: Package build output
run: |
BUILD_DIR=${GITHUB_WORKSPACE}/artifacts
APP_VER_SHORT=$(git describe --tags)
ARCHIVE="artifacts_""$APP_VER_SHORT"".zip"
sudo chown -R $USER: ${BUILD_DIR}
chmod -R 755 ${BUILD_DIR}
ls -al ${BUILD_DIR}
zip -r -j ${ARCHIVE} ${BUILD_DIR}
- name: Save artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARCHIVE }}
path: ${{ env.ARCHIVE }}
if-no-files-found: error
release:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2

# https://docs.github.com/en/free-pro-team@latest/actions/guides/storing-workflow-data-as-artifacts#downloading-or-deleting-artifacts
# A directory for each artifact is created using its name
- name: Download all workflow run artifacts
uses: actions/download-artifact@v2
with:
path: ${GITHUB_WORKSPACE}

- name: Display structure of downloaded files
run: ls -R
working-directory: ${GITHUB_WORKSPACE}

- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create --draft --notes="Release draft from Github Actions" vNext
sleep 10
for i in $(find ./assets -name '*.zip' -type f); do
gh release upload vNext ${i}
done
7 changes: 4 additions & 3 deletions compile.Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@ RUN jq -r '.abi' artifacts/contracts/MintBurnERC20.sol/MintBurnERC20.json > arti

RUN jq -r '.bytecode' artifacts/contracts/Bridge.sol/Bridge.json > artifacts/contracts/Bridge.sol/Bridge.hex
RUN jq -r '.bytecode' artifacts/contracts/Proxy.sol/Proxy.json > artifacts/contracts/Proxy.sol/Proxy.hex
RUN jq -r '.byt`ecode' artifacts/contracts/ERC20Safe.sol/ERC20Safe.json > artifacts/contracts/ERC20Safe.sol/ERC20Safe.hex
RUN jq -r '.bytecode' artifacts/contracts/ERC20Safe.sol/ERC20Safe.json > artifacts/contracts/ERC20Safe.sol/ERC20Safe.hex
RUN jq -r '.bytecode' artifacts/contracts/GenericERC20.sol/GenericERC20.json > artifacts/contracts/GenericERC20.sol/GenericERC20.hex
RUN jq -r '.bytecode' artifacts/contracts/MintBurnERC20.sol/MintBurnERC20.json > artifacts/contracts/MintBurnERC20.sol/MintBurnERC20.hex

FROM golang:1.20.7-bookworm AS go-builder
LABEL description="This Docker image creates the go-wrappers for the Solidity contracts"

RUN apt update && apt install -y zip unzip
RUN go install github.com/ethereum/go-ethereum/cmd/[email protected]

COPY --from=sol-compiler /multiversx /multiversx
WORKDIR /multiversx

RUN go install github.com/ethereum/go-ethereum/cmd/[email protected]

RUN abigen --abi=artifacts/contracts/Bridge.sol/Bridge.abi.json --pkg=contract --out=artifacts/contracts/Bridge.sol/Bridge.go --type=Bridge
RUN abigen --abi=artifacts/contracts/Proxy.sol/Proxy.abi.json --pkg=contract --out=artifacts/contracts/Proxy.sol/Proxy.go --type=Proxy
RUN abigen --abi=artifacts/contracts/ERC20Safe.sol/ERC20Safe.abi.json --pkg=contract --out=artifacts/contracts/ERC20Safe.sol/ERC20Safe.go --type=ERC20Safe
Expand Down
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
artifacts-builder:
build: .
volumes:
- ./artifacts:/multiversx/artifacts_volume
entrypoint: /bin/sh -c "cp -r /multiversx/artifacts/* /multiversx/artifacts_volume"

0 comments on commit e84bf05

Please sign in to comment.