feat(netsim): added support for playbooks #84
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: netsim-integration-CI | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
env: | |
RUST_BACKTRACE: 1 | |
RUSTFLAGS: -Dwarnings | |
MSRV: "1.63" | |
jobs: | |
netsim-integration-tests: | |
name: Run network simulations/benchmarks | |
runs-on: [self-hosted, linux, X64] | |
permissions: | |
issues: write | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@master | |
with: | |
submodules: recursive | |
- name: Install rust stable | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
- name: Install netsim deps | |
run: | | |
cd netsim | |
sudo apt update | |
./setup.sh | |
- name: Build chuck | |
run: | | |
cargo build --release | |
- name: Fetch and build iroh | |
run: | | |
git clone https://github.com/n0-computer/iroh.git | |
cd iroh | |
cargo build --release | |
- name: Fetch and build iroh-ffi | |
run: | | |
git clone https://github.com/n0-computer/iroh-ffi.git | |
cd iroh-ffi | |
echo "iroh = { path = \"../iroh\" }" >> Cargo.toml | |
pip3 install maturin uniffi-bindgen | |
maturin build --release | |
- name: Copy binaries to right location | |
run: | | |
cp target/release/chuck netsim/bins/chuck | |
cp iroh/target/release/iroh netsim/bins/iroh | |
cp iroh-ffi/target/wheels/iroh-*-py3-none-manylinux_2_34_x86_64.whl ./netsim/bins/ | |
- name: Setup python venv | |
run: | | |
cd netsim | |
python3 -m venv venv | |
source venv/bin/activate | |
pip3 install bins/iroh-*.whl | |
pip3 install -r playbooks/requirements.txt | |
- name: Run tests | |
run: | | |
cd netsim | |
sudo kill -9 $(pgrep ovs) | |
sudo mn --clean | |
sudo python3 main.py --integration sims/standard/iroh.json | |
sudo python3 main.py --integration sims/example/playbook.json | |
- name: Setup Environment (PR) | |
if: ${{ github.event_name == 'pull_request' }} | |
shell: bash | |
run: | | |
echo "LAST_COMMIT_SHA=$(git rev-parse --short ${{ github.event.pull_request.head.sha }})" >> ${GITHUB_ENV} | |
echo "HEAD_REF=${{ github.event.pull_request.head.ref }}" >> ${GITHUB_ENV} | |
- name: Setup Environment (Push) | |
if: ${{ github.event_name == 'push' }} | |
shell: bash | |
run: | | |
echo "LAST_COMMIT_SHA=$(git rev-parse --short ${GITHUB_SHA})" >> ${GITHUB_ENV} | |
echo "HEAD_REF=${{ github.head_ref }}" >> ${GITHUB_ENV} | |
- name: Generate reports | |
run: | | |
cd netsim | |
python3 reports_csv.py --prom --commit ${{ env.LAST_COMMIT_SHA }} > report_prom.txt | |
python3 reports_csv.py --metro --commit ${{ env.LAST_COMMIT_SHA }} > report_metro.txt | |
- name: Echo metrics | |
run: | | |
cd netsim | |
d=$(cat report_metro.txt) | |
metro_data=$(printf "%s\n " "$d") | |
echo "$metro_data" |