Update tanssi master #24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - master | |
| - perm-* | |
| jobs: | |
| set-tags: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image_exists: ${{ steps.check-docker-image.outputs.image_exists }} | |
| git_ref: ${{ steps.check-git-ref.outputs.git_ref }} | |
| sha: ${{ steps.get-sha.outputs.sha }} | |
| sha8: ${{ steps.get-sha.outputs.sha8 }} | |
| latest_rt: ${{ steps.get-sha.outputs.latest_rt }} | |
| latest_rt_sha8: ${{ steps.get-sha.outputs.latest_rt_sha8 }} | |
| steps: | |
| - name: Check git ref | |
| id: check-git-ref | |
| # if PR | |
| # else if manual PR | |
| # else (push) | |
| run: | | |
| if [[ -n "${{ github.event.pull_request.head.sha }}" ]]; then | |
| echo "git_branch=$(echo ${GITHUB_HEAD_REF})" >> $GITHUB_OUTPUT | |
| echo "git_ref=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT | |
| elif [[ -n "${{ github.event.inputs.pull_request }}" ]]; then | |
| echo "git_branch=$(echo ${GITHUB_HEAD_REF})" >> $GITHUB_OUTPUT | |
| echo "git_ref=refs/pull/${{ github.event.inputs.pull_request }}/head" >> $GITHUB_OUTPUT | |
| else | |
| echo "git_branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT | |
| echo "git_ref=$GITHUB_REF" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: ${{ steps.check-git-ref.outputs.git_ref }} | |
| - name: Get Latest RT Release | |
| id: get-latest-rt | |
| run: | | |
| LATEST_RUNTIME_RELEASE=$(curl -s https://api.github.com/repos/moondance-labs/tanssi/releases | jq -r '.[] | select(.name | test("runtime";"i")) | .tag_name' | head -n 1 | tr -d '[:blank:]') && [[ ! -z "${LATEST_RUNTIME_RELEASE}" ]] | |
| echo $LATEST_RUNTIME_RELEASE | |
| echo "latest_rt=$LATEST_RUNTIME_RELEASE" >> $GITHUB_OUTPUT | |
| - name: Get Sha | |
| id: get-sha | |
| run: | | |
| echo "sha=$(git log -1 --format='%H')" >> $GITHUB_OUTPUT | |
| echo "sha8=$(git log -1 --format='%H' | cut -c1-8)" >> $GITHUB_OUTPUT | |
| ENDPOINT="https://api.github.com/repos/moondance-labs/tanssi/git/refs/tags/${{ steps.get-latest-rt.outputs.latest_rt }}" | |
| RESPONSE=$(curl -s -H "Accept: application/vnd.github.v3+json" $ENDPOINT) | |
| TYPE=$(echo $RESPONSE | jq -r '.object.type') | |
| if [[ $TYPE == "commit" ]] | |
| then | |
| LATEST_RT_SHA8=$(echo $RESPONSE | jq -r '.object.sha' | cut -c -8) | |
| elif [[ $TYPE == "tag" ]] | |
| then | |
| URL=$(echo $RESPONSE | jq -r '.object.url') | |
| TAG_RESPONSE=$(curl -s -H "Accept: application/vnd.github.v3+json" $URL) | |
| TAG_RESPONSE_CLEAN=$(echo $TAG_RESPONSE | tr -d '\000-\037') | |
| LATEST_RT_SHA8=$(echo $TAG_RESPONSE_CLEAN | jq -r '.object.sha' | cut -c -8) | |
| fi | |
| echo $LATEST_RT_SHA8 | |
| echo "latest_rt_sha8=$LATEST_RT_SHA8" >> $GITHUB_OUTPUT | |
| - name: Check existing docker image | |
| id: check-docker-image | |
| run: | | |
| TAG=sha-${{ steps.get-sha.outputs.sha8 }} | |
| echo "image_exists=$(docker image inspect moondancelabs/tanssi:$TAG > /dev/null && echo "true" || echo "false")" >> $GITHUB_OUTPUT | |
| - name: Display variables | |
| run: | | |
| echo git_ref: ${{ steps.check-git-ref.outputs.git_ref }} | |
| echo sha: ${{ steps.get-sha.outputs.sha }} | |
| echo sha8: ${{ steps.get-sha.outputs.sha8 }} | |
| echo image_exists: ${{ steps.check-docker-image.outputs.image_exists }} | |
| echo latest_rt: ${{ steps.get-latest-rt.outputs.latest_rt }} | |
| echo latest_rt_sha8: ${{ steps.get-sha.outputs.latest_rt_sha8 }} | |
| ####### Static Analyses ####### | |
| cargo-clippy: | |
| runs-on: ubuntu-latest | |
| needs: ["set-tags"] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: ${{ needs.set-tags.outputs.git_ref }} | |
| - name: Setup Rust toolchain | |
| run: rustup show | |
| - name: Checkout tanssi repo | |
| run: | | |
| cd .. | |
| git clone --depth 1 https://github.com/moondance-labs/tanssi | |
| cd - | |
| - name: Install protoc | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y protobuf-compiler | |
| - name: Clippy | |
| run: | | |
| cd fuzz | |
| SKIP_WASM_BUILD=1 env -u RUSTFLAGS cargo clippy --all-targets --locked --workspace | |
| toml-formatting: | |
| runs-on: ubuntu-latest | |
| needs: ["set-tags"] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: ${{ needs.set-tags.outputs.git_ref }} | |
| - name: Setup Rust toolchain | |
| run: rustup show | |
| - name: Install toml-maid | |
| run: cargo install --locked -f toml-maid | |
| - name: Run toml-maid | |
| run: toml-maid --check | |
| ####### Building and Testing binaries ####### | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: ["set-tags"] | |
| env: | |
| TMP_TARGET: "/tmp/target" | |
| CARGO_TARGET_DIR: "target" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: ${{ needs.set-tags.outputs.git_ref }} | |
| - name: Run sccache-cache | |
| uses: mozilla-actions/[email protected] | |
| - name: Setup Variables | |
| shell: bash | |
| run: | | |
| echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV | |
| echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV | |
| echo "SCCACHE_CACHE_SIZE=100GB" >> $GITHUB_ENV | |
| - name: Setup Rust toolchain | |
| run: rustup show | |
| - name: Checkout tanssi repo | |
| run: | | |
| cd .. | |
| git clone --depth 1 https://github.com/moondance-labs/tanssi | |
| cd - | |
| - name: Formatter | |
| run: cargo fmt --all --check | |
| - name: Install protoc | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y protobuf-compiler | |
| - name: Install cargo-fuzz | |
| # Use custom version from github because the latest release is too old | |
| run: cargo install cargo-fuzz --git https://github.com/rust-fuzz/cargo-fuzz --rev a860fd92bc183f1fed45583aa78691b684e80576 | |
| - name: Build | |
| run: | | |
| cd fuzz | |
| SKIP_WASM_BUILD=1 cargo fuzz build fuzz_raw --build-std | |
| strip target/x86_64-unknown-linux-gnu/release/fuzz_raw | |
| SKIP_WASM_BUILD=1 cargo fuzz build fuzz_flashbox_raw --build-std | |
| strip target/x86_64-unknown-linux-gnu/release/fuzz_flashbox_raw | |
| cd .. | |
| mkdir binaries | |
| mv fuzz/target/x86_64-unknown-linux-gnu/release/fuzz_raw binaries/ | |
| mv fuzz/target/x86_64-unknown-linux-gnu/release/fuzz_flashbox_raw binaries/ | |
| - name: Upload binary | |
| uses: actions/[email protected] | |
| with: | |
| name: binaries | |
| path: binaries | |
| docker-tanssi: | |
| runs-on: ubuntu-latest | |
| needs: ["set-tags", "build"] | |
| strategy: | |
| matrix: | |
| image: ["tanssi", "container-chain-simple-template", "container-chain-evm-template"] | |
| if: ${{ (needs.set-tags.outputs.image_exists == 'false') && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push') }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: ${{ needs.set-tags.outputs.git_ref }} | |
| - uses: actions/[email protected] | |
| with: | |
| name: binaries | |
| path: build | |
| - name: Prepare | |
| id: prep | |
| run: | | |
| DOCKER_IMAGE=moondancelabs/${{matrix.image}} | |
| TAGS="${DOCKER_IMAGE}:sha-${{ needs.set-tags.outputs.sha8 }}" | |
| echo "tags=${TAGS}" >> $GITHUB_OUTPUT | |
| echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
| - name: Set up QEMU | |
| uses: docker/[email protected] | |
| - name: Set up Docker Buildx | |
| uses: docker/[email protected] | |
| with: | |
| version: latest | |
| driver-opts: | | |
| image=moby/buildkit:master | |
| - name: Login to DockerHub | |
| uses: docker/[email protected] | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push | |
| id: docker_build | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| file: ./docker/${{matrix.image}}.Dockerfile | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ steps.prep.outputs.tags }} | |
| labels: | | |
| org.opencontainers.image.title=${{ github.event.repository.name }} | |
| org.opencontainers.image.description=${{ github.event.repository.description }} | |
| org.opencontainers.image.url=${{ github.event.repository.html_url }} | |
| org.opencontainers.image.source=${{ github.event.repository.clone_url }} | |
| org.opencontainers.image.created=${{ steps.prep.outputs.created }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }} |