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
24 changes: 24 additions & 0 deletions src/__snapshots__/workflow.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,30 @@ jobs:
"
`;

exports[`Workflow > allows a job matrix with max-parallel 1`] = `
"# Workflow automatically generated by gat
# DO NOT CHANGE THIS FILE MANUALLY

name: Matrix with max parallel
on:
push: null
jobs:
job1:
runs-on: ubuntu-22.04
timeout-minutes: 15
strategy:
fail-fast: false
max-parallel: 2
matrix:
food:
- 🍕
- 🍔
- 🌮
steps:
- run: echo \${{ matrix.food }}
"
`;

exports[`Workflow > allows concurrency groups at workflow level 1`] = `
"# Workflow automatically generated by gat
# DO NOT CHANGE THIS FILE MANUALLY
Expand Down
1 change: 1 addition & 0 deletions src/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type ConcurrencyGroup = {
export interface Matrix {
elements: Array<{ id: string; options: Array<string | number | boolean> }>;
extra?: Array<Record<string, string | number | boolean>>;
maxParallel?: number;
}

export interface Service {
Expand Down
21 changes: 21 additions & 0 deletions src/workflow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,27 @@ describe("Workflow", () => {
expect(await workflow.compile()).toMatchSnapshot();
});

it("allows a job matrix with max-parallel", async () => {
const workflow = new Workflow("Matrix with max parallel");
workflow.on("push").addJob("job1", {
matrix: {
elements: [
{
id: "food",
options: ["🍕", "🍔", "🌮"],
},
],
maxParallel: 2,
},
steps: [
{
run: "echo ${{ matrix.food }}",
},
],
});
expect(await workflow.compile()).toMatchSnapshot();
});

it("allows uses steps", async () => {
const workflow = new Workflow("Uses steps");
workflow
Expand Down
4 changes: 4 additions & 0 deletions src/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ export class Workflow<
strategy: matrix
? {
"fail-fast": false,
"max-parallel":
typeof matrix !== "string" && matrix.maxParallel != null
? matrix.maxParallel
: undefined,
matrix:
typeof matrix === "string"
? matrix
Expand Down
Loading