-
Notifications
You must be signed in to change notification settings - Fork 1
167 lines (135 loc) · 4.49 KB
/
asv.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
# This workflow will install Python dependencies, run benchmarks with airspeed velocity (asv)
# and publish the results to a dashboard on GH Pages.
name: Run benchmarks with ASV
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
PYTHON_VERSION: "3.10"
WORKING_DIR: ${{ github.workspace }}/benchmarks
jobs:
consecutiveness:
runs-on: ubuntu-latest
steps:
- uses: mktcode/consecutive-workflow-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
setup-python:
runs-on: ubuntu-latest
needs: consecutiveness
steps:
- name: Cache Python ${{ env.PYTHON_VERSION }}
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: python-${{ env.PYTHON_VERSION }}
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: "${{ env.PYTHON_VERSION }}"
asv-main:
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
needs: setup-python
permissions:
contents: write
defaults:
run:
working-directory: ${{ env.WORKING_DIR }}
steps:
- name: Checkout main branch of the repository
uses: actions/checkout@v3
- name: Cache Python ${{ env.PYTHON_VERSION }}
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: python-${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
sudo apt-get update
python -m pip install --upgrade pip
pip install asv virtualenv tabulate
- name: Create ASV machine config file
run: asv machine --machine gh-runner --yes
- name: Run ASV for the main branch
run: asv run
- name: Submit results to the repository
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add results/
git commit -m "Add benchmarks"
git push origin main
- name: Generate dashboard HTML
run: |
asv show
asv publish
- name: Deploy to Github pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ${{ env.WORKING_DIR }}/html
asv-pr:
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
needs: setup-python
permissions:
actions: read
pull-requests: write
defaults:
run:
working-directory: ${{ env.WORKING_DIR }}
steps:
- name: Checkout PR branch of the repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache Python ${{ env.PYTHON_VERSION }}
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: python-${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
sudo apt-get update
python -m pip install --upgrade pip
pip install asv virtualenv tabulate
- name: Get current job logs URL
uses: Tiryoh/gha-jobid-action@v0
id: jobs
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
job_name: ${{ github.job }}
- name: Create ASV machine config file
run: asv machine --machine gh-runner --yes
- name: Run comparison of PR against main branch
run: |
git remote add upstream https://github.com/${{github.repository}}.git
git fetch upstream
asv continuous upstream/main HEAD
asv compare upstream/main HEAD --sort ratio | tee output
python format.py
printf "\n\nClick [here]($STEP_URL) to view all benchmarks." >> output
env:
STEP_URL: "${{ steps.jobs.outputs.html_url }}#step:8:1"
- name: Publish comment to PR
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const path = require('path');
const workingDir = process.env.WORKING_DIR;
try {
process.chdir(workingDir);
const comment = fs.readFileSync('output', 'utf-8');
const { data } = await github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: comment,
});
console.log('Comment published:', data.html_url);
} catch (err) {
console.error(err);
}