Skip to content

Examples

Runnable examples live in the lexicon’s examples/ directory. Clone the repo and try them:

Terminal window
cd examples/getting-started
npm install
chant build # produces .github/workflows/ci.yml
chant lint # runs lint rules
npx vitest run # run the tests

examples/getting-started/ — a CI workflow with build and test steps for a Node.js project.

src/
└── ci.ts # Workflow + Job definitions
ci.ts
import { Workflow, Job, Step, Checkout, SetupNode } from "@intentius/chant-lexicon-github";
export const workflow = new Workflow({
name: "CI",
on: {
push: { branches: ["main"] },
pull_request: { branches: ["main"] },
},
permissions: { contents: "read" },
});
export const build = new Job({
"runs-on": "ubuntu-latest",
timeoutMinutes: 15,
steps: [
Checkout({}).step,
SetupNode({ nodeVersion: "22", cache: "npm" }).step,
new Step({ name: "Install", run: "npm ci" }),
new Step({ name: "Build", run: "npm run build" }),
new Step({ name: "Test", run: "npm test" }),
],
});

chant build produces .github/workflows/ci.yml:

name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: npm
- name: Install
run: npm ci
- name: Build
run: npm run build
- name: Test
run: npm test

Patterns demonstrated:

  1. Typed compositesCheckout({}) and SetupNode({...}) instead of raw uses: strings
  2. Permissions — explicit contents: read following least-privilege
  3. TimeouttimeoutMinutes: 15 prevents runaway jobs
  4. Trigger scoping — push and PR on main only