@catladder/pipeline 0.0.0-tagged-release-2fffd3dd → 0.0.0-waitfor-deploy-e64a33ba
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 +2 -2
- package/dist/build/base/createBuildJob.d.ts +4 -2
- package/dist/build/base/createBuildJob.js +18 -17
- package/dist/build/base/getBuildInfo.d.ts +2 -0
- package/dist/build/base/getBuildInfo.js +12 -0
- package/dist/build/docker.d.ts +29 -4
- package/dist/build/docker.js +74 -23
- package/dist/build/index.d.ts +2 -2
- package/dist/build/index.js +1 -1
- package/dist/build/node/buildJob.d.ts +2 -2
- package/dist/build/node/buildJob.js +27 -11
- package/dist/build/node/cache.d.ts +3 -1
- package/dist/build/node/cache.js +34 -6
- 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 +7 -23
- package/dist/build/node/testJob.d.ts +2 -2
- package/dist/build/node/testJob.js +22 -30
- package/dist/build/node/yarn.d.ts +5 -0
- package/dist/build/node/yarn.js +51 -3
- package/dist/build/tests/storybook.test.js +17 -24
- package/dist/build/types.d.ts +13 -0
- package/dist/catladder-gitlab.js +42 -9
- package/dist/config/configruedEnvs.test.js +12 -3
- package/dist/config/readConfig.d.ts +5 -1
- package/dist/config/readConfig.js +20 -5
- package/dist/constants.js +1 -1
- package/dist/context/index.d.ts +4 -3
- package/dist/context/index.js +56 -43
- package/dist/context/resolveReferences.d.ts +6 -0
- package/dist/context/resolveReferences.js +93 -0
- package/dist/context/resolveReferences.test.d.ts +1 -0
- package/dist/context/resolveReferences.test.js +141 -0
- package/dist/deploy/base.d.ts +3 -4
- package/dist/deploy/base.js +55 -35
- package/dist/deploy/custom/deployJob.d.ts +3 -0
- package/dist/deploy/custom/deployJob.js +65 -0
- package/dist/deploy/custom/index.d.ts +1 -0
- package/dist/deploy/custom/index.js +22 -0
- package/dist/deploy/index.d.ts +5 -3
- package/dist/deploy/index.js +12 -0
- package/dist/deploy/kubernetes/cloudsql.js +1 -1
- package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
- package/dist/deploy/kubernetes/deployJob.js +74 -42
- package/dist/deploy/kubernetes/mongodb.js +1 -1
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +87 -0
- package/dist/deploy/kubernetes/processSecretsAsFiles.js +39 -0
- package/dist/deploy/types.d.ts +194 -84
- package/dist/deploy/utils.d.ts +5 -0
- package/dist/deploy/utils.js +36 -0
- package/dist/pipeline/createChildPipeline.d.ts +2 -8
- package/dist/pipeline/createChildPipeline.js +24 -15
- package/dist/pipeline/createChildPipeline.test.js +10 -15
- package/dist/pipeline/createJobs.d.ts +2 -2
- package/dist/pipeline/createJobs.js +95 -33
- 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/runner/index.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +87 -1
- package/dist/types/context.d.ts +19 -8
- 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 +80 -0
- package/dist/types/jobs.js +5 -0
- package/dist/types/pipeline.d.ts +4 -0
- package/dist/types/pipeline.js +3 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +45 -2
- package/package.json +1 -3
- package/src/build/base/constants.ts +2 -2
- package/src/build/base/createBuildJob.ts +31 -34
- package/src/build/base/getBuildInfo.ts +7 -0
- package/src/build/docker.ts +75 -35
- package/src/build/index.ts +4 -3
- package/src/build/node/buildJob.ts +46 -24
- package/src/build/node/cache.ts +31 -6
- package/src/build/node/constants.ts +2 -2
- package/src/build/node/index.ts +4 -4
- package/src/build/node/meteor.ts +12 -18
- package/src/build/node/testJob.ts +35 -40
- package/src/build/node/yarn.ts +25 -4
- package/src/build/tests/storybook.test.ts +10 -2
- package/src/build/types.ts +12 -0
- package/src/catladder-gitlab.ts +12 -7
- package/src/config/configruedEnvs.test.ts +10 -3
- package/src/config/readConfig.ts +18 -6
- package/src/context/index.ts +90 -52
- package/src/context/resolveReferences.test.ts +158 -0
- package/src/context/resolveReferences.ts +66 -0
- package/src/deploy/base.ts +73 -47
- package/src/deploy/custom/deployJob.ts +23 -0
- package/src/deploy/custom/index.ts +1 -0
- package/src/deploy/index.ts +10 -4
- package/src/deploy/kubernetes/cloudsql.ts +3 -4
- package/src/deploy/kubernetes/deployJob.ts +85 -45
- package/src/deploy/kubernetes/mongodb.ts +1 -3
- package/src/deploy/kubernetes/processSecretsAsFiles.ts +34 -0
- package/src/deploy/types.ts +177 -42
- package/src/deploy/utils.ts +30 -0
- package/src/pipeline/createChildPipeline.test.ts +8 -1
- package/src/pipeline/createChildPipeline.ts +23 -18
- package/src/pipeline/createJobs.ts +104 -56
- package/src/pipeline/gitlab/makeGitlabJob.ts +16 -0
- package/src/pipeline/packageManager.ts +99 -0
- package/src/runner/index.ts +3 -1
- package/src/types/config.ts +79 -1
- package/src/types/context.ts +18 -5
- package/src/types/gitlab-types.ts +10 -30
- package/src/types/index.ts +1 -0
- package/src/types/jobs.ts +94 -0
- package/src/types/pipeline.ts +11 -0
- package/src/utils/index.ts +10 -1
- package/dist/pipeline/yarnInfo.d.ts +0 -2
- package/src/pipeline/yarnInfo.ts +0 -54
package/dist/utils/index.js
CHANGED
|
@@ -1,7 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __read = this && this.__read || function (o, n) {
|
|
4
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
5
|
+
if (!m) return o;
|
|
6
|
+
var i = m.call(o),
|
|
7
|
+
r,
|
|
8
|
+
ar = [],
|
|
9
|
+
e;
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
13
|
+
} catch (error) {
|
|
14
|
+
e = {
|
|
15
|
+
error: error
|
|
16
|
+
};
|
|
17
|
+
} finally {
|
|
18
|
+
try {
|
|
19
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
20
|
+
} finally {
|
|
21
|
+
if (e) throw e.error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
29
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
30
|
+
if (ar || !(i in from)) {
|
|
31
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
32
|
+
ar[i] = from[i];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
|
+
};
|
|
37
|
+
|
|
3
38
|
exports.__esModule = true;
|
|
4
|
-
exports.ensureArray = exports.notNil = void 0;
|
|
39
|
+
exports.mergeWithMergingArrays = exports.ensureArray = exports.notNil = void 0;
|
|
5
40
|
|
|
6
41
|
var lodash_1 = require("lodash");
|
|
7
42
|
|
|
@@ -15,4 +50,12 @@ var ensureArray = function (s) {
|
|
|
15
50
|
return (0, lodash_1.isNil)(s) ? null : Array.isArray(s) ? s : [s];
|
|
16
51
|
};
|
|
17
52
|
|
|
18
|
-
exports.ensureArray = ensureArray;
|
|
53
|
+
exports.ensureArray = ensureArray; // see https://github.com/lodash/lodash/issues/5384
|
|
54
|
+
|
|
55
|
+
var mergeWithMergingArrays = function (obj1, obj2) {
|
|
56
|
+
return (0, lodash_1.mergeWith)({}, obj1, obj2, function (prop1, prop2) {
|
|
57
|
+
return Array.isArray(prop1) && Array.isArray(prop2) ? __spreadArray(__spreadArray([], __read(prop1), false), __read(prop2), false) : undefined;
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
exports.mergeWithMergingArrays = mergeWithMergingArrays;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@catladder/pipeline",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-waitfor-deploy-e64a33ba",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build:tsc": "yarn tsc",
|
|
6
6
|
"build": "yarn tsc && yarn build:inline-variables",
|
|
@@ -27,14 +27,12 @@
|
|
|
27
27
|
"eslint": "^8.7.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@gitbeaker/node": "^32.1.2",
|
|
31
30
|
"@types/node": "^17.0.10",
|
|
32
31
|
"child-process-promise": "^2.2.1",
|
|
33
32
|
"js-yaml": "^4.1.0",
|
|
34
33
|
"lodash": "^4.17.21",
|
|
35
34
|
"memoizee": "^0.4.15",
|
|
36
35
|
"path-equal": "^1.1.3",
|
|
37
|
-
"prettier": "^2.5.1",
|
|
38
36
|
"slugify": "^1.6.3",
|
|
39
37
|
"ts-node": "^10.4.0",
|
|
40
38
|
"type-fest": "^2.10.0",
|
|
@@ -2,6 +2,6 @@ export const APP_BUILD_JOB_NAME = "🔨 app";
|
|
|
2
2
|
export const RUNNER_BUILD_RESOURCE_VARIABLES = {
|
|
3
3
|
KUBERNETES_CPU_REQUEST: "0.5",
|
|
4
4
|
KUBERNETES_CPU_LIMIT: "2",
|
|
5
|
-
KUBERNETES_MEMORY_REQUEST: "
|
|
6
|
-
KUBERNETES_MEMORY_LIMIT: "
|
|
5
|
+
KUBERNETES_MEMORY_REQUEST: "1Gi",
|
|
6
|
+
KUBERNETES_MEMORY_LIMIT: "4Gi",
|
|
7
7
|
};
|
|
@@ -1,46 +1,43 @@
|
|
|
1
1
|
import { merge } from "lodash";
|
|
2
|
-
import { Context,
|
|
3
|
-
import {
|
|
2
|
+
import { Context, getRunnerImage } from "../..";
|
|
3
|
+
import { CatladderJob } from "../../types/jobs";
|
|
4
4
|
import { ensureArray } from "../../utils";
|
|
5
|
+
import { ensureNodeVersion } from "../node/yarn";
|
|
5
6
|
import {
|
|
6
7
|
APP_BUILD_JOB_NAME,
|
|
7
8
|
RUNNER_BUILD_RESOURCE_VARIABLES,
|
|
8
9
|
} from "./constants";
|
|
10
|
+
import { getBuildInfo } from "./getBuildInfo";
|
|
9
11
|
|
|
10
12
|
export const createBuildJob = (
|
|
11
13
|
context: Context,
|
|
12
|
-
{ script, ...def }: Partial<
|
|
13
|
-
):
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
{ script, variables, ...def }: Partial<CatladderJob>
|
|
15
|
+
): CatladderJob => {
|
|
16
|
+
return merge(
|
|
17
|
+
{
|
|
18
|
+
name: APP_BUILD_JOB_NAME,
|
|
19
|
+
envMode: "jobPerEnv",
|
|
20
|
+
stage: "build",
|
|
21
|
+
image: getRunnerImage("jobs-default"),
|
|
22
|
+
needs: [],
|
|
23
|
+
cache: [],
|
|
24
|
+
variables: {
|
|
25
|
+
...RUNNER_BUILD_RESOURCE_VARIABLES,
|
|
26
|
+
...(variables ?? {}),
|
|
27
|
+
...context.environment.envVars,
|
|
28
|
+
...(context.componentConfig.build.extraVars ?? {}),
|
|
29
|
+
},
|
|
18
30
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
...RUNNER_BUILD_RESOURCE_VARIABLES,
|
|
28
|
-
...context.environment.envVars,
|
|
29
|
-
...(context.componentConfig.build.extraVars ?? {}),
|
|
30
|
-
},
|
|
31
|
-
retry: BASE_RETRY,
|
|
32
|
-
interruptible: true,
|
|
33
|
-
stage: "build",
|
|
34
|
-
script: [
|
|
35
|
-
...buildInfo,
|
|
36
|
-
`cd ${context.componentConfig.dir}`,
|
|
37
|
-
...(ensureArray(script) ?? []),
|
|
38
|
-
],
|
|
39
|
-
artifacts: {
|
|
40
|
-
paths: [context.componentConfig.dir + "/__build_info.json"],
|
|
41
|
-
},
|
|
31
|
+
script: [
|
|
32
|
+
...getBuildInfo(context),
|
|
33
|
+
...ensureNodeVersion(context), // in pure node repos, we might want to have the nvmrc file in top-level
|
|
34
|
+
`cd ${context.componentConfig.dir}`,
|
|
35
|
+
...(ensureArray(script) ?? []),
|
|
36
|
+
],
|
|
37
|
+
artifacts: {
|
|
38
|
+
paths: [context.componentConfig.dir + "/__build_info.json"],
|
|
42
39
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
},
|
|
41
|
+
def
|
|
42
|
+
);
|
|
46
43
|
};
|
package/src/build/docker.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { merge } from "lodash";
|
|
2
|
+
import { isOfDeployType } from "../deploy";
|
|
1
3
|
import { getRunnerImage } from "../runner";
|
|
2
|
-
import {
|
|
4
|
+
import { Context } from "../types";
|
|
5
|
+
import { CatladderJob } from "../types/jobs";
|
|
3
6
|
|
|
4
7
|
const DOCKER_RUNNER_BUILD_VARIABLES = {
|
|
5
8
|
KUBERNETES_CPU_REQUEST: "0.5",
|
|
@@ -8,49 +11,86 @@ const DOCKER_RUNNER_BUILD_VARIABLES = {
|
|
|
8
11
|
KUBERNETES_MEMORY_LIMIT: "2Gi",
|
|
9
12
|
};
|
|
10
13
|
|
|
14
|
+
export const requiresDockerBuild = (context: Context) => {
|
|
15
|
+
const deployConfig = context.componentConfig.deploy;
|
|
16
|
+
if (isOfDeployType(deployConfig, "kubernetes")) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (isOfDeployType(deployConfig, "custom") && deployConfig.requiresDocker) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return false;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const getDockerBuildVariables = (context: Context) => {
|
|
28
|
+
return {
|
|
29
|
+
...DOCKER_RUNNER_BUILD_VARIABLES,
|
|
30
|
+
DOCKER_BUILDKIT: "1", // see https://docs.docker.com/develop/develop-images/build_enhancements/
|
|
31
|
+
DOCKERFILE_ADDITIONS:
|
|
32
|
+
context.componentConfig.build.docker?.additionsBegin?.join("\n"),
|
|
33
|
+
DOCKERFILE_ADDITIONS_END:
|
|
34
|
+
context.componentConfig.build.docker?.additionsEnd?.join("\n"),
|
|
35
|
+
APP_DIR: context.componentConfig.dir,
|
|
36
|
+
DOCKER_HOST: "tcp://0.0.0.0:2375",
|
|
37
|
+
DOCKER_TLS_CERTDIR: "",
|
|
38
|
+
DOCKER_DIR: ".", // relative to componentdir
|
|
39
|
+
IMAGE_TAG: "$CI_COMMIT_SHA",
|
|
40
|
+
DOCKER_DRIVER: "overlay2",
|
|
41
|
+
|
|
42
|
+
IMAGE_NAME:
|
|
43
|
+
"$CI_REGISTRY_IMAGE/" +
|
|
44
|
+
context.environment.shortName +
|
|
45
|
+
"/" +
|
|
46
|
+
context.componentName,
|
|
47
|
+
|
|
48
|
+
CACHE_IMAGE: "$CI_REGISTRY_IMAGE/caches/" + context.componentName,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
11
52
|
export const DOCKER_BUILD_JOB_NAME = "🔨 docker";
|
|
12
|
-
|
|
53
|
+
|
|
54
|
+
export const createDockerBuildJobBase = (
|
|
13
55
|
context: Context,
|
|
14
|
-
{ script }:
|
|
15
|
-
):
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
56
|
+
{ script, variables, ...def }: Partial<CatladderJob>
|
|
57
|
+
): CatladderJob => {
|
|
58
|
+
return merge(
|
|
59
|
+
{
|
|
60
|
+
name: DOCKER_BUILD_JOB_NAME,
|
|
61
|
+
envMode: "jobPerEnv",
|
|
62
|
+
stage: "build",
|
|
63
|
+
image: getRunnerImage("docker-build"),
|
|
64
|
+
|
|
65
|
+
services: [
|
|
66
|
+
{
|
|
67
|
+
name: "docker:20-dind", // see see https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27300#note_466755332
|
|
68
|
+
command: ["--tls=false"],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
variables: {
|
|
72
|
+
...getDockerBuildVariables(context),
|
|
73
|
+
...(variables ?? {}),
|
|
24
74
|
},
|
|
25
|
-
|
|
26
|
-
variables: {
|
|
27
|
-
...DOCKER_RUNNER_BUILD_VARIABLES,
|
|
28
|
-
DOCKERFILE_ADDITIONS:
|
|
29
|
-
context.componentConfig.build.docker?.additionsBegin?.join("\n"),
|
|
30
|
-
DOCKERFILE_ADDITIONS_END:
|
|
31
|
-
context.componentConfig.build.docker?.additionsEnd?.join("\n"),
|
|
32
|
-
APP_DIR: context.componentConfig.dir,
|
|
33
|
-
DOCKER_HOST: "tcp://0.0.0.0:2375",
|
|
34
|
-
DOCKER_TLS_CERTDIR: "",
|
|
35
|
-
DOCKER_DIR: ".", // relative to componentdir
|
|
36
|
-
IMAGE_TAG: "$CI_COMMIT_SHA",
|
|
37
|
-
DOCKER_DRIVER: "overlay2",
|
|
38
|
-
IMAGE_NAME: "$CI_REGISTRY_IMAGE/" + context.componentName,
|
|
39
|
-
CACHE_IMAGE:
|
|
40
|
-
"$CI_REGISTRY_IMAGE/" + context.componentName + "/cache:cache",
|
|
75
|
+
script: script || [],
|
|
41
76
|
},
|
|
42
|
-
|
|
77
|
+
def
|
|
78
|
+
);
|
|
79
|
+
};
|
|
43
80
|
|
|
44
|
-
|
|
45
|
-
|
|
81
|
+
export const createDockerBuildJobDefault = (
|
|
82
|
+
context: Context,
|
|
83
|
+
{ script, ...def }: Partial<CatladderJob>
|
|
84
|
+
): CatladderJob => {
|
|
85
|
+
return createDockerBuildJobBase(context, {
|
|
46
86
|
script: [
|
|
47
|
-
...script,
|
|
87
|
+
...(script || []),
|
|
48
88
|
"docker login --username gitlab-ci-token --password $CI_JOB_TOKEN $CI_REGISTRY",
|
|
49
|
-
"docker
|
|
50
|
-
"docker build --network host --cache-from $CACHE_IMAGE --tag $IMAGE_NAME:$IMAGE_TAG -f $APP_DIR/Dockerfile .",
|
|
89
|
+
"docker build --network host --cache-from $CACHE_IMAGE --tag $IMAGE_NAME:$IMAGE_TAG -f $APP_DIR/Dockerfile . --build-arg BUILDKIT_INLINE_CACHE=1", //BUILDKIT_INLINE_CACHE, see https://testdriven.io/blog/faster-ci-builds-with-docker-cache/
|
|
51
90
|
"docker push $IMAGE_NAME:$IMAGE_TAG",
|
|
52
91
|
"docker tag $IMAGE_NAME:$IMAGE_TAG $CACHE_IMAGE",
|
|
53
92
|
"docker push $CACHE_IMAGE",
|
|
54
93
|
],
|
|
55
|
-
|
|
94
|
+
...def,
|
|
95
|
+
});
|
|
56
96
|
};
|
package/src/build/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Context } from "../types/context";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { CatladderJob } from "../types/jobs";
|
|
3
4
|
import { createNodeJobs, createStorybookJobs, createMeteorJobs } from "./node";
|
|
4
5
|
|
|
5
6
|
import { BuildConfig } from "./types";
|
|
@@ -8,7 +9,7 @@ export * from "./node";
|
|
|
8
9
|
|
|
9
10
|
export type BuildTypes = {
|
|
10
11
|
[type in BuildConfig["type"]]: {
|
|
11
|
-
jobs: (context: Context) =>
|
|
12
|
+
jobs: (context: Context) => CatladderJob[];
|
|
12
13
|
defaults: () => Partial<Extract<BuildConfig, { type: type }>>;
|
|
13
14
|
};
|
|
14
15
|
};
|
|
@@ -30,7 +31,7 @@ export const BUILD_TYPES: BuildTypes = {
|
|
|
30
31
|
storybook: {
|
|
31
32
|
jobs: createStorybookJobs,
|
|
32
33
|
defaults: () => ({
|
|
33
|
-
buildCommand: ["yarn storybook
|
|
34
|
+
buildCommand: ["yarn build-storybook --quiet -o ./dist"],
|
|
34
35
|
}),
|
|
35
36
|
},
|
|
36
37
|
meteor: {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { Context } from "../../types/context";
|
|
2
|
-
import { GitlabJob, GitlabJobs } from "../../types/gitlab-types";
|
|
3
2
|
import { ensureArray } from "../../utils";
|
|
4
3
|
import { APP_BUILD_JOB_NAME } from "../base/constants";
|
|
5
4
|
import { createBuildJob } from "../base/createBuildJob";
|
|
6
|
-
import {
|
|
5
|
+
import { createDockerBuildJobDefault, requiresDockerBuild } from "../docker";
|
|
6
|
+
import { join } from "path";
|
|
7
7
|
import { isOfBuildType } from "../types";
|
|
8
|
-
import { getNextCache, getNodeCache } from "./cache";
|
|
9
|
-
import {
|
|
8
|
+
import { getNextCache, getNodeCache, getYarnCache } from "./cache";
|
|
9
|
+
import { NODE_RUNNER_BUILD_VARIABLES } from "./constants";
|
|
10
|
+
import { getYarnInstall, getYarnInstallCommand } from "./yarn";
|
|
11
|
+
import { CatladderJob } from "../../types/jobs";
|
|
10
12
|
|
|
11
|
-
export const createNodeBuildJobs = (context: Context):
|
|
13
|
+
export const createNodeBuildJobs = (context: Context): CatladderJob[] => {
|
|
12
14
|
const buildConfig = context.componentConfig.build;
|
|
13
15
|
|
|
14
16
|
if (!isOfBuildType(buildConfig, "node", "node-static", "storybook")) {
|
|
@@ -16,9 +18,12 @@ export const createNodeBuildJobs = (context: Context): GitlabJobs => {
|
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
const yarnInstall = getYarnInstall(context);
|
|
19
|
-
const appBuildJob:
|
|
21
|
+
const appBuildJob: CatladderJob | null =
|
|
20
22
|
buildConfig.buildCommand !== null
|
|
21
23
|
? createBuildJob(context, {
|
|
24
|
+
variables: {
|
|
25
|
+
...NODE_RUNNER_BUILD_VARIABLES,
|
|
26
|
+
},
|
|
22
27
|
cache: [...getNodeCache(context), ...getNextCache(context)],
|
|
23
28
|
script: [
|
|
24
29
|
...yarnInstall,
|
|
@@ -26,29 +31,46 @@ export const createNodeBuildJobs = (context: Context): GitlabJobs => {
|
|
|
26
31
|
],
|
|
27
32
|
artifacts: {
|
|
28
33
|
paths: [
|
|
29
|
-
context.componentConfig.dir
|
|
30
|
-
context.componentConfig.dir
|
|
31
|
-
context.componentConfig.dir
|
|
34
|
+
join(context.componentConfig.dir, "__build_info.json"),
|
|
35
|
+
join(context.componentConfig.dir, "dist"),
|
|
36
|
+
join(context.componentConfig.dir, ".next"),
|
|
37
|
+
...(buildConfig.artifactsPaths?.map((path) =>
|
|
38
|
+
join(context.componentConfig.dir, path)
|
|
39
|
+
) ?? []),
|
|
32
40
|
],
|
|
33
41
|
},
|
|
34
42
|
})
|
|
35
43
|
: null;
|
|
36
44
|
return [
|
|
37
45
|
...(appBuildJob ? [appBuildJob] : []),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
...(requiresDockerBuild(context)
|
|
47
|
+
? [
|
|
48
|
+
createDockerBuildJobDefault(context, {
|
|
49
|
+
script: [
|
|
50
|
+
buildConfig.type === "node-static" ||
|
|
51
|
+
buildConfig.type === "storybook"
|
|
52
|
+
? "ensureNginxDockerfile"
|
|
53
|
+
: "ensureNodeDockerfile",
|
|
54
|
+
],
|
|
55
|
+
cache: [...getYarnCache(context, "pull")],
|
|
56
|
+
variables: {
|
|
57
|
+
// only required for non static
|
|
58
|
+
YARN_INSTALL: getYarnInstallCommand(context, {
|
|
59
|
+
prodOnly: true,
|
|
60
|
+
}),
|
|
61
|
+
YARN_INSTALL_WITHOUT_SCRIPTS: getYarnInstallCommand(context, {
|
|
62
|
+
prodOnly: true,
|
|
63
|
+
noScripts: true,
|
|
64
|
+
}),
|
|
65
|
+
DOCKER_COPY_WORKSPACE_FILES:
|
|
66
|
+
context.packageManagerInfo?.pathsToCopyInDocker
|
|
67
|
+
.map((dir) => `COPY --chown=node:node ${dir} /app/${dir}`)
|
|
68
|
+
?.join("\n"),
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
needs: appBuildJob ? [APP_BUILD_JOB_NAME] : [],
|
|
72
|
+
}),
|
|
73
|
+
]
|
|
74
|
+
: []),
|
|
53
75
|
];
|
|
54
76
|
};
|
package/src/build/node/cache.ts
CHANGED
|
@@ -2,22 +2,38 @@ import { join } from "path";
|
|
|
2
2
|
import { Context } from "../../types/context";
|
|
3
3
|
import { GitlabJobCache } from "../../types/gitlab-types";
|
|
4
4
|
|
|
5
|
-
export const
|
|
6
|
-
|
|
5
|
+
export const getYarnCache = (
|
|
6
|
+
context: Context,
|
|
7
|
+
policy = "pull-push"
|
|
8
|
+
): GitlabJobCache[] => {
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
key: "yarn",
|
|
12
|
+
policy,
|
|
13
|
+
paths: [".yarn"],
|
|
14
|
+
},
|
|
15
|
+
];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const getNodeModulesCache = (
|
|
19
|
+
context: Context,
|
|
20
|
+
policy = "pull-push"
|
|
21
|
+
): GitlabJobCache[] => {
|
|
22
|
+
const componentIsInWorkspace =
|
|
23
|
+
context.packageManagerInfo?.componentIsInWorkspace;
|
|
7
24
|
|
|
8
25
|
return [
|
|
9
26
|
{
|
|
10
27
|
// if component is in a shared workspace, use workspace cache. use individual cache else
|
|
11
28
|
key: componentIsInWorkspace
|
|
12
29
|
? "node-modules-workspace"
|
|
13
|
-
: context.
|
|
14
|
-
policy
|
|
30
|
+
: context.componentConfig.dir + "-node-modules", // we use the dirname, not the component name, because in certain cases we have two apps in the same directory and want to share the cache, e.g. when having storybook in the same package.json
|
|
31
|
+
policy,
|
|
15
32
|
paths: [
|
|
16
|
-
".yarn",
|
|
17
33
|
...(componentIsInWorkspace
|
|
18
34
|
? [
|
|
19
35
|
"node_modules",
|
|
20
|
-
...(context.
|
|
36
|
+
...(context.packageManagerInfo?.workspaces.map((w) =>
|
|
21
37
|
join(w.location, "node_modules")
|
|
22
38
|
) ?? []),
|
|
23
39
|
]
|
|
@@ -26,6 +42,15 @@ export const getNodeCache = (context: Context): GitlabJobCache[] => {
|
|
|
26
42
|
},
|
|
27
43
|
];
|
|
28
44
|
};
|
|
45
|
+
export const getNodeCache = (
|
|
46
|
+
context: Context,
|
|
47
|
+
policy = "pull-push"
|
|
48
|
+
): GitlabJobCache[] => {
|
|
49
|
+
return [
|
|
50
|
+
...getYarnCache(context, policy),
|
|
51
|
+
...getNodeModulesCache(context, policy),
|
|
52
|
+
];
|
|
53
|
+
};
|
|
29
54
|
|
|
30
55
|
export const getNextCache = (context: Context): GitlabJobCache[] => [
|
|
31
56
|
{
|
package/src/build/node/index.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { Context } from "../../types/context";
|
|
2
|
-
import
|
|
2
|
+
import { CatladderJob } from "../../types/jobs";
|
|
3
3
|
import { createNodeBuildJobs } from "./buildJob";
|
|
4
4
|
import { createMeteorBuildJobs } from "./meteor";
|
|
5
5
|
import { createNodeTestJobs } from "./testJob";
|
|
6
6
|
|
|
7
|
-
export const createNodeJobs = (context: Context):
|
|
7
|
+
export const createNodeJobs = (context: Context): CatladderJob[] => {
|
|
8
8
|
return [...createNodeTestJobs(context), ...createNodeBuildJobs(context)];
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
export const createStorybookJobs = (context: Context):
|
|
11
|
+
export const createStorybookJobs = (context: Context): CatladderJob[] => {
|
|
12
12
|
return [...createNodeBuildJobs(context)];
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export const createMeteorJobs = (context: Context):
|
|
15
|
+
export const createMeteorJobs = (context: Context): CatladderJob[] => {
|
|
16
16
|
return [...createNodeTestJobs(context), ...createMeteorBuildJobs(context)];
|
|
17
17
|
};
|
package/src/build/node/meteor.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
|
+
import { getRunnerImage } from "../../runner";
|
|
3
|
+
import { GitlabJobCache } from "../../types";
|
|
2
4
|
import type { Context } from "../../types/context";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
GitlabJobCache,
|
|
6
|
-
GitlabJobs,
|
|
7
|
-
} from "../../types/gitlab-types";
|
|
5
|
+
|
|
6
|
+
import { CatladderJob } from "../../types/jobs";
|
|
8
7
|
|
|
9
8
|
import { APP_BUILD_JOB_NAME } from "../base/constants";
|
|
10
9
|
import { createBuildJob } from "../base/createBuildJob";
|
|
11
|
-
import {
|
|
10
|
+
import { createDockerBuildJobDefault } from "../docker";
|
|
12
11
|
import { isOfBuildType } from "../types";
|
|
13
12
|
import { getNodeCache } from "./cache";
|
|
14
13
|
import { getYarnInstall } from "./yarn";
|
|
@@ -28,7 +27,7 @@ const getMeteorCache = (context: Context): GitlabJobCache[] => [
|
|
|
28
27
|
],
|
|
29
28
|
},
|
|
30
29
|
];
|
|
31
|
-
export const createMeteorBuildJobs = (context: Context):
|
|
30
|
+
export const createMeteorBuildJobs = (context: Context): CatladderJob[] => {
|
|
32
31
|
const buildConfig = context.componentConfig.build;
|
|
33
32
|
|
|
34
33
|
if (!isOfBuildType(buildConfig, "meteor")) {
|
|
@@ -36,10 +35,11 @@ export const createMeteorBuildJobs = (context: Context): GitlabJobs => {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
const yarnInstall = getYarnInstall(context);
|
|
39
|
-
const appBuildJob:
|
|
38
|
+
const appBuildJob: CatladderJob | null =
|
|
40
39
|
buildConfig.buildCommand !== null
|
|
41
40
|
? createBuildJob(context, {
|
|
42
41
|
cache: [...getNodeCache(context), ...getMeteorCache(context)],
|
|
42
|
+
image: getRunnerImage("jobs-meteor"),
|
|
43
43
|
script: [
|
|
44
44
|
...yarnInstall,
|
|
45
45
|
|
|
@@ -61,15 +61,9 @@ export const createMeteorBuildJobs = (context: Context): GitlabJobs => {
|
|
|
61
61
|
: null;
|
|
62
62
|
return [
|
|
63
63
|
...(appBuildJob ? [appBuildJob] : []),
|
|
64
|
-
{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
...createDockerBuildJob(context, {
|
|
69
|
-
script: ["ensureMeteorDockerfile"],
|
|
70
|
-
}),
|
|
71
|
-
needs: appBuildJob ? [APP_BUILD_JOB_NAME] : [],
|
|
72
|
-
},
|
|
73
|
-
},
|
|
64
|
+
createDockerBuildJobDefault(context, {
|
|
65
|
+
script: ["ensureMeteorDockerfile"],
|
|
66
|
+
needs: appBuildJob ? [APP_BUILD_JOB_NAME] : [],
|
|
67
|
+
}),
|
|
74
68
|
];
|
|
75
69
|
};
|