Skip to content

Commit a92912b

Browse files
committed
fix(b2-workflow): broadcast module-target to every module instead of positional mapping
fix #26
1 parent 9e8a1bb commit a92912b

File tree

5 files changed

+26
-12
lines changed

5 files changed

+26
-12
lines changed

b2-workflow/dist/index.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

b2-workflow/dist/index.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

b2-workflow/src/index.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ test('passes through explicit module paths untouched', async () => {
156156
expect(buildArgs).toContain('libs/math/example');
157157
});
158158

159-
// Multiple targets should map positionally to the module list with the last reused as needed.
159+
// Multiple targets should be broadcast to every module.
160160
test('applies per-module targets when multiple values are provided', async () => {
161161
const inputs = createInputs({
162162
modules: ['filesystem', 'chrono'],
@@ -165,9 +165,23 @@ test('applies per-module targets when multiple values are provided', async () =>
165165
await main(inputs);
166166
const buildArgs = exec.getExecOutput.mock.calls[2][1];
167167
expect(buildArgs).toContain('libs/filesystem/test');
168+
expect(buildArgs).toContain('libs/filesystem/example');
169+
expect(buildArgs).toContain('libs/chrono/test');
168170
expect(buildArgs).toContain('libs/chrono/example');
169171
});
170172

173+
// Multiple targets for a single module should all appear in the B2 arguments.
174+
test('broadcasts all targets to a single module', async () => {
175+
const inputs = createInputs({
176+
modules: ['beast2'],
177+
module_target: ['test', 'example']
178+
});
179+
await main(inputs);
180+
const buildArgs = exec.getExecOutput.mock.calls[2][1];
181+
expect(buildArgs).toContain('libs/beast2/test');
182+
expect(buildArgs).toContain('libs/beast2/example');
183+
});
184+
171185
test('derives address model and architecture from arch input when unspecified', async () => {
172186
const inputs = createInputs({
173187
arch: 'arm64'

b2-workflow/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@ export async function main(inputs: Inputs): Promise<void> {
287287
if (moduleTargets.length === 0) {
288288
moduleTargets = ['test'];
289289
}
290-
for (let index = 0; index < inputs.modules.length; ++index) {
291-
const moduleEntry = inputs.modules[index];
290+
for (const moduleEntry of inputs.modules) {
292291
const module = moduleEntry && moduleEntry.trim ? moduleEntry.trim() : moduleEntry;
293292
if (!module) {
294293
continue;
@@ -297,8 +296,9 @@ export async function main(inputs: Inputs): Promise<void> {
297296
if (hasExplicitTarget) {
298297
b2_args.push(module);
299298
} else {
300-
const target = moduleTargets[Math.min(index, moduleTargets.length - 1)];
301-
b2_args.push(`libs/${module}/${target}`);
299+
for (const target of moduleTargets) {
300+
b2_args.push(`libs/${module}/${target}`);
301+
}
302302
}
303303
}
304304

b2-workflow/src/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ When this input is left as the default (\`test\`), every module listed above con
174174
\`libs/filesystem/example\` or \`libs/filesystem//unit_tests\`), the action forwards it verbatim without prefixing it.
175175
176176
This input accepts a single value or a list separated by spaces, commas, or new lines. When multiple values are
177-
provided they are applied positionally to the module list, and the final value is reused for any remaining modules.`
177+
provided, every target is applied to every module.`
178178
},
179179

180180
extra_args: {

0 commit comments

Comments
 (0)