From a59a597c1d89306eb06d8951d34e1bfce7e9d727 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 12:21:05 -0500 Subject: [PATCH 01/31] Try to speedup dockerfile build time --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b1d1331a642..16c17415c84 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,10 @@ RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd # CosmWasm: copy the right library according to architecture. The final location will be found by the linker flag `-lwasmvm_muslc` RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a -RUN BUILD_TAGS=muslc LINK_STATICALLY=true make build +# build +FROM golang +RUN --mount=type=cache,target=/root/.cache/go-build \ + BUILD_TAGS=muslc LINK_STATICALLY=true make build # -------------------------------------------------------- # Runner From f4e5b98ee227f35eed50d89610e0be28272a0062 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 12:25:09 -0500 Subject: [PATCH 02/31] retry --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 16c17415c84..4f8c4462e62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,7 @@ RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a # build FROM golang + RUN --mount=type=cache,target=/root/.cache/go-build \ BUILD_TAGS=muslc LINK_STATICALLY=true make build From c7916f758a2a3a8463bec5b23fb95187630fc480 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 12:27:09 -0500 Subject: [PATCH 03/31] Remove from tag --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4f8c4462e62..06ead791219 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,7 +26,7 @@ RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a # build -FROM golang +# FROM golang RUN --mount=type=cache,target=/root/.cache/go-build \ BUILD_TAGS=muslc LINK_STATICALLY=true make build From 8860015bfe4c62938454b234af27b894cf340036 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 12:38:16 -0500 Subject: [PATCH 04/31] Reorder cosmwasm steps to be before copying whole directory --- Dockerfile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 06ead791219..0333b9c3e12 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,18 +13,17 @@ RUN apk add git # Needed by github.com/zondax/hid RUN apk add linux-headers -WORKDIR /osmosis -COPY . /osmosis - # CosmWasm: see https://github.com/CosmWasm/wasmvm/releases ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479 - -# CosmWasm: copy the right library according to architecture. The final location will be found by the linker flag `-lwasmvm_muslc` +# Copy the right library according to architecture. The final location will be found by the linker flag `-lwasmvm_muslc` RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a +WORKDIR /osmosis +COPY . /osmosis + # build # FROM golang From 74e1702b77b79548c1bd21edec8fe5728d18583b Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 13:00:34 -0500 Subject: [PATCH 05/31] Try cache --- tests/e2e/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/README.md b/tests/e2e/README.md index d34b339f52b..e0d33cf4f62 100644 --- a/tests/e2e/README.md +++ b/tests/e2e/README.md @@ -39,7 +39,7 @@ Conceptually, we can split the e2e setup into 2 parts: 1. Chain Initialization - The chain can either be initailized off of the current branch, or off the prior mainnet release and then upgraded to the current branch. + The chain can either be initialized off of the current branch, or off the prior mainnet release and then upgraded to the current branch. If current, we run chain initialization off of the current Git branch by calling `chain.Init(...)` method in the `configurer/current.go`. From 918fa37e0307149dd8046852dba9b8117c4c9d56 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 13:08:20 -0500 Subject: [PATCH 06/31] add -v flag to go build --- .github/workflows/test.yml | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a5c412feadb..dd173c46802 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Tests & Code Coverage +name: Tests on: pull_request: diff --git a/Makefile b/Makefile index 58a3f128ee2..b8227535201 100644 --- a/Makefile +++ b/Makefile @@ -245,7 +245,7 @@ benchmark: build-e2e-script: mkdir -p $(BUILDDIR) - go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/ ./tests/e2e/initialization/$(E2E_SCRIPT_NAME) + go build -v -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/ ./tests/e2e/initialization/$(E2E_SCRIPT_NAME) docker-build-debug: @docker build -t osmosis:debug --build-arg BASE_IMG_TAG=debug -f Dockerfile . From c0cfb5c3ac410630d7b3a905c8c8116c475f38c9 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 13:12:01 -0500 Subject: [PATCH 07/31] verbose flag try 2 --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b8227535201..e4b10eb2047 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ BUILD_TARGETS := build install build: BUILD_ARGS=-o $(BUILDDIR)/ $(BUILD_TARGETS): go.sum $(BUILDDIR)/ - go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... + go $@ -v -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... $(BUILDDIR)/: mkdir -p $(BUILDDIR)/ @@ -245,7 +245,7 @@ benchmark: build-e2e-script: mkdir -p $(BUILDDIR) - go build -v -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/ ./tests/e2e/initialization/$(E2E_SCRIPT_NAME) + go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/ ./tests/e2e/initialization/$(E2E_SCRIPT_NAME) docker-build-debug: @docker build -t osmosis:debug --build-arg BASE_IMG_TAG=debug -f Dockerfile . From 67c4b616d63b940f6f69f036d3481be670df2a75 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 13:18:54 -0500 Subject: [PATCH 08/31] Try cache again --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0333b9c3e12..5521af2f1ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,8 @@ COPY . /osmosis # build # FROM golang -RUN --mount=type=cache,target=/root/.cache/go-build \ +RUN --mount=type=cache,target=~/.cache/go-build \ + --mount=type=cache,target=~/go/pkg/mod \ BUILD_TAGS=muslc LINK_STATICALLY=true make build # -------------------------------------------------------- From 8a8c028900a02f73487deb3f61afc055960d54e7 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 13:54:32 -0500 Subject: [PATCH 09/31] try changing Github actions caching --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dd173c46802..2f5bf9c0327 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -100,6 +100,7 @@ jobs: ~/.cache/go-build ~/Library/Caches/go-build ~\AppData\Local\go-build + /tmp/.buildx-cache key: ${{ runner.os }}-go-docker-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go-docker-${{ matrix.go-version }}- @@ -116,9 +117,8 @@ jobs: load: true context: . tags: osmosis:debug - # Use experimental Cache backend API: https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#cache-backend-api - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,src=/tmp/.buildx-cache,mode=max build-args: | BASE_IMG_TAG=debug - From cf6e38e69c483535ffd858033fc9f3e4363ee44c Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 13:55:55 -0500 Subject: [PATCH 10/31] Try cache fixing --- .github/workflows/test.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2f5bf9c0327..00fe4441469 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -117,10 +117,20 @@ jobs: load: true context: . tags: osmosis:debug + # Use experimental Cache backend API: https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#cache-backend-api cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,src=/tmp/.buildx-cache,mode=max + cache-to: type=local,src=/tmp/.buildx-cache-new,mode=max build-args: | BASE_IMG_TAG=debug - name: Test e2e and Upgrade run: make test-e2e + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + - + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache \ No newline at end of file From 28e5ed33c806a56519cbe005965aa520de51bacd Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 14:03:17 -0500 Subject: [PATCH 11/31] Fix cache --- .github/workflows/test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 00fe4441469..8979b1007ce 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -119,13 +119,12 @@ jobs: tags: osmosis:debug # Use experimental Cache backend API: https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#cache-backend-api cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,src=/tmp/.buildx-cache-new,mode=max + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max build-args: | BASE_IMG_TAG=debug - name: Test e2e and Upgrade run: make test-e2e - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - # Temp fix # https://github.com/docker/build-push-action/issues/252 From e176580a052f32068f90dca382b7e5552c6ae75d Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 14:26:03 -0500 Subject: [PATCH 12/31] See if failure was a fluke --- tests/e2e/configurer/chain/node.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/configurer/chain/node.go b/tests/e2e/configurer/chain/node.go index 10b4cc99001..8ec7bad7e60 100644 --- a/tests/e2e/configurer/chain/node.go +++ b/tests/e2e/configurer/chain/node.go @@ -68,7 +68,7 @@ func (n *NodeConfig) Run() error { n.t.Logf("started node container: %s", n.Name) return true }, - 5*time.Minute, + 2*time.Minute, time.Second, "Osmosis node failed to produce blocks", ) From 5424f8b8a6393889766b9f201be8cb6c53714c3e Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 14:26:52 -0500 Subject: [PATCH 13/31] Move-cache to right spot --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8979b1007ce..4e7442adde1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -122,9 +122,6 @@ jobs: cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max build-args: | BASE_IMG_TAG=debug - - - name: Test e2e and Upgrade - run: make test-e2e - # Temp fix # https://github.com/docker/build-push-action/issues/252 @@ -132,4 +129,7 @@ jobs: name: Move cache run: | rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache \ No newline at end of file + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + - + name: Test e2e and Upgrade + run: make test-e2e \ No newline at end of file From 71a31b140bae827eb56db50c2037dcf394f5b255 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 15:00:16 -0500 Subject: [PATCH 14/31] Try using absolute path --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5521af2f1ec..5296d1cdbb5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,8 +27,8 @@ COPY . /osmosis # build # FROM golang -RUN --mount=type=cache,target=~/.cache/go-build \ - --mount=type=cache,target=~/go/pkg/mod \ +RUN --mount=type=cache,target=/root/.cache/go-build \ + --mount=type=cache,target=/root/go/pkg/mod \ BUILD_TAGS=muslc LINK_STATICALLY=true make build # -------------------------------------------------------- From 33417f9a021c2612eeac1bcb862868120e36d160 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 17:46:26 -0500 Subject: [PATCH 15/31] Try the buildkit cache workflow --- .github/workflows/test.yml | 14 ++++++++++++++ Makefile | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e7442adde1..f1a4d041a74 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -110,6 +110,20 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - + name: Enable buildkit cache + uses: actions/cache@v2 + with: + path: /tmp/buildkit-cache/buildkit-state.tar + key: ${{ runner.os }}-buildkit-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildkit- + - name: Load buildkit state from cache + uses: dashevo/gh-action-cache-buildkit-state@v1 + with: + builder: buildx_buildkit_${{ steps.buildx.outputs.name }}0 + cache-path: /tmp/buildkit-cache + cache-max-size: 2g - name: Build e2e image uses: docker/build-push-action@v3 diff --git a/Makefile b/Makefile index e4b10eb2047..55a58bc93ae 100644 --- a/Makefile +++ b/Makefile @@ -248,13 +248,13 @@ build-e2e-script: go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/ ./tests/e2e/initialization/$(E2E_SCRIPT_NAME) docker-build-debug: - @docker build -t osmosis:debug --build-arg BASE_IMG_TAG=debug -f Dockerfile . + @DOCKER_BUILDKIT=1 docker build -t osmosis:debug --build-arg BASE_IMG_TAG=debug -f Dockerfile . docker-build-e2e-init-chain: - @docker build -t osmosis-e2e-init-chain:debug --build-arg E2E_SCRIPT_NAME=chain -f tests/e2e/initialization/init.Dockerfile . + @DOCKER_BUILDKIT=1 docker build -t osmosis-e2e-init-chain:debug --build-arg E2E_SCRIPT_NAME=chain -f tests/e2e/initialization/init.Dockerfile . docker-build-e2e-init-node: - @docker build -t osmosis-e2e-init-node:debug --build-arg E2E_SCRIPT_NAME=node -f tests/e2e/initialization/init.Dockerfile . + @DOCKER_BUILDKIT=1 docker build -t osmosis-e2e-init-node:debug --build-arg E2E_SCRIPT_NAME=node -f tests/e2e/initialization/init.Dockerfile . .PHONY: test-mutation From d6c4dda4b54c0ff0d0005d6b46f5fbe1e358789f Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 18:02:15 -0500 Subject: [PATCH 16/31] tryfix buildkit cache --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f1a4d041a74..0b948f19bf2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -110,6 +110,9 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + with: + install: true + driver-opts: image=moby/buildkit:buildx-stable-1 - name: Enable buildkit cache uses: actions/cache@v2 From 6c7645f53925379654b8332703fcbfaffb7e9922 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 20:06:04 -0500 Subject: [PATCH 17/31] More buildkit tries --- .github/workflows/test.yml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0b948f19bf2..3aec5311f3a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -101,6 +101,7 @@ jobs: ~/Library/Caches/go-build ~\AppData\Local\go-build /tmp/.buildx-cache + /var/lib/docker/buildkit key: ${{ runner.os }}-go-docker-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go-docker-${{ matrix.go-version }}- @@ -113,20 +114,6 @@ jobs: with: install: true driver-opts: image=moby/buildkit:buildx-stable-1 - - - name: Enable buildkit cache - uses: actions/cache@v2 - with: - path: /tmp/buildkit-cache/buildkit-state.tar - key: ${{ runner.os }}-buildkit-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildkit- - - name: Load buildkit state from cache - uses: dashevo/gh-action-cache-buildkit-state@v1 - with: - builder: buildx_buildkit_${{ steps.buildx.outputs.name }}0 - cache-path: /tmp/buildkit-cache - cache-max-size: 2g - name: Build e2e image uses: docker/build-push-action@v3 From 0ec6e0cf013a6623d904a5b1459116c766f567a2 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 20:19:20 -0500 Subject: [PATCH 18/31] Check CI re-run From df16a62edfaef480be99ba097c285faa67feef5b Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 20:22:59 -0500 Subject: [PATCH 19/31] See if this makes cache get found again --- .github/workflows/test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3aec5311f3a..7f08c4dae21 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -111,9 +111,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - with: - install: true - driver-opts: image=moby/buildkit:buildx-stable-1 - name: Build e2e image uses: docker/build-push-action@v3 From d1d2f0d63fe093be49eaa08335205ab5f04a2877 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 21:02:21 -0500 Subject: [PATCH 20/31] Retry --- .github/workflows/test.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7f08c4dae21..89b63ab883a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -59,9 +59,10 @@ jobs: ~/.cache/go-build ~/Library/Caches/go-build ~\AppData\Local\go-build - key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} + key: ${{ runner.os }}-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go-${{ matrix.go-version }}- + ${{ runner.os }}-${{ hashFiles('**/go.sum') }} + ${{ runner.os }}- - name: Run all tests run: make test-unit @@ -119,8 +120,8 @@ jobs: context: . tags: osmosis:debug # Use experimental Cache backend API: https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#cache-backend-api - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + cache-from: type=gha + cache-to: type=gha,mode=max build-args: | BASE_IMG_TAG=debug - From debfa7c855329eaaa8fcceb541a25cdfe3dfaf13 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 21:02:54 -0500 Subject: [PATCH 21/31] retry --- .github/workflows/test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 89b63ab883a..ec55ccedaa0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -103,9 +103,10 @@ jobs: ~\AppData\Local\go-build /tmp/.buildx-cache /var/lib/docker/buildkit - key: ${{ runner.os }}-go-docker-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} + key: ${{ runner.os }}-docker-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go-docker-${{ matrix.go-version }}- + ${{ runner.os }}-docker-${{ hashFiles('**/go.sum') }} + ${{ runner.os }}-docker- - name: Set up QEMU uses: docker/setup-qemu-action@v2 From ecd9dd7c354637d2eda7e84546bb50882bfac652 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 21:07:15 -0500 Subject: [PATCH 22/31] retry --- .github/workflows/test.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ec55ccedaa0..57de3a6e506 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -61,7 +61,6 @@ jobs: ~\AppData\Local\go-build key: ${{ runner.os }}-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-${{ hashFiles('**/go.sum') }} ${{ runner.os }}- - name: Run all tests @@ -105,7 +104,6 @@ jobs: /var/lib/docker/buildkit key: ${{ runner.os }}-docker-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-docker-${{ hashFiles('**/go.sum') }} ${{ runner.os }}-docker- - name: Set up QEMU @@ -125,14 +123,6 @@ jobs: cache-to: type=gha,mode=max build-args: | BASE_IMG_TAG=debug - - - # Temp fix - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - name: Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache - name: Test e2e and Upgrade run: make test-e2e \ No newline at end of file From 0b10041efdc330d49d1ebd22b8855f987d8c6acd Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 22:02:47 -0500 Subject: [PATCH 23/31] revert back to main .github folder --- .github/workflows/test.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 57de3a6e506..a5c412feadb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Tests +name: Tests & Code Coverage on: pull_request: @@ -59,9 +59,9 @@ jobs: ~/.cache/go-build ~/Library/Caches/go-build ~\AppData\Local\go-build - key: ${{ runner.os }}-${{ hashFiles('**/go.sum') }} + key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}- + ${{ runner.os }}-go-${{ matrix.go-version }}- - name: Run all tests run: make test-unit @@ -100,11 +100,9 @@ jobs: ~/.cache/go-build ~/Library/Caches/go-build ~\AppData\Local\go-build - /tmp/.buildx-cache - /var/lib/docker/buildkit - key: ${{ runner.os }}-docker-${{ hashFiles('**/go.sum') }} + key: ${{ runner.os }}-go-docker-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-docker- + ${{ runner.os }}-go-docker-${{ matrix.go-version }}- - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -125,4 +123,4 @@ jobs: BASE_IMG_TAG=debug - name: Test e2e and Upgrade - run: make test-e2e \ No newline at end of file + run: make test-e2e From 8f8df84601083560e843f0bd8fb5e96e3b264110 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 22:03:15 -0500 Subject: [PATCH 24/31] Rename tests CI job --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a5c412feadb..9dacb31283a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Tests & Code Coverage +name: Tests on: pull_request: @@ -29,7 +29,7 @@ jobs: name: Skipping test run: echo Should I skip tests? ${{ steps.skip_check.outputs.should_skip }} - go_test: + go: needs: should_run_go_test if: ${{ needs.should_run_test.outputs.should_skip != 'true' }} runs-on: ubuntu-latest @@ -66,7 +66,7 @@ jobs: name: Run all tests run: make test-unit - e2e_test: + e2e: runs-on: ubuntu-latest timeout-minutes: 25 steps: From 542e379210027b4b59800104b0940b759d27174e Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 22:06:29 -0500 Subject: [PATCH 25/31] Undo -v flag in install --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 55a58bc93ae..316b70dc386 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ BUILD_TARGETS := build install build: BUILD_ARGS=-o $(BUILDDIR)/ $(BUILD_TARGETS): go.sum $(BUILDDIR)/ - go $@ -v -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... + go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... $(BUILDDIR)/: mkdir -p $(BUILDDIR)/ From caeeb4e51da33ab8cf45680aedad46aeaf39a105 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 22:33:48 -0500 Subject: [PATCH 26/31] Add go mod download earlier in build process --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5296d1cdbb5..c48a255f7a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,10 +22,12 @@ RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a WORKDIR /osmosis + +RUN go mod download +# TODO: Document what this is for COPY . /osmosis # build -# FROM golang RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/root/go/pkg/mod \ From 35aa0b76457575c334d102f9c93f8c0c14153dfb Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 22:59:07 -0500 Subject: [PATCH 27/31] Try staging download better --- Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index c48a255f7a8..dfb17fbb7d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,10 +21,12 @@ RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd # Copy the right library according to architecture. The final location will be found by the linker flag `-lwasmvm_muslc` RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a +# Get go dependencies first +COPY go.mod go.lock /osmosis/ WORKDIR /osmosis - RUN go mod download -# TODO: Document what this is for + +# Copy all files into our docker repo COPY . /osmosis # build @@ -39,7 +41,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ FROM gcr.io/distroless/base-debian11:${BASE_IMG_TAG} -COPY --from=build /osmosis/build/osmosisd /bin/osmosisd +COPY --from=build /osmosis-copy/build/osmosisd /bin/osmosisd ENV HOME /osmosis WORKDIR $HOME From 52e5dc672baaba7033fae9483c49b1cd614cc0ce Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 23:00:01 -0500 Subject: [PATCH 28/31] Accidental local change --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index dfb17fbb7d2..81b573ac86b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,7 +41,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ FROM gcr.io/distroless/base-debian11:${BASE_IMG_TAG} -COPY --from=build /osmosis-copy/build/osmosisd /bin/osmosisd +COPY --from=build /osmosis/build/osmosisd /bin/osmosisd ENV HOME /osmosis WORKDIR $HOME From 88c477e607a9bee0be505736a3099d895ac769b6 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 23:01:36 -0500 Subject: [PATCH 29/31] correct filename --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 81b573ac86b..38a57fec02f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,7 @@ RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a # Get go dependencies first -COPY go.mod go.lock /osmosis/ +COPY go.mod go.sum /osmosis/ WORKDIR /osmosis RUN go mod download From 6029639bbf55a70212801c14649d9242f37c24d9 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 23:24:25 -0500 Subject: [PATCH 30/31] Try further layer reduction, use cache in go mod download --- Dockerfile | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 38a57fec02f..e8df0dca488 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,23 +8,26 @@ ARG BASE_IMG_TAG=nonroot FROM golang:1.18.2-alpine3.15 as build -RUN set -eux; apk add --no-cache ca-certificates build-base; -RUN apk add git -# Needed by github.com/zondax/hid -RUN apk add linux-headers +# linux-headers needed by github.com/zondax/hid +RUN set -eux; apk add --no-cache ca-certificates build-base; apk add git linux-headers # CosmWasm: see https://github.com/CosmWasm/wasmvm/releases -ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a -ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a -RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc -RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479 +# 1) Add the releases into /lib/ +ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.aarch64.a \ + https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a \ + /lib/ +# 2) Verify their hashes +RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc; \ + sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479 # Copy the right library according to architecture. The final location will be found by the linker flag `-lwasmvm_muslc` RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a # Get go dependencies first COPY go.mod go.sum /osmosis/ WORKDIR /osmosis -RUN go mod download +RUN --mount=type=cache,target=/root/.cache/go-build \ + --mount=type=cache,target=/root/go/pkg/mod \ + go mod download # Copy all files into our docker repo COPY . /osmosis From 348152472817d55267964169fd014a5cb17fe1aa Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 31 Jul 2022 23:35:06 -0500 Subject: [PATCH 31/31] See speed on cache re-run