Skip to content

Commit

Permalink
Improves CI and allow manual execution (#534)
Browse files Browse the repository at this point in the history
* Testing to split build and rust tests

* check rust tests before release/docker CI

* Better sccache check for CI

* Testing rust tests after build

* Chmod moonbeam executable in CI

* Improves fork test

* Testing concurrent build/test

* Fixes CI yaml

* Fixes sleep time in CI

* Testing more concurrency

* too much concurrency ?

* Testing separating checks

* remove duplicated clippy

* longer fork test

* restore sequential checks

* fixes typo

* fixes ci deps

* Putting rust test before checks

* Adds manual workflow

* Fixes comments
  • Loading branch information
crystalin authored Jun 25, 2021
1 parent dafc21a commit dcc70fb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
34 changes: 15 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ name: Release

# This is only allowing pushes on the moonbeam repo for pull requests.
####### DO NOT CHANGE THIS !! #######
on: ["push"]
on:
push:
workflow_dispatch:

jobs:
####### Check files and formatting #######
Expand Down Expand Up @@ -94,7 +96,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
# Install sccache
- uses: actions/cache@v2
with:
path: ${{ runner.tool_cache }}/cargo-sccache
Expand All @@ -104,29 +105,31 @@ jobs:
# https://github.com/actions-rs/toolchain/issues/126#issuecomment-782989659
- name: Setup Rust toolchain
run: rustup show

- name: Install sccache
- name: SCCache
run: |
if [ ! -f ${{ runner.tool_cache }}/cargo-sccache/bin/sccache ]; then
cargo install sccache --git https://github.com/paritytech/sccache.git --no-default-features --features=dist-client --root ${{ runner.tool_cache }}/cargo-sccache
fi
shell: bash
- name: Start sccache
run: |
chmod +x ${{ runner.tool_cache }}/cargo-sccache/bin/sccache
${{ runner.tool_cache }}/cargo-sccache/bin/sccache --start-server
if [[ -z `pgrep sccache` ]]; then
chmod +x ${{ runner.tool_cache }}/cargo-sccache/bin/sccache
${{ runner.tool_cache }}/cargo-sccache/bin/sccache --start-server
fi
${{ runner.tool_cache }}/cargo-sccache/bin/sccache -s
echo "RUSTC_WRAPPER=${{ runner.tool_cache }}/cargo-sccache/bin/sccache" >> $GITHUB_ENV
- id: get-rust-versions
run: |
echo "::set-output name=rustc::$(rustc --version)"
- name: Build Node
run: cargo build --release --all
- name: Unit tests
run: cargo test --release --all
- name: Format code with rustfmt
run: cargo fmt -- --check

# We determine whether there are unmodified Cargo.lock files by:
# 1. Asking git for a list of all modified files
# 2. Using grep to reduce the list to only Cargo.lock files
# 3. Counting the number of lines of output

- name: Check Cargo Toml
run: |
# Make sure git is working, and if not abort early. When git is not working it looks like:
Expand All @@ -146,13 +149,10 @@ jobs:
echo $DIFF_INDEX | grep Cargo.lock
false
fi
- name: Check with Clippy
run: cargo clippy --release --workspace
- name: Ensure benchmarking compiles
run: cargo check --release --features=runtime-benchmarks
- name: Unit tests
run: cargo test --release --all
- name: Stop sccache
run: |
${{ runner.tool_cache }}/cargo-sccache/bin/sccache --stop-server || true
- name: Save parachain binary
run: |
mkdir -p build
Expand All @@ -162,10 +162,6 @@ jobs:
with:
name: moonbeam
path: build
- name: Check with Clippy
run: cargo clippy --release --workspace
- name: Format code with rustfmt
run: cargo fmt -- --check

typescript-tests:
runs-on: self-hosted
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Rust directories
**/target
**/scripts/tmp
.cargo/

# Typescript directories
**/node_modules
Expand Down
7 changes: 4 additions & 3 deletions tests/tests/test-fork-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ describeDevMoonbeam("Fork", (context) => {
const retractedTx = await context.web3.eth.getTransaction(insertedTx);
expect(retractedTx).to.not.be.null;

// Fork 4 blocks 0-1-2-3-4
// Fork from 0-1-2
// to 0-1b-2b-3b-4b-5b-6b
let parentHash = await context.polkadotApi.rpc.chain.getBlockHash(0);
// Create enough blocks to ensure the TX is re-scheduled and that chain is new best
for (let i = 0; i < 10; i++) {
for (let i = 0; i < 7; i++) {
parentHash = (await context.createBlock({ parentHash, finalize: false })).block.hash;
}
const finalTx = await context.web3.eth.getTransaction(insertedTx);
// The Tx should have been inserted in the new best chain
expect(finalTx.blockNumber).to.be.greaterThan(retractedTx.blockNumber);
expect(finalTx.blockHash).to.not.be.eq(retractedTx.blockHash);
});
});

0 comments on commit dcc70fb

Please sign in to comment.