-
Notifications
You must be signed in to change notification settings - Fork 3
178 lines (157 loc) · 5.81 KB
/
netsim.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
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}}