@catladder/pipeline 1.1.2 → 1.2.0

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 (42) hide show
  1. package/dist/build/base/createBuildJob.js +6 -2
  2. package/dist/build/base/getBuildInfo.d.ts +2 -0
  3. package/dist/build/base/getBuildInfo.js +12 -0
  4. package/dist/build/docker.js +2 -1
  5. package/dist/build/node/meteor.js +3 -0
  6. package/dist/build/tests/storybook.test.js +7 -1
  7. package/dist/build/types.d.ts +7 -0
  8. package/dist/constants.js +1 -1
  9. package/dist/context/index.d.ts +1 -0
  10. package/dist/context/index.js +19 -10
  11. package/dist/deploy/index.d.ts +3 -1
  12. package/dist/deploy/index.js +4 -0
  13. package/dist/deploy/kubernetes/cloudsql.js +1 -1
  14. package/dist/deploy/kubernetes/deployJob.js +18 -3
  15. package/dist/deploy/types.d.ts +134 -2
  16. package/dist/deploy/utils.d.ts +4 -0
  17. package/dist/deploy/utils.js +18 -0
  18. package/dist/pipeline/createChildPipeline.d.ts +3 -0
  19. package/dist/pipeline/createChildPipeline.js +4 -1
  20. package/dist/pipeline/createJobs.js +21 -9
  21. package/dist/runner/index.d.ts +1 -1
  22. package/dist/tsconfig.tsbuildinfo +1 -1
  23. package/dist/types/config.d.ts +57 -0
  24. package/dist/types/context.d.ts +2 -0
  25. package/package.json +1 -1
  26. package/src/build/base/createBuildJob.ts +4 -7
  27. package/src/build/base/getBuildInfo.ts +7 -0
  28. package/src/build/docker.ts +3 -2
  29. package/src/build/node/meteor.ts +2 -0
  30. package/src/build/tests/storybook.test.ts +6 -0
  31. package/src/build/types.ts +6 -0
  32. package/src/context/index.ts +13 -4
  33. package/src/deploy/index.ts +3 -2
  34. package/src/deploy/kubernetes/cloudsql.ts +3 -4
  35. package/src/deploy/kubernetes/deployJob.ts +24 -3
  36. package/src/deploy/types.ts +66 -1
  37. package/src/deploy/utils.ts +17 -0
  38. package/src/pipeline/createChildPipeline.ts +4 -1
  39. package/src/pipeline/createJobs.ts +5 -0
  40. package/src/runner/index.ts +3 -1
  41. package/src/types/config.ts +49 -0
  42. package/src/types/context.ts +2 -0
@@ -2,24 +2,77 @@
2
2
  export type DeployConfigBase = {};
3
3
  type AllowUnknownProps<T extends Record<string, unknown>> = T &
4
4
  Record<string, unknown>;
