-
Notifications
You must be signed in to change notification settings - Fork 12
143 lines (125 loc) · 5.08 KB
/
run_examples.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
name: Run Examples
on:
push:
pull_request:
workflow_dispatch:
jobs:
check_example_directories:
runs-on: ubuntu-latest
outputs:
dir: ${{ steps.set-dirs.outputs.dir }}
steps:
- uses: actions/checkout@v2
- id: set-dirs
run: echo "::set-output name=dir::$(ls -d example/*/ | jq -R -s -c 'split("\n")[:-1]')"
run:
runs-on: ubuntu-latest
needs: [check_example_directories]
strategy:
fail-fast: false
matrix:
# List matrix strategy from directories dynamically
dir: ${{fromJson(needs.check_example_directories.outputs.dir)}}
steps:
- name: Set up Python
uses: actions/setup-python@v2
- name: Set up SCons
shell: bash
run: |
python -c "import sys; print(sys.version)"
python -m pip install scons==4.8
scons --version
- uses: chickensoft-games/setup-godot@v1
name: 🤖 Setup Godot
with:
version: 4.3.0
use-dotnet: false
include-templates: true
- name: Checkout project
uses: actions/checkout@v2
with:
submodules: recursive
- name: Build binary
shell: bash
run: |
scons
- name: (Web) Install emsdk toolchain
if: ${{ endsWith(matrix.dir, 'Web/') }}
uses: mymindstorm/setup-emsdk@v14
with:
version: 3.1.64
- name: (Web) Build binary
if: ${{ endsWith(matrix.dir, 'Web/') }}
shell: bash
run: |
scons platform=web target=template_debug
- name: Prepare project
shell: bash
run: |
cp godot-solana-sdk.gdextension bin/
cd ${{matrix.dir}}
ln -s ../../bin
mkdir .godot
echo "res://bin/godot-solana-sdk.gdextension" >> .godot/extension_list.cfg
- name: Setup Solana tools
uses: metadaoproject/[email protected]
- name: Load Test Accounts
id: test_accounts
run: |
cd ${{matrix.dir}}
if [ -d "test_accounts" ]; then
for file in "test_accounts"/*; do
if [ -f "$file" ]; then
str="${str} --account `echo -n "${file##*/}" | cut -f 1 -d '.' | tr -d $'\n'` ${{matrix.dir}}${file}"
fi
done
fi
mkdir -p test_accounts
solana program dump --url mainnet-beta CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR test_accounts/CMV3.so
str="${str} --bpf-program CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR ${{matrix.dir}}test_accounts/CMV3.so"
solana program dump --url mainnet-beta metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s test_accounts/MPMD.so
str="${str} --bpf-program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s ${{matrix.dir}}test_accounts/MPMD.so"
echo "VALIDATOR_ARGS=${str}" >> "$GITHUB_OUTPUT"
- name: Setup Local Validator
uses: switchboard-xyz/[email protected]
with:
solana-version: v1.18.22
cluster: devnet
args: "${{steps.test_accounts.outputs.VALIDATOR_ARGS}}"
- name: (Web) Download Puppeteer
if: ${{ endsWith(matrix.dir, 'Web/') }}
uses: actions/setup-node@v4
with:
node-version: 20
- name: (Web) Setup Puppeteer
if: ${{ endsWith(matrix.dir, 'Web/') }}
run: |
cd .github/workflows/puppeteer
npm init -y
npm install puppeteer
- name: (Web) Export project to web
if: ${{ endsWith(matrix.dir, 'Web/') }}
run: |
cd ${{matrix.dir}}
mkdir tmp
godot --headless --path . --export-debug Web tmp/tmp_js_export.html
- name: (Web) Download wallet mock
if: ${{ endsWith(matrix.dir, 'Web/') }}
uses: actions/checkout@v4
with:
repository: 'Virus-Axel/solana-wallet-mock'
path: 'solana-wallet-mock'
- name: (Web) Test project in browser
if: ${{ endsWith(matrix.dir, 'Web/') }}
run: |
python3 .github/workflows/puppeteer/serve.py --no-browser --root `pwd`/${{matrix.dir}}tmp &
cd .github/workflows/puppeteer
node puppeteer.js | (grep 'ALL TESTS PASSED')
exit $?
- name: Test project
if: ${{ endsWith(matrix.dir, 'Web/') == false }}
shell: bash
run: |
cd ${{matrix.dir}}
godot --headless --quit-after 5000 | ( ! grep FAIL)
exit $?