@catladder/pipeline 0.0.0-fix-command-710f75f1 → 0.0.0-hidden-secrets-da086bf2

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.
Files changed (90) hide show
  1. package/dist/build/custom/buildJob.js +1 -0
  2. package/dist/build/docker.d.ts +4 -18
  3. package/dist/build/docker.js +15 -9
  4. package/dist/build/index.js +7 -1
  5. package/dist/build/rails/build.js +37 -16
  6. package/dist/build/rails/index.d.ts +2 -2
  7. package/dist/build/rails/test.js +1 -2
  8. package/dist/build/types.d.ts +36 -4
  9. package/dist/bundles/catladder-gitlab/index.js +536 -214
  10. package/dist/constants.js +1 -1
  11. package/dist/context/getEnvironment.js +1 -0
  12. package/dist/context/getEnvironmentContext.js +5 -3
  13. package/dist/context/getEnvironmentVariables.d.ts +5 -1
  14. package/dist/context/getEnvironmentVariables.js +7 -2
  15. package/dist/deploy/base.js +1 -1
  16. package/dist/deploy/cloudRun/index.js +14 -6
  17. package/dist/deploy/index.d.ts +2 -1
  18. package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +3 -1
  19. package/dist/deploy/kubernetes/additionalSecretKeys.js +5 -1
  20. package/dist/deploy/kubernetes/deployJob.js +4 -4
  21. package/dist/deploy/kubernetes/kubeValues.d.ts +1 -0
  22. package/dist/deploy/kubernetes/kubeValues.js +9 -6
  23. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +1 -0
  24. package/dist/deploy/types/custom.d.ts +2 -1
  25. package/dist/deploy/types/googleCloudRun.d.ts +5 -1
  26. package/dist/deploy/types/kubernetes.d.ts +9 -0
  27. package/dist/pipeline/createAllJobs.d.ts +8 -0
  28. package/dist/pipeline/createAllJobs.js +164 -0
  29. package/dist/pipeline/createChildPipeline.js +24 -48
  30. package/dist/pipeline/createJobsForComponent.d.ts +3 -0
  31. package/dist/pipeline/{createJobs.js → createJobsForComponent.js} +8 -105
  32. package/dist/pipeline/gitlab/createGitlabJobs.d.ts +14 -0
  33. package/dist/pipeline/gitlab/createGitlabJobs.js +260 -0
  34. package/dist/pipeline/index.d.ts +1 -1
  35. package/dist/pipeline/index.js +1 -1
  36. package/dist/tsconfig.tsbuildinfo +1 -1
  37. package/dist/types/config.d.ts +3 -3
  38. package/dist/types/context.d.ts +3 -1
  39. package/dist/types/environmentContext.d.ts +7 -0
  40. package/dist/types/gitlab-types.d.ts +5 -1
  41. package/dist/types/jobs.d.ts +9 -2
  42. package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +8 -20
  43. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +8 -20
  44. package/examples/__snapshots__/cloud-run-non-public.ts.snap +8 -20
  45. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +3092 -0
  46. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +16 -40
  47. package/examples/__snapshots__/custom-build-job.ts.snap +8 -20
  48. package/examples/__snapshots__/kubernetes-application-customization.ts.snap +2280 -0
  49. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +24 -24
  50. package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1911 -0
  51. package/examples/cloud-run-with-sql-reuse-db.ts +54 -0
  52. package/examples/kubernetes-application-customization.ts +57 -0
  53. package/examples/rails-k8s-with-worker.ts +95 -0
  54. package/package.json +1 -1
  55. package/src/build/custom/buildJob.ts +1 -0
  56. package/src/build/docker.ts +13 -6
  57. package/src/build/index.ts +7 -1
  58. package/src/build/node/cache.ts +2 -2
  59. package/src/build/rails/build.ts +20 -10
  60. package/src/build/rails/index.ts +2 -2
  61. package/src/build/rails/test.ts +43 -39
  62. package/src/build/types.ts +40 -5
  63. package/src/config/configruedEnvs.ts +2 -8
  64. package/src/context/getEnvironment.ts +1 -0
  65. package/src/context/getEnvironmentContext.ts +6 -6
  66. package/src/context/getEnvironmentVariables.ts +9 -4
  67. package/src/deploy/base.ts +1 -1
  68. package/src/deploy/cloudRun/deployJob.ts +1 -1
  69. package/src/deploy/cloudRun/index.ts +12 -4
  70. package/src/deploy/index.ts +4 -1
  71. package/src/deploy/kubernetes/additionalSecretKeys.ts +1 -1
  72. package/src/deploy/kubernetes/deployJob.ts +2 -1
  73. package/src/deploy/kubernetes/kubeValues.ts +7 -5
  74. package/src/deploy/types/custom.ts +2 -1
  75. package/src/deploy/types/googleCloudRun.ts +6 -1
  76. package/src/deploy/types/kubernetes.ts +11 -1
  77. package/src/pipeline/createAllJobs.ts +38 -0
  78. package/src/pipeline/createChildPipeline.ts +6 -22
  79. package/src/pipeline/createJobsForComponent.ts +64 -0
  80. package/src/pipeline/gitlab/createGitlabJobs.ts +149 -0
  81. package/src/pipeline/index.ts +1 -1
  82. package/src/types/context.ts +3 -1
  83. package/src/types/environmentContext.ts +7 -0
  84. package/src/types/gitlab-types.ts +10 -3
  85. package/src/types/jobs.ts +11 -2
  86. package/dist/pipeline/createJobs.d.ts +0 -3
  87. package/dist/pipeline/gitlab/makeGitlabJob.d.ts +0 -10
  88. package/dist/pipeline/gitlab/makeGitlabJob.js +0 -44
  89. package/src/pipeline/createJobs.ts +0 -199
  90. package/src/pipeline/gitlab/makeGitlabJob.ts +0 -23
@@ -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
- };