-
Notifications
You must be signed in to change notification settings - Fork 23
114 lines (97 loc) · 3.2 KB
/
reusable-e2e.yaml
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
name: Run Spawn E2E
# Chain name MUST be `mychain` using binary name `appd`
on:
workflow_call:
inputs:
id:
type: string
required: true
description: 'ID / description of the whole thing'
spawn-create-cmd:
type: string
required: true
description: 'The spawn command to create the chain'
start-chain-cmd:
type: string
required: true
description: 'The command which runs the chain via the shell'
spawn-extra-cmd:
type: string
required: false
description: 'Extra command to run after the chain is created'
env:
GO_VERSION: 1.22.3
JQ_VERSION: '1.7'
JQ_FORCE: false
jobs:
run:
runs-on: ubuntu-latest
steps:
# === BASE SETUP ===
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: 'Setup jq'
uses: dcarbone/install-jq-action@v2
with:
version: '${{ env.JQ_VERSION }}'
force: '${{ env.JQ_FORCE }}'
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Go Build Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Go Mod Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
# === SETUP SPAWN ===
- name: Download Spawn Bin
uses: actions/download-artifact@master
with:
name: spawn
path: /home/runner/go/bin
- name: Spawn Permission # put into path
run: chmod +x /home/runner/go/bin/spawn && ls -l
# === Chain Creation & Validation ===
- name: Spawn Gen - '${{inputs.id}}'
run: |
git config --global --add url."git@github.com:".insteadOf "https://github.com/"
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
${{ inputs.spawn-create-cmd }}
pwd
- name: Spawn Extra Generation
if : ${{ inputs.spawn-extra-cmd }}
run: ${{ inputs.spawn-extra-cmd }}
- name: Build and Run '${{inputs.id}}'
run: |
cd mychain
${{ inputs.start-chain-cmd }}
# Runs the unit test after the chain is started in the background
# This way the work is parallelized
- name: Unit Test - '${{inputs.id}}'
run: |
cd mychain
go test ./...
- name: Validate '${{inputs.id}}' is Running
run: |
for ((i = 1; i <= 10; i++)); do
res=`appd status --output=json | jq -r 'has("sync_info")'`
if [ "$res" == "true" ]; then
echo "Chain is running"
exit 0
else
echo "Chain is not running"
# exit 1
sleep 5
fi
done
lsof -i tcp:26657 | awk 'NR!=1 {print $2}' | xargs kill || true
exit 1