From 2d05591a93d94265a67fc399425a8861b72cbefe Mon Sep 17 00:00:00 2001 From: scorpioborn <97235353+scorpioborn@users.noreply.github.com> Date: Wed, 8 May 2024 14:03:48 +0300 Subject: [PATCH] feat: cross compile wasm ibc compatibility --- .github/workflows/test.yml | 56 ++++++++++++++++++++++++++++---------- Makefile | 20 ++++++++++++++ go.mod | 2 +- go.sum | 4 +-- 4 files changed, 65 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cdcbba2e..5b9fe851 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,24 +27,52 @@ jobs: key: ${{ runner.os }}-go-tparse-binary build: + name: sged-${{ matrix.targetos }}-${{ matrix.arch }} runs-on: ubuntu-latest + strategy: matrix: - go-arch: ["amd64", "arm", "arm64"] + arch: [amd64, arm64] + targetos: [darwin, linux] + include: + - targetos: darwin + arch: arm64 + steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v5 - with: - go-version: 1.22 - - uses: technote-space/get-diff-action@v4 - id: git_diff + - name: Check out repository code + uses: actions/checkout@v4 + - name: Get git diff + uses: technote-space/get-diff-action@v6.1.2 with: PATTERNS: | - **/**.go + **/**.wasm + !tests/** + **/**.go !**/*_test.go go.mod go.sum - - name: Build - run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build + Makefile + .github/workflows/build.yml + - name: 🐿 Setup Golang + uses: actions/setup-go@v5 + if: env.GIT_DIFF + with: + go-version-file: go.mod + env: + GOOS: ${{ matrix.targetos }} + GOARCH: ${{ matrix.arch }} + - name: Download Dependencies + if: env.GIT_DIFF + run: go mod download + - name: Build sged + if: env.GIT_DIFF + run: | + GOWRK=off go build cmd/sged/main.go + - name: Upload sged artifact + if: env.GIT_DIFF + uses: actions/upload-artifact@v3 + with: + name: sged-${{ matrix.targetos }}-${{ matrix.arch }} + path: cmd/sged/sged split-test-files: runs-on: ubuntu-latest @@ -52,7 +80,7 @@ jobs: - uses: actions/setup-go@v5 with: go-version: 1.22 - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Create a file with all the pkgs run: go list ./... > pkgs.txt - name: Split pkgs into 4 files @@ -83,7 +111,7 @@ jobs: matrix: part: ["00", "01", "02", "03"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version: 1.22 @@ -110,7 +138,7 @@ jobs: runs-on: ubuntu-latest needs: tests steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: technote-space/get-diff-action@v4 with: PATTERNS: | @@ -161,7 +189,7 @@ jobs: matrix: part: ["00", "01", "02", "03"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version: 1.22 diff --git a/Makefile b/Makefile index 31e9a316..1d89bef5 100644 --- a/Makefile +++ b/Makefile @@ -132,6 +132,8 @@ $(BUILD_TARGETS): check_version go.sum $(BUILDDIR)/ $(BUILDDIR)/: mkdir -p $(BUILDDIR)/ +build-reproducible: build-reproducible-amd64 build-reproducible-arm64 + build-reproducible-amd64: go.sum mkdir -p $(BUILDDIR) $(DOCKER) buildx create --name sgebuilder --node sgebinary || true @@ -150,6 +152,24 @@ build-reproducible-amd64: go.sum $(DOCKER) cp sgebinary:/bin/sged $(BUILDDIR)/sged-linux-amd64 $(DOCKER) rm -f sgebinary +build-reproducible-arm64: go.sum + mkdir -p $(BUILDDIR) + $(DOCKER) buildx create --name sgebuilder || true + $(DOCKER) buildx use sgebuilder + $(DOCKER) buildx build \ + --build-arg GO_VERSION=$(GO_VERSION) \ + --build-arg GIT_VERSION=$(VERSION) \ + --build-arg GIT_COMMIT=$(COMMIT) \ + --build-arg RUNNER_IMAGE=alpine:3.18 \ + --platform linux/arm64 \ + -t sge:local-arm64 \ + --load \ + -f Dockerfile . + $(DOCKER) rm -f sgebinary || true + $(DOCKER) create -ti --name sgebinary sge:local-arm64 + $(DOCKER) cp sgebinary:/bin/sged $(BUILDDIR)/sged-linux-arm64 + $(DOCKER) rm -f sgebinary + build-linux: go.sum LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build diff --git a/go.mod b/go.mod index 9b006d01..44044b6d 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/cosmos/cosmos-sdk v0.47.8 github.com/cosmos/gogoproto v1.4.10 github.com/cosmos/ibc-apps/modules/ibc-hooks/v7 v7.0.0-20240502201956-e9b46e4bf0ad - github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-0.20231213092633-b306e7a706e1 + github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-ibc-go-v7.3-wasmvm-v1.5 github.com/cosmos/ibc-go/v7 v7.4.0 github.com/golang-jwt/jwt v3.2.2+incompatible github.com/golang-jwt/jwt/v4 v4.5.0 diff --git a/go.sum b/go.sum index 289bc8eb..459ce2ea 100644 --- a/go.sum +++ b/go.sum @@ -473,8 +473,8 @@ github.com/cosmos/iavl v0.20.1 h1:rM1kqeG3/HBT85vsZdoSNsehciqUQPWrR4BYmqE2+zg= github.com/cosmos/iavl v0.20.1/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A= github.com/cosmos/ibc-apps/modules/ibc-hooks/v7 v7.0.0-20240502201956-e9b46e4bf0ad h1:ozJyL/gd3hXYQodS7EESUQgu+1CeJ9nvb9sfHufmsjI= github.com/cosmos/ibc-apps/modules/ibc-hooks/v7 v7.0.0-20240502201956-e9b46e4bf0ad/go.mod h1:JwHFbo1oX/ht4fPpnPvmhZr+dCkYK1Vihw+vZE9umR4= -github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-0.20231213092633-b306e7a706e1 h1:fCtG9qasnNzhgxGR1jM9eBufZ5WQVpy0KdaOpKRfg8Y= -github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-0.20231213092633-b306e7a706e1/go.mod h1:h114vYKBtI5zKBeSyr8y5JZ8ZtpQJInO4TYww2IQr6o= +github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-ibc-go-v7.3-wasmvm-v1.5 h1:sMoHjep+KInjMrppNCEutMVm1p8nI9WhKCuMQ+EcUHw= +github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-ibc-go-v7.3-wasmvm-v1.5/go.mod h1:VR2Hg2i/X1bafbmmNsV2Khwsg0PzNeuWoVKmSN5dAwo= github.com/cosmos/ibc-go/v7 v7.4.0 h1:8FqYMptvksgMvlbN4UW9jFxTXzsPyfAzEZurujXac8M= github.com/cosmos/ibc-go/v7 v7.4.0/go.mod h1:L/KaEhzV5TGUCTfGysVgMBQtl5Dm7hHitfpk+GIeoAo= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM=