@catladder/pipeline 1.141.1 → 1.142.1
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/bundles/catladder-gitlab/index.js +3 -3
- package/dist/constants.js +1 -1
- package/dist/deploy/cloudRun/index.js +3 -2
- package/dist/deploy/cloudRun/utils/database.d.ts +4 -2
- package/dist/deploy/cloudRun/utils/database.js +15 -2
- package/dist/deploy/types/googleCloudRun.d.ts +14 -0
- package/dist/pipeline/createChildPipeline.js +9 -59
- package/dist/pipeline/getPipelineStages.d.ts +8 -0
- package/dist/pipeline/getPipelineStages.js +53 -0
- package/dist/pipeline/gitlab/createGitlabJobs.d.ts +2 -3
- package/dist/pipeline/gitlab/createGitlabPipeline.d.ts +3 -0
- package/dist/pipeline/gitlab/createGitlabPipeline.js +21 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/deploy/cloudRun/index.ts +8 -2
- package/src/deploy/cloudRun/utils/database.ts +23 -1
- package/src/deploy/types/googleCloudRun.ts +15 -0
- package/src/pipeline/createChildPipeline.ts +8 -30
- package/src/pipeline/getPipelineStages.ts +22 -0
- package/src/pipeline/gitlab/createGitlabJobs.ts +1 -1
- package/src/pipeline/gitlab/createGitlabPipeline.ts +22 -0
|
@@ -62,6 +62,21 @@ export type DeployConfigCloudRunCloudSql = {
|
|
|
62
62
|
*/
|
|
63
63
|
deleteDatabaseOnStop?: boolean;
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* format of the `DATABASE_URL` environment variable
|
|
67
|
+
*
|
|
68
|
+
* the options are:
|
|
69
|
+
* - prisma: adds [required but ignored hostname](https://www.prisma.io/docs/orm/overview/databases/postgresql#connecting-via-sockets):
|
|
70
|
+
* `postgresql://$DB_USER:$DB_PASSWORD@localhost/$DB_NAME?host=/cloudsql/$CLOUD_SQL_INSTANCE_CONNECTION_NAME`
|
|
71
|
+
* - rails: percent-encodes the socket in the host part
|
|
72
|
+
* `postgresql://$DB_USER:$DB_PASSWORD@%2Fcloudsql%2FprojectId%3Aregion%3Ainstancename/$DB_NAME?`
|
|
73
|
+
* - jdbc: for use with Google Cloud SQL Connector for Java
|
|
74
|
+
* `jdbc:postgresql:///$DB_NAME?cloudSqlInstance=$CLOUD_SQL_INSTANCE_CONNECTION_NAME&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=$DB_USER&password=$DB_PASSWORD`
|
|
75
|
+
*
|
|
76
|
+
* defaults to prisma
|
|
77
|
+
*/
|
|
78
|
+
dbConnectionStringFormat?: "prisma" | "rails" | "jdbc";
|
|
79
|
+
|
|
65
80
|
/**
|
|
66
81
|
* add additional query params to the database connection string
|
|
67
82
|
*/
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RULES_ALWAYS } from "../rules";
|
|
3
|
-
import { getRunnerImage } from "../runner";
|
|
4
|
-
import type { GitlabPipeline, Pipeline, PipelineType } from "../types";
|
|
1
|
+
import type { Pipeline, PipelineType } from "../types";
|
|
5
2
|
import type { Config, PipelineTrigger } from "../types/config";
|
|
6
|
-
import { BASE_STAGES } from "../types/jobs";
|
|
7
3
|
import { createAllJobs } from "./createAllJobs";
|
|
4
|
+
import { getPipelineStages } from "./getPipelineStages";
|
|
8
5
|
import { createGitlabJobs } from "./gitlab/createGitlabJobs";
|
|
6
|
+
import { createGitlabPipelineFromStagesAndJobs } from "./gitlab/createGitlabPipeline";
|
|
9
7
|
|
|
10
8
|
export const createChildPipeline = async <T extends PipelineType>(
|
|
11
9
|
type: T,
|
|
@@ -13,34 +11,14 @@ export const createChildPipeline = async <T extends PipelineType>(
|
|
|
13
11
|
config: Config
|
|
14
12
|
): Promise<Pipeline<T>> => {
|
|
15
13
|
const jobs = await createAllJobs(config, trigger);
|
|
14
|
+
const stages = getPipelineStages(config);
|
|
16
15
|
|
|
17
|
-
// while technically not required, we group different envs in its own stage
|
|
18
|
-
// each job from `createJobs` that is defined as `envMode: "stagePerEnv"` will have `deploy dev`, etc. instead of just `deploy`
|
|
19
|
-
// this is just so that it looks nicer in gitlab and makes running mutliple manual tasks more easy to use
|
|
20
|
-
|
|
21
|
-
const allEnvs = getAllEnvsInAllComponents(config);
|
|
22
|
-
const stages = BASE_STAGES.reduce<string[]>(
|
|
23
|
-
(acc, baseStage) => [
|
|
24
|
-
...acc,
|
|
25
|
-
baseStage,
|
|
26
|
-
...allEnvs.map((e) => `${baseStage} ${e}`),
|
|
27
|
-
],
|
|
28
|
-
[]
|
|
29
|
-
);
|
|
30
16
|
if (type === "gitlab") {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
variables: {
|
|
34
|
-
FF_USE_FASTZIP: "true",
|
|
35
|
-
GIT_DEPTH: 1, // no need the full depth
|
|
36
|
-
},
|
|
37
|
-
workflow: {
|
|
38
|
-
rules: RULES_ALWAYS,
|
|
39
|
-
},
|
|
17
|
+
const gitlabJobs = await createGitlabJobs(jobs);
|
|
18
|
+
return createGitlabPipelineFromStagesAndJobs(
|
|
40
19
|
stages,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return pipeline as Pipeline<T>;
|
|
20
|
+
gitlabJobs
|
|
21
|
+
) as Pipeline<T>;
|
|
44
22
|
}
|
|
45
23
|
throw new Error(`${type} is not supported`);
|
|
46
24
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getAllEnvsInAllComponents } from "../config";
|
|
2
|
+
import type { Config } from "../types/config";
|
|
3
|
+
import { BASE_STAGES } from "../types/jobs";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
while technically not required, we group different envs in its own stage
|
|
8
|
+
each job from `createJobs` that is defined as `envMode: "stagePerEnv"` will have `deploy dev`, etc. instead of just `deploy`
|
|
9
|
+
this is just so that it looks nicer in gitlab and makes running mutliple manual tasks more easy to use
|
|
10
|
+
*/
|
|
11
|
+
export function getPipelineStages(config: Config) {
|
|
12
|
+
const allEnvs = getAllEnvsInAllComponents(config);
|
|
13
|
+
const stages = BASE_STAGES.reduce<string[]>(
|
|
14
|
+
(acc, baseStage) => [
|
|
15
|
+
...acc,
|
|
16
|
+
baseStage,
|
|
17
|
+
...allEnvs.map((e) => `${baseStage} ${e}`),
|
|
18
|
+
],
|
|
19
|
+
[]
|
|
20
|
+
);
|
|
21
|
+
return stages;
|
|
22
|
+
}
|
|
@@ -5,7 +5,7 @@ import type { CatladderJob, CatladderJobNeed } from "../../types/jobs";
|
|
|
5
5
|
import type { AllCatladderJobs } from "../createAllJobs";
|
|
6
6
|
import { notNil } from "../../utils";
|
|
7
7
|
|
|
8
|
-
type AllGitlabJobs = Record<string, GitlabJobDef>;
|
|
8
|
+
export type AllGitlabJobs = Record<string, GitlabJobDef>;
|
|
9
9
|
|
|
10
10
|
const removeUndefined = <T extends Record<string, unknown>>(obj: T): T =>
|
|
11
11
|
Object.fromEntries(
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RULES_ALWAYS } from "../../rules";
|
|
2
|
+
import { getRunnerImage } from "../../runner";
|
|
3
|
+
import type { Pipeline } from "../../types";
|
|
4
|
+
import type { AllGitlabJobs } from "./createGitlabJobs";
|
|
5
|
+
|
|
6
|
+
export function createGitlabPipelineFromStagesAndJobs(
|
|
7
|
+
stages: string[],
|
|
8
|
+
gitlabJobs: AllGitlabJobs
|
|
9
|
+
): Pipeline<"gitlab"> {
|
|
10
|
+
return {
|
|
11
|
+
image: getRunnerImage("jobs-default"), // default image
|
|
12
|
+
variables: {
|
|
13
|
+
FF_USE_FASTZIP: "true",
|
|
14
|
+
GIT_DEPTH: 1, // no need the full depth
|
|
15
|
+
},
|
|
16
|
+
workflow: {
|
|
17
|
+
rules: RULES_ALWAYS,
|
|
18
|
+
},
|
|
19
|
+
stages,
|
|
20
|
+
jobs: gitlabJobs,
|
|
21
|
+
};
|
|
22
|
+
}
|