Skip to content

Commit f24513b

Browse files
committed
feat(build-matrix): allow to build jobs on specific image
1 parent 8dd6a7b commit f24513b

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

src/api/config.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ export enum JobStage {
4444
}
4545

4646
export interface Build {
47+
image?: string;
4748
env?: string;
48-
rvm?: string;
4949
}
5050

5151
export interface Matrix {
@@ -372,7 +372,35 @@ function parseMatrix(matrix: any | null): Matrix {
372372
return { include: [], exclude: [], allow_failures: [] };
373373
} else {
374374
if (Array.isArray(matrix)) {
375-
const include = matrix.map((m: Build) => m);
375+
let image = null;
376+
let env = null;
377+
378+
const include = matrix.map((m: Build) => {
379+
if (m.image) {
380+
if (m.image.includes('\n')) {
381+
let splitted = m.image.split('\n');
382+
image = splitted[0];
383+
if (splitted[1].startsWith('env:')) {
384+
env = splitted[1].replace('env:', '').trim();
385+
}
386+
} else {
387+
image = m.image;
388+
}
389+
} else if (m.env) {
390+
if (m.env.includes('\n')) {
391+
let splitted = m.env.split('\n');
392+
env = splitted[0].split(' ');
393+
if (splitted[1].startsWith('image:')) {
394+
image = splitted[1].replace('image:', '').trim();
395+
}
396+
} else {
397+
env = m.env;
398+
}
399+
}
400+
401+
return { image, env };
402+
});
403+
376404
return { include: include, exclude: [], allow_failures: [] };
377405
} else if (typeof matrix === 'object') {
378406
let include = [];
@@ -471,7 +499,7 @@ export function generateJobsAndEnv(repo: Repository, config: Config): JobsAndEnv
471499
commands: installCommands.concat(testCommands),
472500
env: env,
473501
stage: JobStage.test,
474-
image: config.image
502+
image: i.image || config.image
475503
};
476504
})).concat(config.jobs.include.map((job, i) => {
477505
const env = globalEnv.concat(job.env && job.env.global || []);

0 commit comments

Comments
 (0)