Skip to content

CI

CI #1535

Workflow file for this run

name: CI
on:
pull_request:
push:
branches:
- master
- perm-*
workflow_dispatch:
inputs:
commit:
description: commit for which we need to run the action
required: false
jobs:
set-tags:
runs-on: ubuntu-latest
outputs:
image_exists: ${{ steps.check-docker-image.outputs.image_exists }}
sha: ${{ steps.get-sha.outputs.sha }}
sha8: ${{ steps.get-sha.outputs.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.commit }}" ]]; then
echo "git_ref=${{ github.event.inputs.commit }}" >> $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@v2
with:
ref: ${{ steps.check-git-ref.outputs.git_ref }}
- 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
- 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 }}
check-copyright:
runs-on: ubuntu-latest
needs: ["set-tags"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- name: Find un-copyrighted files
run: |
find . \! -name '*.expanded.rs' -name '*.rs' -exec grep -H -E -o -c Copyright {} \; | grep ':0' || true
FILECOUNT=$(find . \! -name '*.expanded.rs' -name '*.rs' -exec grep -H -E -o -c Copyright {} \; | grep -c ':0' || true)
if [[ $FILECOUNT -eq 0 ]]; then
true
else
false
fi
####### Building and Testing binaries #######
cargo-clippy:
runs-on: self-hosted
needs: ["set-tags"]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- name: Setup Rust toolchain
run: rustup show
- name: Clippy
run: SKIP_WASM_BUILD=1 env -u RUSTFLAGS cargo clippy --features runtime-benchmarks
build:
runs-on: self-hosted
needs: ["set-tags"]
env:
RUSTFLAGS: "-C opt-level=3 -D warnings"
TMP_TARGET: "/tmp/target"
CARGO_TARGET_DIR: "target"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- name: Setup Rust toolchain
run: rustup show
- name: Formatter
run: cargo fmt --all --check
- name: Build
run: cargo build --features=fast-runtime --release --all
- name: Check runtime benchmarks
run: cargo check --features=runtime-benchmarks --release --all
- name: Test
run: cargo test --release --all
- name: Save runtime wasm
run: |
mkdir -p runtimes
cp $CARGO_TARGET_DIR/release/wbuild/container-chain-template-simple-runtime/container_chain_template_simple_runtime.compact.wasm runtimes/;
cp $CARGO_TARGET_DIR/release/wbuild/container-chain-template-frontier-runtime/container_chain_template_frontier_runtime.compact.wasm runtimes/;
cp $CARGO_TARGET_DIR/release/wbuild/dancebox-runtime/dancebox_runtime.compact.compressed.wasm runtimes/;
- name: Upload runtimes
uses: actions/[email protected]
with:
name: runtimes
path: runtimes
- name: Save tanssi and template binaries
run: |
mkdir -p binaries
cp $CARGO_TARGET_DIR/release/tanssi-node binaries/tanssi-node;
cp $CARGO_TARGET_DIR/release/container-chain-template-simple-node binaries/container-chain-template-simple-node;
cp $CARGO_TARGET_DIR/release/container-chain-template-frontier-node binaries/container-chain-template-frontier-node;
- name: Upload binary
uses: actions/[email protected]
with:
name: binaries
path: binaries
typescript-tests:
runs-on: ubuntu-latest
needs: ["set-tags", "build"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- name: Pnpm
uses: pnpm/action-setup@v2
with:
version: 7
- name: Node
uses: actions/setup-node@v2
with:
node-version: 18.x
cache: "pnpm"
cache-dependency-path: test/pnpm-lock.yaml
- name: "Download binaries"
uses: actions/[email protected]
with:
name: binaries
path: target/release
- name: "Install and run upgrade test"
run: |
chmod uog+x target/release/tanssi-node
cd test
pnpm install --frozen-lockfile
pnpm moonwall test dev_tanssi
typescript-tests-frontier:
runs-on: ubuntu-latest
needs: ["set-tags", "build"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- name: Pnpm
uses: pnpm/action-setup@v2
with:
version: 7
- name: Node
uses: actions/setup-node@v2
with:
node-version: 18.x
cache: "pnpm"
cache-dependency-path: test/pnpm-lock.yaml
- name: "Download binaries"
uses: actions/[email protected]
with:
name: binaries
path: target/release
- name: "Install and run upgrade test"
run: |
chmod uog+x target/release/container-chain-template-frontier-node
cd test
pnpm install --frozen-lockfile
pnpm moonwall test dev_frontier_template
typescript-dancebox-specs:
runs-on: ubuntu-latest
needs: ["set-tags", "build"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- name: Pnpm
uses: pnpm/action-setup@v2
with:
version: 7
- name: Node
uses: actions/setup-node@v2
with:
node-version: 18.x
cache: "pnpm"
cache-dependency-path: test/pnpm-lock.yaml
- name: "Download binaries"
uses: actions/[email protected]
with:
name: binaries
path: target/release
- name: "Install and run upgrade test"
run: |
chmod uog+x target/release/tanssi-node
cd test
pnpm install --frozen-lockfile
pnpm moonwall test dev_dancebox_specs
zombienet-tests:
runs-on: self-hosted
needs: ["set-tags", "build"]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- name: Pnpm
uses: pnpm/action-setup@v2
with:
version: 7
- name: Node
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "pnpm"
cache-dependency-path: test/pnpm-lock.yaml
- name: "Download binaries"
uses: actions/[email protected]
with:
name: binaries
path: target/release
- name: "Run zombie test"
run: |
chmod uog+x target/release/tanssi-node
chmod uog+x target/release/container-chain-template-simple-node
chmod uog+x target/release/container-chain-template-frontier-node
cd test
pnpm install --frozen-lockfile
## Run tests
pnpm moonwall test zombie_tanssi
- name: "Gather zombie logs"
if: failure()
run: |
ls -ltr /tmp
latest_zombie_dir=$(find /tmp -type d -iname "*zombie*" -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" ")
logs_dir="logs"
mkdir -p "$logs_dir"
find "$latest_zombie_dir" -type f -name "*.log" -exec cp {} "$logs_dir" \;
- name: "Upload zombie logs"
if: failure()
uses: actions/[email protected]
with:
name: logs
path: logs
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 == 'workflow_dispatch') }}
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 }}