Skip to content
/ actions Public

Custom Github Actions collection of helpers of common tasks

Notifications You must be signed in to change notification settings

Ensono/actions

Repository files navigation

Code Coverage

Ensono Github Actions

Collection of GHA custom actions.

Set up

The repo set up has been modified to suit the below setup. General overview/guidance on JS tasks can be found in this doc

Components:

  • Using Jest
  • Setting up as a monorepo with the ability to add multiple tasks
  • Use esbuild for bundling and generating a single deployable file
    • speeds up deployments
    • allows for multiple tasks within the same extension as there is a 50MB limit (bundled tasks is about 400kb) as opposed to 10MB+ depending on dependencies used.
  • pnpm
    • using workspaces also allows for easy lib sharing across different tasks - coupled with a bundler
    • workspace level dependency lock-file
  • Typescript 5.x

Install

In the root run the below:

Once we have these 2 installed we can use pnpm for everything, see the pnpm-workspace.yaml for details on how the workspace lookups are organised.

pnpm i

To run the tests in all the tasks

pnpm run test

To run the build of all the tasks

pnpm run build

Notes

Current tasks

  • process-json
  • taskctl-setup

Adding a Task

There are various components in adding a task to this extension.

A Task is a "small" program written in Typescript that expects an input, this input is defined in a task.json file and an output which is set as a result enum with an optional message from the task itself.

An Example is left in the .github/actions folder under .github/actions/playground-echo, inspection of that folder will provide a structure for all subsequent tasks.

Step 1

Firstly create a folder inside the root of the repo e.g. my-awesome-foo, this will be where your task lives.

mkdir -p my-awesome-foo && cd my-awesome-foo
pnpm init -y --scope=@ensono-actions --name=my-awesome-foo

This will generate a skeleton package.json which is required

Step 2

Create an action.yml

Step 3 - write the task

Using typescript and a src as dir for all TS + tests (either colocated or in a separate __tests__ directory as long as they are named *.test.ts)

copy over tsconfig.json/jest.config.js from playground-echo task, it will inherit all root level specs for both TS and Jest, with the ability to override.

Name your main file src/index.ts this should be minimal as all it needs to inlcude is the method call to your task. See existing tasks for examples of both sync and async actions.

Adding any dependencies should always be installed via pnpm i -D [email protected] --save-exact and as devDependencies as the bundler will only take what it needs, @SEMVER can be omitted if you use --save-exact.

Testing once published

See the .github/workflows/tester.yml for details on how to test it in YAML.

IF a task outputs a variable - there is a slightly different way to pick it up:

  • within the same job
  • across different jobs

About

Custom Github Actions collection of helpers of common tasks

Resources

Stars

Watchers

Forks

Packages

No packages published