No description
Find a file
Martin Pitt 51292fbc25 packit: Drop obsolete sandcastle hack
Since commit 9d4c08ff2a, SRPM builds happen in COPR, so we can drop the
sandcastle hack.

Also drop the duplicated `post-upstream-clone` key.
2022-06-07 17:09:25 +02:00
.fmf Add FMF test metadata and scripts 2021-03-04 11:25:53 +01:00
.github/workflows Move example COPR release to packit 2022-05-03 10:30:13 +02:00
packaging spec: move AppStream validation to %check 2022-05-12 16:43:56 +02:00
plans Add FMF test metadata and scripts 2021-03-04 11:25:53 +01:00
po po: Update German translations 2022-03-09 22:30:00 +01:00
src package.json: Drop core-js 2021-11-29 10:58:57 +01:00
test test: Bump Cockpit test API to 267, use --track-naughties option 2022-04-19 13:14:21 +02:00
.babelrc.json Move babel config into separate file 2021-04-09 09:46:56 +02:00
.cirrus.yml cirrus CI: Move to Fedora 35 2021-09-03 07:42:17 +02:00
.eslintignore Ignore src/lib for eslint 2021-04-09 09:46:56 +02:00
.eslintrc.json package.json: bump eslint to ^8.0.0 and all eslint-x dependencies 2022-04-11 07:56:29 +02:00
.gitignore po: merge translations for metainfo file 2022-03-09 16:02:26 +01:00
cockpituous-release Move example COPR release to packit 2022-05-03 10:30:13 +02:00
LICENSE Initial commit with a LICENSE and README 2017-06-14 18:19:15 +02:00
Makefile Pick up cockpit test API fix for Firefox 101 2022-06-06 20:53:36 +02:00
org.cockpit-project.starter-kit.metainfo.xml metainfo: add few more URLs/references 2022-04-04 17:08:17 +02:00
package.json package.json: Update @patternfly/patternfly, @patternfly/react-core 2022-06-06 08:22:58 +02:00
packit.yaml packit: Drop obsolete sandcastle hack 2022-06-07 17:09:25 +02:00
README.md Move example COPR release to packit 2022-05-03 10:30:13 +02:00
webpack.config.js webpack: Always regenerate and clean up dist/ 2022-04-21 15:26:00 +02:00

Cockpit Starter Kit

Scaffolding for a Cockpit module.

Getting and building the source

Make sure you have npm available (usually from your distribution package). These commands check out the source and build it into the dist/ directory:

git clone https://github.com/cockpit-project/starter-kit.git
cd starter-kit
make

Installing

make install compiles and installs the package in /usr/share/cockpit/. The convenience targets srpm and rpm build the source and binary rpms, respectively. Both of these make use of the dist target, which is used to generate the distribution tarball. In production mode, source files are automatically minified and compressed. Set NODE_ENV=production if you want to duplicate this behavior.

For development, you usually want to run your module straight out of the git tree. To do that, run make devel-install, which links your checkout to the location were cockpit-bridge looks for packages. If you prefer to do this manually:

mkdir -p ~/.local/share/cockpit
ln -s `pwd`/dist ~/.local/share/cockpit/starter-kit

After changing the code and running make again, reload the Cockpit page in your browser.

You can also use watch mode to automatically update the webpack on every code change with

$ npm run watch

or

$ make watch

When developing against a virtual machine, webpack can also automatically upload the code changes by setting the RSYNC environment variable to the remote hostname.

$ RSYNC=c make watch

To "uninstall" the locally installed version, run make devel-uninstall, or remove manually the symlink:

rm ~/.local/share/cockpit/starter-kit

Running eslint

Cockpit Starter Kit uses ESLint to automatically check JavaScript code style in .js and .jsx files.

The linter is executed within every build as a webpack preloader.

For developer convenience, the ESLint can be started explicitly by:

$ npm run eslint

Violations of some rules can be fixed automatically by:

$ npm run eslint:fix

Rules configuration can be found in the .eslintrc.json file.

Running tests locally

Run make check to build an RPM, install it into a standard Cockpit test VM (centos-8-stream by default), and run the test/check-application integration test on it. This uses Cockpit's Chrome DevTools Protocol based browser tests, through a Python API abstraction. Note that this API is not guaranteed to be stable, so if you run into failures and don't want to adjust tests, consider checking out Cockpit's test/common from a tag instead of main (see the test/common target in Makefile).

After the test VM is prepared, you can manually run the test without rebuilding the VM, possibly with extra options for tracing and halting on test failures (for interactive debugging):

TEST_OS=centos-8-stream test/check-application -tvs

It is possible to setup the test environment without running the tests:

TEST_OS=centos-8-stream make prepare-check

You can also run the test against a different Cockpit image, for example:

TEST_OS=fedora-34 make check

Running tests in CI

These tests can be run in Cirrus CI, on their free Linux Containers environment which explicitly supports /dev/kvm. Please see Quick Start how to set up Cirrus CI for your project after forking from starter-kit.

The included .cirrus.yml runs the integration tests for two operating systems (Fedora and CentOS 8). Note that if/once your project grows bigger, or gets frequent changes, you may need to move to a paid account, or different infrastructure with more capacity.

Tests also run in Packit for all currently supported Fedora releases; see the packit.yaml control file. You need to enable Packit-as-a-service in your GitHub project to use this. To run the tests in the exact same way for upstream pull requests and for Fedora package update gating, the tests are wrapped in the FMF metadata format for using with the tmt test management tool. Note that Packit tests can not run their own virtual machine images, thus they only run @nondestructive tests.

Customizing

After cloning the Starter Kit you should rename the files, package names, and labels to your own project's name. Use these commands to find out what to change:

find -iname '*starter*'
git grep -i starter

Automated release

Once your cloned project is ready for a release, you should consider automating that. Cockpituous release and Packit aim to fully automate project releases to GitHub, Fedora, Ubuntu, COPR, Docker Hub, and other places. The intention is that the only manual step for releasing a project is to create a signed tag for the version number; pushing the tag then triggers a GitHub action that calls a set of release scripts.

starter-kit includes an example cockpitous release script

and a packit.yaml control file with detailed comments how to use it. There is also an example GitHub release action to set up secrets and run cockpituous.

Automated maintenance

It is important to keep your NPM modules up to date, to keep up with security updates and bug fixes. This is done with the npm-update bot script which is run weekly or upon manual request through the npm-update.yml GitHub action.

Further reading