-
Notifications
You must be signed in to change notification settings - Fork 70
274 lines (257 loc) · 10.7 KB
/
tool.yml
File metadata and controls
274 lines (257 loc) · 10.7 KB
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# Copyright 2026 OpenC3, Inc.
# All Rights Reserved.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See LICENSE.md for more details.
# This file may also be used under the terms of a commercial license
# if purchased from OpenC3, Inc.
name: Frontend Generator Tests
# Only run on a push to main to avoid running for all the dependabot PRs
on:
push:
branches:
- main
pull_request:
branches:
- "**"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
OPENC3_API_PASSWORD: password
permissions:
contents: read
jobs:
frontend-generators:
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 24
- name: Install pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
with:
version: 9
- name: openc3.sh build
# This `shell` line is required to get around a known issue: https://github.com/actions/runner/issues/241#issuecomment-745902718
shell: 'script -q -e -c "bash {0}"'
run: ./openc3.sh build
- name: openc3.sh run
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
! docker ps | grep openc3
./openc3.sh run
sleep 10s
docker ps | grep openc3
# Test Vue.js tool generation and build
- name: Generate and build Vue.js tool
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
# Generate plugin
./openc3.sh cli generate plugin tool-vue-test --ruby
cd openc3-cosmos-tool-vue-test
# Generate Vue tool
../openc3.sh cli generate tool_vue 'Test Vue Tool' --ruby
# Verify tool structure created
test -f package.json
test -f vite.config.js
test -f src/App.vue
test -d src/tools/testvuetool
test -f src/tools/testvuetool/testvuetool.vue
# Verify tool was added to plugin.txt
grep -q 'TOOL testvuetool "Test Vue Tool"' plugin.txt
grep -q 'INLINE_URL main.js' plugin.txt
# Verify package.json has required scripts
grep -q '"build"' package.json
grep -q '"serve"' package.json
# Build plugin (skip --frozen-lockfile for fresh plugins, keep --ignore-scripts)
pnpm install --ignore-scripts
rake build VERSION=1.0.0
# Verify build output (Vue builds to tools/testvuetool/ directory)
test -f tools/testvuetool/main.js
# Verify output is a SystemJS module
grep -q "System.register" tools/testvuetool/main.js
# Validate gem
../openc3.sh cli validate openc3-cosmos-tool-vue-test-1.0.0.gem
cd ..
# Test Angular tool generation and build
- name: Generate and build Angular tool
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
# Generate plugin
./openc3.sh cli generate plugin tool-angular-test --ruby
cd openc3-cosmos-tool-angular-test
# Generate Angular tool
../openc3.sh cli generate tool_angular 'Test Angular Tool' --ruby
# Verify tool structure created
test -f package.json
test -f angular.json
test -f src/main.single-spa.ts
# Verify tool was added to plugin.txt
grep -q 'TOOL testangulartool "Test Angular Tool"' plugin.txt
grep -q 'INLINE_URL main.js' plugin.txt
# Verify package.json has required scripts
grep -q '"build"' package.json
# Build plugin (skip --frozen-lockfile for fresh plugins, keep --ignore-scripts)
pnpm install --ignore-scripts
rake build VERSION=1.0.0
# Verify build output (Angular builds to tools/testangulartool/)
test -f tools/testangulartool/main.js
# Verify output is a SystemJS module
grep -q "System.register" tools/testangulartool/main.js
# Validate gem
../openc3.sh cli validate openc3-cosmos-tool-angular-test-1.0.0.gem
cd ..
# Test React tool generation and build
- name: Generate and build React tool
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
# Generate plugin
./openc3.sh cli generate plugin tool-react-test --ruby
cd openc3-cosmos-tool-react-test
# Generate React tool
../openc3.sh cli generate tool_react 'Test React Tool' --ruby
# Verify tool structure created
test -f package.json
test -f webpack.config.js
test -f src/root.component.js
# Verify tool was added to plugin.txt
grep -q 'TOOL testreacttool "Test React Tool"' plugin.txt
grep -q 'INLINE_URL main.js' plugin.txt
# Verify package.json has required scripts
grep -q '"build"' package.json
# Build plugin (skip --frozen-lockfile for fresh plugins, keep --ignore-scripts)
pnpm install --ignore-scripts
rake build VERSION=1.0.0
# Verify build output (React builds to tools/testreacttool/)
test -f tools/testreacttool/main.js
# Verify output is a SystemJS module
grep -q "System.register" tools/testreacttool/main.js
# Validate gem
../openc3.sh cli validate openc3-cosmos-tool-react-test-1.0.0.gem
cd ..
# Test Svelte tool generation and build
- name: Generate and build Svelte tool
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
# Generate plugin
./openc3.sh cli generate plugin tool-svelte-test --ruby
cd openc3-cosmos-tool-svelte-test
# Generate Svelte tool
../openc3.sh cli generate tool_svelte 'Test Svelte Tool' --ruby
# Verify tool structure created
test -f package.json
test -f rollup.config.js
test -f src/App.svelte
# Verify tool was added to plugin.txt
grep -q 'TOOL testsveltetool "Test Svelte Tool"' plugin.txt
grep -q 'INLINE_URL main.js' plugin.txt
# Verify package.json has required scripts
grep -q '"build"' package.json
# Build plugin (skip --frozen-lockfile for fresh plugins, keep --ignore-scripts)
pnpm install --ignore-scripts
rake build VERSION=1.0.0
# Verify build output (Svelte builds to tools/testsveltetool/)
test -f tools/testsveltetool/main.js
# Verify output is a SystemJS module
grep -q "System.register" tools/testsveltetool/main.js
# Validate gem
../openc3.sh cli validate openc3-cosmos-tool-svelte-test-1.0.0.gem
cd ..
# Test widget generator
- name: Generate and build widget
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
# Generate plugin
./openc3.sh cli generate plugin widget-test --ruby
cd openc3-cosmos-widget-test
# Generate widget
../openc3.sh cli generate widget TestWidget --ruby
# Verify widget structure created in src/ directory
test -f src/TestWidget.vue
test -f package.json
test -f vite.config.js
# Verify widget was added to plugin.txt with correct format
grep -q "WIDGET Test" plugin.txt
# Verify package.json has required scripts
grep -q '"build"' package.json
# Build plugin (skip --frozen-lockfile for fresh plugins, keep --ignore-scripts)
pnpm install --ignore-scripts
rake build VERSION=1.0.0
# Verify build output (widgets build to tools/widgets/TestWidget/)
test -f tools/widgets/TestWidget/TestWidget.umd.min.js
# Validate gem
../openc3.sh cli validate openc3-cosmos-widget-test-1.0.0.gem
cd ..
# Test command_validator generator
- name: Generate command validator
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
# Generate plugin
./openc3.sh cli generate plugin validator-test --ruby
cd openc3-cosmos-validator-test
# Generate target first (required for command_validator)
../openc3.sh cli generate target EXAMPLE --ruby
# Generate command_validator
../openc3.sh cli generate command_validator EXAMPLE test --ruby
# Verify command_validator file created
ls targets/EXAMPLE/lib | grep test_command_validator.rb
# Build plugin using documented workflow for non-tool plugins (README line 13)
../openc3.sh cli rake build VERSION=1.0.0
../openc3.sh cli validate openc3-cosmos-validator-test-1.0.0.gem
cd ..
# Test generic tool command (should default to Vue)
- name: Test generic tool command
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
# Generate plugin
./openc3.sh cli generate plugin tool-generic-test --ruby
cd openc3-cosmos-tool-generic-test
# Generate tool without specifying type (should default to Vue)
../openc3.sh cli generate tool 'Generic Tool' --ruby
# Verify tool structure (should be Vue.js)
test -f package.json
test -f vite.config.js
# Verify it's a Vue project by checking for Vue dependencies
grep -q "vue" package.json
# Build plugin (skip --frozen-lockfile for fresh plugins, keep --ignore-scripts)
pnpm install --ignore-scripts
rake build VERSION=1.0.0
# Verify build output (should be in tools/generictool/)
test -f tools/generictool/main.js
# Validate gem
../openc3.sh cli validate openc3-cosmos-tool-generic-test-1.0.0.gem
cd ..
- name: openc3.sh stop
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
./openc3.sh stop
sleep 20s
! docker ps | grep openc3
- name: Cleanup volumes
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
docker volume ls | grep openc3
./openc3.sh cleanup force
! docker volume ls | grep openc3