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
5 changes: 5 additions & 0 deletions changelog.d/gha-single-axis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
section: renderers
---

- **Single-dimension GitHub Actions matrices render horizontally**. A matrix that varies one dimension (such as `node: [22, 24]`) now places its values across one row with each run's mark beneath them instead of one row per value, restoring the layout from before the renderer moved to `MatrixGrid`. This keeps short workflows completely visible in short stages. `MatrixGrid` adds an `across` prop for this layout, and the harness now checks that compact scenarios open in a 1056 × 520 stage without scrolling.
4 changes: 3 additions & 1 deletion docs/guides/renderer-kit-type.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,6 @@ empty hatched cell. A cell without `content` shows a small mark, using its full
name (`title`) as a tooltip and for screen readers (or `present`, "Present" by
default, when it has no title). Added or removed values and cells render as
change regions. Pass a `caption` to place several grids side by side, one per
extra dimension.
extra dimension. With one axis (no `columns`), cells run down the side by
default. Pass `across` to place them in one row under their values instead,
keeping a few short values (such as versions) to two rows.
5 changes: 3 additions & 2 deletions docs/reference/renderer-kit.md
Original file line number Diff line number Diff line change
Expand Up @@ -4584,15 +4584,16 @@ What one cell holds: whether something is there, its change, and anything its he
### `MatrixGrid`

```ts
MatrixGrid(__0: { "caption"?: Iterable<ReactNode, any, any> | Promise<Iterable<ReactNode, any, any> | ReactElement<unknown, string | { (props: any): Iterable<ReactNode, any, any> | Promise | Promise<ReactNode> | ReactElement<unknown, recursive> | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component<any, any, any> }> | ReactPortal | bigint | false | null | number | string | true | undefined> | ReactElement<unknown, string | { (props: any): Iterable<ReactNode, any, any> | Promise<Iterable<ReactNode, any, any> | ReactElement<unknown, recursive> | ReactPortal | bigint | false | null | number | string | true | undefined> | Promise<ReactNode> | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component<any, any, any> }> | ReactPortal | bigint | false | null | number | string | true | undefined; "cell": { (row: string, column: string | undefined): MatrixCell | null }; "columns"?: MatrixAxis; "emphasis"?: number; "label": string; "present"?: string; "rows": MatrixAxis; "vacant"?: string }): Element
MatrixGrid(__0: { "across"?: false | true; "caption"?: Iterable<ReactNode, any, any> | Promise<Iterable<ReactNode, any, any> | ReactElement<unknown, string | { (props: any): Iterable<ReactNode, any, any> | Promise | Promise<ReactNode> | ReactElement<unknown, recursive> | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component<any, any, any> }> | ReactPortal | bigint | false | null | number | string | true | undefined> | ReactElement<unknown, string | { (props: any): Iterable<ReactNode, any, any> | Promise<Iterable<ReactNode, any, any> | ReactElement<unknown, recursive> | ReactPortal | bigint | false | null | number | string | true | undefined> | Promise<ReactNode> | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component<any, any, any> }> | ReactPortal | bigint | false | null | number | string | true | undefined; "cell": { (row: string, column: string | undefined): MatrixCell | null }; "columns"?: MatrixAxis; "emphasis"?: number; "label": string; "present"?: string; "rows": MatrixAxis; "vacant"?: string }): Element
```

A grid over two axes, as a table: the axes' names in its corner (`os × compiler`), each axis's values once along its
edge, and each cell what `cell(row, column)` returns: by default a small mark that something is there, with its whole
name (or `present`) as a tooltip and for assistive technology, so a cell never repeats its headings. A cell with nothing (`null`)
is vacant, on the kit's hatch. A value, row, column or cell that arrives or leaves is a kit change region, struck
through when it leaves, fading with `emphasis` (or the item's around it). Leave out `columns` for a single list of
cells along `rows`. `caption` names the grid when several stand together (one per further dimension).
cells along `rows`: down the side, or with `across`, in one row under the values. `caption` names the grid when
several stand together (one per further dimension).

### `MatrixValue`

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/renderers.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Built-in Projections GitHub Actions renderer: a workflow's triggers, its jobs an
- Handles: `github-actions`
- Comparison modes: `diff`, `side-by-side`
- Package: `@githubnext/projections-renderer-github-actions`
- Example scenarios ([`scenarios.json`](../../packages/renderers/github-actions/scenarios.json)): Narrow a build matrix to one runtime; Sign a release before publishing it; A build and test workflow
- Example scenarios ([`scenarios.json`](../../packages/renderers/github-actions/scenarios.json)): Narrow a build matrix to one runtime; Sign a release before publishing it; Test on newer Node.js and deploy the worker on its own; A build and test workflow

## `graph`

Expand Down
11 changes: 6 additions & 5 deletions packages/extractors/github-actions-jobs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ missing or empty `jobs` mapping, `needs` references to an undeclared job or an
expression, and `needs` cycles, reported as a path such as
`build → test → build`.

`tests/fixtures` contains two before-and-after pairs with golden extractions
(rewritten with `PROJECTIONS_UPDATE_GOLDEN=1`): a build matrix narrowed to one
runtime and a release pipeline that gains a signing job. The
[`github-actions` renderer](../../renderers/github-actions/README.md) uses these
same fixtures for its scenarios and tests.
`tests/fixtures` contains three before-and-after pairs with golden extractions
(update with `PROJECTIONS_UPDATE_GOLDEN=1`): a build matrix narrowed to one
runtime, a release pipeline that adds a signing job, and a delivery workflow
whose single-dimension test matrix updates to newer Node.js versions. The
[`github-actions` renderer](../../renderers/github-actions/README.md) reuses
these fixtures for its scenarios and tests.

If you need an evaluated pipeline (for another CI system or for what actually
ran), write a custom extractor that emits `dag/v0` jobs and `precedes`
Expand Down
17 changes: 17 additions & 0 deletions packages/extractors/github-actions-jobs/tests/extractions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,20 @@ fn a_pipeline_keeps_its_needs_reusable_calls_and_dynamic_matrices() {
json!({"event": "workflow_dispatch", "filters": [{"key": "inputs", "values": ["dry-run"]}]})
);
}

