Skip to content
Merged
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
2 changes: 1 addition & 1 deletion lexicons/github/docs/src/content/docs/composites.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const download = DownloadArtifact({
});

// Combine composites in a job
export const build = new Job({
export const combinedJob = new Job({
"runs-on": "ubuntu-latest",
steps: [
checkout.step,
Expand Down
2 changes: 1 addition & 1 deletion lexicons/github/docs/src/content/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const workflow = new Workflow({
permissions: { contents: "read" },
});

export const build = new Job({
export const buildJob = new Job({
"runs-on": "ubuntu-latest",
timeoutMinutes: 15,
steps: [
Expand Down
2 changes: 1 addition & 1 deletion lexicons/github/docs/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const workflow = new Workflow({
permissions: { contents: "read" },
});

export const build = new Job({
export const buildJob = new Job({
"runs-on": "ubuntu-latest",
timeoutMinutes: 15,
steps: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const download = DownloadArtifact({
});

// Combine composites in a job
export const build = new Job({
export const combinedJob = new Job({
"runs-on": "ubuntu-latest",
steps: [
checkout.step,
Expand Down
2 changes: 1 addition & 1 deletion lexicons/github/examples/docs-snippets/src/quickstart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const workflow = new Workflow({
permissions: { contents: "read" },
});

export const build = new Job({
export const buildJob = new Job({
"runs-on": "ubuntu-latest",
timeoutMinutes: 15,
steps: [
Expand Down
2 changes: 1 addition & 1 deletion lexicons/github/examples/examples.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describeAllExamples(
expect(output).toContain("GITHUB_OUTPUT");
},
},
"docs-snippets": { skipLint: true, skipBuild: true },
"docs-snippets": { skipLint: true },
"reusable-workflow": {
skipLint: true,
checks: (output) => {
Expand Down
6 changes: 2 additions & 4 deletions lexicons/github/src/composites/cache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Composite, mergeDefaults } from "@intentius/chant";
import type { Step } from "../generated/index";
import { Step } from "../generated/index";

export interface CacheActionProps {
path: string;
Expand All @@ -18,9 +18,7 @@ export const CacheAction = Composite<CacheActionProps>((props) => {
};
if (props.restoreKeys !== undefined) withObj["restore-keys"] = props.restoreKeys.join("\n");

const { createProperty } = require("@intentius/chant/runtime");
const StepClass = createProperty("GitHub::Actions::Step", "github");
const step = new StepClass(mergeDefaults({
const step = new Step(mergeDefaults({
name: "Cache",
uses: "actions/cache@v4",
with: withObj,
Expand Down
7 changes: 2 additions & 5 deletions lexicons/github/src/composites/checkout.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Composite, mergeDefaults } from "@intentius/chant";
import type { Step } from "../generated/index";
import { Step } from "../generated/index";

export interface CheckoutProps {
ref?: string;
Expand All @@ -23,10 +23,7 @@ export const Checkout = Composite<CheckoutProps>((props) => {
if (props.submodules !== undefined) withObj.submodules = String(props.submodules);
if (props.sshKey !== undefined) withObj["ssh-key"] = props.sshKey;

// Import Step lazily to avoid circular dependency at module load time
const { createProperty } = require("@intentius/chant/runtime");
const StepClass = createProperty("GitHub::Actions::Step", "github");
const step = new StepClass(mergeDefaults({
const step = new Step(mergeDefaults({
name: "Checkout",
uses: "actions/checkout@v4",
...(Object.keys(withObj).length > 0 ? { with: withObj } : {}),
Expand Down
18 changes: 7 additions & 11 deletions lexicons/github/src/composites/deploy-environment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Composite, mergeDefaults } from "@intentius/chant";
import type { Job } from "../generated/index";
import { Job, Step } from "../generated/index";

export interface DeployEnvironmentProps {
/** Environment name. Required. */
Expand Down Expand Up @@ -38,15 +38,11 @@ export const DeployEnvironment = Composite<DeployEnvironmentProps>((props) => {
const deployScriptArr = Array.isArray(deployScript) ? deployScript : [deployScript];
const cleanupScriptArr = Array.isArray(cleanupScript) ? cleanupScript : [cleanupScript];

const { createProperty, createResource } = require("@intentius/chant/runtime");
const StepClass = createProperty("GitHub::Actions::Step", "github");
const JobClass = createResource("GitHub::Actions::Job", "github", {});

// ── Deploy job ─────────────────────────────────────────────────────
const deploySteps = [
new StepClass({ name: "Checkout", uses: "actions/checkout@v4" }),
new Step({ name: "Checkout", uses: "actions/checkout@v4" }),
...deployScriptArr.map(
(cmd: string) => new StepClass({ name: "Deploy", run: cmd }),
(cmd: string) => new Step({ name: "Deploy", run: cmd }),
),
];

Expand All @@ -55,7 +51,7 @@ export const DeployEnvironment = Composite<DeployEnvironmentProps>((props) => {
environment.url = url;
}

const deployJob = new JobClass(mergeDefaults({
const deployJob = new Job(mergeDefaults({
"runs-on": runsOn,
environment,
concurrency: {
Expand All @@ -67,13 +63,13 @@ export const DeployEnvironment = Composite<DeployEnvironmentProps>((props) => {

// ── Cleanup job ────────────────────────────────────────────────────
const cleanupSteps = [
new StepClass({ name: "Checkout", uses: "actions/checkout@v4" }),
new Step({ name: "Checkout", uses: "actions/checkout@v4" }),
...cleanupScriptArr.map(
(cmd: string) => new StepClass({ name: "Cleanup", run: cmd }),
(cmd: string) => new Step({ name: "Cleanup", run: cmd }),
),
];

const cleanupJob = new JobClass(mergeDefaults({
const cleanupJob = new Job(mergeDefaults({
"runs-on": runsOn,
environment: { name },
steps: cleanupSteps,
Expand Down
21 changes: 8 additions & 13 deletions lexicons/github/src/composites/docker-build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Composite, mergeDefaults } from "@intentius/chant";
import type { Job, Workflow } from "../generated/index";
import { Job, Step, Workflow } from "../generated/index";

export interface DockerBuildProps {
/** Image tag. Default: "${{ github.sha }}" */
Expand Down Expand Up @@ -43,15 +43,10 @@ export const DockerBuild = Composite<DockerBuildProps>((props) => {
defaults,
} = props;

const { createProperty, createResource } = require("@intentius/chant/runtime");
const StepClass = createProperty("GitHub::Actions::Step", "github");
const JobClass = createResource("GitHub::Actions::Job", "github", {});
const WorkflowClass = createResource("GitHub::Actions::Workflow", "github", {});

// ── Steps ──────────────────────────────────────────────────────────
const checkout = new StepClass({ name: "Checkout", uses: "actions/checkout@v4" });
const checkout = new Step({ name: "Checkout", uses: "actions/checkout@v4" });

const login = new StepClass({
const login = new Step({
name: "Log in to container registry",
uses: "docker/login-action@v3",
with: {
Expand All @@ -61,7 +56,7 @@ export const DockerBuild = Composite<DockerBuildProps>((props) => {
},
});

const setupBuildx = new StepClass({
const setupBuildx = new Step({
name: "Set up Docker Buildx",
uses: "docker/setup-buildx-action@v3",
});
Expand All @@ -72,7 +67,7 @@ export const DockerBuild = Composite<DockerBuildProps>((props) => {
tags.push(`${imageName}:latest`);
}

const metadata = new StepClass({
const metadata = new Step({
name: "Extract metadata",
id: "meta",
uses: "docker/metadata-action@v5",
Expand Down Expand Up @@ -100,18 +95,18 @@ export const DockerBuild = Composite<DockerBuildProps>((props) => {
.join("\n");
}

const buildPush = new StepClass({
const buildPush = new Step({
name: "Build and push",
uses: "docker/build-push-action@v6",
with: buildPushWith,
});

const job = new JobClass(mergeDefaults({
const job = new Job(mergeDefaults({
"runs-on": runsOn,
steps: [checkout, login, setupBuildx, metadata, buildPush],
}, defaults?.job));

const workflow = new WorkflowClass(mergeDefaults({
const workflow = new Workflow(mergeDefaults({
name: "Docker Build",
on: {
push: { branches: ["main"] },
Expand Down
6 changes: 2 additions & 4 deletions lexicons/github/src/composites/download-artifact.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Composite, mergeDefaults } from "@intentius/chant";
import type { Step } from "../generated/index";
import { Step } from "../generated/index";

export interface DownloadArtifactProps {
name?: string;
Expand All @@ -17,9 +17,7 @@ export const DownloadArtifact = Composite<DownloadArtifactProps>((props) => {
if (props.path !== undefined) withObj.path = props.path;
if (props.mergeMultiple !== undefined) withObj["merge-multiple"] = String(props.mergeMultiple);

const { createProperty } = require("@intentius/chant/runtime");
const StepClass = createProperty("GitHub::Actions::Step", "github");
const step = new StepClass(mergeDefaults({
const step = new Step(mergeDefaults({
name: "Download Artifact",
uses: "actions/download-artifact@v4",
...(Object.keys(withObj).length > 0 ? { with: withObj } : {}),
Expand Down
33 changes: 14 additions & 19 deletions lexicons/github/src/composites/go-ci.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Composite, mergeDefaults } from "@intentius/chant";
import type { Job, Workflow } from "../generated/index";
import { Job, Step, Workflow } from "../generated/index";

export interface GoCIProps {
/** Go version. Default: "1.22" */
Expand Down Expand Up @@ -30,52 +30,47 @@ export const GoCI = Composite<GoCIProps>((props) => {
defaults,
} = props;

const { createProperty, createResource } = require("@intentius/chant/runtime");
const StepClass = createProperty("GitHub::Actions::Step", "github");
const JobClass = createResource("GitHub::Actions::Job", "github", {});
const WorkflowClass = createResource("GitHub::Actions::Workflow", "github", {});

// ── Build job ──────────────────────────────────────────────────────
const buildJob = new JobClass(mergeDefaults({
const buildJob = new Job(mergeDefaults({
"runs-on": runsOn,
steps: [
new StepClass({ name: "Checkout", uses: "actions/checkout@v4" }),
new StepClass({
new Step({ name: "Checkout", uses: "actions/checkout@v4" }),
new Step({
name: "Setup Go",
uses: "actions/setup-go@v5",
with: { "go-version": goVersion },
}),
new StepClass({ name: "Build", run: buildCommand }),
new Step({ name: "Build", run: buildCommand }),
],
}, defaults?.buildJob));

// ── Test job ───────────────────────────────────────────────────────
const testJob = new JobClass(mergeDefaults({
const testJob = new Job(mergeDefaults({
"runs-on": runsOn,
steps: [
new StepClass({ name: "Checkout", uses: "actions/checkout@v4" }),
new StepClass({
new Step({ name: "Checkout", uses: "actions/checkout@v4" }),
new Step({
name: "Setup Go",
uses: "actions/setup-go@v5",
with: { "go-version": goVersion },
}),
new StepClass({ name: "Test", run: testCommand }),
new Step({ name: "Test", run: testCommand }),
],
}, defaults?.testJob));

// ── Lint job (optional) ────────────────────────────────────────────
const lintJob =
lintCommand !== null
? new JobClass(mergeDefaults({
? new Job(mergeDefaults({
"runs-on": runsOn,
steps: [
new StepClass({ name: "Checkout", uses: "actions/checkout@v4" }),
new StepClass({
new Step({ name: "Checkout", uses: "actions/checkout@v4" }),
new Step({
name: "Setup Go",
uses: "actions/setup-go@v5",
with: { "go-version": goVersion },
}),
new StepClass({
new Step({
name: "Lint",
uses: "golangci/golangci-lint-action@v6",
with: { args: lintCommand },
Expand All @@ -84,7 +79,7 @@ export const GoCI = Composite<GoCIProps>((props) => {
}, defaults?.lintJob))
: undefined;

const workflow = new WorkflowClass(mergeDefaults({
const workflow = new Workflow(mergeDefaults({
name: "Go CI",
on: {
push: { branches: ["main"] },
Expand Down
21 changes: 8 additions & 13 deletions lexicons/github/src/composites/node-ci.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Composite, mergeDefaults } from "@intentius/chant";
import type { Job, Workflow } from "../generated/index";
import { Job, Step, Workflow } from "../generated/index";

export interface NodeCIProps {
nodeVersion?: string;
Expand All @@ -26,17 +26,12 @@ export const NodeCI = Composite<NodeCIProps>((props) => {
const install = installCommand ?? (packageManager === "npm" ? "npm ci" : `${packageManager} install`);
const run = packageManager === "npm" ? "npm run" : packageManager;

const { createProperty, createResource } = require("@intentius/chant/runtime");
const StepClass = createProperty("GitHub::Actions::Step", "github");
const JobClass = createResource("GitHub::Actions::Job", "github", {});
const WorkflowClass = createResource("GitHub::Actions::Workflow", "github", {});

const checkoutStep = new StepClass({
const checkoutStep = new Step({
name: "Checkout",
uses: "actions/checkout@v4",
});

const setupNodeStep = new StepClass({
const setupNodeStep = new Step({
name: "Setup Node.js",
uses: "actions/setup-node@v4",
with: {
Expand All @@ -45,27 +40,27 @@ export const NodeCI = Composite<NodeCIProps>((props) => {
},
});

const installStep = new StepClass({
const installStep = new Step({
name: "Install dependencies",
run: install,
});

const buildStep = new StepClass({
const buildStep = new Step({
name: "Build",
run: `${run} ${buildScript}`,
});

const testStep = new StepClass({
const testStep = new Step({
name: "Test",
run: `${run} ${testScript}`,
});

const job = new JobClass(mergeDefaults({
const job = new Job(mergeDefaults({
"runs-on": "ubuntu-latest",
steps: [checkoutStep, setupNodeStep, installStep, buildStep, testStep],
}, defaults?.job));

const workflow = new WorkflowClass(mergeDefaults({
const workflow = new Workflow(mergeDefaults({
name: "CI",
on: {
push: { branches: ["main"] },
Expand Down
Loading
Loading