From 80b8084c0415a4636e71a0f4520e18ad3c1dae16 Mon Sep 17 00:00:00 2001 From: Rano | Ranadeep Date: Sat, 20 Apr 2024 07:47:57 -0400 Subject: [PATCH] ci(ibc-clients): upload Tendermint CosmWasm client as workflow artifact (#1173) * tendermint wasm08 client as workflow artifact * rm retention days * lints on comments * conditional retention days * use actions-rust-lang over dtolnay * imp docker run * use cosmwasm/optimizer 0.15.1 * correct mount paths * validate checksum * s/wasm08/cosmwasm * .yaml over .yml * install cargo binary before wasm compile to avoid docker mount permission * fix permissions manually * use id * tendermint over tm * document tendermint cw artifact * grammar --- .github/workflows/upload-cw-clients.yaml | 96 ++++++++++++++++++++++++ ibc-clients/README.md | 8 ++ 2 files changed, 104 insertions(+) create mode 100644 .github/workflows/upload-cw-clients.yaml diff --git a/.github/workflows/upload-cw-clients.yaml b/.github/workflows/upload-cw-clients.yaml new file mode 100644 index 000000000..b67bdf317 --- /dev/null +++ b/.github/workflows/upload-cw-clients.yaml @@ -0,0 +1,96 @@ +name: Upload CosmWasm clients as Github workflow artifact +on: + pull_request: + paths: + - .github/workflows/upload-cw-clients.yaml + - Cargo.toml + - ci/** + - ibc/** + - ibc-core/** + - ibc-apps/** + - ibc-data-types/** + - ibc-clients/** + - ibc-primitives/** + - ibc-query/** + - ibc-testkit/** + - ibc-derive/** + push: + branches: main + paths: + - .github/workflows/upload-cw-clients.yaml + - Cargo.toml + - ci/** + - ibc/** + - ibc-core/** + - ibc-apps/** + - ibc-data-types/** + - ibc-clients/** + - ibc-primitives/** + - ibc-query/** + - ibc-testkit/** + - ibc-derive/** + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + upload-tendermint-cw-client: + name: Compile and upload Tendermint CosmWasm client + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions-rust-lang/setup-rust-toolchain@v1 + + # `cosmwasm/optimizer` requires `Cargo.lock`. but currently, + # `Cargo.lock` is not committed, because `ibc-rs` is treated as library. + - name: Produce `Cargo.lock` file + run: cargo update -p ibc-client-tendermint-cw + + - name: Create mount directories + run: mkdir -p "${HOME}/.cargo/registry" "$(pwd)"/target + + - name: Compile cosmwasm blob for tendermint light client + run: | + docker run \ + -v "$(pwd)":/code \ + -v "$(pwd)"/target:/target \ + -v "${HOME}/.cargo/registry":/usr/local/cargo/registry \ + cosmwasm/optimizer:0.15.1 ./ibc-clients/ics07-tendermint/cw-contract + + - name: Fix permissions + run: | + sudo chown -R $(id -u):$(id -g) "$(pwd)"/target + sudo chown -R $(id -u):$(id -g) "${HOME}/.cargo/registry" + + - name: Install `cosmwasm-check` from crates.io + uses: baptiste0928/cargo-install@v3 + with: + crate: cosmwasm-check + + - name: Check compiled CosmWasm contract + working-directory: artifacts + run: | + sha256sum -c checksums.txt + cosmwasm-check ibc_client_tendermint_cw.wasm + + - name: Upload compiled CosmWasm contract + uses: actions/upload-artifact@v4 + with: + name: tendermint-cw-${{ github.sha }} + path: artifacts/ibc_client_tendermint_cw.wasm + # Retain the artifact for 1 week for PRs and 3 months for `main` branch + retention-days: ${{ github.event_name == 'pull_request' && 7 || 90 }} + overwrite: true + + # # An example workflow to download the artifact: + # download-tendermint-cw-client: + # name: Download pre-compiled Tendermint CosmWasm client + # runs-on: ubuntu-latest + # steps: + # - uses: actions/download-artifact@v4 + # with: + # name: tendermint-cw-${{ env.IBC_RS_COMMIT_HASH }} + # repository: cosmos/ibc-rs + # - run: ls -l ibc_client_tendermint_cw.wasm diff --git a/ibc-clients/README.md b/ibc-clients/README.md index 014ab3248..f65b3c7bd 100644 --- a/ibc-clients/README.md +++ b/ibc-clients/README.md @@ -27,6 +27,14 @@ IBC light clients: - [ibc-client-tendermint](./ics07-tendermint): Implementation - [ibc-client-tendermint-cw](./ics07-tendermint/cw-contract): CosmWasm Contract +> [!TIP] +> The pre-compiled CosmWasm contract for `ibc-client-tendermint-cw` is available +> as Github workflow artifacts at +> [_Actions_](https://github.com/cosmos/ibc-rs/actions/workflows/upload-cw-clients.yaml) +> tab. They can be downloaded +> [during a Github workflow](https://github.com/cosmos/ibc-rs/blob/1098f252c04152812f026520e28e323f3bc0507e/.github/workflows/upload-cw-clients.yaml#L87-L96) +> using `actions/download-artifact@v4` action. + ### ICS-08: WASM Proxy Light Client - [ibc-client-wasm-types](./ics08-wasm/types)