Update polkadot-sdk to stable2409 #90
This file contains 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: 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: | |
- main | |
- 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 }} | |
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 }} | |
polkadot_ver: ${{ steps.get-sha.outputs.polkadot_ver}} | |
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@v4 | |
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 | |
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 | |
echo "polkadot_ver=$(grep 'frame-system' Cargo.toml | sed -nE 's/.*polkadot-v([0-9]+\.[0-9]+\.[0-9]+).*/\1/p' | head -1)" >> $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 polkadot_repo: ${{ steps.get-sha.outputs.polkadot_repo }} | |
echo polkadot_commit: ${{ steps.get-sha.outputs.polkadot_commit }} | |
echo polkadot_ver: ${{ steps.get-sha.outputs.polkadot_ver }} | |
check-copyright: | |
runs-on: ubuntu-latest | |
needs: ["set-tags"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
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@v4 | |
with: | |
ref: ${{ needs.set-tags.outputs.git_ref }} | |
- uses: gaurav-nelson/github-action-markdown-link-check@v1 | |
with: | |
use-quiet-mode: "yes" | |
max-depth: 4 | |
check-rust-fmt: | |
name: "Check with rustfmt" | |
runs-on: ubuntu-latest | |
needs: ["set-tags"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
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 --all --check | |
####### Static Analyses ####### | |
cargo-clippy: | |
runs-on: ubuntu-latest | |
needs: ["set-tags"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.set-tags.outputs.git_ref }} | |
- name: Setup Rust toolchain | |
run: rustup show | |
- name: Find toml files with lints key not set | |
run: ./.github/scripts/check_toml_lints.sh | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
- name: Clippy | |
run: SKIP_WASM_BUILD=1 cargo clippy --all-targets --locked --workspace --features try-runtime,runtime-benchmarks | |
cargo-toml-feature-propagation: | |
runs-on: ubuntu-latest | |
needs: ["set-tags"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.set-tags.outputs.git_ref }} | |
- name: Setup Rust toolchain | |
run: rustup show | |
- name: Install zepter | |
run: cargo install --locked -f zepter --version 1.1.0 | |
- name: Run zepter | |
run: zepter run check | |
toml-formatting: | |
runs-on: ubuntu-latest | |
needs: ["set-tags"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
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: | |
labels: ubuntu-latest | |
needs: ["set-tags"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.set-tags.outputs.git_ref }} | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
- name: Cargo build | |
uses: ./.github/workflow-templates/cargo-build | |
rust-test: | |
runs-on: | |
labels: ubuntu-latest | |
needs: ["set-tags"] | |
env: | |
RUSTC_WRAPPER: "sccache" | |
CARGO_INCREMENTAL: "0" | |
SCCACHE_CACHE_SIZE: "100GB" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.set-tags.outputs.git_ref }} | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
- name: Run sccache-cache | |
uses: mozilla-actions/[email protected] | |
- 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/v2.30.0/mold-2.30.0-$(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 --release --all | |
- name: Run sccache stat for check pre test | |
run: ${SCCACHE_PATH} --show-stats |