@catladder/pipeline 1.10.2 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/base/constants.js +1 -1
- package/dist/build/base/createBuildJob.d.ts +4 -2
- package/dist/build/base/createBuildJob.js +13 -18
- package/dist/build/docker.d.ts +6 -3
- package/dist/build/docker.js +24 -9
- package/dist/build/index.d.ts +2 -2
- package/dist/build/node/buildJob.d.ts +2 -2
- package/dist/build/node/buildJob.js +26 -13
- package/dist/build/node/cache.d.ts +3 -1
- package/dist/build/node/cache.js +33 -5
- package/dist/build/node/constants.js +2 -2
- package/dist/build/node/index.d.ts +4 -4
- package/dist/build/node/meteor.d.ts +2 -2
- package/dist/build/node/meteor.js +4 -23
- package/dist/build/node/testJob.d.ts +2 -2
- package/dist/build/node/testJob.js +20 -29
- package/dist/build/node/yarn.d.ts +4 -0
- package/dist/build/node/yarn.js +10 -3
- package/dist/build/tests/storybook.test.js +10 -23
- package/dist/build/types.d.ts +6 -0
- package/dist/catladder-gitlab.js +33 -2
- package/dist/constants.js +1 -1
- package/dist/context/index.d.ts +2 -2
- package/dist/context/index.js +2 -2
- package/dist/deploy/base.d.ts +3 -4
- package/dist/deploy/base.js +27 -33
- package/dist/deploy/index.d.ts +2 -2
- package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
- package/dist/deploy/kubernetes/deployJob.js +32 -38
- package/dist/pipeline/createChildPipeline.d.ts +2 -11
- package/dist/pipeline/createChildPipeline.js +24 -18
- package/dist/pipeline/createChildPipeline.test.js +3 -14
- package/dist/pipeline/createJobs.d.ts +2 -2
- package/dist/pipeline/createJobs.js +29 -23
- package/dist/pipeline/gitlab/makeGitlabJob.d.ts +8 -0
- package/dist/pipeline/gitlab/makeGitlabJob.js +45 -0
- package/dist/pipeline/packageManager.d.ts +2 -0
- package/dist/pipeline/{yarnInfo.js → packageManager.js} +69 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/context.d.ts +15 -6
- package/dist/types/gitlab-types.d.ts +10 -22
- package/dist/types/gitlab-types.js +1 -3
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.js +3 -1
- package/dist/types/jobs.d.ts +75 -0
- package/dist/types/jobs.js +5 -0
- package/dist/types/pipeline.d.ts +4 -0
- package/dist/types/pipeline.js +3 -0
- package/package.json +1 -1
- package/src/build/base/constants.ts +1 -1
- package/src/build/base/createBuildJob.ts +29 -31
- package/src/build/docker.ts +50 -45
- package/src/build/index.ts +3 -2
- package/src/build/node/buildJob.ts +35 -25
- package/src/build/node/cache.ts +30 -5
- package/src/build/node/constants.ts +2 -2
- package/src/build/node/index.ts +4 -4
- package/src/build/node/meteor.ts +10 -18
- package/src/build/node/testJob.ts +31 -40
- package/src/build/node/yarn.ts +20 -3
- package/src/build/tests/storybook.test.ts +4 -2
- package/src/build/types.ts +6 -0
- package/src/catladder-gitlab.ts +9 -5
- package/src/context/index.ts +8 -4
- package/src/deploy/base.ts +40 -45
- package/src/deploy/index.ts +2 -2
- package/src/deploy/kubernetes/deployJob.ts +43 -48
- package/src/pipeline/createChildPipeline.test.ts +2 -1
- package/src/pipeline/createChildPipeline.ts +23 -21
- package/src/pipeline/createJobs.ts +50 -41
- package/src/pipeline/gitlab/makeGitlabJob.ts +16 -0
- package/src/pipeline/packageManager.ts +99 -0
- package/src/types/context.ts +14 -3
- package/src/types/gitlab-types.ts +10 -30
- package/src/types/index.ts +1 -0
- package/src/types/jobs.ts +88 -0
- package/src/types/pipeline.ts +11 -0
- package/dist/pipeline/yarnInfo.d.ts +0 -2
- package/src/pipeline/yarnInfo.ts +0 -54
package/src/types/context.ts
CHANGED
|
@@ -22,17 +22,28 @@ export type CommitInfo = {
|
|
|
22
22
|
trigger: PipelineTrigger;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
type Workspace = {
|
|
26
|
+
name: string;
|
|
27
|
+
location: string;
|
|
28
|
+
workspaceDependencies: string[];
|
|
29
|
+
mismatchedWorkspaceDependencies: string[];
|
|
30
|
+
};
|
|
31
|
+
export type YarnPackageManagerInfo = {
|
|
32
|
+
type: "yarn";
|
|
26
33
|
version: string;
|
|
27
|
-
workspaces:
|
|
34
|
+
workspaces: Workspace[];
|
|
35
|
+
currentWorkspace?: Workspace;
|
|
28
36
|
isClassic: boolean;
|
|
29
37
|
componentIsInWorkspace: boolean;
|
|
38
|
+
pathsToCopyInDocker: string[];
|
|
30
39
|
};
|
|
40
|
+
|
|
41
|
+
export type PackageManagerInfo = YarnPackageManagerInfo;
|
|
31
42
|
export type Context = {
|
|
32
43
|
componentName: string;
|
|
33
44
|
componentConfig: ComponentConfig;
|
|
34
45
|
fullConfig: Config;
|
|
35
46
|
environment: Environment;
|
|
36
47
|
commitInfo?: CommitInfo;
|
|
37
|
-
|
|
48
|
+
packageManagerInfo?: PackageManagerInfo;
|
|
38
49
|
};
|
|
@@ -56,39 +56,19 @@ export type GitlabJobDef = {
|
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
export const GITLAB_BASE_STAGES = [
|
|
60
|
-
"setup",
|
|
61
|
-
"test",
|
|
62
|
-
"build",
|
|
63
|
-
"deploy",
|
|
64
|
-
"verify",
|
|
65
|
-
"stop",
|
|
66
|
-
] as const;
|
|
67
|
-
export type GitlabBaseStage = typeof GITLAB_BASE_STAGES[number];
|
|
68
59
|
export type GitlabVariables = Record<string, string | undefined>;
|
|
69
60
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* envMode sets the behavior of the job regarding multiple envs:
|
|
77
|
-
* - none: the job does not run per env, but once for all envs
|
|
78
|
-
* - jobPerEnv: the job runs once per env
|
|
79
|
-
* - stagePerEnv: the job runs once per env and is organized in its own stage. This mproves usability in gitlab, but works the same as `jobPerEnv`
|
|
80
|
-
*/
|
|
81
|
-
envMode: "jobPerEnv" | "stagePerEnv" | "none";
|
|
82
|
-
job: GitlabJobDef;
|
|
83
|
-
needsStages?: {
|
|
84
|
-
stage: GitlabBaseStage;
|
|
85
|
-
artifacts?: boolean;
|
|
86
|
-
}[];
|
|
87
|
-
};
|
|
88
|
-
export type GitlabJobs = GitlabJob[];
|
|
89
|
-
|
|
61
|
+
/**
|
|
62
|
+
* this is not precicily the type of a gitlab-pipeline
|
|
63
|
+
* the jobs nee to be merge into the object.
|
|
64
|
+
* Problem is, that this type cannot be represented properly with typescript, see https://github.com/microsoft/TypeScript/issues/17867
|
|
65
|
+
*/
|
|
90
66
|
export type GitlabPipeline = {
|
|
67
|
+
image: string;
|
|
91
68
|
variables: GitlabVariables;
|
|
69
|
+
workflow?: {
|
|
70
|
+
rules: GitlabRule[];
|
|
71
|
+
};
|
|
92
72
|
stages: string[];
|
|
93
|
-
jobs:
|
|
73
|
+
jobs: Record<string, GitlabJobDef>;
|
|
94
74
|
};
|
package/src/types/index.ts
CHANGED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Artifacts,
|
|
3
|
+
GitlabEnvironment,
|
|
4
|
+
GitlabJobCache,
|
|
5
|
+
GitlabRule,
|
|
6
|
+
GitlabVariables,
|
|
7
|
+
Service,
|
|
8
|
+
} from "./gitlab-types";
|
|
9
|
+
|
|
10
|
+
export const BASE_STAGES = [
|
|
11
|
+
"setup",
|
|
12
|
+
"test",
|
|
13
|
+
"build",
|
|
14
|
+
"deploy",
|
|
15
|
+
"verify",
|
|
16
|
+
"stop",
|
|
17
|
+
] as const;
|
|
18
|
+
export type BaseStage = typeof BASE_STAGES[number];
|
|
19
|
+
|
|
20
|
+
export type CatladderJob<S = BaseStage> = {
|
|
21
|
+
/**
|
|
22
|
+
* the name of the job (without any env or app prefix and suffix)
|
|
23
|
+
*/
|
|
24
|
+
name: string;
|
|
25
|
+
/**
|
|
26
|
+
* envMode sets the behavior of the job regarding multiple envs:
|
|
27
|
+
* - none: the job does not run per env, but once for all envs
|
|
28
|
+
* - jobPerEnv: the job runs once per env
|
|
29
|
+
* - stagePerEnv: the job runs once per env and is organized in its own stage. This mproves usability in gitlab, but works the same as `jobPerEnv`
|
|
30
|
+
*/
|
|
31
|
+
envMode: "jobPerEnv" | "stagePerEnv" | "none";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* the stage of the job
|
|
35
|
+
*/
|
|
36
|
+
stage: S;
|
|
37
|
+
/**
|
|
38
|
+
* does this require another stage?
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* script to run
|
|
43
|
+
*/
|
|
44
|
+
script: (string | undefined)[];
|
|
45
|
+
|
|
46
|
+
needsStages?: {
|
|
47
|
+
stage: S;
|
|
48
|
+
artifacts?: boolean;
|
|
49
|
+
}[];
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* does this require another job?
|
|
53
|
+
*/
|
|
54
|
+
needs?: Array<string | { job: string; artifacts: boolean }>;
|
|
55
|
+
/**
|
|
56
|
+
* cache config, we use here the same shape as gitlab itself
|
|
57
|
+
*/
|
|
58
|
+
cache?: GitlabJobCache | GitlabJobCache[];
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* job artifacts, we also use gitlab shape here
|
|
62
|
+
*/
|
|
63
|
+
artifacts?: Artifacts;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* additional services, mainly used for docker
|
|
67
|
+
*/
|
|
68
|
+
services?: Service[];
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* image to use
|
|
72
|
+
*/
|
|
73
|
+
image?: string;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* variables to pass
|
|
77
|
+
*/
|
|
78
|
+
variables: GitlabVariables;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* whether failures are allowed
|
|
82
|
+
*/
|
|
83
|
+
allow_failure?: boolean;
|
|
84
|
+
|
|
85
|
+
environment?: GitlabEnvironment;
|
|
86
|
+
|
|
87
|
+
rules?: GitlabRule[];
|
|
88
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GitlabJobDef, GitlabPipeline } from "./gitlab-types";
|
|
2
|
+
|
|
3
|
+
export type PipelineType = "gitlab";
|
|
4
|
+
|
|
5
|
+
export type PipelineJob<T extends PipelineType> = T extends "gitlab"
|
|
6
|
+
? GitlabJobDef
|
|
7
|
+
: never;
|
|
8
|
+
|
|
9
|
+
export type Pipeline<T extends PipelineType> = T extends "gitlab"
|
|
10
|
+
? GitlabPipeline
|
|
11
|
+
: never;
|
package/src/pipeline/yarnInfo.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { exec } from "child-process-promise";
|
|
2
|
-
import { Config, YarnInfo } from "../types";
|
|
3
|
-
import { pathEqual } from "path-equal";
|
|
4
|
-
import memoizee from "memoizee";
|
|
5
|
-
|
|
6
|
-
const execOrFail = async (cmd: string, onFail: string): Promise<string> => {
|
|
7
|
-
try {
|
|
8
|
-
return await exec(cmd).then((r) => r.stdout);
|
|
9
|
-
} catch (e) {
|
|
10
|
-
return onFail ?? null;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const getYarnVersion = memoizee(
|
|
15
|
-
async () => {
|
|
16
|
-
return await execOrFail("yarn --version", "");
|
|
17
|
-
},
|
|
18
|
-
{ promise: true }
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const getWorkspaces = memoizee(
|
|
22
|
-
async (isClassic: boolean): Promise<YarnInfo["workspaces"]> => {
|
|
23
|
-
return isClassic
|
|
24
|
-
? Object.values(
|
|
25
|
-
JSON.parse(
|
|
26
|
-
JSON.parse(await execOrFail("yarn workspaces --json info", "{}"))
|
|
27
|
-
?.data ?? "{}"
|
|
28
|
-
)
|
|
29
|
-
)
|
|
30
|
-
: JSON.parse(`[${await execOrFail("yarn workspaces list --json", "")}]`);
|
|
31
|
-
},
|
|
32
|
-
{ promise: true }
|
|
33
|
-
);
|
|
34
|
-
export const getYarnInfo = async (
|
|
35
|
-
config: Config,
|
|
36
|
-
componentName: string
|
|
37
|
-
): Promise<YarnInfo> => {
|
|
38
|
-
const version = await getYarnVersion();
|
|
39
|
-
if (!version) throw new Error("could not get yarn version");
|
|
40
|
-
const isClassic = version.startsWith("1");
|
|
41
|
-
|
|
42
|
-
const component = config.components[componentName];
|
|
43
|
-
const workspaces = await getWorkspaces(isClassic);
|
|
44
|
-
const componentIsInWorkspace = workspaces.some((w) =>
|
|
45
|
-
pathEqual(component.dir, w.location)
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
workspaces,
|
|
50
|
-
version,
|
|
51
|
-
isClassic,
|
|
52
|
-
componentIsInWorkspace,
|
|
53
|
-
};
|
|
54
|
-
};
|