Skip to content

Commit

Permalink
build rust with cached deps
Browse files Browse the repository at this point in the history
  • Loading branch information
flipchan committed Nov 18, 2022
1 parent a36c83e commit 1a416fa
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 103 deletions.
7 changes: 0 additions & 7 deletions .github/dependabot.yml

This file was deleted.

137 changes: 137 additions & 0 deletions .github/workflows/build_compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Build and Check


on:
pull_request:
push:
branches:
- master
workflow_dispatch:
inputs:
pull_request:
description: set to pull_request number to execute on external pr
required: false

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 }}

check-cargo-toml-format:
name: "Check Cargo.toml files format"
runs-on: self-hosted
needs: ["set-tags"]
steps:
- name: Checkout
uses: actions/checkout@v2
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-rust-fmt:
name: "Check with rustfmt"
runs-on: ubuntu-latest
needs: ["set-tags"]
steps:
- name: Checkout
uses: actions/checkout@v2
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


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

build:
runs-on: self-hosted
needs: ["set-tags"]
env:
CARGO_SCCACHE_COMMIT: bed5571c
RUSTFLAGS: "-C opt-level=3 -D warnings"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- uses: actions/cache@v2
with:
path: ${{ runner.tool_cache }}/cargo-sccache-${CARGO_SCCACHE_COMMIT}
key: ${{ runner.OS }}-sccache-bin-${{ env.CARGO_SCCACHE_COMMIT }}-v1

# 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: SCCache
run: |
# We altered the path to avoid old actions to overwrite it
SCCACHE_PATH=${{ runner.tool_cache }}/cargo-sccache-${CARGO_SCCACHE_COMMIT}
SCCACHE_BIN=${SCCACHE_PATH}/bin/sccache
if [ ! -f $SCCACHE_BIN ]; then
cargo install sccache --git https://github.com/purestake/sccache.git --rev $CARGO_SCCACHE_COMMIT --force --no-default-features --features=dist-client --root $SCCACHE_PATH
fi
ls -la $SCCACHE_BIN
ps aux | grep sccache
if [[ -z `pgrep sccache` ]]; then
chmod +x $SCCACHE_BIN
$SCCACHE_BIN --start-server
fi
$SCCACHE_BIN -s
echo "RUSTC_WRAPPER=$SCCACHE_BIN" >> $GITHUB_ENV
- name: Build Node
run: |
env
cargo build --release --all
- name: Unit tests
run: |
cargo install cargo-expand
cargo test --release --all
- name: Cargo check
run: cargo check --release
- name: Save binary
run: |
mkdir -p build
cp target/release/substrate build/substrate;
- name: Upload binary
uses: actions/upload-artifact@v2
with:
name: substrate
path: build
- name: Save runtime wasm
run: |
mkdir -p runtimes
cp target/release/wbuild/*/*.compact.compressed.wasm runtimes/;
- name: Upload runtimes
uses: actions/upload-artifact@v2
with:
name: runtimes
path: runtimes


19 changes: 0 additions & 19 deletions .github/workflows/md-link-check.yml

This file was deleted.

7 changes: 0 additions & 7 deletions .github/workflows/mlc_config.json

This file was deleted.

32 changes: 0 additions & 32 deletions .github/workflows/polkadot-companion-labels.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/release-bot.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/trigger-review-pipeline.yml

This file was deleted.

0 comments on commit 1a416fa

Please sign in to comment.