From e2a13e855e1a19734d4ff40b4a530238332437ea Mon Sep 17 00:00:00 2001 From: Albert Le Batteux Date: Thu, 22 Aug 2024 18:09:42 +0200 Subject: [PATCH] chore(ci): CI test of portal-loop (#2064)
Contributors' checklist... - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
--- .github/workflows/portal-loop.yml | 60 ++++++++++++++++++++++++++++++- Dockerfile | 58 ++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/.github/workflows/portal-loop.yml b/.github/workflows/portal-loop.yml index 1c83a2854c2..b81957b22db 100644 --- a/.github/workflows/portal-loop.yml +++ b/.github/workflows/portal-loop.yml @@ -1,13 +1,17 @@ name: portal-loop on: + pull_request: + branches: + - master push: paths: - "misc/loop/**" - ".github/workflows/portal-loop.yml" branches: - "master" - - "ops/portal-loop" + # NOTE(albttx): branch name to simplify tests for this workflow + - "ci/portal-loop" tags: - "v*" @@ -46,3 +50,57 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + + test-portal-loop-docker-compose: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: "Setup the images" + run: | + cd misc/loop + + docker compose build + docker compose pull + docker compose up -d + + - name: "Test1 - Portal loop start gnoland" + run: | + while + block_height=$(curl -s localhost:26657/status | jq -r '.result.sync_info.latest_block_height') + echo "Current block height: $block_height" + [[ "$block_height" -lt 10 ]] + do + sleep 1 + done + + curl -s localhost:26657/status | jq + + - name: "Buid new gnolang/gno image" + run: | + docker build -t ghcr.io/gnolang/gno/gnoland:master -f Dockerfile --target gnoland . + + - name: "Wait for new docker image" + run: | + ip_addr=$(cat misc/loop/traefik/gno.yml | grep -o "http://.*:26657") + while + new_ip_addr=$(cat misc/loop/traefik/gno.yml | grep -o "http://.*:26657") + echo "${ip_addr} -> ${new_ip_addr}" + [[ "${ip_addr}" == ${new_ip_addr} ]] + do + sleep 5 + done + + - name: "Test2 - Wait portal-loop start new image" + run: | + while + block_height=$(curl -s localhost:26657/status | jq -r '.result.sync_info.latest_block_height') + echo "Current block height: $block_height" + [[ "$block_height" -lt 10 ]] + do + sleep 5 + done + docker ps -a + curl -s localhost:26657/status | jq diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000000..fa5a9e47270 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,58 @@ +# build gno +FROM golang:1.22-alpine AS build-gno +RUN go env -w GOMODCACHE=/root/.cache/go-build +WORKDIR /gnoroot +ENV GNOROOT="/gnoroot" +COPY . ./ +RUN --mount=type=cache,target=/root/.cache/go-build go mod download +RUN --mount=type=cache,target=/root/.cache/go-build go build -o ./build/gnoland ./gno.land/cmd/gnoland +RUN --mount=type=cache,target=/root/.cache/go-build go build -o ./build/gnokey ./gno.land/cmd/gnokey +RUN --mount=type=cache,target=/root/.cache/go-build go build -o ./build/gnoweb ./gno.land/cmd/gnoweb +RUN --mount=type=cache,target=/root/.cache/go-build go build -o ./build/gno ./gnovm/cmd/gno + +# Base image +FROM alpine:3.17 AS base +WORKDIR /gnoroot +ENV GNOROOT="/gnoroot" +RUN apk add ca-certificates +CMD [ "" ] + +# alpine images +# gnoland +FROM base AS gnoland +COPY --from=build-gno /gnoroot/build/gnoland /usr/bin/gnoland +COPY --from=build-gno /gnoroot/examples /gnoroot/examples +COPY --from=build-gno /gnoroot/gnovm/stdlibs /gnoroot/gnovm/stdlibs +COPY --from=build-gno /gnoroot/gno.land/genesis/genesis_txs.jsonl /gnoroot/gno.land/genesis/genesis_txs.jsonl +COPY --from=build-gno /gnoroot/gno.land/genesis/genesis_balances.txt /gnoroot/gno.land/genesis/genesis_balances.txt +EXPOSE 26656 26657 +ENTRYPOINT ["/usr/bin/gnoland"] + +# gnokey +FROM base AS gnokey +COPY --from=build-gno /gnoroot/build/gnokey /usr/bin/gnokey +# gofmt is required by `gnokey maketx addpkg` +COPY --from=build-gno /usr/local/go/bin/gofmt /usr/bin/gofmt +ENTRYPOINT ["/usr/bin/gnokey"] + +# gno +FROM base AS gno +COPY --from=build-gno /gnoroot/build/gno /usr/bin/gno +ENTRYPOINT ["/usr/bin/gno"] + +# gnoweb +FROM base AS gnoweb +COPY --from=build-gno /gnoroot/build/gnoweb /usr/bin/gnoweb +COPY --from=build-gno /opt/gno/src/gno.land/cmd/gnoweb /opt/gno/src/gnoweb +EXPOSE 8888 +ENTRYPOINT ["/usr/bin/gnoweb"] + +# all, contains everything. +FROM base AS all +COPY --from=build-gno /gnoroot/build/* /usr/bin/ +COPY --from=build-gno /gnoroot/examples /gnoroot/examples +COPY --from=build-gno /gnoroot/gnovm/stdlibs /gnoroot/gnovm/stdlibs +COPY --from=build-gno /gnoroot/gno.land/genesis/genesis_txs.jsonl /gnoroot/gno.land/genesis/genesis_txs.jsonl +COPY --from=build-gno /gnoroot/gno.land/genesis/genesis_balances.txt /gnoroot/gno.land/genesis/genesis_balances.txt +# gofmt is required by `gnokey maketx addpkg` +COPY --from=build-gno /usr/local/go/bin/gofmt /usr/bin