diff --git a/openc3/templates/plugin/.github/workflows/playwright.yml b/openc3/templates/plugin/.github/workflows/playwright.yml new file mode 100644 index 0000000000..4ee77789cd --- /dev/null +++ b/openc3/templates/plugin/.github/workflows/playwright.yml @@ -0,0 +1,62 @@ +# Builds this plugin and installs it into a real COSMOS with Playwright. +# +# Runs the most recent COSMOS Core release in Docker, builds the plugin gem, and +# drives the Admin tool the way an operator would: Install From File, submit the +# variables dialog, and wait for the install to report Complete. That catches +# what unit tests can't - a plugin.txt that doesn't parse, a target that doesn't +# build, a microservice that won't start. +# +# Nothing here needs configuring as the plugin grows. Tool pages are discovered +# from the COSMOS API after install and checked for browser console errors, and +# a frontend is built with pnpm whenever the plugin has a package.json, so +# `cli generate tool` and `cli generate widget` are covered with no edit here. +# +# Runs on every commit and once a week. The weekly run is what catches a new +# COSMOS release breaking this plugin. Note that GitHub disables scheduled +# workflows in a repo with no activity for 60 days. + +name: Playwright + +on: + push: + branches: [main] + pull_request: + branches: ["**"] + # Off the hour because scheduled runs at :00 get queued behind everyone else's + schedule: + - cron: '27 7 * * 1' + workflow_dispatch: + inputs: + cosmos_version: + description: 'COSMOS version to run, or latest' + required: false + type: string + default: 'latest' + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + # Superseding a pull request run is fine, but a scheduled run and a push to + # main share a ref, so cancelling on those would have them kill each other + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + playwright: + uses: OpenC3/.github/.github/workflows/plugin-playwright-reusable.yml@main + with: + plugin_directory: . + cosmos_version: ${{ inputs.cosmos_version || 'latest' }} + # Once you have added targets with `cli generate target`, list them here + # and the install is checked for them: + # expected_targets: MY_TARGET ANOTHER_TARGET + # + # install_demo: true # Uncomment if this plugin references INST/INST2 + # is_tool: true # Uncomment to require that this plugin registers a tool + # + # Tool pages are checked for browser console errors automatically. Add + # regexes here for errors to allow: + # console_ignore: | + # some third party gripe + # another known message diff --git a/openc3/templates/plugin/.github/workflows/release.yml b/openc3/templates/plugin/.github/workflows/release.yml new file mode 100644 index 0000000000..91205cbd89 --- /dev/null +++ b/openc3/templates/plugin/.github/workflows/release.yml @@ -0,0 +1,45 @@ +# Builds the gem, tags the commit, and creates a GitHub release. Run it by hand +# from the Actions tab and give it a version number. +# +# Both publish steps are off by default so a first release works with no setup +# at all. Tick the box in the run dialog when you are ready to publish, after +# adding the matching secret to the repo: +# +# Deploy to OpenC3 App Store -> OPENC3_API_TOKEN (your store account token) +# Publish the gem to RubyGems -> RUBYGEMS_API_KEY (your RubyGems API key) +# +# A tool or widget frontend needs nothing set here: once the plugin has a +# package.json it is built with pnpm before the gem is packaged. + +name: Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Version number' + required: true + type: string + deploy_to_store: + description: 'Deploy to OpenC3 App Store' + required: false + type: boolean + default: false + deploy_to_rubygems: + description: 'Publish the gem to RubyGems' + required: false + type: boolean + default: false + +jobs: + release: + uses: OpenC3/.github/.github/workflows/release-cosmos-plugin-reusable.yml@main + with: + version: ${{ inputs.version }} + deploy_to_store: ${{ inputs.deploy_to_store }} + deploy_to_rubygems: ${{ inputs.deploy_to_rubygems }} + plugin_directory: . + # is_tool: true # Uncomment to fail the release if package.json is missing + secrets: + OPENC3_API_TOKEN: ${{ secrets.OPENC3_API_TOKEN }} + RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} diff --git a/openc3/templates/plugin/.github/workflows/unit-tests.yml b/openc3/templates/plugin/.github/workflows/unit-tests.yml new file mode 100644 index 0000000000..528e1e6277 --- /dev/null +++ b/openc3/templates/plugin/.github/workflows/unit-tests.yml @@ -0,0 +1,34 @@ +# Runs this plugin's unit tests on every push and pull request. +# +# Python tests are discovered in tests/ or test/, Ruby specs in spec/ or specs/. +# Whichever this plugin doesn't have is skipped, so there is nothing to set up: +# add a test file and it starts running. A plugin with no tests at all passes +# with a warning until you set require_tests below. +# +# Dependencies are picked up automatically - requirements.txt for the code under +# test, /requirements.txt for test only ones, and a Gemfile for Ruby +# when there is one. + +name: Unit Tests + +on: + push: + branches: [main] + pull_request: + branches: ["**"] + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + unit-tests: + uses: OpenC3/.github/.github/workflows/plugin-unit-tests-reusable.yml@main + with: + plugin_directory: . + # python_version: '3.12' # Uncomment to pin a different Python + # ruby_version: '3.4' # Uncomment to pin a different Ruby + # require_tests: true # Uncomment to fail the build when there are no tests diff --git a/openc3/templates/plugin/README.md b/openc3/templates/plugin/README.md index 66d27ea11a..f88ebe3f86 100644 --- a/openc3/templates/plugin/README.md +++ b/openc3/templates/plugin/README.md @@ -39,6 +39,28 @@ docker run -it -v %cd%:/openc3/local -w /openc3/local docker.io/openc3inc/openc3 1. pnpm install --frozen-lockfile --ignore-scripts 1. rake build VERSION=1.0.0 +## Continuous integration + +`.github/workflows/` ships three GitHub Actions workflows that work as soon as +you push this plugin to GitHub. They call shared workflows from `OpenC3/.github`, +so the steps stay current without you updating anything here. + +- **Unit Tests** - on every push and pull request. Runs Python tests in `tests/` + or `test/` and Ruby specs in `spec/` or `specs/`. Whichever you don't have is + skipped, so just add a test file. +- **Playwright** - on every push and pull request, plus weekly. Builds the gem, + starts the latest COSMOS release in Docker, and installs the plugin through the + Admin tool, which catches a `plugin.txt` that doesn't parse, a target that + doesn't build, or a microservice that won't start. The weekly run is what tells + you a new COSMOS release broke this plugin. Once you add targets, list them in + `expected_targets` so the install is verified against them. +- **Release** - manual, from the Actions tab. Builds the gem, tags the commit and + creates a GitHub release. Publishing to the OpenC3 App Store and to RubyGems is + off until you add the matching secret and tick the box. + +Adding a tool or a widget needs no change to any of these. All three build a +frontend with pnpm as soon as the plugin has a `package.json`. + ## Installing into OpenC3 COSMOS 1. Go to the OpenC3 Admin Tool, Plugins Tab