@catladder/pipeline 0.0.0-fix-command-710f75f1 → 0.0.0-fix-error-sql-db-delete-b3878c2e
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/custom/buildJob.js +1 -0
- package/dist/build/docker.d.ts +4 -18
- package/dist/build/docker.js +15 -9
- package/dist/build/index.js +7 -1
- package/dist/build/rails/build.js +37 -16
- package/dist/build/rails/index.d.ts +2 -2
- package/dist/build/rails/test.js +1 -2
- package/dist/build/types.d.ts +36 -4
- package/dist/bundles/catladder-gitlab/index.js +543 -218
- package/dist/constants.js +1 -1
- package/dist/context/getEnvironment.js +1 -0
- package/dist/context/getEnvironmentContext.js +5 -3
- package/dist/context/getEnvironmentVariables.d.ts +5 -1
- package/dist/context/getEnvironmentVariables.js +7 -2
- package/dist/deploy/base.js +1 -1
- package/dist/deploy/cloudRun/index.js +14 -6
- package/dist/deploy/custom/deployJob.js +6 -3
- package/dist/deploy/index.d.ts +2 -1
- package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +3 -1
- package/dist/deploy/kubernetes/additionalSecretKeys.js +5 -1
- package/dist/deploy/kubernetes/deployJob.js +4 -4
- package/dist/deploy/kubernetes/kubeValues.d.ts +1 -0
- package/dist/deploy/kubernetes/kubeValues.js +9 -6
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +1 -0
- package/dist/deploy/types/custom.d.ts +2 -1
- package/dist/deploy/types/googleCloudRun.d.ts +5 -1
- package/dist/deploy/types/kubernetes.d.ts +9 -0
- package/dist/pipeline/createAllJobs.d.ts +8 -0
- package/dist/pipeline/createAllJobs.js +164 -0
- package/dist/pipeline/createChildPipeline.js +24 -48
- package/dist/pipeline/createJobsForComponent.d.ts +3 -0
- package/dist/pipeline/{createJobs.js → createJobsForComponent.js} +8 -105
- package/dist/pipeline/gitlab/createGitlabJobs.d.ts +14 -0
- package/dist/pipeline/gitlab/createGitlabJobs.js +260 -0
- package/dist/pipeline/index.d.ts +1 -1
- package/dist/pipeline/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +3 -3
- package/dist/types/context.d.ts +3 -1
- package/dist/types/environmentContext.d.ts +7 -0
- package/dist/types/gitlab-types.d.ts +5 -1
- package/dist/types/jobs.d.ts +9 -2
- package/dist/utils/gitlab.js +1 -1
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +32 -32
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +32 -32
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +32 -32
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +3116 -0
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +65 -65
- package/examples/__snapshots__/custom-build-job.ts.snap +32 -32
- package/examples/__snapshots__/custom-deploy.ts.snap +1384 -0
- package/examples/__snapshots__/kubernetes-application-customization.ts.snap +2280 -0
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +2204 -0
- package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +24 -24
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1911 -0
- package/examples/cloud-run-with-sql-reuse-db.ts +54 -0
- package/examples/custom-deploy.ts +25 -0
- package/examples/kubernetes-application-customization.ts +57 -0
- package/examples/kubernetes-with-cloud-sql-legacy.ts +33 -0
- package/examples/rails-k8s-with-worker.ts +95 -0
- package/package.json +1 -1
- package/src/build/custom/buildJob.ts +1 -0
- package/src/build/docker.ts +13 -6
- package/src/build/index.ts +7 -1
- package/src/build/node/cache.ts +2 -2
- package/src/build/rails/build.ts +20 -10
- package/src/build/rails/index.ts +2 -2
- package/src/build/rails/test.ts +43 -39
- package/src/build/types.ts +40 -5
- package/src/config/configruedEnvs.ts +2 -8
- package/src/context/getEnvironment.ts +1 -0
- package/src/context/getEnvironmentContext.ts +6 -6
- package/src/context/getEnvironmentVariables.ts +9 -4
- package/src/deploy/base.ts +1 -1
- package/src/deploy/cloudRun/deployJob.ts +1 -1
- package/src/deploy/cloudRun/index.ts +12 -4
- package/src/deploy/custom/deployJob.ts +9 -1
- package/src/deploy/index.ts +4 -1
- package/src/deploy/kubernetes/additionalSecretKeys.ts +1 -1
- package/src/deploy/kubernetes/deployJob.ts +2 -1
- package/src/deploy/kubernetes/kubeValues.ts +7 -5
- package/src/deploy/types/custom.ts +2 -1
- package/src/deploy/types/googleCloudRun.ts +6 -1
- package/src/deploy/types/kubernetes.ts +11 -1
- package/src/pipeline/createAllJobs.ts +38 -0
- package/src/pipeline/createChildPipeline.ts +6 -22
- package/src/pipeline/createJobsForComponent.ts +64 -0
- package/src/pipeline/gitlab/createGitlabJobs.ts +149 -0
- package/src/pipeline/index.ts +1 -1
- package/src/types/context.ts +3 -1
- package/src/types/environmentContext.ts +7 -0
- package/src/types/gitlab-types.ts +10 -3
- package/src/types/jobs.ts +11 -2
- package/src/utils/gitlab.ts +1 -1
- package/dist/pipeline/createJobs.d.ts +0 -3
- package/dist/pipeline/gitlab/makeGitlabJob.d.ts +0 -10
- package/dist/pipeline/gitlab/makeGitlabJob.js +0 -44
- package/src/pipeline/createJobs.ts +0 -199
- package/src/pipeline/gitlab/makeGitlabJob.ts +0 -23
package/src/types/jobs.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
GitlabRule,
|
|
6
6
|
GitlabVariables,
|
|
7
7
|
GitlabJobService,
|
|
8
|
+
GitlabJobImage,
|
|
8
9
|
} from "./gitlab-types";
|
|
9
10
|
|
|
10
11
|
export const BASE_STAGES = [
|
|
@@ -18,7 +19,9 @@ export const BASE_STAGES = [
|
|
|
18
19
|
] as const;
|
|
19
20
|
export type BaseStage = typeof BASE_STAGES[number];
|
|
20
21
|
|
|
21
|
-
export type CatladderJobNeed =
|
|
22
|
+
export type CatladderJobNeed =
|
|
23
|
+
| string
|
|
24
|
+
| { job: string; artifacts: boolean; componentName?: string };
|
|
22
25
|
export type CatladderJob<S = BaseStage> = {
|
|
23
26
|
/**
|
|
24
27
|
* the name of the job (without any env or app prefix and suffix)
|
|
@@ -52,9 +55,15 @@ export type CatladderJob<S = BaseStage> = {
|
|
|
52
55
|
|
|
53
56
|
/**
|
|
54
57
|
* does this require another job (from the same component)?
|
|
58
|
+
*
|
|
59
|
+
* You can also require a job from another component if you set `componentName`
|
|
60
|
+
*
|
|
55
61
|
*/
|
|
56
62
|
needs?: Array<CatladderJobNeed>;
|
|
57
63
|
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated set `componentName` to `needs` if you want to wait for a job from another component
|
|
66
|
+
*/
|
|
58
67
|
needsOtherComponent?: Array<{
|
|
59
68
|
componentName: string;
|
|
60
69
|
job: string;
|
|
@@ -78,7 +87,7 @@ export type CatladderJob<S = BaseStage> = {
|
|
|
78
87
|
/**
|
|
79
88
|
* image to use
|
|
80
89
|
*/
|
|
81
|
-
image?:
|
|
90
|
+
image?: GitlabJobImage;
|
|
82
91
|
|
|
83
92
|
/**
|
|
84
93
|
* variables to pass
|
package/src/utils/gitlab.ts
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { PipelineJob } from "../types";
|
|
2
|
-
import type { Config, PipelineTrigger } from "../types/config";
|
|
3
|
-
export declare const createJobs: <T extends "gitlab">(type: T, envs: string[], config: Config, componentName: string, trigger: PipelineTrigger) => Promise<Record<string, PipelineJob<T>>>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { GitlabJobDef } from "../../types";
|
|
2
|
-
import type { CatladderJob } from "../../types/jobs";
|
|
3
|
-
export declare const makeGitlabJob: ({
|
|
4
|
-
envMode,
|
|
5
|
-
needsStages,
|
|
6
|
-
needsOtherComponent,
|
|
7
|
-
name,
|
|
8
|
-
needs,
|
|
9
|
-
...rest
|
|
10
|
-
}: CatladderJob<string>) => GitlabJobDef;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __assign = this && this.__assign || function () {
|
|
4
|
-
__assign = Object.assign || function (t) {
|
|
5
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
-
s = arguments[i];
|
|
7
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __rest = this && this.__rest || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
|
-
exports.__esModule = true;
|
|
22
|
-
exports.makeGitlabJob = void 0;
|
|
23
|
-
var lodash_1 = require("lodash");
|
|
24
|
-
var defaults_1 = require("../../defaults");
|
|
25
|
-
var getJobName = function (need) {
|
|
26
|
-
return (0, lodash_1.isObject)(need) ? need.job : need;
|
|
27
|
-
};
|
|
28
|
-
var makeGitlabJob = function (_a) {
|
|
29
|
-
var envMode = _a.envMode,
|
|
30
|
-
needsStages = _a.needsStages,
|
|
31
|
-
needsOtherComponent = _a.needsOtherComponent,
|
|
32
|
-
name = _a.name,
|
|
33
|
-
needs = _a.needs,
|
|
34
|
-
rest = __rest(_a, ["envMode", "needsStages", "needsOtherComponent", "name", "needs"]);
|
|
35
|
-
return __assign(__assign({}, rest), {
|
|
36
|
-
// sort in a predictable manner for snapshot tests
|
|
37
|
-
needs: needs === null || needs === void 0 ? void 0 : needs.sort(function (a, b) {
|
|
38
|
-
return getJobName(a).localeCompare(getJobName(b));
|
|
39
|
-
}),
|
|
40
|
-
retry: defaults_1.BASE_RETRY,
|
|
41
|
-
interruptible: true
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
exports.makeGitlabJob = makeGitlabJob;
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { isFunction, isObject } from "lodash";
|
|
2
|
-
import { BUILD_TYPES } from "../build";
|
|
3
|
-
import { createContext } from "../context";
|
|
4
|
-
import { DEPLOY_TYPES } from "../deploy";
|
|
5
|
-
import type { PipelineJob, PipelineType } from "../types";
|
|
6
|
-
import type { Config, PipelineTrigger } from "../types/config";
|
|
7
|
-
import type { CommitInfo, Context } from "../types/context";
|
|
8
|
-
import type { CatladderJob, CatladderJobNeed } from "../types/jobs";
|
|
9
|
-
import { notNil } from "../utils";
|
|
10
|
-
import { getBaseCommitInfo } from "./commitInfo/getCommitInfo";
|
|
11
|
-
import { makeGitlabJob } from "./gitlab/makeGitlabJob";
|
|
12
|
-
import { getPackageManagerInfo } from "./packageManager";
|
|
13
|
-
|
|
14
|
-
const injectDefaultVarsInCustomJobs = (
|
|
15
|
-
context: Context,
|
|
16
|
-
jobs: CatladderJob[]
|
|
17
|
-
) =>
|
|
18
|
-
jobs.map(({ variables, ...job }) => ({
|
|
19
|
-
variables: {
|
|
20
|
-
...(context.environment.envVars ?? {}),
|
|
21
|
-
...(variables ?? {}),
|
|
22
|
-
},
|
|
23
|
-
...job,
|
|
24
|
-
}));
|
|
25
|
-
const getCustomJobs = (context: Context) => {
|
|
26
|
-
if (!context.componentConfig.customJobs) {
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
const rawJobs = isFunction(context.componentConfig.customJobs)
|
|
30
|
-
? context.componentConfig.customJobs(context)
|
|
31
|
-
: context.componentConfig.customJobs;
|
|
32
|
-
return injectDefaultVarsInCustomJobs(context, rawJobs);
|
|
33
|
-
};
|
|
34
|
-
const createRawJobs = (context: Context): CatladderJob[] => {
|
|
35
|
-
if (context.componentConfig.deploy === false) {
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
|
-
const buildJobs =
|
|
39
|
-
BUILD_TYPES[context.componentConfig.build.type].jobs(context);
|
|
40
|
-
const deployJobs =
|
|
41
|
-
DEPLOY_TYPES[context.componentConfig.deploy.type].jobs(context);
|
|
42
|
-
|
|
43
|
-
const customJobs = getCustomJobs(context);
|
|
44
|
-
return [...buildJobs, ...deployJobs, ...customJobs];
|
|
45
|
-
};
|
|
46
|
-
const getFullJobName = (
|
|
47
|
-
name: string,
|
|
48
|
-
componentName: string,
|
|
49
|
-
env?: string | null
|
|
50
|
-
) => {
|
|
51
|
-
if (env) {
|
|
52
|
-
return `${componentName} ${name} | ${env} `;
|
|
53
|
-
}
|
|
54
|
-
return `${componentName} ${name}`;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const getFullReferencedJobName = (
|
|
58
|
-
referencedJobName: string,
|
|
59
|
-
componentName: string,
|
|
60
|
-
env: string,
|
|
61
|
-
allRawJobs: CatladderJob[]
|
|
62
|
-
) => {
|
|
63
|
-
const referencedJob = allRawJobs.find((j) => j.name === referencedJobName);
|
|
64
|
-
if (!referencedJob) {
|
|
65
|
-
throw new Error("unknown job referenced: " + referencedJobName);
|
|
66
|
-
}
|
|
67
|
-
const envToSet = referencedJob.envMode !== "none" ? env : null;
|
|
68
|
-
return getFullJobName(referencedJobName, componentName, envToSet);
|
|
69
|
-
};
|
|
70
|
-
// replaces references to other jobs with the full name
|
|
71
|
-
// the full name contains the componentname and the env name (if any)
|
|
72
|
-
const replaceReferences = (
|
|
73
|
-
job: CatladderJob,
|
|
74
|
-
componentName: string,
|
|
75
|
-
env: string,
|
|
76
|
-
allRawJobs: CatladderJob[]
|
|
77
|
-
): CatladderJob<string> => {
|
|
78
|
-
const stage =
|
|
79
|
-
job.envMode === "stagePerEnv" ? `${job.stage} ${env}` : job.stage;
|
|
80
|
-
|
|
81
|
-
const needsFromNeeds: CatladderJob["needs"] = job.needs?.map((n) =>
|
|
82
|
-
isObject(n)
|
|
83
|
-
? {
|
|
84
|
-
job: getFullReferencedJobName(n.job, componentName, env, allRawJobs),
|
|
85
|
-
artifacts: n.artifacts,
|
|
86
|
-
}
|
|
87
|
-
: getFullReferencedJobName(n, componentName, env, allRawJobs)
|
|
88
|
-
);
|
|
89
|
-
const needsFromOtherComponents: CatladderJob["needs"] =
|
|
90
|
-
job.needsOtherComponent?.map((other) => ({
|
|
91
|
-
artifacts: other.artifacts,
|
|
92
|
-
job: getFullReferencedJobName(
|
|
93
|
-
other.job,
|
|
94
|
-
other.componentName,
|
|
95
|
-
env,
|
|
96
|
-
allRawJobs
|
|
97
|
-
),
|
|
98
|
-
}));
|
|
99
|
-
const needs = [
|
|
100
|
-
...(needsFromNeeds ?? []),
|
|
101
|
-
...(needsFromOtherComponents ?? []),
|
|
102
|
-
];
|
|
103
|
-
return {
|
|
104
|
-
...job,
|
|
105
|
-
stage,
|
|
106
|
-
needs,
|
|
107
|
-
environment: job.environment?.on_stop
|
|
108
|
-
? {
|
|
109
|
-
...job.environment,
|
|
110
|
-
on_stop: getFullReferencedJobName(
|
|
111
|
-
job.environment.on_stop,
|
|
112
|
-
componentName,
|
|
113
|
-
env,
|
|
114
|
-
allRawJobs
|
|
115
|
-
),
|
|
116
|
-
}
|
|
117
|
-
: job.environment,
|
|
118
|
-
};
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
// this can be removed once https://gitlab.com/gitlab-org/gitlab/-/issues/220758 is resolved
|
|
122
|
-
const addStageNeeds = (jobs: CatladderJob[]): CatladderJob[] => {
|
|
123
|
-
// when a job defines needsStages, we add these as needs
|
|
124
|
-
return jobs.map((job) => {
|
|
125
|
-
if (!job.needsStages || job.needsStages.length === 0) {
|
|
126
|
-
return job;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const neededJobs = jobs
|
|
130
|
-
.map((j) => {
|
|
131
|
-
const neededStage = job.needsStages?.find((s) => j.stage === s.stage);
|
|
132
|
-
if (neededStage) {
|
|
133
|
-
return {
|
|
134
|
-
job: j.name,
|
|
135
|
-
artifacts: neededStage.artifacts ?? false,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
})
|
|
139
|
-
.filter(notNil);
|
|
140
|
-
return {
|
|
141
|
-
...job,
|
|
142
|
-
|
|
143
|
-
needs: [...(job.needs ?? []), ...neededJobs],
|
|
144
|
-
};
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
export const createJobs = async <T extends PipelineType>(
|
|
149
|
-
type: T,
|
|
150
|
-
envs: string[],
|
|
151
|
-
config: Config,
|
|
152
|
-
componentName: string,
|
|
153
|
-
trigger: PipelineTrigger
|
|
154
|
-
): Promise<Record<string, PipelineJob<T>>> => {
|
|
155
|
-
const commitInfo: CommitInfo = {
|
|
156
|
-
...(await getBaseCommitInfo()),
|
|
157
|
-
trigger,
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const packageManagerInfo = await getPackageManagerInfo(config, componentName);
|
|
161
|
-
|
|
162
|
-
return envs.reduce(async (acc, env) => {
|
|
163
|
-
const context = await createContext(
|
|
164
|
-
config,
|
|
165
|
-
componentName,
|
|
166
|
-
env,
|
|
167
|
-
commitInfo,
|
|
168
|
-
packageManagerInfo
|
|
169
|
-
);
|
|
170
|
-
const jobs = addStageNeeds(createRawJobs(context));
|
|
171
|
-
|
|
172
|
-
const result = {
|
|
173
|
-
...(await acc),
|
|
174
|
-
...jobs.reduce<Record<string, PipelineJob<T>>>((acc, job) => {
|
|
175
|
-
const jobWithResolvedReferences = replaceReferences(
|
|
176
|
-
job,
|
|
177
|
-
componentName,
|
|
178
|
-
env,
|
|
179
|
-
jobs
|
|
180
|
-
);
|
|
181
|
-
const jobName = getFullJobName(
|
|
182
|
-
job.name,
|
|
183
|
-
componentName,
|
|
184
|
-
job.envMode !== "none" ? env : undefined
|
|
185
|
-
);
|
|
186
|
-
if (type === "gitlab") {
|
|
187
|
-
return {
|
|
188
|
-
...acc,
|
|
189
|
-
[jobName]: makeGitlabJob(
|
|
190
|
-
jobWithResolvedReferences
|
|
191
|
-
) as PipelineJob<T>,
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
throw new Error("not supported");
|
|
195
|
-
}, await Promise.resolve({})),
|
|
196
|
-
};
|
|
197
|
-
return result;
|
|
198
|
-
}, {});
|
|
199
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { isObject } from "lodash";
|
|
2
|
-
import { BASE_RETRY } from "../../defaults";
|
|
3
|
-
import type { GitlabJobDef } from "../../types";
|
|
4
|
-
import type { CatladderJob, CatladderJobNeed } from "../../types/jobs";
|
|
5
|
-
const getJobName = (need: CatladderJobNeed) =>
|
|
6
|
-
isObject(need) ? need.job : need;
|
|
7
|
-
|
|
8
|
-
export const makeGitlabJob = ({
|
|
9
|
-
envMode,
|
|
10
|
-
needsStages,
|
|
11
|
-
needsOtherComponent,
|
|
12
|
-
name,
|
|
13
|
-
needs,
|
|
14
|
-
...rest
|
|
15
|
-
}: CatladderJob<string>): GitlabJobDef => {
|
|
16
|
-
return {
|
|
17
|
-
...rest,
|
|
18
|
-
// sort in a predictable manner for snapshot tests
|
|
19
|
-
needs: needs?.sort((a, b) => getJobName(a).localeCompare(getJobName(b))),
|
|
20
|
-
retry: BASE_RETRY,
|
|
21
|
-
interruptible: true,
|
|
22
|
-
};
|
|
23
|
-
};
|