-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
28 lines (25 loc) · 835 Bytes
/
action.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
name: 'Python import time'
description: 'Bound the time it takes for some python code to import stuff.'
branding:
icon: 'zap'
color: 'yellow'
inputs:
code:
description: 'The code to measure.'
required: True
threshold:
description: 'The time threshold. If the code takes longer than that to import stuff, the action will fail.'
required: False
default: 250000
runs:
using: "composite"
steps:
- name: Check import time of `${{inputs.code}}` ⏳
shell: bash
env:
CODE: ${{inputs.code}}
THRESHOLD: ${{inputs.threshold}}
run: |
importtime="$(python -X importtime -c "${CODE}" 2>&1 | tail -n+2 | awk '{s+=$3}END{print s}')"
echo "Import time for '${CODE}' is ${importtime} and threshold is ${THRESHOLD}"
test "${importtime}" -le "${THRESHOLD}"