-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (82 loc) · 3.07 KB
/
shared.yaml
File metadata and controls
88 lines (82 loc) · 3.07 KB
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
on:
workflow_call:
inputs:
runners:
type: string
default: '["ubuntu-latest"]'
fmt:
type: string
default: '[]'
build:
type: string
default: '[]'
lint:
type: string
default: '[]'
unit-test:
type: string
default: '[]'
integration-test:
type: string
default: '[]'
jobs:
plan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Create manifest
id: plan
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
with:
script: |
const defaultRunners = JSON.parse(core.getInput('runners'));
const targetIncludes = {
fmt: JSON.parse(core.getInput('fmt')),
build: JSON.parse(core.getInput('build')),
lint: JSON.parse(core.getInput('lint')),
'unit-test': JSON.parse(core.getInput('unit-test')),
'integration-test': JSON.parse(core.getInput('integration-test')),
};
const defaultTargets = Object.entries(targetIncludes)
.filter(([_, includes]) => includes.length === 0)
.map(([target]) => target);
const defaultIncludes = defaultTargets.length > 0 ? defaultRunners.map(runner => ({
runner,
targets: defaultTargets
})) : [];
const customIncludes = Object.entries(targetIncludes)
.filter(([_, includes]) => includes.length > 0)
.flatMap(([target, includes]) => includes.map(include => ({
...include,
targets: [target]
})));
const includes = [...defaultIncludes, ...customIncludes];
const plan = { matrix: { include: includes } };
console.log(JSON.stringify(plan, undefined, 2));
return plan;
env:
INPUT_RUNNERS: ${{ inputs.runners }}
INPUT_FMT: ${{ inputs.fmt }}
INPUT_BUILD: ${{ inputs.build }}
INPUT_LINT: ${{ inputs.lint }}
INPUT_UNIT-TEST: ${{ inputs.unit-test }}
INPUT_INTEGRATION-TEST: ${{ inputs.integration-test }}
outputs:
plan: ${{ steps.plan.outputs.result }}
fan-out:
needs: [plan]
strategy:
matrix: ${{ fromJson(needs.plan.outputs.plan).matrix }}
runs-on: ${{ matrix.runner }}
name: ${{ join(matrix.targets) }} ${{ matrix.args }} on ${{ matrix.runner }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0
- uses: jdx/mise-action@c0b8518a9f5e56c720e9545c993b77ff15dc7b27 # v3.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: pnpm install
- uses: nrwl/nx-set-shas@40f1175ceec169e68c9857c27aa7c5063692aa9a # v4.0.6
- run: pnpm nx affected --target=${{ join(matrix.targets) }} ${{ matrix.args }}