|
| 1 | +# This workflow uses actions that are not certified by GitHub. |
| 2 | +# They are provided by a third-party and are governed by |
| 3 | +# separate terms of service, privacy policy, and support |
| 4 | +# documentation. |
| 5 | + |
| 6 | +name: Frontend Generator Tests |
| 7 | + |
| 8 | +# Only run on a push to main to avoid running for all the dependabot PRs |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + pull_request: |
| 14 | + branches: |
| 15 | + - "**" |
| 16 | + |
| 17 | +env: |
| 18 | + OPENC3_API_PASSWORD: password |
| 19 | + |
| 20 | +jobs: |
| 21 | + frontend-generators: |
| 22 | + if: ${{ github.actor != 'dependabot[bot]' }} |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v5 |
| 26 | + - name: Set up Node.js |
| 27 | + uses: actions/setup-node@v4 |
| 28 | + with: |
| 29 | + node-version: '20' |
| 30 | + - name: Install pnpm |
| 31 | + uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4 |
| 32 | + with: |
| 33 | + version: 9 |
| 34 | + - name: openc3.sh build |
| 35 | + # This `shell` line is required to get around a known issue: https://github.com/actions/runner/issues/241#issuecomment-745902718 |
| 36 | + shell: 'script -q -e -c "bash {0}"' |
| 37 | + run: ./openc3.sh build |
| 38 | + - name: openc3.sh run |
| 39 | + shell: 'script -q -e -c "bash {0}"' |
| 40 | + run: | |
| 41 | + set -e |
| 42 | + ! docker ps | grep openc3 |
| 43 | + ./openc3.sh run |
| 44 | + sleep 10s |
| 45 | + docker ps | grep openc3 |
| 46 | +
|
| 47 | + # Test Vue.js tool generation and build |
| 48 | + - name: Generate and build Vue.js tool |
| 49 | + shell: 'script -q -e -c "bash {0}"' |
| 50 | + run: | |
| 51 | + set -e |
| 52 | + # Generate plugin |
| 53 | + ./openc3.sh cli generate plugin tool-vue-test --ruby |
| 54 | + cd openc3-cosmos-tool-vue-test |
| 55 | + # Generate Vue tool |
| 56 | + ../openc3.sh cli generate tool_vue 'Test Vue Tool' --ruby |
| 57 | + # Verify tool structure created |
| 58 | + test -f package.json |
| 59 | + test -f vite.config.js |
| 60 | + test -f src/App.vue |
| 61 | + test -d src/tools/testvuetool |
| 62 | + test -f src/tools/testvuetool/testvuetool.vue |
| 63 | + # Verify tool was added to plugin.txt |
| 64 | + grep -q 'TOOL testvuetool "Test Vue Tool"' plugin.txt |
| 65 | + grep -q 'INLINE_URL main.js' plugin.txt |
| 66 | + # Verify package.json has required scripts |
| 67 | + grep -q '"build"' package.json |
| 68 | + grep -q '"serve"' package.json |
| 69 | + # Build plugin (skip --frozen-lockfile for fresh plugins, keep --ignore-scripts) |
| 70 | + pnpm install --ignore-scripts |
| 71 | + rake build VERSION=1.0.0 |
| 72 | + # Verify build output (Vue builds to tools/testvuetool/ directory) |
| 73 | + test -f tools/testvuetool/main.js |
| 74 | + # Verify output is a SystemJS module |
| 75 | + grep -q "System.register" tools/testvuetool/main.js |
| 76 | + # Validate gem |
| 77 | + ../openc3.sh cli validate openc3-cosmos-tool-vue-test-1.0.0.gem |
| 78 | + cd .. |
| 79 | +
|
| 80 | + # Test Angular tool generation and build |
| 81 | + - name: Generate and build Angular tool |
| 82 | + shell: 'script -q -e -c "bash {0}"' |
| 83 | + run: | |
| 84 | + set -e |
| 85 | + # Generate plugin |
| 86 | + ./openc3.sh cli generate plugin tool-angular-test --ruby |
| 87 | + cd openc3-cosmos-tool-angular-test |
| 88 | + # Generate Angular tool |
| 89 | + ../openc3.sh cli generate tool_angular 'Test Angular Tool' --ruby |
| 90 | + # Verify tool structure created |
| 91 | + test -f package.json |
| 92 | + test -f angular.json |
| 93 | + test -f src/main.single-spa.ts |
| 94 | + # Verify tool was added to plugin.txt |
| 95 | + grep -q 'TOOL testangulartool "Test Angular Tool"' plugin.txt |
| 96 | + grep -q 'INLINE_URL main.js' plugin.txt |
| 97 | + # Verify package.json has required scripts |
| 98 | + grep -q '"build"' package.json |
| 99 | + # Build plugin (skip --frozen-lockfile for fresh plugins, keep --ignore-scripts) |
| 100 | + pnpm install --ignore-scripts |
| 101 | + rake build VERSION=1.0.0 |
| 102 | + # Verify build output (Angular builds to tools/testangulartool/) |
| 103 | + test -f tools/testangulartool/main.js |
| 104 | + # Verify output is a SystemJS module |
| 105 | + grep -q "System.register" tools/testangulartool/main.js |
| 106 | + # Validate gem |
| 107 | + ../openc3.sh cli validate openc3-cosmos-tool-angular-test-1.0.0.gem |
| 108 | + cd .. |
| 109 | +
|
| 110 | + # Test React tool generation and build |
| 111 | + - name: Generate and build React tool |
| 112 | + shell: 'script -q -e -c "bash {0}"' |
| 113 | + run: | |
| 114 | + set -e |
| 115 | + # Generate plugin |
| 116 | + ./openc3.sh cli generate plugin tool-react-test --ruby |
| 117 | + cd openc3-cosmos-tool-react-test |
| 118 | + # Generate React tool |
| 119 | + ../openc3.sh cli generate tool_react 'Test React Tool' --ruby |
| 120 | + # Verify tool structure created |
| 121 | + test -f package.json |
| 122 | + test -f webpack.config.js |
| 123 | + test -f src/root.component.js |
| 124 | + # Verify tool was added to plugin.txt |
| 125 | + grep -q 'TOOL testreacttool "Test React Tool"' plugin.txt |
| 126 | + grep -q 'INLINE_URL main.js' plugin.txt |
| 127 | + # Verify package.json has required scripts |
| 128 | + grep -q '"build"' package.json |
| 129 | + # Build plugin (skip --frozen-lockfile for fresh plugins, keep --ignore-scripts) |
| 130 | + pnpm install --ignore-scripts |
| 131 | + rake build VERSION=1.0.0 |
| 132 | + # Verify build output (React builds to tools/testreacttool/) |
| 133 | + test -f tools/testreacttool/main.js |
| 134 | + # Verify output is a SystemJS module |
| 135 | + grep -q "System.register" tools/testreacttool/main.js |
| 136 | + # Validate gem |
| 137 | + ../openc3.sh cli validate openc3-cosmos-tool-react-test-1.0.0.gem |
| 138 | + cd .. |
| 139 | +
|
| 140 | + # Test Svelte tool generation and build |
| 141 | + - name: Generate and build Svelte tool |
| 142 | + shell: 'script -q -e -c "bash {0}"' |
| 143 | + run: | |
| 144 | + set -e |
| 145 | + # Generate plugin |
| 146 | + ./openc3.sh cli generate plugin tool-svelte-test --ruby |
| 147 | + cd openc3-cosmos-tool-svelte-test |
| 148 | + # Generate Svelte tool |
| 149 | + ../openc3.sh cli generate tool_svelte 'Test Svelte Tool' --ruby |
| 150 | + # Verify tool structure created |
| 151 | + test -f package.json |
| 152 | + test -f rollup.config.js |
| 153 | + test -f src/App.svelte |
| 154 | + # Verify tool was added to plugin.txt |
| 155 | + grep -q 'TOOL testsveltetool "Test Svelte Tool"' plugin.txt |
| 156 | + grep -q 'INLINE_URL main.js' plugin.txt |
| 157 | + # Verify package.json has required scripts |
| 158 | + grep -q '"build"' package.json |
| 159 | + # Build plugin (skip --frozen-lockfile for fresh plugins, keep --ignore-scripts) |
| 160 | + pnpm install --ignore-scripts |
| 161 | + rake build VERSION=1.0.0 |
| 162 | + # Verify build output (Svelte builds to tools/testsveltetool/) |
| 163 | + test -f tools/testsveltetool/main.js |
| 164 | + # Verify output is a SystemJS module |
| 165 | + grep -q "System.register" tools/testsveltetool/main.js |
| 166 | + # Validate gem |
| 167 | + ../openc3.sh cli validate openc3-cosmos-tool-svelte-test-1.0.0.gem |
| 168 | + cd .. |
| 169 | +
|
| 170 | + # Test widget generator |
| 171 | + - name: Generate and build widget |
| 172 | + shell: 'script -q -e -c "bash {0}"' |
| 173 | + run: | |
| 174 | + set -e |
| 175 | + # Generate plugin |
| 176 | + ./openc3.sh cli generate plugin widget-test --ruby |
| 177 | + cd openc3-cosmos-widget-test |
| 178 | + # Generate widget |
| 179 | + ../openc3.sh cli generate widget TestWidget --ruby |
| 180 | + # Verify widget structure created in src/ directory |
| 181 | + test -f src/TestWidget.vue |
| 182 | + test -f package.json |
| 183 | + test -f vite.config.js |
| 184 | + # Verify widget was added to plugin.txt with correct format |
| 185 | + grep -q "WIDGET Test" plugin.txt |
| 186 | + # Verify package.json has required scripts |
| 187 | + grep -q '"build"' package.json |
| 188 | + # Build plugin (skip --frozen-lockfile for fresh plugins, keep --ignore-scripts) |
| 189 | + pnpm install --ignore-scripts |
| 190 | + rake build VERSION=1.0.0 |
| 191 | + # Verify build output (widgets build to tools/widgets/TestWidget/) |
| 192 | + test -f tools/widgets/TestWidget/TestWidget.umd.min.js |
| 193 | + # Validate gem |
| 194 | + ../openc3.sh cli validate openc3-cosmos-widget-test-1.0.0.gem |
| 195 | + cd .. |
| 196 | +
|
| 197 | + # Test command_validator generator |
| 198 | + - name: Generate command validator |
| 199 | + shell: 'script -q -e -c "bash {0}"' |
| 200 | + run: | |
| 201 | + set -e |
| 202 | + # Generate plugin |
| 203 | + ./openc3.sh cli generate plugin validator-test --ruby |
| 204 | + cd openc3-cosmos-validator-test |
| 205 | + # Generate target first (required for command_validator) |
| 206 | + ../openc3.sh cli generate target EXAMPLE --ruby |
| 207 | + # Generate command_validator |
| 208 | + ../openc3.sh cli generate command_validator EXAMPLE test --ruby |
| 209 | + # Verify command_validator file created |
| 210 | + ls targets/EXAMPLE/lib | grep test_command_validator.rb |
| 211 | + # Build plugin using documented workflow for non-tool plugins (README line 13) |
| 212 | + ../openc3.sh cli rake build VERSION=1.0.0 |
| 213 | + ../openc3.sh cli validate openc3-cosmos-validator-test-1.0.0.gem |
| 214 | + cd .. |
| 215 | +
|
| 216 | + # Test generic tool command (should default to Vue) |
| 217 | + - name: Test generic tool command |
| 218 | + shell: 'script -q -e -c "bash {0}"' |
| 219 | + run: | |
| 220 | + set -e |
| 221 | + # Generate plugin |
| 222 | + ./openc3.sh cli generate plugin tool-generic-test --ruby |
| 223 | + cd openc3-cosmos-tool-generic-test |
| 224 | + # Generate tool without specifying type (should default to Vue) |
| 225 | + ../openc3.sh cli generate tool 'Generic Tool' --ruby |
| 226 | + # Verify tool structure (should be Vue.js) |
| 227 | + test -f package.json |
| 228 | + test -f vite.config.js |
| 229 | + # Verify it's a Vue project by checking for Vue dependencies |
| 230 | + grep -q "vue" package.json |
| 231 | + # Build plugin (skip --frozen-lockfile for fresh plugins, keep --ignore-scripts) |
| 232 | + pnpm install --ignore-scripts |
| 233 | + rake build VERSION=1.0.0 |
| 234 | + # Verify build output (should be in tools/generictool/) |
| 235 | + test -f tools/generictool/main.js |
| 236 | + # Validate gem |
| 237 | + ../openc3.sh cli validate openc3-cosmos-tool-generic-test-1.0.0.gem |
| 238 | + cd .. |
| 239 | +
|
| 240 | + - name: openc3.sh stop |
| 241 | + shell: 'script -q -e -c "bash {0}"' |
| 242 | + run: | |
| 243 | + set -e |
| 244 | + ./openc3.sh stop |
| 245 | + sleep 20s |
| 246 | + ! docker ps | grep openc3 |
| 247 | +
|
| 248 | + - name: Cleanup volumes |
| 249 | + shell: 'script -q -e -c "bash {0}"' |
| 250 | + run: | |
| 251 | + set -e |
| 252 | + docker volume ls | grep openc3 |
| 253 | + ./openc3.sh cleanup force |
| 254 | + ! docker volume ls | grep openc3 |
0 commit comments