mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-09 12:29:27 +00:00
set up CI (#45)
* begin to setup ci * attempt to fix build * fix paths in build script * fix * satisfy clippy * update fmt check to use nightly * use nightly for build * fmt * fix fmt install * update test script * try to fix fmt * merge w develop * maybe fix build script * install wasm toolchain * install solc-select, use stable rust to build * Correct clippy warnings Currently intended to be done with: cargo clippy --features "recommended merlin batch serialize experimental ed25519 ristretto p256 secp256k1 multisig" -- -A clippy::type_complexity -A dead_code * Remove try-runtime I tried to get this to work for an hour. I have no idea why it doesn't, yet it doesn't. * Rewrite workflow Splits tasks into a more modular structure. Also uses actions-rs/toolchain. * Add a cache * Immediately try building ETH/Monero while this is fixed Adds solc-select use. * Revert selective advance building of ETH/XMR ETH builds now, so it hopefully should work now. Also moves from on push to on push to develop. * Install Monero runtime dependencies Specify missing Rust toolchain setting. * Correct multi-line commands * Fix multi-line commands again Cache Ethereum artifacts. * Add Foundry * Move Clippy under build * Minimal rustup Adds wasm Clippy. Puts Clippy before build. * Use nightly clippy * Remove old clippy call from under build * Have the Monero build script support ARCH specification Requirement for CI. * Add WASM toolchain to tests * Remove Ethereum cache which did not work as needed * Remove extraneous quotes which broke builds on Arch Co-authored-by: Luke Parker <lukeparker5132@gmail.com>
This commit is contained in:
parent
76a7160ea5
commit
bd93d6ec8a
8 changed files with 293 additions and 120 deletions
199
.github/workflows/tests.yml
vendored
Normal file
199
.github/workflows/tests.yml
vendored
Normal file
|
@ -0,0 +1,199 @@
|
|||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: "recursive"
|
||||
|
||||
- name: Install solc
|
||||
run: |
|
||||
pip3 install solc-select
|
||||
solc-select install 0.8.9
|
||||
solc-select use 0.8.9
|
||||
|
||||
- name: Install Monero Dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install build-essential cmake pkg-config libboost-all-dev \
|
||||
libssl-dev libzmq3-dev libpgm-dev libunbound-dev \
|
||||
libsodium-dev ccache
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
default: true
|
||||
|
||||
- name: Install WASM toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
profile: minimal
|
||||
target: wasm32-unknown-unknown
|
||||
|
||||
# Cache everything, not only for performance, yet to export these to the
|
||||
# following jobs
|
||||
- name: Monero cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
./coins/monero/c/.build
|
||||
./coins/monero/c/monero/build
|
||||
# Hash src, as theoretically, a different version of Monero warranting
|
||||
# a rebuild would've changed *something* under src
|
||||
key: ${{ runner.os }}-${{ hashFiles('./coins/monero/c/monero/src') }}
|
||||
|
||||
- name: Cargo/Rust cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo
|
||||
./target
|
||||
key: ${{ runner.os }}-cargo-rust
|
||||
|
||||
- name: Build
|
||||
run: ARCH=default cargo build --all-features
|
||||
|
||||
# Mirror the build job for Clippy
|
||||
clippy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: "recursive"
|
||||
|
||||
- name: Install solc
|
||||
run: |
|
||||
pip3 install solc-select
|
||||
solc-select install 0.8.9
|
||||
solc-select use 0.8.9
|
||||
|
||||
- name: Install Monero Dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install build-essential cmake pkg-config libboost-all-dev \
|
||||
libssl-dev libzmq3-dev libpgm-dev libunbound-dev \
|
||||
libsodium-dev ccache
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
# Clippy requires nightly for some reason
|
||||
toolchain: nightly
|
||||
profile: minimal
|
||||
default: true
|
||||
components: clippy
|
||||
|
||||
- name: Install WASM toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
profile: minimal
|
||||
target: wasm32-unknown-unknown
|
||||
|
||||
# Grab the Monero cache since it'll be unaffected by Rust versioning
|
||||
- name: Monero cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
./coins/monero/c/.build
|
||||
./coins/monero/c/monero/build
|
||||
key: ${{ runner.os }}-${{ hashFiles('./coins/monero/c/monero/src') }}
|
||||
|
||||
# Define a separate cache for nightly Rust
|
||||
- name: Cargo/Rust nightly cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo
|
||||
./target
|
||||
key: ${{ runner.os }}-cargo-rust-nightly
|
||||
|
||||
- name: Run Clippy
|
||||
run: cargo clippy --all-features -- -D warnings -A clippy::type_complexity -A dead_code
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: "recursive"
|
||||
|
||||
- name: Install solc
|
||||
run: |
|
||||
pip3 install solc-select
|
||||
solc-select install 0.8.9
|
||||
solc-select use 0.8.9
|
||||
|
||||
- name: Install Foundry
|
||||
uses: foundry-rs/foundry-toolchain@v1
|
||||
with:
|
||||
version: nightly
|
||||
|
||||
- name: Install Monero Dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install libboost-all-dev libssl-dev libzmq3-dev libpgm-dev \
|
||||
libunbound-dev libsodium-dev
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
default: true
|
||||
|
||||
- name: Install WASM toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
profile: minimal
|
||||
target: wasm32-unknown-unknown
|
||||
|
||||
- name: Monero cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
./coins/monero/c/.build
|
||||
./coins/monero/c/monero/build
|
||||
key: ${{ runner.os }}-${{ hashFiles('./coins/monero/c/monero/src') }}
|
||||
|
||||
- name: Cargo/Rust cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo
|
||||
./target
|
||||
key: ${{ runner.os }}-cargo-rust
|
||||
|
||||
- name: Monero Regtest Daemon
|
||||
run: ./coins/monero/c/monero/build/release/bin/monerod --regtest --offline --fixed-difficulty=1 --detach
|
||||
|
||||
- name: Run tests
|
||||
run: cargo test --all-features
|
||||
|
||||
fmt:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install rustfmt
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
profile: minimal
|
||||
components: rustfmt
|
||||
|
||||
- name: Run rustfmt
|
||||
run: cargo +nightly fmt -- --check
|
|
@ -1,7 +1,8 @@
|
|||
use ethers_solc::{Project, ProjectPathsConfig};
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=contracts/Schnorr.sol");
|
||||
println!("cargo:rerun-if-changed=contracts");
|
||||
println!("cargo:rerun-if-changed=artifacts");
|
||||
|
||||
// configure the project with all its paths, solc, cache etc.
|
||||
let project = Project::builder()
|
||||
|
|
|
@ -26,12 +26,40 @@ fn main() {
|
|||
// If the signaling file was deleted, run this script again to rebuild Monero though
|
||||
println!("cargo:rerun-if-changed=c/.build/monero");
|
||||
if !Path::new("c/.build/monero").exists() {
|
||||
if !Command::new("make")
|
||||
.arg(format!("-j{}", &env::var("THREADS").unwrap_or("2".to_string())))
|
||||
if !Command::new("mkdir")
|
||||
.args(&["-p", "build/release"])
|
||||
.current_dir(&Path::new("c/monero"))
|
||||
.status()
|
||||
.unwrap()
|
||||
.success()
|
||||
{
|
||||
panic!("failed to mkdir");
|
||||
}
|
||||
|
||||
if !Command::new("cmake")
|
||||
.args(&[
|
||||
"-D",
|
||||
&format!("ARCH={}", &env::var("ARCH").unwrap_or_else(|_| "native".to_string())),
|
||||
"-D",
|
||||
"BUILD_TESTS=OFF",
|
||||
"-D",
|
||||
"CMAKE_BUILD_TYPE=Release",
|
||||
"../..",
|
||||
])
|
||||
.current_dir(&Path::new("c/monero/build/release"))
|
||||
.status()
|
||||
.unwrap()
|
||||
.success()
|
||||
{
|
||||
panic!("failed to call cmake. Please check your dependencies");
|
||||
}
|
||||
|
||||
if !Command::new("make")
|
||||
.arg(format!("-j{}", &env::var("THREADS").unwrap_or_else(|_| "2".to_string())))
|
||||
.current_dir(&Path::new("c/monero/build/release"))
|
||||
.status()
|
||||
.unwrap()
|
||||
.success()
|
||||
{
|
||||
panic!("make failed to build Monero. Please check your dependencies");
|
||||
}
|
||||
|
|
|
@ -49,13 +49,9 @@ frame-benchmarking-cli = { git = "https://github.com/serai-dex/substrate" }
|
|||
serai-consensus = { path = "../consensus" }
|
||||
serai-runtime = { path = "../runtime" }
|
||||
|
||||
# CLI-specific dependencies
|
||||
try-runtime-cli = { git = "https://github.com/serai-dex/substrate", optional = true }
|
||||
|
||||
[build-dependencies]
|
||||
substrate-build-script-utils = { git = "https://github.com/serai-dex/substrate.git" }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
runtime-benchmarks = ["serai-runtime/runtime-benchmarks"]
|
||||
try-runtime = ["serai-runtime/try-runtime", "try-runtime-cli"]
|
||||
|
|
|
@ -40,14 +40,6 @@ pub enum Subcommand {
|
|||
#[clap(subcommand)]
|
||||
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
|
||||
|
||||
/// Try some command against the runtime state
|
||||
#[cfg(feature = "try-runtime")]
|
||||
TryRuntime(try_runtime_cli::TryRuntimeCmd),
|
||||
|
||||
/// Try some command against the runtime state. Note: `try-runtime` feature must be enabled
|
||||
#[cfg(not(feature = "try-runtime"))]
|
||||
TryRuntime,
|
||||
|
||||
/// DB meta columns information
|
||||
ChainInfo(sc_cli::ChainInfoCmd),
|
||||
}
|
||||
|
|
|
@ -114,21 +114,6 @@ pub fn run() -> sc_cli::Result<()> {
|
|||
BenchmarkCmd::Machine(cmd) => cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()),
|
||||
}),
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
Some(Subcommand::TryRuntime(cmd)) => cli.create_runner(cmd)?.async_run(|config| {
|
||||
Ok((
|
||||
cmd.run::<Block, service::ExecutorDispatch>(config),
|
||||
sc_service::TaskManager::new(
|
||||
config.tokio_handle.clone(),
|
||||
config.prometheus_config.as_ref().map(|cfg| &cfg.registry),
|
||||
)
|
||||
.map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?,
|
||||
))
|
||||
}),
|
||||
|
||||
#[cfg(not(feature = "try-runtime"))]
|
||||
Some(Subcommand::TryRuntime) => Err("TryRuntime wasn't enabled when building the node".into()),
|
||||
|
||||
Some(Subcommand::ChainInfo(cmd)) => {
|
||||
cli.create_runner(cmd)?.sync_run(|config| cmd.run::<Block>(&config))
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ sp-api = { git = "https://github.com/serai-dex/substrate", default-features = fa
|
|||
frame-support = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
frame-system = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
frame-executive = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
frame-try-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false, optional = true }
|
||||
|
||||
pallet-randomness-collective-flip = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
pallet-timestamp = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
|
@ -92,15 +91,4 @@ runtime-benchmarks = [
|
|||
"pallet-balances/runtime-benchmarks",
|
||||
]
|
||||
|
||||
try-runtime = [
|
||||
"frame-executive/try-runtime",
|
||||
"frame-try-runtime",
|
||||
"frame-system/try-runtime",
|
||||
|
||||
"pallet-randomness-collective-flip/try-runtime",
|
||||
"pallet-timestamp/try-runtime",
|
||||
"pallet-balances/try-runtime",
|
||||
"pallet-transaction-payment/try-runtime",
|
||||
]
|
||||
|
||||
default = ["std"]
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#[cfg(feature = "std")]
|
||||
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic, impl_opaque_keys,
|
||||
|
@ -280,11 +279,11 @@ construct_runtime!(
|
|||
UncheckedExtrinsic = UncheckedExtrinsic
|
||||
{
|
||||
System: frame_system,
|
||||
RandomnessCollectiveFlip: pallet_randomness_collective_flip,
|
||||
RandomnessCollectiveFlip: pallet_randomness_collective_flip,
|
||||
Timestamp: pallet_timestamp,
|
||||
Balances: pallet_balances,
|
||||
TransactionPayment: pallet_transaction_payment,
|
||||
Contracts: pallet_contracts,
|
||||
Contracts: pallet_contracts,
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -302,7 +301,7 @@ mod benches {
|
|||
);
|
||||
}
|
||||
|
||||
impl_runtime_apis! {
|
||||
sp_api::impl_runtime_apis! {
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
fn version() -> RuntimeVersion {
|
||||
VERSION
|
||||
|
@ -396,6 +395,65 @@ impl_runtime_apis! {
|
|||
}
|
||||
}
|
||||
|
||||
impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>
|
||||
for Runtime
|
||||
{
|
||||
fn call(
|
||||
origin: AccountId,
|
||||
dest: AccountId,
|
||||
value: Balance,
|
||||
gas_limit: u64,
|
||||
storage_deposit_limit: Option<Balance>,
|
||||
input_data: Vec<u8>,
|
||||
) -> pallet_contracts_primitives::ContractExecResult<Balance> {
|
||||
Contracts::bare_call(
|
||||
origin,
|
||||
dest,
|
||||
value,
|
||||
gas_limit,
|
||||
storage_deposit_limit,
|
||||
input_data,
|
||||
CONTRACTS_DEBUG_OUTPUT
|
||||
)
|
||||
}
|
||||
|
||||
fn instantiate(
|
||||
origin: AccountId,
|
||||
value: Balance,
|
||||
gas_limit: u64,
|
||||
storage_deposit_limit: Option<Balance>,
|
||||
code: pallet_contracts_primitives::Code<Hash>,
|
||||
data: Vec<u8>,
|
||||
salt: Vec<u8>,
|
||||
) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, Balance> {
|
||||
Contracts::bare_instantiate(
|
||||
origin,
|
||||
value,
|
||||
gas_limit,
|
||||
storage_deposit_limit,
|
||||
code,
|
||||
data,
|
||||
salt,
|
||||
CONTRACTS_DEBUG_OUTPUT
|
||||
)
|
||||
}
|
||||
|
||||
fn upload_code(
|
||||
origin: AccountId,
|
||||
code: Vec<u8>,
|
||||
storage_deposit_limit: Option<Balance>,
|
||||
) -> pallet_contracts_primitives::CodeUploadResult<Hash, Balance> {
|
||||
Contracts::bare_upload_code(origin, code, storage_deposit_limit)
|
||||
}
|
||||
|
||||
fn get_storage(
|
||||
address: AccountId,
|
||||
key: Vec<u8>,
|
||||
) -> pallet_contracts_primitives::GetStorageResult {
|
||||
Contracts::get_storage(address, key)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl frame_benchmarking::Benchmark<Block> for Runtime {
|
||||
fn benchmark_metadata(extra: bool) -> (
|
||||
|
@ -456,78 +514,4 @@ impl_runtime_apis! {
|
|||
Ok(batches)
|
||||
}
|
||||
}
|
||||
|
||||
impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>
|
||||
for Runtime
|
||||
{
|
||||
fn call(
|
||||
origin: AccountId,
|
||||
dest: AccountId,
|
||||
value: Balance,
|
||||
gas_limit: u64,
|
||||
storage_deposit_limit: Option<Balance>,
|
||||
input_data: Vec<u8>,
|
||||
) -> pallet_contracts_primitives::ContractExecResult<Balance> {
|
||||
Contracts::bare_call(
|
||||
origin,
|
||||
dest,
|
||||
value,
|
||||
gas_limit,
|
||||
storage_deposit_limit,
|
||||
input_data,
|
||||
CONTRACTS_DEBUG_OUTPUT
|
||||
)
|
||||
}
|
||||
|
||||
fn instantiate(
|
||||
origin: AccountId,
|
||||
value: Balance,
|
||||
gas_limit: u64,
|
||||
storage_deposit_limit: Option<Balance>,
|
||||
code: pallet_contracts_primitives::Code<Hash>,
|
||||
data: Vec<u8>,
|
||||
salt: Vec<u8>,
|
||||
) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, Balance> {
|
||||
Contracts::bare_instantiate(
|
||||
origin,
|
||||
value,
|
||||
gas_limit,
|
||||
storage_deposit_limit,
|
||||
code,
|
||||
data,
|
||||
salt,
|
||||
CONTRACTS_DEBUG_OUTPUT
|
||||
)
|
||||
}
|
||||
|
||||
fn upload_code(
|
||||
origin: AccountId,
|
||||
code: Vec<u8>,
|
||||
storage_deposit_limit: Option<Balance>,
|
||||
) -> pallet_contracts_primitives::CodeUploadResult<Hash, Balance> {
|
||||
Contracts::bare_upload_code(origin, code, storage_deposit_limit)
|
||||
}
|
||||
|
||||
fn get_storage(
|
||||
address: AccountId,
|
||||
key: Vec<u8>,
|
||||
) -> pallet_contracts_primitives::GetStorageResult {
|
||||
Contracts::get_storage(address, key)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
impl frame_try_runtime::TryRuntime<Block> for Runtime {
|
||||
fn on_runtime_upgrade() -> (Weight, Weight) {
|
||||
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
|
||||
// have a backtrace here. If any of the pre/post migration checks fail, we shall stop
|
||||
// right here and right now.
|
||||
let weight = Executive::try_runtime_upgrade().unwrap();
|
||||
(weight, BlockWeights::get().max_block)
|
||||
}
|
||||
|
||||
fn execute_block_no_check(block: Block) -> Weight {
|
||||
Executive::execute_block_no_check(block)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue