-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
78 lines (70 loc) · 2.55 KB
/
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
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
name: Hardhat Session
author: 721 Labs
description: "Run your Hardhat tests in a dedicated, session-lived container"
inputs:
cmd:
required: true
description: "Hardhat cmd with args e.g. `npx hardhat <cmd>`"
session-id:
required: false
description: "ID of session to resume; passed in from previous job"
hardhat-directory:
required: false
description: "Directory containing your Hardhat project if it's not contained within root."
default: "."
outputs:
session-id:
description: "Newly started session ID"
value: ${{ steps.start-session.outputs.session-id }}
session-endpoint:
description: "Endpoint to POST RPC requests to"
value: ${{ steps.start-session.outputs.session-endpoint }}
runs:
using: "composite"
steps:
- name: "Copy files into hardhat-dir"
run: |
cp ${{ github.action_path }}/dist/pre/index.js ${{ inputs.hardhat-directory }}/pre.js
cp ${{ github.action_path }}/dist/hh-config/index.js ${{ inputs.hardhat-directory}}/hh-config.js
shell: "bash"
- name: "Validate Command"
run: "node pre.js"
shell: "bash"
working-directory: ${{ inputs.hardhat-directory }}
env:
INPUT_CMD: ${{ inputs.cmd }}
- name: "Resuming Session"
run: |
echo "Session Resumed: ${{ inputs.session-id }}"
shell: "bash"
if: ${{ inputs.session-id }}
- name: "Start Session"
id: start-session
run: "node ${{ github.action_path }}/dist/main/index.js"
shell: "bash"
if: ${{ inputs.session-id == null }}
- name: "Configure Hardhat"
id: config-hardhat
run: "node hh-config.js"
shell: "bash"
working-directory: ${{ inputs.hardhat-directory }}
env:
sessionId: ${{ steps.start-session.outputs.session-id || inputs.session-id }}
cmd: ${{ inputs.cmd }}
- name: "Wait for session to start"
run: "node ${{ github.action_path }}/dist/wait/index.js"
shell: "bash"
env:
sessionId: ${{ steps.start-session.outputs.session-id || inputs.session-id }}
- name: "Run Hardhat Command"
run: yarn hardhat ${{ steps.config-hardhat.outputs.clean-cmd }} --config ${{ steps.config-hardhat.outputs.config-path }} --network $SESSION_ID
shell: "bash"
working-directory: ${{ inputs.hardhat-directory }}
env:
SESSION_ID: ${{ steps.start-session.outputs.session-id || inputs.session-id }}
- name: "Clean up custom Hardhat config"
run: rm -rf ${{ steps.config-hardhat.outputs.config-path }}
shell: "bash"
branding:
color: "red"
icon: "box"