Skip to content
Open
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
62 changes: 62 additions & 0 deletions openc3/templates/plugin/.github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -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
45 changes: 45 additions & 0 deletions openc3/templates/plugin/.github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have this: https://github.com/OpenC3/.github/blob/main/workflow-templates/release-cosmos-plugin.yml. I'd rather you make the changes there than add a new workflow.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now that these are separate things but I would still like for them to be somehow unified.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmthomas I'm not sure how they would be more unified -- this is "include a GitHub workflow in any generated plugin that will automatically use the OpenC3-provided release workflow"


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 }}
34 changes: 34 additions & 0 deletions openc3/templates/plugin/.github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -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, <test dir>/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
22 changes: 22 additions & 0 deletions openc3/templates/plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading