@catladder/pipeline 0.0.0-node16-ddfae617 → 0.0.0-prettier-cbceeed9
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/bin/catladder-gitlab-dev.js +3 -0
- package/bin/catladder-gitlab.js +1 -1
- package/dist/build/base/createBuildJob.d.ts +2 -2
- package/dist/build/base/createBuildJob.js +15 -30
- package/dist/build/base/writeBuildInfo.d.ts +2 -0
- package/dist/build/base/{getBuildInfo.js → writeBuildInfo.js} +3 -6
- package/dist/build/custom/buildJob.d.ts +3 -0
- package/dist/build/custom/buildJob.js +83 -0
- package/dist/build/custom/index.d.ts +3 -0
- package/dist/build/custom/index.js +40 -0
- package/dist/build/docker.d.ts +33 -9
- package/dist/build/docker.js +51 -54
- package/dist/build/index.d.ts +6 -5
- package/dist/build/index.js +20 -6
- package/dist/build/node/buildJob.d.ts +2 -2
- package/dist/build/node/buildJob.js +3 -25
- package/dist/build/node/cache.d.ts +2 -2
- package/dist/build/node/cache.js +19 -22
- package/dist/build/node/index.d.ts +1 -1
- package/dist/build/node/index.js +3 -16
- package/dist/build/node/meteor.d.ts +1 -1
- package/dist/build/node/meteor.js +9 -20
- package/dist/build/node/testJob.d.ts +2 -2
- package/dist/build/node/testJob.js +7 -21
- package/dist/build/node/yarn.d.ts +1 -1
- package/dist/build/node/yarn.js +14 -15
- package/dist/build/rails/build.d.ts +3 -0
- package/dist/build/rails/build.js +51 -0
- package/dist/build/rails/index.d.ts +3 -0
- package/dist/build/rails/index.js +41 -0
- package/dist/build/rails/test.d.ts +3 -0
- package/dist/build/rails/test.js +94 -0
- package/dist/build/types.d.ts +84 -9
- package/dist/build/types.js +0 -4
- package/dist/bundles/catladder-gitlab/index.js +32979 -0
- package/dist/catladder-gitlab.js +7 -26
- package/dist/config/{configruedEnvs.test.d.ts → __tests__/configruedEnvs.test.d.ts} +0 -0
- package/dist/config/{configruedEnvs.test.js → __tests__/configruedEnvs.test.js} +10 -12
- package/dist/config/configruedEnvs.d.ts +1 -1
- package/dist/config/configruedEnvs.js +7 -22
- package/dist/config/index.js +0 -4
- package/dist/config/readConfig.d.ts +1 -1
- package/dist/config/readConfig.js +2 -13
- package/dist/constants.js +1 -1
- package/dist/context/{resolveReferences.test.d.ts → __tests__/resolveReferences.test.d.ts} +0 -0
- package/dist/context/__tests__/resolveReferences.test.js +336 -0
- package/dist/context/getEnvConfig.d.ts +2 -0
- package/dist/context/getEnvConfig.js +18 -0
- package/dist/context/getEnvType.d.ts +4 -0
- package/dist/context/getEnvType.js +13 -0
- package/dist/context/getEnvironment.d.ts +3 -0
- package/dist/{pipeline/createChildPipeline.test.js → context/getEnvironment.js} +42 -84
- package/dist/context/getEnvironmentContext.d.ts +4 -0
- package/dist/context/getEnvironmentContext.js +33 -0
- package/dist/context/getEnvironmentVariables.d.ts +10 -0
- package/dist/context/getEnvironmentVariables.js +260 -0
- package/dist/context/getLabels.d.ts +8 -0
- package/dist/context/getLabels.js +38 -0
- package/dist/context/index.d.ts +5 -6
- package/dist/context/index.js +158 -208
- package/dist/context/resolveReferences.d.ts +1 -3
- package/dist/context/resolveReferences.js +213 -52
- package/dist/defaults/index.d.ts +1 -1
- package/dist/deploy/base.d.ts +4 -2
- package/dist/deploy/base.js +38 -33
- package/dist/deploy/cloudRun/deployJob.d.ts +3 -0
- package/dist/deploy/cloudRun/deployJob.js +238 -0
- package/dist/deploy/cloudRun/index.d.ts +4 -0
- package/dist/deploy/cloudRun/index.js +112 -0
- package/dist/deploy/cloudRun/utils/createArgsString.d.ts +11 -0
- package/dist/deploy/cloudRun/utils/createArgsString.js +55 -0
- package/dist/deploy/cloudRun/utils/database.d.ts +4 -0
- package/dist/deploy/cloudRun/utils/database.js +64 -0
- package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.d.ts +2 -0
- package/dist/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.js +10 -0
- package/dist/deploy/cloudRun/utils/jobName.d.ts +1 -0
- package/dist/deploy/cloudRun/utils/jobName.js +8 -0
- package/dist/deploy/custom/deployJob.d.ts +2 -2
- package/dist/deploy/custom/deployJob.js +10 -16
- package/dist/deploy/custom/index.d.ts +2 -1
- package/dist/deploy/custom/index.js +14 -19
- package/dist/deploy/dockerTag/deployJob.d.ts +3 -0
- package/dist/deploy/dockerTag/deployJob.js +24 -0
- package/dist/deploy/dockerTag/index.d.ts +2 -0
- package/dist/deploy/dockerTag/index.js +17 -0
- package/dist/deploy/index.d.ts +12 -8
- package/dist/deploy/index.js +7 -20
- package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +4 -0
- package/dist/deploy/kubernetes/additionalSecretKeys.js +24 -0
- package/dist/deploy/kubernetes/cloudSql/index.d.ts +13 -0
- package/dist/deploy/kubernetes/cloudSql/index.js +30 -0
- package/dist/deploy/kubernetes/deployJob.d.ts +2 -2
- package/dist/deploy/kubernetes/deployJob.js +17 -91
- package/dist/deploy/kubernetes/index.d.ts +3 -1
- package/dist/deploy/kubernetes/index.js +42 -4
- package/dist/deploy/kubernetes/kubeEnv.d.ts +9 -0
- package/dist/deploy/kubernetes/kubeEnv.js +72 -0
- package/dist/deploy/kubernetes/kubeValues.d.ts +97 -0
- package/dist/deploy/kubernetes/kubeValues.js +124 -0
- package/dist/deploy/kubernetes/mongodb.d.ts +18 -5
- package/dist/deploy/kubernetes/mongodb.js +96 -10
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +25 -21
- package/dist/deploy/kubernetes/processSecretsAsFiles.js +2 -10
- package/dist/deploy/types/base.d.ts +14 -0
- package/dist/deploy/types/base.js +3 -0
- package/dist/deploy/types/custom.d.ts +33 -0
- package/dist/deploy/types/custom.js +3 -0
- package/dist/deploy/types/dockerTag.d.ts +10 -0
- package/dist/deploy/types/dockerTag.js +3 -0
- package/dist/deploy/types/googleCloudRun.d.ts +121 -0
- package/dist/deploy/types/googleCloudRun.js +3 -0
- package/dist/deploy/types/index.d.ts +22 -0
- package/dist/deploy/types/index.js +31 -0
- package/dist/deploy/types/kubernetes.d.ts +276 -0
- package/dist/deploy/types/kubernetes.js +3 -0
- package/dist/deploy/utils.d.ts +2 -2
- package/dist/deploy/utils.js +3 -10
- package/dist/index.js +0 -10
- package/dist/pipeline/commitInfo/getBuildId.d.ts +1 -0
- package/dist/pipeline/commitInfo/getBuildId.js +135 -0
- package/dist/pipeline/commitInfo/getCommitInfo.d.ts +2 -0
- package/dist/pipeline/commitInfo/getCommitInfo.js +140 -0
- package/dist/pipeline/createAllJobs.d.ts +8 -0
- package/dist/{build/tests/storybook.test.js → pipeline/createAllJobs.js} +54 -104
- package/dist/pipeline/createChildPipeline.d.ts +2 -2
- package/dist/pipeline/createChildPipeline.js +40 -121
- package/dist/pipeline/createJobsForComponent.d.ts +3 -0
- package/dist/pipeline/{createJobs.js → createJobsForComponent.js} +33 -192
- 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 -5
- package/dist/pipeline/packageManager.d.ts +1 -1
- package/dist/pipeline/packageManager.js +20 -173
- package/dist/pipeline/yarn/yarnUtils.d.ts +4 -0
- package/dist/pipeline/yarn/yarnUtils.js +193 -0
- package/dist/rules/index.d.ts +3 -1
- package/dist/rules/index.js +7 -6
- package/dist/runner/index.d.ts +2 -3
- package/dist/runner/index.js +0 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +19 -25
- package/dist/types/config.js +6 -16
- package/dist/types/context.d.ts +16 -3
- package/dist/types/environmentContext.d.ts +28 -0
- package/dist/types/environmentContext.js +3 -0
- package/dist/types/gitlab-types.d.ts +39 -7
- package/dist/types/index.js +0 -6
- package/dist/types/jobs.d.ts +25 -17
- package/dist/types/jobs.js +1 -1
- package/dist/types/pipeline.d.ts +1 -1
- package/dist/types/utils.d.ts +1 -0
- package/dist/types/utils.js +3 -0
- package/dist/utils/gitlab.d.ts +5 -0
- package/dist/utils/gitlab.js +48 -0
- package/dist/utils/index.js +5 -15
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +1560 -0
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +1560 -0
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +1560 -0
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +3092 -0
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +3103 -0
- package/examples/__snapshots__/custom-build-job.ts.snap +1162 -0
- package/examples/__snapshots__/custom-envs.ts.snap +261 -0
- package/examples/__snapshots__/kubernetes-application-customization.ts.snap +2280 -0
- package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +4077 -0
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1911 -0
- package/examples/__snapshots__/wait-for-other-deploy.ts.snap +1626 -0
- package/examples/__utils__/helpers.ts +14 -0
- package/examples/cloud-run-memory-limit.ts +28 -0
- package/examples/cloud-run-no-cpu-throttling.ts +33 -0
- package/examples/cloud-run-non-public.ts +27 -0
- package/examples/cloud-run-with-sql-reuse-db.ts +54 -0
- package/examples/cloud-run-with-sql.ts +61 -0
- package/examples/custom-build-job.ts +28 -0
- package/examples/custom-envs.ts +31 -0
- package/examples/kubernetes-application-customization.ts +57 -0
- package/examples/kubernetes-with-jobs.ts +68 -0
- package/examples/rails-k8s-with-worker.ts +95 -0
- package/examples/wait-for-other-deploy.ts +36 -0
- package/package.json +16 -13
- package/scripts/bundle +2 -0
- package/src/build/base/createBuildJob.ts +12 -5
- package/src/build/base/{getBuildInfo.ts → writeBuildInfo.ts} +2 -2
- package/src/build/custom/buildJob.ts +64 -0
- package/src/build/custom/index.ts +7 -0
- package/src/build/docker.ts +58 -33
- package/src/build/index.ts +24 -5
- package/src/build/node/buildJob.ts +2 -2
- package/src/build/node/cache.ts +19 -8
- package/src/build/node/index.ts +1 -1
- package/src/build/node/meteor.ts +8 -2
- package/src/build/node/testJob.ts +4 -2
- package/src/build/node/yarn.ts +21 -10
- package/src/build/rails/build.ts +38 -0
- package/src/build/rails/index.ts +8 -0
- package/src/build/rails/test.ts +86 -0
- package/src/build/types.ts +97 -2
- package/src/catladder-gitlab.ts +4 -2
- package/src/config/{configruedEnvs.test.ts → __tests__/configruedEnvs.test.ts} +3 -3
- package/src/config/configruedEnvs.ts +2 -7
- package/src/config/readConfig.ts +1 -1
- package/src/context/{resolveReferences.test.ts → __tests__/resolveReferences.test.ts} +23 -38
- package/src/context/getEnvConfig.ts +21 -0
- package/src/context/getEnvType.ts +17 -0
- package/src/context/getEnvironment.ts +40 -0
- package/src/context/getEnvironmentContext.ts +57 -0
- package/src/context/getEnvironmentVariables.ts +155 -0
- package/src/context/getLabels.ts +20 -0
- package/src/context/index.ts +28 -193
- package/src/context/resolveReferences.ts +35 -31
- package/src/defaults/index.ts +1 -1
- package/src/deploy/base.ts +43 -19
- package/src/deploy/cloudRun/deployJob.ts +276 -0
- package/src/deploy/cloudRun/index.ts +95 -0
- package/src/deploy/cloudRun/utils/createArgsString.ts +26 -0
- package/src/deploy/cloudRun/utils/database.ts +55 -0
- package/src/deploy/cloudRun/utils/gcloudServiceAccountLoginCommands.ts +14 -0
- package/src/deploy/cloudRun/utils/jobName.ts +2 -0
- package/src/deploy/custom/deployJob.ts +13 -3
- package/src/deploy/custom/index.ts +9 -1
- package/src/deploy/dockerTag/deployJob.ts +31 -0
- package/src/deploy/dockerTag/index.ts +9 -0
- package/src/deploy/index.ts +26 -17
- package/src/deploy/kubernetes/additionalSecretKeys.ts +23 -0
- package/src/deploy/kubernetes/cloudSql/index.ts +28 -0
- package/src/deploy/kubernetes/deployJob.ts +21 -78
- package/src/deploy/kubernetes/index.ts +42 -1
- package/src/deploy/kubernetes/kubeEnv.ts +48 -0
- package/src/deploy/kubernetes/kubeValues.ts +96 -0
- package/src/deploy/kubernetes/mongodb.ts +104 -7
- package/src/deploy/kubernetes/processSecretsAsFiles.ts +1 -1
- package/src/deploy/types/base.ts +17 -0
- package/src/deploy/types/custom.ts +36 -0
- package/src/deploy/types/dockerTag.ts +12 -0
- package/src/deploy/types/googleCloudRun.ts +179 -0
- package/src/deploy/types/index.ts +28 -0
- package/src/deploy/types/kubernetes.ts +301 -0
- package/src/deploy/utils.ts +6 -2
- package/src/pipeline/commitInfo/getBuildId.ts +6 -0
- package/src/pipeline/commitInfo/getCommitInfo.ts +12 -0
- package/src/pipeline/createAllJobs.ts +38 -0
- package/src/pipeline/createChildPipeline.ts +9 -20
- package/src/pipeline/createJobsForComponent.ts +64 -0
- package/src/pipeline/gitlab/createGitlabJobs.ts +149 -0
- package/src/pipeline/index.ts +1 -1
- package/src/pipeline/packageManager.ts +4 -38
- package/src/pipeline/yarn/yarnUtils.ts +37 -0
- package/src/rules/index.ts +9 -6
- package/src/runner/index.ts +2 -1
- package/src/types/config.ts +26 -13
- package/src/types/context.ts +23 -2
- package/src/types/environmentContext.ts +33 -0
- package/src/types/gitlab-types.ts +36 -6
- package/src/types/jobs.ts +30 -6
- package/src/types/pipeline.ts +1 -1
- package/src/types/utils.ts +7 -0
- package/src/utils/gitlab.ts +23 -0
- package/tsconfig.json +3 -1
- package/dist/build/base/getBuildInfo.d.ts +0 -2
- package/dist/build/tests/storybook.test.d.ts +0 -1
- package/dist/context/resolveReferences.test.js +0 -141
- package/dist/deploy/kubernetes/cloudsql.d.ts +0 -6
- package/dist/deploy/kubernetes/cloudsql.js +0 -16
- package/dist/deploy/types.d.ts +0 -196
- package/dist/deploy/types.js +0 -16
- package/dist/pipeline/createChildPipeline.test.d.ts +0 -1
- package/dist/pipeline/createJobs.d.ts +0 -3
- package/dist/pipeline/gitlab/makeGitlabJob.d.ts +0 -8
- package/dist/pipeline/gitlab/makeGitlabJob.js +0 -45
- package/src/build/tests/storybook.test.ts +0 -54
- package/src/deploy/kubernetes/cloudsql.ts +0 -12
- package/src/deploy/types.ts +0 -189
- package/src/pipeline/createChildPipeline.test.ts +0 -49
- package/src/pipeline/createJobs.ts +0 -195
- package/src/pipeline/gitlab/makeGitlabJob.ts +0 -16
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Config } from "../../src";
|
|
2
|
+
import { createChildPipeline } from "../../src";
|
|
3
|
+
|
|
4
|
+
const ALL_TRIGGERS = ["mainBranch", "taggedRelease", "mr"] as const;
|
|
5
|
+
|
|
6
|
+
export const createAllPipelines = async (config: Config) =>
|
|
7
|
+
Object.fromEntries(
|
|
8
|
+
await Promise.all(
|
|
9
|
+
ALL_TRIGGERS.map(async (trigger) => [
|
|
10
|
+
trigger,
|
|
11
|
+
await createChildPipeline("gitlab", trigger, config),
|
|
12
|
+
])
|
|
13
|
+
)
|
|
14
|
+
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
|
+
const config: Config = {
|
|
4
|
+
appName: "test-app",
|
|
5
|
+
customerName: "pan",
|
|
6
|
+
components: {
|
|
7
|
+
api: {
|
|
8
|
+
dir: "api",
|
|
9
|
+
build: {
|
|
10
|
+
type: "node",
|
|
11
|
+
},
|
|
12
|
+
deploy: {
|
|
13
|
+
type: "google-cloudrun",
|
|
14
|
+
projectId: "google-project-id",
|
|
15
|
+
region: "europe-west6",
|
|
16
|
+
|
|
17
|
+
service: {
|
|
18
|
+
// defaults to 512Mi
|
|
19
|
+
memory: "1024Mi",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
it("matches snapshot", async () => {
|
|
27
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
28
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
|
+
const config: Config = {
|
|
4
|
+
appName: "test-app",
|
|
5
|
+
customerName: "pan",
|
|
6
|
+
components: {
|
|
7
|
+
api: {
|
|
8
|
+
dir: "api",
|
|
9
|
+
build: {
|
|
10
|
+
type: "node",
|
|
11
|
+
},
|
|
12
|
+
deploy: {
|
|
13
|
+
type: "google-cloudrun",
|
|
14
|
+
projectId: "google-project-id",
|
|
15
|
+
region: "europe-west6",
|
|
16
|
+
|
|
17
|
+
service: {
|
|
18
|
+
minInstances: 1,
|
|
19
|
+
// careful, this is expensive!
|
|
20
|
+
// this will always allocate the cpu
|
|
21
|
+
// use this if you have background tasks.
|
|
22
|
+
|
|
23
|
+
// consider using cloud task instead of this
|
|
24
|
+
noCpuThrottling: true,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
it("matches snapshot", async () => {
|
|
32
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
33
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
|
+
|
|
4
|
+
const config: Config = {
|
|
5
|
+
appName: "test-app",
|
|
6
|
+
customerName: "pan",
|
|
7
|
+
components: {
|
|
8
|
+
api: {
|
|
9
|
+
dir: "api",
|
|
10
|
+
build: {
|
|
11
|
+
type: "node",
|
|
12
|
+
},
|
|
13
|
+
deploy: {
|
|
14
|
+
type: "google-cloudrun",
|
|
15
|
+
projectId: "asdf",
|
|
16
|
+
region: "asia-east1",
|
|
17
|
+
service: {
|
|
18
|
+
allowUnauthenticated: false,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
it("matches snapshot", async () => {
|
|
26
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
27
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Config, DeployConfigCloudRunCloudSql } from "../src";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
|
+
|
|
4
|
+
const CLOUD_SQL: DeployConfigCloudRunCloudSql = {
|
|
5
|
+
type: "unmanaged",
|
|
6
|
+
instanceConnectionName: "projectId:region:instancename",
|
|
7
|
+
dbUser: "my-user",
|
|
8
|
+
};
|
|
9
|
+
const config: Config = {
|
|
10
|
+
appName: "test-app",
|
|
11
|
+
customerName: "pan",
|
|
12
|
+
components: {
|
|
13
|
+
api: {
|
|
14
|
+
dir: "api",
|
|
15
|
+
build: {
|
|
16
|
+
type: "node",
|
|
17
|
+
},
|
|
18
|
+
deploy: {
|
|
19
|
+
type: "google-cloudrun",
|
|
20
|
+
projectId: "google-project-id",
|
|
21
|
+
region: "europe-west6",
|
|
22
|
+
cloudSql: CLOUD_SQL,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
worker: {
|
|
26
|
+
dir: "api",
|
|
27
|
+
build: {
|
|
28
|
+
type: "node",
|
|
29
|
+
buildCommand: "yarn build:worker",
|
|
30
|
+
},
|
|
31
|
+
deploy: {
|
|
32
|
+
type: "google-cloudrun",
|
|
33
|
+
projectId: "google-project-id",
|
|
34
|
+
region: "europe-west6",
|
|
35
|
+
cloudSql: {
|
|
36
|
+
...CLOUD_SQL,
|
|
37
|
+
// override the db base name to the other component's name
|
|
38
|
+
// if ommited, this defaults to the component's name
|
|
39
|
+
dbBaseName: "api",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
vars: {
|
|
43
|
+
public: {
|
|
44
|
+
// need to reference the password
|
|
45
|
+
DB_PASSWORD: "${api:DB_PASSWORD}",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
it("matches snapshot", async () => {
|
|
53
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
54
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
|
+
const config: Config = {
|
|
4
|
+
appName: "test-app",
|
|
5
|
+
customerName: "pan",
|
|
6
|
+
components: {
|
|
7
|
+
api: {
|
|
8
|
+
dir: "api",
|
|
9
|
+
build: {
|
|
10
|
+
type: "node",
|
|
11
|
+
},
|
|
12
|
+
deploy: {
|
|
13
|
+
type: "google-cloudrun",
|
|
14
|
+
projectId: "google-project-id",
|
|
15
|
+
region: "europe-west6",
|
|
16
|
+
// optional, set min and max instances
|
|
17
|
+
// defaults to 0-100
|
|
18
|
+
service: {
|
|
19
|
+
minInstances: 0,
|
|
20
|
+
maxInstances: 5,
|
|
21
|
+
},
|
|
22
|
+
cloudSql: {
|
|
23
|
+
type: "unmanaged",
|
|
24
|
+
instanceConnectionName: "projectId:region:instancename",
|
|
25
|
+
dbUser: "my-user",
|
|
26
|
+
},
|
|
27
|
+
jobs: {
|
|
28
|
+
migration: {
|
|
29
|
+
when: "postDeploy",
|
|
30
|
+
command: "yarn migrate",
|
|
31
|
+
},
|
|
32
|
+
["send-reminders"]: {
|
|
33
|
+
when: "schedule",
|
|
34
|
+
command: "yarn job:send-reminders",
|
|
35
|
+
schedule: "0 * * * *",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
www: {
|
|
41
|
+
dir: "www",
|
|
42
|
+
build: {
|
|
43
|
+
type: "node",
|
|
44
|
+
},
|
|
45
|
+
deploy: {
|
|
46
|
+
type: "google-cloudrun",
|
|
47
|
+
projectId: "google-project-id",
|
|
48
|
+
region: "europe-west6",
|
|
49
|
+
},
|
|
50
|
+
vars: {
|
|
51
|
+
public: {
|
|
52
|
+
API_URL: "${api:ROOT_URL}/graphql",
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
it("matches snapshot", async () => {
|
|
60
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
61
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
|
+
|
|
4
|
+
const config: Config = {
|
|
5
|
+
appName: "test-app",
|
|
6
|
+
customerName: "pan",
|
|
7
|
+
components: {
|
|
8
|
+
www: {
|
|
9
|
+
dir: "www",
|
|
10
|
+
build: {
|
|
11
|
+
type: "custom",
|
|
12
|
+
jobImage: "foo",
|
|
13
|
+
docker: {
|
|
14
|
+
type: "nginx",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
deploy: {
|
|
18
|
+
type: "google-cloudrun",
|
|
19
|
+
projectId: "asdf",
|
|
20
|
+
region: "asia-east1",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
it("matches snapshot", async () => {
|
|
27
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
28
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
|
+
|
|
4
|
+
const config: Config<{ CustomEnvs: "asdf" | "bla" }> = {
|
|
5
|
+
appName: "test-app",
|
|
6
|
+
customerName: "pan",
|
|
7
|
+
components: {
|
|
8
|
+
api: {
|
|
9
|
+
dir: "api",
|
|
10
|
+
build: {
|
|
11
|
+
type: "node",
|
|
12
|
+
},
|
|
13
|
+
deploy: false,
|
|
14
|
+
env: {
|
|
15
|
+
local: {
|
|
16
|
+
port: 4000,
|
|
17
|
+
},
|
|
18
|
+
asdf: {
|
|
19
|
+
type: "dev",
|
|
20
|
+
},
|
|
21
|
+
bla: {
|
|
22
|
+
type: "dev",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
it("matches snapshot", async () => {
|
|
30
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
31
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
|
+
const config: Config = {
|
|
4
|
+
appName: "test-app",
|
|
5
|
+
customerName: "pan",
|
|
6
|
+
components: {
|
|
7
|
+
api: {
|
|
8
|
+
dir: "api",
|
|
9
|
+
build: {
|
|
10
|
+
type: "node",
|
|
11
|
+
},
|
|
12
|
+
deploy: {
|
|
13
|
+
type: "kubernetes",
|
|
14
|
+
cluster: {
|
|
15
|
+
name: "some-cluster-name",
|
|
16
|
+
region: "europe-west6",
|
|
17
|
+
projectId: "some-project-id",
|
|
18
|
+
type: "gcloud",
|
|
19
|
+
domainCanonical: "panter.cloud",
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
values: {
|
|
23
|
+
application: {
|
|
24
|
+
command: "node main.js",
|
|
25
|
+
autoscale: {
|
|
26
|
+
minReplicas: 2,
|
|
27
|
+
maxReplicas: 5,
|
|
28
|
+
metrics: [
|
|
29
|
+
{
|
|
30
|
+
type: "Resource",
|
|
31
|
+
resource: {
|
|
32
|
+
name: "cpu",
|
|
33
|
+
|
|
34
|
+
target: {
|
|
35
|
+
type: "Utilization",
|
|
36
|
+
averageUtilization: 0.5,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
resources: {
|
|
43
|
+
limits: {
|
|
44
|
+
cpu: "1",
|
|
45
|
+
memory: "2048Mi",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
it("matches snapshot", async () => {
|
|
56
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
57
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
|
+
const config: Config = {
|
|
4
|
+
appName: "test-app",
|
|
5
|
+
customerName: "pan",
|
|
6
|
+
components: {
|
|
7
|
+
api: {
|
|
8
|
+
dir: "api",
|
|
9
|
+
build: {
|
|
10
|
+
type: "node",
|
|
11
|
+
},
|
|
12
|
+
deploy: {
|
|
13
|
+
type: "kubernetes",
|
|
14
|
+
cluster: {
|
|
15
|
+
name: "some-cluster-name",
|
|
16
|
+
region: "europe-west6",
|
|
17
|
+
projectId: "some-project-id",
|
|
18
|
+
type: "gcloud",
|
|
19
|
+
domainCanonical: "panter.cloud",
|
|
20
|
+
},
|
|
21
|
+
values: {
|
|
22
|
+
jobs: {
|
|
23
|
+
migration: {
|
|
24
|
+
command: "yarn migrate",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
cronjobs: {
|
|
28
|
+
["send-emails"]: {
|
|
29
|
+
command: "yarn send emails",
|
|
30
|
+
schedule: "0 * * * *",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
env: {
|
|
36
|
+
review: {
|
|
37
|
+
deploy: {
|
|
38
|
+
values: {
|
|
39
|
+
cronjobs: {
|
|
40
|
+
["send-emails"]: false,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
www: {
|
|
48
|
+
dir: "www",
|
|
49
|
+
build: {
|
|
50
|
+
type: "node",
|
|
51
|
+
},
|
|
52
|
+
deploy: {
|
|
53
|
+
type: "kubernetes",
|
|
54
|
+
cluster: {
|
|
55
|
+
name: "some-cluster-name",
|
|
56
|
+
region: "europe-west6",
|
|
57
|
+
projectId: "some-project-id",
|
|
58
|
+
type: "gcloud",
|
|
59
|
+
domainCanonical: "panter.cloud",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
it("matches snapshot", async () => {
|
|
67
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
68
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
|
+
|
|
4
|
+
// the image version should match your `.ruby-version`
|
|
5
|
+
const RAILS_TEST_STAGE_IMAGE = "ruby:3.2.1"
|
|
6
|
+
|
|
7
|
+
const config: Config = {
|
|
8
|
+
appName: "test-app",
|
|
9
|
+
customerName: "pan",
|
|
10
|
+
components: {
|
|
11
|
+
app: {
|
|
12
|
+
dir: ".",
|
|
13
|
+
vars: {
|
|
14
|
+
public: {
|
|
15
|
+
RAILS_ENV: "production",
|
|
16
|
+
},
|
|
17
|
+
secret: [
|
|
18
|
+
"SECRET_KEY_BASE",
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
build: {
|
|
22
|
+
type: "rails",
|
|
23
|
+
test: {
|
|
24
|
+
// if operating system dependencies are required you can either
|
|
25
|
+
// - build a dedicated image
|
|
26
|
+
// - use `command` to apt-get install them before running the test command
|
|
27
|
+
jobImage: RAILS_TEST_STAGE_IMAGE,
|
|
28
|
+
},
|
|
29
|
+
lint: {
|
|
30
|
+
jobImage: RAILS_TEST_STAGE_IMAGE,
|
|
31
|
+
},
|
|
32
|
+
audit: {
|
|
33
|
+
jobImage: RAILS_TEST_STAGE_IMAGE,
|
|
34
|
+
},
|
|
35
|
+
cnbBuilder: {
|
|
36
|
+
buildVars: { SECRET_KEY_BASE: "dummy-value" },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
deploy: {
|
|
40
|
+
type: "kubernetes",
|
|
41
|
+
cluster: {
|
|
42
|
+
name: "some-cluster-name",
|
|
43
|
+
region: "europe-west6",
|
|
44
|
+
projectId: "some-project-id",
|
|
45
|
+
type: "gcloud",
|
|
46
|
+
domainCanonical: "panter.cloud",
|
|
47
|
+
},
|
|
48
|
+
values: {
|
|
49
|
+
cloudsql: { enabled: true, projectId: "some-project-id" },
|
|
50
|
+
application: {
|
|
51
|
+
// if deployed to Google Cloud Run use a gem like cloudtasker instead of a permanently running expensive worker
|
|
52
|
+
worker: {
|
|
53
|
+
enabled: true,
|
|
54
|
+
command: "launcher bundle exec rake jobs:work",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
jobs: {
|
|
58
|
+
"db-migrate": {
|
|
59
|
+
hook: "post-install,post-upgrade",
|
|
60
|
+
command:
|
|
61
|
+
"launcher bundle exec rake db:migrate",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
env: {
|
|
67
|
+
review: {
|
|
68
|
+
deploy: {
|
|
69
|
+
values: {
|
|
70
|
+
jobs: {
|
|
71
|
+
"db-prepare-seed": {
|
|
72
|
+
hook: "post-install",
|
|
73
|
+
command:
|
|
74
|
+
"launcher bundle exec rake db:prepare db:seed",
|
|
75
|
+
},
|
|
76
|
+
"db-migrate": {
|
|
77
|
+
hook: "post-upgrade",
|
|
78
|
+
command:
|
|
79
|
+
"launcher bundle exec rake db:migrate",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
prod: {
|
|
86
|
+
host: "my-fancy-website.com"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
it("matches snapshot", async () => {
|
|
94
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
95
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
|
+
|
|
4
|
+
const config: Config<{ CustomEnvs: "asdf" | "bla" }> = {
|
|
5
|
+
appName: "test-app",
|
|
6
|
+
customerName: "pan",
|
|
7
|
+
components: {
|
|
8
|
+
api: {
|
|
9
|
+
dir: "api",
|
|
10
|
+
build: {
|
|
11
|
+
type: "node",
|
|
12
|
+
},
|
|
13
|
+
deploy: {
|
|
14
|
+
type: "custom",
|
|
15
|
+
requiresDocker: false,
|
|
16
|
+
script: ["yarn deploy"],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
www: {
|
|
20
|
+
dir: "www",
|
|
21
|
+
build: {
|
|
22
|
+
type: "node",
|
|
23
|
+
},
|
|
24
|
+
deploy: {
|
|
25
|
+
waitFor: ["api"],
|
|
26
|
+
type: "custom",
|
|
27
|
+
requiresDocker: false,
|
|
28
|
+
script: ["yarn deploy"],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
it("matches snapshot", async () => {
|
|
35
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
36
|
+
});
|
package/package.json
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@catladder/pipeline",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-prettier-cbceeed9",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build:tsc": "yarn tsc",
|
|
6
|
-
"build": "yarn
|
|
7
|
-
"build:
|
|
6
|
+
"build": "yarn build:compile && yarn build:inline-variables && yarn build:bundle",
|
|
7
|
+
"build:bundle": "./scripts/bundle",
|
|
8
|
+
"build:compile": "yarn tsc",
|
|
8
9
|
"build:inline-variables": "yarn babel --keep-file-extension --extensions \".ts,.js\" --config-file ./babel-inline.json dist --out-dir dist",
|
|
9
|
-
"
|
|
10
|
+
"build:watch": "yarn tsc -w",
|
|
10
11
|
"lint": "eslint \"src/**/*.ts\"",
|
|
11
12
|
"lint:fix": "eslint \"src/**/*.ts\" --fix"
|
|
12
13
|
},
|
|
13
|
-
"main": "dist/index.js",
|
|
14
14
|
"types": "dist/index.d.ts",
|
|
15
|
+
"main": "dist/index.js",
|
|
16
|
+
"sideEffects": false,
|
|
15
17
|
"bin": {
|
|
16
18
|
"catladder-gitlab": "./bin/catladder-gitlab.js"
|
|
17
19
|
},
|
|
@@ -20,22 +22,23 @@
|
|
|
20
22
|
"@babel/core": "^7.0.0-0",
|
|
21
23
|
"@babel/plugin-syntax-typescript": "^7.16.7",
|
|
22
24
|
"@babel/preset-typescript": "^7.16.5",
|
|
25
|
+
"@jest/globals": "^29.3.1",
|
|
23
26
|
"@types/child-process-promise": "^2.2.2",
|
|
24
27
|
"@types/jest": "^27.4.0",
|
|
25
|
-
"@types/lodash": "^4.14.
|
|
26
|
-
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
|
|
27
|
-
"eslint": "^8.7.0"
|
|
28
|
-
},
|
|
29
|
-
"dependencies": {
|
|
28
|
+
"@types/lodash": "^4.14.185",
|
|
30
29
|
"@types/node": "^17.0.10",
|
|
30
|
+
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
|
|
31
31
|
"child-process-promise": "^2.2.1",
|
|
32
|
+
"eslint": "^8.7.0",
|
|
32
33
|
"js-yaml": "^4.1.0",
|
|
33
34
|
"lodash": "^4.17.21",
|
|
34
35
|
"memoizee": "^0.4.15",
|
|
35
|
-
"path-equal": "
|
|
36
|
-
"slugify": "^1.6.3"
|
|
36
|
+
"path-equal": "1.1.3",
|
|
37
|
+
"slugify": "^1.6.3"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"string-replace-async": "^2.0.0",
|
|
37
41
|
"ts-node": "^10.4.0",
|
|
38
|
-
"type-fest": "^2.10.0",
|
|
39
42
|
"typescript": "^4.5.4"
|
|
40
43
|
},
|
|
41
44
|
"stableVersion": "0.1.0"
|
package/scripts/bundle
ADDED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { merge } from "lodash";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
import type { Context } from "../..";
|
|
4
|
+
import { getRunnerImage } from "../..";
|
|
5
|
+
import type { CatladderJob } from "../../types/jobs";
|
|
4
6
|
import { ensureArray } from "../../utils";
|
|
5
7
|
import { ensureNodeVersion } from "../node/yarn";
|
|
6
8
|
import {
|
|
7
9
|
APP_BUILD_JOB_NAME,
|
|
8
10
|
RUNNER_BUILD_RESOURCE_VARIABLES,
|
|
9
11
|
} from "./constants";
|
|
10
|
-
import {
|
|
12
|
+
import { writeBuildInfo } from "./writeBuildInfo";
|
|
11
13
|
|
|
12
14
|
export const createBuildJob = (
|
|
13
15
|
context: Context,
|
|
@@ -29,13 +31,18 @@ export const createBuildJob = (
|
|
|
29
31
|
},
|
|
30
32
|
|
|
31
33
|
script: [
|
|
32
|
-
...
|
|
34
|
+
...writeBuildInfo(context),
|
|
33
35
|
...ensureNodeVersion(context), // in pure node repos, we might want to have the nvmrc file in top-level
|
|
34
36
|
`cd ${context.componentConfig.dir}`,
|
|
35
37
|
...(ensureArray(script) ?? []),
|
|
36
38
|
],
|
|
37
39
|
artifacts: {
|
|
38
|
-
paths: [context.componentConfig.dir
|
|
40
|
+
paths: [join(context.componentConfig.dir, "__build_info.json")],
|
|
41
|
+
reports: {
|
|
42
|
+
junit: context.componentConfig.build.artifactsReports?.junit?.map(
|
|
43
|
+
(p) => join(context.componentConfig.dir, p)
|
|
44
|
+
),
|
|
45
|
+
},
|
|
39
46
|
},
|
|
40
47
|
},
|
|
41
48
|
def
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Context } from "../../types";
|
|
1
|
+
import type { Context } from "../../types";
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const writeBuildInfo = (context: Context) => {
|
|
4
4
|
return [
|
|
5
5
|
`echo '{"id":"${context.commitInfo?.buildId}","time":"${context.commitInfo?.buildTime}"}' > ${context.componentConfig.dir}/__build_info.json`,
|
|
6
6
|
];
|