Skip to content

Commit

Permalink
feat: cross compile wasm ibc compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
scorpioborn committed May 8, 2024
1 parent 9e34176 commit 2d05591
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 17 deletions.
56 changes: 42 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,60 @@ 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/[email protected]
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
steps:
- 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
Expand Down Expand Up @@ -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
Expand All @@ -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: |
Expand Down Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 2d05591

Please sign in to comment.