Skip to content

Bump version to 2402 #9805

Bump version to 2402

Bump version to 2402 #9805

Workflow file for this run

name: Build
# Using a single file workflow is the preferred solution for our CI over workflow_runs.
# 1. It generates only 1 action item in the list making it more readable
# 2. It includes the PR/Commit text in the action item
# 3. Artifacts are not available between workflows.
on:
pull_request:
push:
branches:
- master
- perm-*
workflow_dispatch:
inputs:
pull_request:
description: set to pull_request number to execute on external pr
required: false
env:
NODE_OPTIONS: "--max-old-space-size=12288"
jobs:
####### Check files and formatting #######
set-tags:
runs-on: ubuntu-latest
outputs:
git_branch: ${{ steps.check-git-ref.outputs.git_branch }}
git_ref: ${{ steps.check-git-ref.outputs.git_ref }}
image_exists: ${{ steps.check-docker-image.outputs.image_exists }}
sha: ${{ steps.get-sha.outputs.sha }}
sha8: ${{ steps.get-sha.outputs.sha8 }}
polkadot_repo: ${{ steps.get-sha.outputs.polkadot_repo }}
polkadot_commit: ${{ steps.get-sha.outputs.polkadot_commit }}
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
- 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/purestake/moonbeam/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
echo "polkadot_repo=$(egrep -o 'https.*/polkadot' Cargo.lock | head -1)" >> $GITHUB_OUTPUT
echo "polkadot_commit=$(egrep -o '/polkadot.*#([^\"]*)' Cargo.lock | \
head -1 | sed 's/.*#//' | cut -c1-8)" >> $GITHUB_OUTPUT
LATEST_RT_SHA8=$(curl -s 'https://api.github.com/repos/purestake/moonbeam/git/refs/tags/${{ steps.get-latest-rt.outputs.latest_rt }}' | jq -r '.object.sha' | cut -c 1-8) && [[ ! -z "${LATEST_RT_SHA8}" ]]
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 manifest inspect purestake/moonbeam:$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 }}
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
check-links:
runs-on: ubuntu-latest
needs: ["set-tags"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: "yes"
check-editorconfig:
name: "Check editorconfig"
runs-on: ubuntu-latest
needs: ["set-tags"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- name: Setup editorconfig checker
run: |
ls /tmp/bin/ec-linux-amd64 || \
cd /tmp && \
wget https://github.com/editorconfig-checker/editorconfig-checker/releases/download/2.5.0/ec-linux-amd64.tar.gz && \
tar xvf ec-linux-amd64.tar.gz && \
chmod +x bin/ec-linux-amd64
- name: Check files
run: /tmp/bin/ec-linux-amd64 --exclude "typescript-api\/src\/moon(?:base|beam|river)\/interfaces\/.*\.ts"
check-prettier:
name: "Check with Prettier"
runs-on: ubuntu-latest
needs: ["set-tags"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Check with Prettier
run: |
npx prettier --check --ignore-path .prettierignore '**/*.(yml|js|ts|json)' \
|| (git diff --quiet \
|| (echo 'Unable to show a diff because there are unstaged changes'; false) \
&& (npx prettier --ignore-path \
.prettierignore '**/*.(yml|js|ts|json)' -w --loglevel silent \
&& git --no-pager diff; git restore .) && false)
npx prettier --check --ignore-path .prettierignore '**/*.(yml|js|ts|json)'
check-cargo-toml-format:
name: "Check Cargo.toml files format"
runs-on:
labels: bare-metal
needs: ["set-tags"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
# With rustup's nice new toml format, we just need to run rustup show to install the toolchain
# https://github.com/actions-rs/toolchain/issues/126#issuecomment-782989659
- name: Setup Rust toolchain
run: rustup show
- name: Check Cargo.toml files format with toml_sort
run: ./scripts/check-cargo-toml-files-format.sh
check-forbid-evm-reentrancy:
name: "Check 'forbid-evm-reentrancy'"
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: Verifies all 'pallet-evm/ethereum' use 'forbid-evm-reentrancy' feature
run: ./scripts/check-forbid-evm-reentrancy.sh
check-rust-fmt:
name: "Check with rustfmt"
runs-on: ubuntu-latest
needs: ["set-tags"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
# With rustup's nice new toml format, we just need to run rustup show to install the toolchain
# https://github.com/actions-rs/toolchain/issues/126#issuecomment-782989659
- name: Setup Rust toolchain
run: rustup show
- name: Format code with rustfmt
run: cargo fmt -- --check
####### Preparing polkadot binary for parachain tests #######
####### For non-official repo, the script will fail if a new version of
####### polkadot needs to be pushed.
####### This job must not be skipped (otherwise the ts-tests are not run)
prepare-polkadot:
runs-on: bare-metal
needs: ["set-tags"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- name: Login to DockerHub
# We should make sure that external PRs can't login to docker,
# but the check to detect if a PR is "external" not work when
# this workflow is trigerred by a push.
if: |
github.event_name == 'push' ||
github.event.pull_request.head.repo.full_name == github.repository
uses: docker/login-action@v2.2.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: index.docker.io
- name: Check & build polkadot docker image
run: |
POLKADOT_REPO=${{ needs.set-tags.outputs.polkadot_repo }}
POLKADOT_COMMIT=${{ needs.set-tags.outputs.polkadot_commit }}
DOCKER_TAG="purestake/moonbase-relay-testnet:sha-$POLKADOT_COMMIT"
POLKADOT_EXISTS=$(docker manifest inspect $DOCKER_TAG > /dev/null && \
echo "true" || echo "false")
if [[ "$POLKADOT_EXISTS" == "false" ]]; then
# $POLKADOT_COMMIT and $POLKADOT_REPO is used to build the relay image
./scripts/build-alphanet-relay-image.sh
docker push $DOCKER_TAG
fi
- name: Check & prepare para-test docker image
run: |
POLKADOT_REPO=${{ needs.set-tags.outputs.polkadot_repo }}
POLKADOT_COMMIT=${{ needs.set-tags.outputs.polkadot_commit }}
DOCKER_TAG="docker.io/purestake/polkadot-para-tests:sha-$POLKADOT_COMMIT"
POLKADOT_EXISTS=$(docker manifest inspect $DOCKER_TAG > /dev/null && \
echo "true" || echo "false")
if [[ "$POLKADOT_EXISTS" == "false" ]]; then
mkdir -p build
MOONBEAM_DOCKER_TAG="docker.io/purestake/moonbase-relay-testnet:sha-$POLKADOT_COMMIT"
# Clear the dummy container if it wasn't properly cleaned up
docker rm -f dummy 2> /dev/null | true
docker create --pull always -ti --name dummy $MOONBEAM_DOCKER_TAG bash
docker cp dummy:/usr/local/bin/polkadot build/polkadot
docker rm -f dummy
docker build . --pull --no-cache -f docker/polkadot-para-tests.Dockerfile \
--network=host \
--build-arg HOST_UID="$UID" \
-t $DOCKER_TAG
docker push $DOCKER_TAG
fi
####### Building and Testing binaries #######
cargo-clippy:
runs-on:
labels: bare-metal
needs: ["set-tags"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- name: Install Protoc
uses: arduino/setup-protoc@v1
- name: Setup Rust toolchain
run: rustup show
- name: Clippy
run: SKIP_WASM_BUILD=1 env -u RUSTFLAGS cargo clippy --features try-runtime,runtime-benchmarks
build:
runs-on:
labels: bare-metal
needs: ["set-tags"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- name: Cargo build
uses: ./.github/workflow-templates/cargo-build
- name: Upload runtimes
uses: actions/upload-artifact@v3.1.2
with:
name: runtimes
path: runtimes
- name: Upload binary
uses: actions/upload-artifact@v3.1.2
with:
name: moonbeam
path: build
build-features:
runs-on:
labels: bare-metal
needs: ["set-tags"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- name: Cargo build
uses: ./.github/workflow-templates/cargo-build
with:
features: "try-runtime,runtime-benchmarks"
- name: Upload binary
uses: actions/upload-artifact@v3.1.2
with:
name: moonbeam-features
path: build
rust-test:
runs-on:
labels: bare-metal
needs: ["set-tags"]
env:
RUSTC_WRAPPER: "sccache"
CARGO_INCREMENTAL: "0"
SCCACHE_CACHE_SIZE: "100GB"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3
- name: Setup Variables
shell: bash
run: |
echo "RUSTFLAGS=-C opt-level=3 -D warnings -C linker=clang -C link-arg=-fuse-ld=$(pwd)/mold/bin/mold" >> $GITHUB_ENV
- name: Setup Mold Linker
shell: bash
run: |
mkdir -p mold
curl -L --retry 10 --silent --show-error https://github.com/rui314/mold/releases/download/v1.1.1/mold-1.1.1-$(uname -m)-linux.tar.gz | tar -C $(realpath mold) --strip-components=1 -xzf -
# With rustup's nice new toml format, we just need to run rustup show to install the toolchain
# https://github.com/actions-rs/toolchain/issues/126#issuecomment-782989659
- name: Setup Rust toolchain
run: |
if ! which "rustup" > /dev/null; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
fi
rustup show
# Checks are run after uploading artifacts since they are modified by the tests
- name: Unit tests
run: |
cargo test --profile testnet --all --features=evm-tracing
- name: Run sccache stat for check pre test
run: ${SCCACHE_PATH} --show-stats
typescript-tests:
runs-on:
labels: bare-metal
needs: ["set-tags", "build", "prepare-polkadot"]
env:
BINARY_PATH: "../build/moonbeam"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- uses: actions/download-artifact@v3.0.2
with:
name: moonbeam
path: build
- name: Typescript Tests (Dev Service)
uses: ./.github/workflow-templates/typescript-tests
with:
moonbeam-binary: build/moonbeam
timeout: 30000
typescript-tracing-tests:
if: github.ref == 'refs/heads/master' || contains(github.event.pull_request.labels.*.name, 'A10-evmtracing')
runs-on:
labels: bare-metal
needs: ["set-tags", "build"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- uses: actions/download-artifact@v3.0.2
with:
name: moonbeam
path: build
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Get tracing runtimes
run: |
./scripts/build-last-tracing-runtime.sh ${{ needs.set-tags.outputs.git_branch }}
mkdir -p tests/moonbase-overrides/
mv build/wasm/moonbase-runtime-local-substitute-tracing.wasm tests/moonbase-overrides/
- name: Typescript tracing tests (against dev service)
env:
BINARY_PATH: ../build/moonbeam
ETHAPI_CMD: --ethapi=txpool,debug,trace
FORCE_WASM_EXECUTION: true
FORCE_COMPILED_WASM: true
WASM_RUNTIME_OVERRIDES: moonbase-overrides
run: |
chmod uog+x build/moonbeam
#### Preparing the repository
cd moonbeam-types-bundle
npm ci
npm run build
#### Preparing the typescript api
cd ../typescript-api
npm ci
cd ../tests
npm ci
#### Prepares and copies the typescript generated API to include in the tests
npm run setup-typescript-api
#### Compile typescript tests into javascript (more stable for Mocha)
#### This also better display typescript issues
npm run build
#### Run tracing tests with mocha
node_modules/.bin/mocha --exit --parallel -j 2 'build/tracing-tests/**/test-*.js'
docker-moonbeam:
runs-on: ubuntu-latest
needs: ["set-tags", "build"]
if: ${{ needs.set-tags.outputs.image_exists }} == false && ${{ github.event.pull_request.head.repo.full_name == github.repository }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- uses: actions/download-artifact@v3.0.2
with:
name: moonbeam
path: build
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=purestake/moonbeam
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/setup-qemu-action@v2.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.5.0
with:
version: latest
driver-opts: |
image=moby/buildkit:master
- name: Login to DockerHub
uses: docker/login-action@v2.2.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push moonbeam
id: docker_build
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/moonbeam.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 }}
test-wasm-upgrade-chopsticks:
runs-on:
labels: bare-metal
needs: ["set-tags", "build"]
strategy:
matrix:
chain: ["moonbase", "moonriver", "moonbeam"]
env:
GH_WORKFLOW_MATRIX_CHAIN: ${{ matrix.chain }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- uses: pnpm/action-setup@v2
with:
version: 7
- uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "pnpm"
cache-dependency-path: test/pnpm-lock.yaml
- name: "Download runtime"
uses: actions/download-artifact@v3.0.2
with:
name: runtimes
path: test/runtimes
- name: "Install and run upgrade test"
run: |
cd test
pnpm i
pnpm moonwall test CI_upgrade_RT_${{matrix.chain}}
zombie_upgrade_test:
runs-on:
labels: bare-metal
needs: ["set-tags", "build", "prepare-polkadot"]
strategy:
matrix:
## TODO: add moonriver here when it is ready
chain: ["moonbase", "moonbeam"]
env:
GH_WORKFLOW_MATRIX_CHAIN: ${{ matrix.chain }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- uses: pnpm/action-setup@v2
with:
version: 7
- uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "pnpm"
cache-dependency-path: test/pnpm-lock.yaml
- name: "Download branch built runtime"
uses: actions/download-artifact@v3.0.2
with:
name: runtimes
path: test/tmp
- name: "Download branch built node"
uses: actions/download-artifact@v3.0.2
with:
name: moonbeam
path: test/tmp
- name: Retrieve polkadot binary from docker
run: |
POLKADOT_COMMIT=${{ needs.set-tags.outputs.polkadot_commit }}
DOCKER_TAG="purestake/moonbase-relay-testnet:sha-$POLKADOT_COMMIT"
docker rm -f dummy 2> /dev/null | true
docker create -ti --name dummy $DOCKER_TAG bash
docker cp dummy:/usr/local/bin/polkadot test/tmp/polkadot
docker rm -f dummy
- name: Retrieve moonbeam binary from docker (for plainSpec generation)
run: |
MOONBEAM_COMMIT=${{ needs.set-tags.outputs.latest_rt_sha8 }}
DOCKER_TAG="purestake/moonbeam:sha-$MOONBEAM_COMMIT"
docker rm -f moonbeam_container 2> /dev/null | true
docker create --name moonbeam_container $DOCKER_TAG bash
docker cp moonbeam_container:moonbeam/moonbeam test/tmp/moonbeam_rt
docker rm -f moonbeam_container
- name: "Run zombie upgrade test"
run: |
cd test
pnpm i
## Generate old spec using latest published node, modify it, and generate raw spec
chmod uog+x tmp/moonbeam_rt
tmp/moonbeam_rt build-spec --chain ${{ matrix.chain }}-local > tmp/${{ matrix.chain }}-plain-spec.json
pnpm ts-node --esm scripts/modify-plain-specs.ts process tmp/${{ matrix.chain }}-plain-spec.json tmp/${{ matrix.chain }}-modified-spec.json
tmp/moonbeam_rt build-spec --chain tmp/${{ matrix.chain }}-modified-spec.json --raw > tmp/${{ matrix.chain }}-raw-spec.json
## Start zombie network and run tests
chmod uog+x tmp/moonbeam
chmod uog+x tmp/polkadot
pnpm moonwall test zombie_${{ matrix.chain }}_ci