mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
fb45ff66eb
This allows us to completely skip the "Install Rust" step in CI because the rust-toolchain file completely describes what we need. The first invocation of cargo will simply install all the required components. Additionally, we make all caches dependant on the version of Rust that we require.
149 lines
4.3 KiB
YAML
149 lines
4.3 KiB
YAML
name: CI
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- 'staging'
|
|
- 'trying'
|
|
- 'master'
|
|
|
|
jobs:
|
|
static_analysis:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Cache ~/.cargo/bin directory
|
|
id: cargo-bin-cache
|
|
uses: actions/cache@v2.1.4
|
|
with:
|
|
path: ~/.cargo/bin
|
|
key: ubuntu-rust-${{ hashFiles('rust-toolchain') }}-cargo-bin-directory-v1
|
|
|
|
- name: Install tomlfmt
|
|
if: steps.cargo-bin-cache.outputs.cache-hit != 'true'
|
|
run: cargo install cargo-tomlfmt
|
|
|
|
- name: Check Cargo.toml formatting
|
|
run: |
|
|
cargo tomlfmt -d -p Cargo.toml
|
|
cargo tomlfmt -d -p monero-harness/Cargo.toml
|
|
cargo tomlfmt -d -p swap/Cargo.toml
|
|
|
|
- name: Check code formatting
|
|
run: cargo fmt --all -- --check
|
|
|
|
- name: Run clippy with default features
|
|
run: cargo clippy --workspace --all-targets -- -D warnings
|
|
|
|
- name: Run clippy with all features enabled
|
|
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
|
|
|
|
build:
|
|
strategy:
|
|
matrix:
|
|
target: [ x86_64-unknown-linux-gnu, x86_64-apple-darwin ]
|
|
include:
|
|
- target: x86_64-unknown-linux-gnu
|
|
os: ubuntu-latest
|
|
- target: x86_64-apple-darwin
|
|
os: macos-latest
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Cache target and registry directory
|
|
uses: actions/cache@v2.1.4
|
|
with:
|
|
path: |
|
|
target
|
|
~/.cargo/registry
|
|
key: rust-${{ matrix.target }}-build-${{ hashFiles('Cargo.lock') }}-${{ hashFiles('rust-toolchain') }}-v1
|
|
|
|
- name: Build binary
|
|
run: |
|
|
cargo build -p swap --target ${{ matrix.target }}
|
|
|
|
- name: Upload swap_cli binary
|
|
uses: actions/upload-artifact@v2-preview
|
|
with:
|
|
name: swap-${{ matrix.target }}
|
|
path: target/${{ matrix.target }}/debug/swap_cli
|
|
|
|
- name: Upload nectar binary
|
|
uses: actions/upload-artifact@v2-preview
|
|
with:
|
|
name: nectar-${{ matrix.target }}
|
|
path: target/${{ matrix.target }}/debug/nectar
|
|
|
|
test:
|
|
env:
|
|
RUST_TEST_TASKS: 2
|
|
strategy:
|
|
matrix:
|
|
target: [ x86_64-unknown-linux-gnu, x86_64-apple-darwin ]
|
|
include:
|
|
- target: x86_64-unknown-linux-gnu
|
|
os: ubuntu-latest
|
|
- target: x86_64-apple-darwin
|
|
os: macos-latest
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Cache target and registry directory
|
|
uses: actions/cache@v2.1.4
|
|
with:
|
|
path: |
|
|
target
|
|
~/.cargo/registry
|
|
key: rust-${{ matrix.target }}-test-${{ hashFiles('Cargo.lock') }}-${{ hashFiles('rust-toolchain') }}-v1
|
|
|
|
- name: Build tests
|
|
run: cargo build --tests --workspace --all-features
|
|
|
|
- name: Run monero-harness tests
|
|
if: matrix.os == 'ubuntu-latest'
|
|
run: cargo test --package monero-harness --all-features
|
|
|
|
- name: Run library tests for swap
|
|
run: cargo test --package swap --lib --all-features
|
|
|
|
docker_tests:
|
|
env:
|
|
TARGET: x86_64-unknown-linux-gnu
|
|
strategy:
|
|
matrix:
|
|
test_name: [
|
|
happy_path,
|
|
happy_path_restart_bob_before_comm,
|
|
bob_refunds_using_cancel_and_refund_command,
|
|
bob_refunds_using_cancel_and_refund_command_timelock_not_expired,
|
|
bob_refunds_using_cancel_and_refund_command_timelock_not_expired_force,
|
|
]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Cache target and registry directory
|
|
uses: actions/cache@v2.1.4
|
|
with:
|
|
path: |
|
|
target
|
|
~/.cargo/registry
|
|
key: rust-${{ matrix.target }}-test-${{ hashFiles('Cargo.lock') }}-${{ hashFiles('rust-toolchain') }}-v1
|
|
|
|
- name: Run test ${{ matrix.test_name }}
|
|
run: cargo test --package swap --all-features --test ${{ matrix.test_name }} ""
|
|
env:
|
|
MONERO_ADDITIONAL_SLEEP_PERIOD: 60000
|
|
RUST_MIN_STACK: 16777216 # 16 MB. Default is 8MB. This is fine as in tests we start 2 programs: Alice and Bob.
|