Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
254 changes: 254 additions & 0 deletions .github/workflows/tool.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

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:
- "**"

env:
OPENC3_API_PASSWORD: password

jobs:
frontend-generators:
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
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
14 changes: 8 additions & 6 deletions openc3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,12 @@ case $1 in
# mapped as volume (-v) /openc3/local and container working directory (-w) also set to /openc3/local.
# This allows tools running in the container to have a consistent path to the current working directory.
# Run the command "ruby /openc3/bin/openc3cli" with all parameters starting at 2 since the first is 'openc3'
args=`echo $@ | { read _ args; echo $args; }`
# Shift off the first argument (script name) to get CLI args
shift
if [ "$OPENC3_ENTERPRISE" -eq 1 ]; then
${DOCKER_COMPOSE_COMMAND} -f "$(dirname -- "$0")/compose.yaml" run -it --rm -v `pwd`:/openc3/local:z -w /openc3/local -e OPENC3_API_USER=$OPENC3_API_USER -e OPENC3_API_PASSWORD=$OPENC3_API_PASSWORD --no-deps openc3-cosmos-cmd-tlm-api ruby /openc3/bin/openc3cli $args
${DOCKER_COMPOSE_COMMAND} -f "$(dirname -- "$0")/compose.yaml" run -it --rm -v `pwd`:/openc3/local:z -w /openc3/local -e OPENC3_API_USER=$OPENC3_API_USER -e OPENC3_API_PASSWORD=$OPENC3_API_PASSWORD --no-deps openc3-cosmos-cmd-tlm-api ruby /openc3/bin/openc3cli "$@"
else
${DOCKER_COMPOSE_COMMAND} -f "$(dirname -- "$0")/compose.yaml" run -it --rm -v `pwd`:/openc3/local:z -w /openc3/local -e OPENC3_API_PASSWORD=$OPENC3_API_PASSWORD --no-deps openc3-cosmos-cmd-tlm-api ruby /openc3/bin/openc3cli $args
${DOCKER_COMPOSE_COMMAND} -f "$(dirname -- "$0")/compose.yaml" run -it --rm -v `pwd`:/openc3/local:z -w /openc3/local -e OPENC3_API_PASSWORD=$OPENC3_API_PASSWORD --no-deps openc3-cosmos-cmd-tlm-api ruby /openc3/bin/openc3cli "$@"
fi
set +a
;;
Expand Down Expand Up @@ -309,11 +310,12 @@ case $1 in
set -a
. "$(dirname -- "$0")/.env"
# Same as cli but run as root user
args=`echo $@ | { read _ args; echo $args; }`
# Shift off the first argument (script name) to get CLI args
shift
if [ "$OPENC3_ENTERPRISE" -eq 1 ]; then
${DOCKER_COMPOSE_COMMAND} -f "$(dirname -- "$0")/compose.yaml" run -it --rm --user=root -v `pwd`:/openc3/local:z -w /openc3/local -e OPENC3_API_USER=$OPENC3_API_USER -e OPENC3_API_PASSWORD=$OPENC3_API_PASSWORD --no-deps openc3-cosmos-cmd-tlm-api ruby /openc3/bin/openc3cli $args
${DOCKER_COMPOSE_COMMAND} -f "$(dirname -- "$0")/compose.yaml" run -it --rm --user=root -v `pwd`:/openc3/local:z -w /openc3/local -e OPENC3_API_USER=$OPENC3_API_USER -e OPENC3_API_PASSWORD=$OPENC3_API_PASSWORD --no-deps openc3-cosmos-cmd-tlm-api ruby /openc3/bin/openc3cli "$@"
else
${DOCKER_COMPOSE_COMMAND} -f "$(dirname -- "$0")/compose.yaml" run -it --rm --user=root -v `pwd`:/openc3/local:z -w /openc3/local -e OPENC3_API_PASSWORD=$OPENC3_API_PASSWORD --no-deps openc3-cosmos-cmd-tlm-api ruby /openc3/bin/openc3cli $args
${DOCKER_COMPOSE_COMMAND} -f "$(dirname -- "$0")/compose.yaml" run -it --rm --user=root -v `pwd`:/openc3/local:z -w /openc3/local -e OPENC3_API_PASSWORD=$OPENC3_API_PASSWORD --no-deps openc3-cosmos-cmd-tlm-api ruby /openc3/bin/openc3cli "$@"
fi
set +a
;;
Expand Down
Loading
Loading