@catladder/pipeline 1.100.2 → 1.101.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 (49) hide show
  1. package/dist/build/node/buildJob.js +9 -8
  2. package/dist/build/node/yarn.js +1 -1
  3. package/dist/build/types.d.ts +8 -4
  4. package/dist/bundles/catladder-gitlab/index.js +3 -3
  5. package/dist/constants.js +1 -1
  6. package/dist/context/getEnvironmentVariables.js +4 -1
  7. package/dist/deploy/base.js +5 -4
  8. package/dist/deploy/types/base.d.ts +8 -0
  9. package/dist/pipeline/commitInfo/getBuildId.d.ts +6 -1
  10. package/dist/pipeline/commitInfo/getBuildId.js +22 -2
  11. package/dist/pipeline/commitInfo/getCommitInfo.js +4 -1
  12. package/dist/pipeline/gitlab/createGitlabJobs.d.ts +1 -0
  13. package/dist/pipeline/gitlab/createGitlabJobs.js +3 -1
  14. package/dist/tsconfig.tsbuildinfo +1 -1
  15. package/dist/types/context.d.ts +1 -0
  16. package/dist/types/gitlab-types.d.ts +1 -0
  17. package/dist/types/jobs.d.ts +4 -0
  18. package/dist/utils/index.d.ts +1 -1
  19. package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +80 -32
  20. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +80 -32
  21. package/examples/__snapshots__/cloud-run-non-public.ts.snap +80 -32
  22. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +160 -64
  23. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +160 -64
  24. package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +64 -24
  25. package/examples/__snapshots__/custom-build-job.ts.snap +64 -24
  26. package/examples/__snapshots__/custom-deploy.ts.snap +64 -28
  27. package/examples/__snapshots__/custom-envs.ts.snap +56 -22
  28. package/examples/__snapshots__/custom-sbom-java.ts.snap +64 -24
  29. package/examples/__snapshots__/kubernetes-application-customization.ts.snap +148 -52
  30. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +148 -52
  31. package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +148 -52
  32. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +296 -104
  33. package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +148 -52
  34. package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +108 -36
  35. package/examples/__snapshots__/wait-for-other-deploy.ts.snap +120 -48
  36. package/package.json +1 -1
  37. package/src/build/node/buildJob.ts +6 -1
  38. package/src/build/node/yarn.ts +2 -1
  39. package/src/build/types.ts +10 -5
  40. package/src/context/getEnvironmentVariables.ts +4 -1
  41. package/src/deploy/base.ts +7 -2
  42. package/src/deploy/types/base.ts +10 -0
  43. package/src/pipeline/commitInfo/getBuildId.ts +11 -0
  44. package/src/pipeline/commitInfo/getCommitInfo.ts +2 -1
  45. package/src/pipeline/gitlab/createGitlabJobs.ts +2 -0
  46. package/src/types/context.ts +1 -0
  47. package/src/types/gitlab-types.ts +1 -0
  48. package/src/types/jobs.ts +5 -0
  49. package/src/utils/index.ts +1 -1
@@ -4,3 +4,14 @@ export const getBuildId = async () =>
4
4
  await exec("git describe --tags || git rev-parse HEAD").then((s) =>
5
5
  s.stdout.trim()
6
6
  );
7
+
8
+ // thx chat gpt
9
+ /**
10
+ * returns the last tagged version string Major.minor.patch
11
+ * returns 0.0.0 if there is no tag
12
+ */
13
+ export const getCurrentVersionString = async () => {
14
+ return await exec(
15
+ 'latest_tag=$(git describe --tags --abbrev=0 2>/dev/null); if [ -z "$latest_tag" ]; then echo "0.0.0"; else echo "${latest_tag#v}"; fi | cut -d "." -f 1-3'
16
+ ).then((s) => s.stdout.trim());
17
+ };
@@ -1,5 +1,5 @@
1
1
  import type { CommitInfo } from "../../types";
2
- import { getBuildId } from "./getBuildId";
2
+ import { getBuildId, getCurrentVersionString } from "./getBuildId";
3
3
  export const getBaseCommitInfo = async (): Promise<
4
4
  Omit<CommitInfo, "trigger">
5
5
  > => ({
@@ -9,4 +9,5 @@ export const getBaseCommitInfo = async (): Promise<
9
9
  : "unknown",
10
10
  buildTime: new Date().toISOString(),
11
11
  buildId: await getBuildId(),
12
+ currentVersion: await getCurrentVersionString(),
12
13
  });
@@ -51,6 +51,7 @@ export const makeGitlabJob = (
51
51
  needsOtherComponent,
52
52
  name,
53
53
  needs,
54
+ jobTags,
54
55
  ...job
55
56
  }: CatladderJob<string>,
56
57
  allJobs: AllCatladderJobs
@@ -101,6 +102,7 @@ export const makeGitlabJob = (
101
102
 
102
103
  const gitlabJob: GitlabJobDef = removeUndefined({
103
104
  ...job,
105
+ tags: jobTags,
104
106
  stage,
105
107
  environment: job.environment?.on_stop
106
108
  ? {
@@ -35,6 +35,7 @@ export type CommitInfo = {
35
35
  buildTime: string;
36
36
  buildId: string;
37
37
  trigger: PipelineTrigger;
38
+ currentVersion: string;
38
39
  };
39
40
 
40
41
  type Workspace = {
@@ -77,6 +77,7 @@ export type GitlabJobDef = {
77
77
  environment?: GitlabEnvironment;
78
78
  allow_failure?: boolean;
79
79
  parallel?: number;
80
+ tags?: string[];
80
81
  trigger?: {
81
82
  strategy: "depend";
82
83
  include: Array<{
package/src/types/jobs.ts CHANGED
@@ -109,4 +109,9 @@ export type CatladderJob<S = BaseStage> = {
109
109
  * We use the same shape as GitLab itself.
110
110
  */
111
111
  parallel?: number;
112
+
113
+ /**
114
+ * tags for the underlying job runner (e.g gitlab)
115
+ */
116
+ jobTags?: string[];
112
117
  };
@@ -6,7 +6,7 @@ export function notNil<TValue>(
6
6
  return value !== null && value !== undefined;
7
7
  }
8
8
 
9
- export const ensureArray = <T>(s: T | T[]): T[] | null =>
9
+ export const ensureArray = <T>(s: undefined | T | T[]): T[] | null =>
10
10
  isNil(s) ? null : Array.isArray(s) ? s : [s];
11
11
 
12
12
  // see https://github.com/lodash/lodash/issues/5384