5
+
6
+ export type DeployConfigKubernetesClusterGCloud = {
7
+ type: "gcloud";
8
+ /**
9
+ * gcoud name of the cluster
10
+ */
11
+ name: string;
12
+ /**
13
+ * google cloud project id
14
+ */
15
+ projectId: string;
16
+ /**
17
+ * region
18
+ */
19
+ region: string;
20
+ /**
21
+ * domain of the cluster, for canonical domains without custom hostnames (e.g. review and dev apps)
22
+ */
23
+ domainCanonical?: string;
24
+ };
25
+ export type DeployConfigKubernetesCluster = DeployConfigKubernetesClusterGCloud; // currently only this
5
26
  export type DeployConfigKubernetes = {
6
27
  type: "kubernetes";
7
- cluster?: string;
28
+ /**
29
+ * cluster config to use.
30
+ */
31
+ cluster?: DeployConfigKubernetesCluster;
32
+ /**
33
+ * prints out debug info (helm --debug)
34
+ */
35
+ debug?: boolean;
8
36
  additionalHelmArgs?: string[];
37
+ /**
38
+ * values to configure the app
39
+ */
9
40
  values?: AllowUnknownProps<{
41
+ /**
42
+ * enable cloudsql db. Currently you have to manually set it up
43
+ */
10
44
  cloudsql?: {
11
45
  enabled: boolean;
12
46
  instanceId?: string;
13
47
  projectId?: string;
14
48
  region?: string;
15
49
  };
50
+ /**
51
+ * enable mongodb. The mongodb is deployed using a helm chart.
52
+ * Consider using external services instead of this.
53
+ */
16
54
  mongodb?: AllowUnknownProps<{
17
55
  enabled: boolean;
18
56
  }>;
57
+ /**
58
+ * enable mailhog. Mailhog is a virtual mail server that catches all outgoing mailsl and show them in a mailbox.
59
+ * This is great for development as it prevents to accidentially send out real emails and helps with debugging outgoing mails.
60
+ *
61
+ * It will automaticaly inject a MAIL_URL env var.
62
+ *
63
+ * Turn it of for production.
64
+ */
19
65
  mailhog?: {
20
66
  enabled: boolean;
21
67
  };
68
+ /**
69
+ * post-install/upgrade jobs. These use the app image and have all env vars available.
70
+ * Typically used for migrations and seeds
71
+ */
22
72
  jobs?: Record<string, AllowUnknownProps<{ command: string }>>;
73
+ /**
74
+ * cronjobs that run periodically. These use the app image have all env vars available.
75
+ */
23
76
  cronjobs?: Record<
24
77
  string,
25
78
  AllowUnknownProps<{
@@ -28,9 +81,21 @@ export type DeployConfigKubernetes = {
28
81
  concurrencyPolicy?: "Forbid" | "Allow" | "Replace";
29
82
  }>
30
83
  >;
84
+ /**
85
+ * configuration for the application ("Deployment" in kubernetes)
86
+ */
31
87
  application?: AllowUnknownProps<{
88
+ /**
89
+ * redirects
90
+ */
32
91
  redirects?: AllowUnknownProps<{ host: string }>[];
92
+ /**
93
+ * how many pods will be started
94
+ */
33
95
  replicas?: number;
96
+ /**
97
+ * kubernetes resources
98
+ */
34
99
  resources?: {
35
100
  limits?: {
36
101
  cpu?: string;
@@ -0,0 +1,17 @@
1
+ import { Config } from "../types";
2
+ import type { DeployConfigKubernetesCluster } from "./types";
3
+
4
+ export const getFullKubernetesClusterName = (
5
+ cluster: DeployConfigKubernetesCluster
6
+ ) => {
7
+ if (cluster.type === "gcloud") {
8
+ return `gke_${cluster.projectId}_${cluster.region}_${cluster.name}`;
9
+ }
10
+ };
11
+
12
+ export const getKubernetesNamespace = (
13
+ config: Pick<Config, "customerName" | "appName">,
14
+ env: string
15
+ ) => {
16
+ return `${config.customerName}-${config.appName}-${env}`;
17
+ };
@@ -39,7 +39,10 @@ export const createChildPipeline = async (
39
39
  );
40
40
 
41
41
  const childPipeline = {
42
- image: getRunnerImage("jobs"), // default image
42
+ image: getRunnerImage("jobs-default"), // default image
43
+ variables: {
44
+ FF_USE_FASTZIP: "true",
45
+ },
43
46
  workflow: {
44
47
  rules: RULES_ALWAYS,
45
48
  },
@@ -1,3 +1,4 @@
1
+ import { exec } from "child-process-promise";
1
2
  import { isObject } from "lodash";
2
3
  import { BUILD_TYPES } from "../build";
3
4
  import { createContext } from "../context";
@@ -126,6 +127,10 @@ export const createJobs = async (
126
127
  const commitInfo: CommitInfo = {
127
128
  refName: process.env.CI_COMMIT_REF_NAME ?? "unknown",
128
129
  refSlug: process.env.CI_COMMIT_REF_SLUG ?? "unknown",
130
+ buildTime: new Date().toISOString(),
131
+ buildId: await exec("git describe --tags || git rev-parse HEAD").then((s) =>
132
+ s.stdout.trim()
133
+ ),
129
134
  trigger,
130
135
  };
131
136
 
@@ -1,7 +1,9 @@
1
1
  import { PIPELINE_IMAGE_TAG, DOCKER_REGISTRY } from "../constants";
2
2
 
3
3
  type RunnerImageName =
4
- | "jobs"
4
+ | "jobs-default"
5
+ | "jobs-meteor"
6
+ | "jobs-testing-chrome"
5
7
  | "kubernetes"
6
8
  | "base-pipeline"
7
9
  | "docker-build"
@@ -46,16 +46,34 @@ export const isKnowEnvType = (env: string): env is EnvType => {
46
46
  };
47
47
 
48
48
  export type EnvVars = {
49
+ /**
50
+ * public env vars (means: they are checked in the repo)
51
+ */
49
52
  public?: Record<string, any>;
53
+ /**
54
+ * secret env vars. These vars can be managed with catladder/cli
55
+ */
50
56
  secret?: string[];
57
+ /**
58
+ * With fromComponents you can inject env vars from other components.
59
+ */
51
60
  fromComponents?: {
52
61
  [otherApp: string]: Record<string, string>;
53
62
  };
54
63
  };
55
64
 
56
65
  export type DefaultEnvConfig = {
66
+ /**
67
+ * how the app is deployed
68
+ */
57
69
  deploy: DeployConfig | false;
70
+ /**
71
+ * how the app is built and its runtime
72
+ */
58
73
  build: BuildConfig;
74
+ /**
75
+ * environment variables
76
+ */
59
77
  vars?: EnvVars;
60
78
  };
61
79
 
@@ -64,12 +82,22 @@ export type DevLocalEnvConfig = {
64
82
  port?: number;
65
83
  };
66
84
  export type EnvConfig<E extends EnvType = EnvType> = {
85
+ /**
86
+ * type of the env (stage, prod, review, dev)
87
+ */
67
88
  type?: E;
89
+ /**
90
+ * hostname that is used. If not set, a "canonical" url is created
91
+ */
68
92
  hostname?: string;
69
93
  } & PartialDeep<DefaultEnvConfig>;
70
94
 
71
95
  export type Env = {
96
+ /**
97
+ * local is a special env that is only used in local development
98
+ */
72
99
  local?: DevLocalEnvConfig;
100
+
73
101
  dev?: EnvConfig<"dev"> | false;
74
102
  stage?: EnvConfig<"stage"> | false;
75
103
  review?: EnvConfig<"review"> | false;
@@ -77,12 +105,33 @@ export type Env = {
77
105
  } & Record<string, EnvConfig | false>;
78
106
 
79
107
  export type ComponentConfig = {
108
+ /**
109
+ * specify environment configurations
110
+ */
80
111
  env?: Env;
112
+ /**
113
+ * the directory of the component (e.g. where the package.json or similar is located). You can set "." if you only have one app.
114
+ */
81
115
  dir: string;
82
116
  } & DefaultEnvConfig;
83
117
 
84
118
  export type Config = {
119
+ /**
120
+ * name of the customer or group
121
+ */
85
122
  customerName: string;
123
+ /**
124
+ * name of the app / project
125
+ */
86
126
  appName: string;
127
+ /**
128
+ * if a env does not define a hostname, it will generate a canonical one (e.g. for review, dev and stage).
129
+ * This prop specifies the domain that is used for these urls.
130
+ *
131
+ */
132
+ domainCanonical?: string;
133
+ /**
134
+ * components (sub apps)
135
+ */
87
136
  components: Record<string, ComponentConfig>;
88
137
  };
@@ -17,6 +17,8 @@ export type Environment = {
17
17
  export type CommitInfo = {
18
18
  refName: string;
19
19
  refSlug: string;
20
+ buildTime: string;
21
+ buildId: string;
20
22
  trigger: PipelineTrigger;
21
23
  };
22
24