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

feat: 在ci中检查生成物结果,运行example测试/check code gen in ci #48

Merged
merged 2 commits into from
Jul 21, 2022
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
16 changes: 10 additions & 6 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,28 @@ jobs:
- name: install tinygo
run: |
wget -q https://github.com/ipfs-force-community/tinygo/releases/download/fvm%400.0.1/tinygo_ubuntu_20.04_linux.tar.gz
sudo tar -xvf tinygo_ubuntu_20.04_linux.tar.gz -C /usr/local
sudo tar -xf tinygo_ubuntu_20.04_linux.tar.gz -C /usr/local
sudo chmod 777 /usr/local/tinygo/bin/*
rm tinygo_ubuntu_20.04_linux.tar.gz

- name: Build
run: |
make build
make install

- name: Lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2
golangci-lint run --timeout 10m
golangci-lint run ./... --timeout 10m

- name: Test
- name: gen-check
run: |
export PATH=$PATH:/usr/local/tinygo/bin
make test
make code-gen
git status --porcelain
test -z "$(git status --porcelain)"

- name: Example
- name: Test
run: |
export PATH=$PATH:/usr/local/tinygo/bin
cargo run -p ci -- example
make test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
target
./bin/*
.idea
.vscode
./tesx
*.log
/bin
27 changes: 15 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
current_dir = $(shell pwd)

build-tool:
build:
ifeq (,$(wildcard ${current_dir}/bin/go-fvm-sdk-tools))
cargo build -p go-fvm-sdk-tools --out-dir ${current_dir}/bin --release -Z unstable-options
cargo build -p go-fvm-sdk-tools --release
endif

build: build-tool

gen:
install:build
cp -f ./target/release/go-fvm-sdk-tools /usr/local/bin

code-gen:
cd ./sdk/gen && go run main.go
cd ./sdk/cases && ./gen.sh
cd ./examples/hellocontract/gen && go run main.go
cd ./examples/hellocontract && go-fvm-sdk-tools build
cd ./examples/erc20/gen && go run main.go
cd ./examples/erc20 && go-fvm-sdk-tools build

clean:
rm -rf ./bin/*

gen-case:
cd ./sdk/cases && ./gen.sh ${current_dir}

test: build gen-case
cd ./sdk/cases && ${current_dir}/bin/go-fvm-sdk-tools test
test: build code-gen
cd ./sdk/cases && go-fvm-sdk-tools test
cd ./examples/hellocontract && go-fvm-sdk-tools test
cd ./examples/erc20 && go-fvm-sdk-tools test
11 changes: 1 addition & 10 deletions examples/hellocontract/contract/helloworld.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,7 @@ func NewState() *State {
func Constructor() error {
// This constant should be part of the SDK.
// var ActorID = 1;

caller, err := sdk.Caller()
if err != nil {
sdk.Abort(ferrors.USR_ILLEGAL_STATE, "unable to get caller")
}

if caller != 1 {
sdk.Abort(ferrors.USR_ILLEGAL_STATE, "constructor invoked by non-init actor")
}
_ = sdk.SaveState(&State{})
_ = sdk.Constructor(&State{})
return nil
}

Expand Down
13 changes: 10 additions & 3 deletions examples/hellocontract/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ module hellocontract
go 1.16

replace (
erc20 => ./
github.com/davecgh/go-spew => github.com/ipfs-force-community/go-spew v1.1.2-0.20220524052205-0034150c051a
github.com/filecoin-project/go-address => github.com/ipfs-force-community/go-address v0.0.7-0.20220524010936-42617a156be1
github.com/filecoin-project/go-state-types => github.com/ipfs-force-community/go-state-types v0.1.8-0.20220523102255-d400d329d9c1
github.com/ipfs-force-community/go-fvm-sdk => ../..
github.com/ipfs/go-block-format => github.com/ipfs-force-community/go-block-format v0.0.4-0.20220425095807-073e9266335c
github.com/klauspost/cpuid/v2 => github.com/ipfs-force-community/cpuid/v2 v2.0.13-0.20220421095210-bfbeb72f34dd
github.com/ipfs/go-ipld-cbor => github.com/ipfs-force-community/go-ipld-cbor v0.0.7-0.20220713070731-f5190aacb1a4
github.com/klauspost/cpuid/v2 => github.com/ipfs-force-community/cpuid/v2 v2.0.13-0.20220523085810-ac111993ce74
github.com/minio/blake2b-simd => github.com/ipfs-force-community/blake2b-simd v0.0.0-20220523083450-6e9a68832d69
github.com/minio/sha256-simd => github.com/ipfs-force-community/sha256-simd v1.0.1-0.20220421100150-fcbba4b6ea96
github.com/polydawn/refmt => github.com/hunjixin/refmt v0.0.0-20220520091210-cb3c7d292019
github.com/stretchr/testify => github.com/ipfs-force-community/testify v1.7.1-0.20220616060316-ea4f53121ac3
github.com/whyrusleeping/cbor-gen => github.com/ipfs-force-community/cbor-gen v0.0.0-20220421100448-dc345220256c
golang.org/x/crypto => github.com/ipfs-force-community/crypto v0.0.0-20220421095836-dd8044371872
hellocontract => ./
golang.org/x/crypto => github.com/ipfs-force-community/crypto v0.0.0-20220523090957-2aff239c26f7
lukechampine.com/blake3 => github.com/ipfs-force-community/blake3 v1.1.8-0.20220609024944-51450f2b2fc0
)

Expand Down
69 changes: 18 additions & 51 deletions examples/hellocontract/go.sum

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions examples/hellocontract/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"accounts": [
{
"priv_key": "6c3b9aa767f785b537c0d8ba5fa54677e6a6e281320dfbb27c889b8fa460670f",
"address": "f1m674sjwmga36qi3wkowt3wozwpahrkdlvd4tpci",
"balance": 10000
},
{
"priv_key": "b10da48cea4c09676b8e0efcd806941465060736032bb898420d0863dca72538",
"address": "f1dwyrbh74hr5nwqv2gjedjyvgphxxkffxug4rkkq",
"balance": 10000
},
{
"priv_key": "c51b8a31c98b9fe13065b485c9f8658c194c430843570ccac2720a3b30b47adb",
"address": "f15o3zaqettjmmarblwzjr66lwddsi6rbtxjwzngq",
"balance": 10000
}
],
"contracts":[
{
"name": "helloworld",
"binary": "hellocontract.wasm",
"constructor": "",
"cases": [

]
}
]
}
Binary file removed sdk/cases/abort.wasm
Binary file not shown.
Binary file removed sdk/cases/debug.wasm
Binary file not shown.
Binary file removed sdk/cases/gas.wasm
Binary file not shown.
4 changes: 1 addition & 3 deletions sdk/cases/gen.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#!/bin/bash

root_dir=$1
echo ${root_dir}
for i in *.go; do
filename=$(echo $i | cut -d . -f1)
target="${filename}.wasm"
${root_dir}/bin/go-fvm-sdk-tools build --output $target --wat -- $i
go-fvm-sdk-tools build --output $target --wat -- $i
echo "Build ${target} successfully"
done
Binary file removed sdk/cases/ipld.wasm
Binary file not shown.
Binary file removed sdk/cases/message.wasm
Binary file not shown.
Binary file removed sdk/cases/network.wasm
Binary file not shown.
Binary file removed sdk/cases/send.wasm
Binary file not shown.
Binary file removed sdk/cases/sself.wasm
Binary file not shown.