#[test]
fn a_matrix_over_one_dimension_moves_to_newer_versions() {
let before = case("delivery", "before");
let after = case("delivery", "after");
let versions = |extraction: &Value| {
entity(extraction, "job:test")["data"]["matrix"]["runs"]
.as_array()
.unwrap()
.iter()
.map(|run| run["values"]["node"].clone())
.collect::<Vec<_>>()
};
assert_eq!(versions(&before), [json!(20), json!(22)]);
assert_eq!(versions(&after), [json!(22), json!(24)]);
assert!(edges(&after, "precedes").contains(&("job:test".into(), "job:deploy-worker".into())));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
{
"entities": [
{
"confidence": "authoritative",
"data": {
"events": [
{
"event": "push",
"filters": [
{
"key": "branches",
"values": [
"main"
]
}
]
}
],
"workflow": "Delivery"
},
"evidence": [
{
"kind": "github-actions-workflow",
"source": ".github/workflows/delivery.yml"
}
],
"id": "trigger:on",
"kind": "trigger",
"label": "push"
},
{
"confidence": "authoritative",
"data": {
"runsOn": [
"ubuntu-latest"
],
"steps": {
"actions": [
{
"action": "actions/checkout",
"count": 1,
"ref": "v4"
}
],
"run": 1,
"total": 2
}
},
"evidence": [
{
"kind": "github-actions-workflow",
"source": ".github/workflows/delivery.yml"
}
],
"id": "job:deploy",
"kind": "job",
"label": "deploy"
},
{
"confidence": "authoritative",
"data": {
"runsOn": [
"ubuntu-latest"
],
"steps": {
"actions": [
{
"action": "actions/checkout",
"count": 1,
"ref": "v4"
}
],
"run": 1,
"total": 2
}
},
"evidence": [
{
"kind": "github-actions-workflow",
"source": ".github/workflows/delivery.yml"
}
],
"id": "job:deploy-worker",
"kind": "job",
"label": "deploy-worker"
},
{
"confidence": "authoritative",
"data": {
"matrix": {
"dimensions": [
{
"key": "node",
"values": [
22,
24
]
}
],
"runs": [
{
"values": {
"node": 22
}
},
{
"values": {
"node": 24
}
}
]
},
"runsOn": [
"ubuntu-latest"
],
"steps": {
"actions": [
{
"action": "actions/checkout",
"count": 1,
"ref": "v4"
},
{
"action": "actions/setup-node",
"count": 1,
"ref": "v4"
}
],
"run": 1,
"total": 3
}
},
"evidence": [
{
"kind": "github-actions-workflow",
"source": ".github/workflows/delivery.yml"
}
],
"id": "job:test",
"kind": "job",
"label": "test"
}
],
"metadata": {
"limitations": [
"Declaration graph only: a matrix expands and its values fill names and runners, but other expressions, reusable workflows' own jobs, conditions and runtime scheduling are not evaluated."
],
"source": "GitHub Actions workflow declaration",
"workflow": ".github/workflows/delivery.yml"
},
"protocolVersion": 0,
"relationships": [
{
"confidence": "authoritative",
"evidence": [
{
"kind": "github-actions-workflow",
"source": ".github/workflows/delivery.yml"
}
],
"from": "job:test",
"id": "precedes:job%3Atest:job%3Adeploy",
"kind": "precedes",
"to": "job:deploy"
},
{
"confidence": "authoritative",
"evidence": [
{
"kind": "github-actions-workflow",
"source": ".github/workflows/delivery.yml"
}
],
"from": "job:test",
"id": "precedes:job%3Atest:job%3Adeploy-worker",
"kind": "precedes",
"to": "job:deploy-worker"
},
{
"confidence": "authoritative",
"evidence": [
{
"kind": "github-actions-workflow",
"source": ".github/workflows/delivery.yml"
}
],
"from": "trigger:on",
"id": "triggers:trigger%3Aon:job%3Atest",
"kind": "triggers",
"to": "job:test"
}
],
"schema": "dag/v0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Delivery
on:
push:
branches: [main]

jobs:
# The worker runs its TypeScript as is, with Node's type stripping, which needs Node 22 or later.
test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [22, 24]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: npm
- run: npm ci && npm run lint && npm test

# deploy.sh builds each app's image from the repository root, so it gets the workspace packages it imports.
deploy:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ./deploy.sh api storefront

# The worker charges orders, so it ships on its own and can be rolled back without the storefront.
deploy-worker:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ./deploy.sh worker
Loading
Loading