forked from libp2p/test-plans
-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (119 loc) · 5.13 KB
/
perf.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
name: libp2p perf test
# How to configure a repository for running this workflow:
# 1. Run 'make ssh-keygen' in 'perf' to generate a new SSH key pair named 'user' in 'perf/terraform/region/files'
# 2. Export AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY for the account of your choice
# 3. Run 'terraform apply' in 'perf/terraform' to create the AWS resources
# 4. Run 'terraform output' in 'perf/terraform' to get the bucket name
# 5. Go to https://console.aws.amazon.com/iamv2/home?#/users/details/perf?section=security_credentials
# 6. Click 'Create access key' to get the access key ID and secret access key
# 7. Go to https://github.com/libp2p/test-plans/settings/secrets/actions
# 8. Click 'New repository secret', set the name to 'PERF_AWS_SECRET_ACCESS_KEY', and paste the secret access key from step 6
# 9. Click 'New repository secret', set the name to 'PERF_SSH_PRIVATE_KEY', and paste the private key from step 1
# 10. Go to https://github.com/libp2p/test-plans/settings/variables/actions
# 11. Click 'New repository variable', set the name to 'PERF_AWS_ACCESS_KEY_ID', and paste the access key ID from step 6
# 12. Click 'New repository variable', set the name to 'PERF_AWS_BUCKET', and paste the bucket name from step 4
on:
workflow_dispatch:
workflow_call:
# Example:
# uses: libp2p/test-plans/.github/workflows/perf.yml@master
# with:
# aws-access-key-id: ${{ vars.PERF_AWS_ACCESS_KEY_ID }}
# aws-bucket: ${{ vars.PERF_AWS_BUCKET }}
# ref: master
# secrets:
# PERF_AWS_SECRET_ACCESS_KEY: ${{ secrets.PERF_AWS_SECRET_ACCESS_KEY }}
# PERF_SSH_PRIVATE_KEY: ${{ secrets.PERF_SSH_PRIVATE_KEY }}
inputs:
aws-access-key-id:
type: string
required: true
description: The AWS access key ID of 'aws_iam_user.perf'
aws-bucket:
type: string
required: true
description: The AWS bucket as output by 'output.bucket_name'
ref:
type: string
required: false
description: The ref of the test-plans repo to use (defaults to 'master')
default: master
secrets:
PERF_AWS_SECRET_ACCESS_KEY: # The AWS secret access key of 'aws_iam_user.perf'
required: true
PERF_SSH_PRIVATE_KEY: # The SSH private key for 'aws_key_pair.perf'
required: true
jobs:
perf:
name: Perf
runs-on: ubuntu-latest
timeout-minutes: 40
defaults:
run:
shell: bash
working-directory: perf
env:
AWS_ACCESS_KEY_ID: ${{ inputs.aws-access-key-id || vars.PERF_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.PERF_AWS_SECRET_ACCESS_KEY }}
steps:
- name: Configure SSH
uses: webfactory/ssh-agent@d4b9b8ff72958532804b70bbe600ad43b36d5f2e # v0.8.0
with:
ssh-private-key: ${{ secrets.PERF_SSH_PRIVATE_KEY }}
- name: Checkout test-plans
uses: actions/checkout@v3
with:
repository: libp2p/test-plans
ref: ${{ inputs.ref || github.ref }}
- id: server
name: Provision server
run: echo "id=$(make provision-server | tail -n 1)" >> $GITHUB_OUTPUT
- id: client
name: Provision client
run: echo "id=$(make provision-client | tail -n 1)" >> $GITHUB_OUTPUT
- id: ip
name: Wait for client/server IP
env:
SERVER_ID: ${{ steps.server.outputs.id }}
CLIENT_ID: ${{ steps.client.outputs.id }}
run: |
read SERVER_IP CLIENT_IP <<< $(make wait SERVER_ID=$SERVER_ID CLIENT_ID=$CLIENT_ID | tail -n 1)
echo "server=$SERVER_IP" >> $GITHUB_OUTPUT
echo "client=$CLIENT_IP" >> $GITHUB_OUTPUT
- name: Download dependencies
run: npm ci
working-directory: perf/runner
- name: Run tests
env:
SERVER_IP: ${{ steps.ip.outputs.server }}
CLIENT_IP: ${{ steps.ip.outputs.client }}
run: npm run start -- --client-public-ip $CLIENT_IP --server-public-ip $SERVER_IP
working-directory: perf/runner
- name: Archive results
uses: actions/upload-artifact@v2
with:
name: results
path: perf/runner/benchmark-results.json
- id: s3
name: Upload results
env:
AWS_BUCKET: ${{ inputs.aws-bucket || vars.PERF_AWS_BUCKET }}
AWS_BUCKET_PATH: ${{ github.repository }}/${{ github.run_id }}/${{ github.run_attempt }}/benchmark-results.json
run: |
aws s3 cp benchmark-results.json s3://$AWS_BUCKET/$AWS_BUCKET_PATH --acl public-read --region us-west-2
echo "url=https://$AWS_BUCKET.s3.amazonaws.com/$AWS_BUCKET_PATH" >> $GITHUB_OUTPUT
working-directory: perf/runner
- name: Set summary
env:
URL: ${{ steps.s3.outputs.url }}
run: echo "$URL" >> $GITHUB_STEP_SUMMARY
- name: Deprovision client
if: always() && steps.client.outputs.id != ''
env:
CLIENT_ID: ${{ steps.client.outputs.id }}
run: make deprovision-client CLIENT_ID=$CLIENT_ID
- name: Deprovision server
if: always() && steps.server.outputs.id != ''
env:
SERVER_ID: ${{ steps.server.outputs.id }}
run: make deprovision-server SERVER_ID=$SERVER_ID