Skip to content

[WIP] feat: add quinn compatibility tests DO NOT MERGE! #213

[WIP] feat: add quinn compatibility tests DO NOT MERGE!

[WIP] feat: add quinn compatibility tests DO NOT MERGE! #213

Workflow file for this run

name: netsim-CI
on:
# pull_request:
push:
branches:
- main
issue_comment:
types: [created, edited, deleted]
env:
RUST_BACKTRACE: 1
RUSTFLAGS: -Dwarnings
MSRV: "1.63"
IROH_FORCE_STAGING_RELAYS: "1"
jobs:
netsim:
name: Run network simulations/benchmarks
if: >-
(github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
startsWith(github.event.comment.body, '/perf')) || github.event_name != 'issue_comment'
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: Copy binaries to right location
run: |
cp target/release/chuck netsim/bins/chuck
cp iroh/target/release/iroh netsim/bins/iroh
- name: Detect comment commands
if: github.event_name == 'issue_comment'
id: detect_comment_config
run: |
a='${{ github.event.comment.body }}'
if [[ $a == '/perf config'* ]];
then
a=$(echo "'$a'" | tr '\n' ' ' | tr -s " " | sed -e 's/.*```\(.*\)```.*/\1/')
export NETSIM_CONFIG="$a"
echo "NETSIM_CONFIG<<EOFMARKER" >> ${GITHUB_OUTPUT}
echo "${NETSIM_CONFIG}" >> ${GITHUB_OUTPUT}
echo "EOFMARKER" >> ${GITHUB_OUTPUT}
fi
echo "'$NETSIM_CONFIG'"
- name: Run tests
run: |
cd netsim
sudo kill -9 $(pgrep ovs)
sudo mn --clean
c='${{ steps.detect_comment_config.outputs.NETSIM_CONFIG }}'
if [ -z "${c}" ];
then
sudo python3 main.py sims/iroh
else
echo $c >> custom_sim.json
sudo python3 main.py custom_sim.json
fi
- name: Generate report
id: generate_report
run: |
cd netsim
python3 reports_csv.py --table > report.txt
export NETSIM_REPORT=$(cat report.txt)
echo "NETSIM_REPORT<<EOFMARKER" >> ${GITHUB_OUTPUT}
echo "${NETSIM_REPORT}" >> ${GITHUB_OUTPUT}
echo "EOFMARKER" >> ${GITHUB_OUTPUT}
- name: Setup Environment
shell: bash
run: |
echo "LAST_COMMIT_SHA=unknown" >> ${GITHUB_ENV}
echo "HEAD_REF=unknown" >> ${GITHUB_ENV}
- name: Setup Environment (Issue)
if: ${{ github.event_name == 'issue_comment' }}
shell: bash
run: |
echo "LAST_COMMIT_SHA=$(git rev-parse --short ${{ github.event.issue.pull_request.head.sha }})" >> ${GITHUB_ENV}
echo "HEAD_REF=${{ github.event.issue.pull_request.head.ref }}" >> ${GITHUB_ENV}
- 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: Respond Issue
uses: peter-evans/create-or-update-comment@v2
if: github.event_name == 'issue_comment'
with:
issue-number: ${{ github.event.issue.number }}
body: |
`${{ env.HEAD_REF }}.${{ env.LAST_COMMIT_SHA }}`
Perf report:
${{ steps.generate_report.outputs.NETSIM_REPORT }}
- name: Respond PR
uses: peter-evans/create-or-update-comment@v2
if: github.event.pull_request
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
`${{ env.HEAD_REF }}.${{ env.LAST_COMMIT_SHA }}`
Perf report:
${{ steps.generate_report.outputs.NETSIM_REPORT }}
- 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: Dump reports
if: github.event_name != 'issue_comment'
run: |
export AWS_ACCESS_KEY_ID=${{secrets.S3_ACCESS_KEY_ID}}
export AWS_SECRET_ACCESS_KEY=${{secrets.S3_ACCESS_KEY}}
export AWS_DEFAULT_REGION=us-west-2
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip -q awscliv2.zip
sudo ./aws/install --update
cd netsim
tar cvzf report.tar.gz report_prom.txt report.txt report_metro.txt logs/ report/
aws s3 cp ./report.tar.gz s3://${{secrets.S3_REPORT_BUCKET}}/${{ env.LAST_COMMIT_SHA }}.tar.gz --no-progress
instance=$(echo "${{ env.HEAD_REF }}" | tr -c '[:alnum:]' '_')
d=$(cat report_prom.txt)
prom_data=$(printf "%s\n " "$d")
curl -X POST -H "Content-Type: text/plain" --data "$prom_data" ${{secrets.PROM_ENDPOINT}}/metrics/job/chucksim/instance/${instance}
- name: Echo metrics
# if: github.ref_name=='main'
run: |
cd netsim
d=$(cat report_metro.txt)
metro_data=$(printf "%s\n " "$d")
echo "$metro_data"
# curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ${{secrets.METRO_TOKEN}}" --data "$metro_data" ${{secrets.METRO_ENDPOINT}}