Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
claude/adoring-hopper-5x74bqclaude/affectionate-feynman-ykrf1hclaude/architecture-audit-design-wxprenclaude/build-status-update-3MXsfclaude/charming-meitner-mllb5rclaude/compare-gate-gluecron-s4mFQclaude/confident-faraday-tikcwbclaude/continue-work-XMTlIclaude/crontech-gluecron-deploy-7MIECclaude/crontech-platform-setup-SeKfwclaude/design-2026claude/ecstatic-ptolemy-jMdigclaude/enhance-github-integration-QNHdGclaude/fix-aa-loop-issue-PonMQclaude/fix-actions-and-processclaude/fix-desktop-errors-XqoW8claude/fix-red-workflowsclaude/fix-website-access-6FKJNclaude/gatetest-integration-hardeningclaude/github-audit-improvements-bDFr9claude/gluecron-launch-status-FoMRlclaude/hopeful-lamport-olfCTclaude/issue-to-pr-and-protectionsclaude/jolly-heisenberg-2sg1Qclaude/launch-preparation-QmTb6claude/new-session-xk1l7claude/plan-platform-architecture-kkN4yclaude/platform-analysis-roadmap-1nUGLclaude/platform-launch-assessment-8dWV8claude/polish-platform-release-AeDrUclaude/resume-previous-work-KzyLwclaude/review-crontech-handoff-qYEVqclaude/review-project-completeness-lHhS2claude/review-readme-docs-ulqPKclaude/serene-edison-rj87weclaude/setup-multi-repo-dev-BCwNQclaude/ship-fixes-and-tests-Jvz1cclaude/site-audit-competitive-pctlwgclaude/site-migration-vercel-XstpKclaude/standalone-product-repos-XHFTDcopilot/feat-smart-empty-states-keyboard-first-enhancementcopilot/feat-smart-morning-digest-review-context-restorecopilot/fix-and-process-workflowscopilot/update-ai-powered-code-reviewfeat/debt-mapfeat/push-policy-codeowners-hardeningfeat/smart-digest-contextfeat/stage-impactfeat/t1-secret-migrationfeat/u-polishfeat/w-self-hostfeat/w2-claude-configfix/agent-journey-orphan-sweepgatetest/auto-fix-1776586424172gatetest/auto-fix-1776586534814gatetest/auto-fix-1776590685143gatetest/auto-fix-1776590808199mainops/redeploy-retriggerstyle/dxt-cta-themeworktree-agent-a3377aad30d55da26worktree-agent-a7ef607b7ee1d6c74
workflow-matrix.test.ts3.7 KB · 109 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
 * Unit tests for src/lib/workflow-matrix.ts (Agent 4, Sprint 1).
 *
 * Pure-function coverage: cartesian expansion, include/exclude semantics,
 * validator guardrails. No DB, no I/O — just data transformations.
 */

import { describe, it, expect } from "bun:test";
import { expandMatrix, validateMatrix } from "../lib/workflow-matrix";

describe("workflow-matrix — expandMatrix", () => {
  it("empty axes {} with no include returns []", () => {
    const combos = expandMatrix({ axes: {} });
    expect(combos).toEqual([]);
  });

  it("single axis expands to one combo per value in alpha-key order", () => {
    const combos = expandMatrix({ axes: { os: ["a", "b", "c"] } });
    expect(combos).toHaveLength(3);
    expect(combos[0]).toEqual({ os: "a" });
    expect(combos[1]).toEqual({ os: "b" });
    expect(combos[2]).toEqual({ os: "c" });
  });

  it("two axes produce the cartesian product with both keys", () => {
    const combos = expandMatrix({
      axes: { os: ["ubuntu", "mac"], node: [16, 18] },
    });
    expect(combos).toHaveLength(4);
    // Every combo must contain both keys.
    for (const c of combos) {
      expect(Object.keys(c).sort()).toEqual(["node", "os"]);
    }
    // Verify all four combinations are present.
    const serialized = combos.map((c) => JSON.stringify(c)).sort();
    expect(serialized).toEqual(
      [
        { node: 16, os: "ubuntu" },
        { node: 16, os: "mac" },
        { node: 18, os: "ubuntu" },
        { node: 18, os: "mac" },
      ]
        .map((c) => JSON.stringify(c))
        .sort()
    );
  });

  it("exclude removes matching combos", () => {
    const combos = expandMatrix({
      axes: { os: ["a", "b"], node: [16, 18] },
      exclude: [{ os: "a", node: 16 }],
    });
    expect(combos).toHaveLength(3);
    expect(combos.find((c) => c.os === "a" && c.node === 16)).toBeUndefined();
  });

  it("include adds a standalone combo when it does not match any cartesian entry", () => {
    const combos = expandMatrix({
      axes: { os: ["a"] },
      include: [{ os: "windows", extra: "bonus" }],
    });
    // One from the axes + one standalone include.
    expect(combos).toHaveLength(2);
    expect(combos.find((c) => c.os === "windows" && c.extra === "bonus")).toBeDefined();
  });

  it("include extends an existing combo with extra keys when axis keys match", () => {
    const combos = expandMatrix({
      axes: { os: ["a", "b"] },
      include: [{ os: "a", env: "prod" }],
    });
    expect(combos).toHaveLength(2);
    const aCombo = combos.find((c) => c.os === "a");
    const bCombo = combos.find((c) => c.os === "b");
    expect(aCombo).toEqual({ os: "a", env: "prod" });
    expect(bCombo).toEqual({ os: "b" });
  });

  it("empty axis value [] yields no combos", () => {
    const combos = expandMatrix({ axes: { os: [] } });
    expect(combos).toEqual([]);
  });

  it("validateMatrix rejects non-object input and non-array axis values", () => {
    expect(validateMatrix(null).ok).toBe(false);
    expect(validateMatrix(undefined).ok).toBe(false);
    expect(validateMatrix("not an object").ok).toBe(false);
    expect(validateMatrix([]).ok).toBe(false);
    const badAxis = validateMatrix({ axes: { os: "not-an-array" } });
    expect(badAxis.ok).toBe(false);
    if (!badAxis.ok) expect(badAxis.error).toMatch(/array/i);
  });

  it("validateMatrix accepts a well-formed spec", () => {
    const good = validateMatrix({
      axes: { os: ["a", "b"] },
      include: [{ os: "a", env: "x" }],
      exclude: [{ os: "b" }],
      failFast: true,
      maxParallel: 4,
    });
    expect(good.ok).toBe(true);
    if (good.ok) {
      expect(good.spec.axes.os).toEqual(["a", "b"]);
      expect(good.spec.failFast).toBe(true);
      expect(good.spec.maxParallel).toBe(4);
    }
  });
});