@catladder/pipeline 1.165.0 → 1.166.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.
- package/dist/build/base/createAppBuildJob.d.ts +3 -1
- package/dist/build/base/createAppBuildJob.js +6 -4
- package/dist/build/base/createBuildJobDefinition.d.ts +7 -0
- package/dist/build/base/createBuildJobDefinition.js +58 -0
- package/dist/build/cache/createJobCache.d.ts +6 -0
- package/dist/build/cache/createJobCache.js +109 -0
- package/dist/build/cache/getAllCacheConfigsFromConfig.d.ts +3 -0
- package/dist/build/cache/getAllCacheConfigsFromConfig.js +66 -0
- package/dist/build/cache/transformLegacyJobCache.d.ts +3 -0
- package/dist/build/cache/transformLegacyJobCache.js +29 -0
- package/dist/build/custom/buildJob.js +2 -45
- package/dist/build/custom/testJob.d.ts +1 -1
- package/dist/build/custom/testJob.js +12 -11
- package/dist/build/docker.d.ts +4 -3
- package/dist/build/docker.js +5 -2
- package/dist/build/node/buildJob.js +5 -17
- package/dist/build/node/cache.d.ts +6 -6
- package/dist/build/node/cache.js +8 -9
- package/dist/build/node/meteor.js +2 -3
- package/dist/build/node/testJob.js +6 -5
- package/dist/build/node/yarn.js +1 -2
- package/dist/build/rails/test.js +3 -3
- package/dist/build/sbom.js +1 -1
- package/dist/build/types.d.ts +43 -4
- package/dist/bundles/catladder-gitlab/index.js +2 -2
- package/dist/constants.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/gitlab-types.d.ts +2 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/jobDefinition.d.ts +5 -0
- package/dist/types/jobDefinition.js +5 -0
- package/dist/types/jobs.d.ts +3 -2
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +7 -2
- package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +4 -4
- package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +817 -1717
- package/examples/__snapshots__/custom-build-job-with-tests.test.ts.snap +0 -4
- package/examples/__snapshots__/custom-build-job.test.ts.snap +0 -4
- package/examples/__snapshots__/custom-sbom-java.test.ts.snap +0 -4
- package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +4 -4
- package/examples/__snapshots__/native-app.test.ts.snap +24 -20
- package/examples/__snapshots__/workspace-api-www-custom-cache.test.ts.snap +2374 -0
- package/examples/__snapshots__/workspace-api-www.test.ts.snap +2354 -0
- package/examples/cloud-run-with-sql.ts +1 -23
- package/examples/workspace-api-www-custom-cache.test.ts +11 -0
- package/examples/workspace-api-www-custom-cache.ts +51 -0
- package/examples/workspace-api-www.test.ts +11 -0
- package/examples/workspace-api-www.ts +45 -0
- package/package.json +1 -1
- package/src/build/base/createAppBuildJob.ts +6 -4
- package/src/build/base/createBuildJobDefinition.ts +38 -0
- package/src/build/cache/createJobCache.ts +85 -0
- package/src/build/cache/getAllCacheConfigsFromConfig.ts +33 -0
- package/src/build/cache/transformLegacyJobCache.ts +14 -0
- package/src/build/custom/buildJob.ts +2 -14
- package/src/build/custom/testJob.ts +7 -6
- package/src/build/docker.ts +5 -3
- package/src/build/node/buildJob.ts +6 -29
- package/src/build/node/cache.ts +20 -21
- package/src/build/node/meteor.ts +7 -8
- package/src/build/node/testJob.ts +7 -6
- package/src/build/node/yarn.ts +1 -1
- package/src/build/rails/test.ts +4 -4
- package/src/build/sbom.ts +2 -2
- package/src/build/types.ts +54 -4
- package/src/types/gitlab-types.ts +2 -2
- package/src/types/index.ts +1 -0
- package/src/types/jobDefinition.ts +9 -0
- package/src/types/jobs.ts +5 -8
- package/src/utils/index.ts +4 -1
package/src/build/node/meteor.ts
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import { join } from "path";
|
|
2
1
|
import { getRunnerImage } from "../../runner";
|
|
3
|
-
import type { GitlabJobCache } from "../../types";
|
|
4
2
|
import type { ComponentContext } from "../../types/context";
|
|
5
3
|
|
|
6
4
|
import type { CatladderJob } from "../../types/jobs";
|
|
7
5
|
|
|
8
6
|
import { createComponentBuildJobs } from "../base";
|
|
9
7
|
import { getDockerBuildScriptWithBuiltInDockerFile } from "../docker";
|
|
8
|
+
import type { CacheConfig } from "../types";
|
|
10
9
|
import { isOfBuildType } from "../types";
|
|
11
10
|
import { getNodeCache } from "./cache";
|
|
12
11
|
import { getYarnInstall } from "./yarn";
|
|
13
12
|
|
|
14
|
-
const getMeteorCache = (context: ComponentContext):
|
|
13
|
+
const getMeteorCache = (context: ComponentContext): CacheConfig[] => [
|
|
15
14
|
{
|
|
16
|
-
key:
|
|
15
|
+
key: "meteor-build-cache",
|
|
17
16
|
policy: "pull-push",
|
|
18
17
|
paths: [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
".meteor/local/resolver-result-cache.json",
|
|
19
|
+
".meteor/local/plugin-cache",
|
|
20
|
+
".meteor/local/isopacks",
|
|
21
|
+
".meteor/local/bundler-cache/scanner",
|
|
23
22
|
],
|
|
24
23
|
},
|
|
25
24
|
];
|
|
@@ -5,11 +5,12 @@ import {
|
|
|
5
5
|
type ComponentContext,
|
|
6
6
|
} from "../../types/context";
|
|
7
7
|
import type { CatladderJob } from "../../types/jobs";
|
|
8
|
-
import {
|
|
8
|
+
import { ensureArrayOrNull, notNil } from "../../utils";
|
|
9
9
|
import { createArtifactsConfig } from "../base/createArtifactsConfig";
|
|
10
10
|
import { getNodeCache } from "./cache";
|
|
11
11
|
import { NODE_RUNNER_BUILD_VARIABLES } from "./constants";
|
|
12
12
|
import { ensureNodeVersion, getYarnInstall } from "./yarn";
|
|
13
|
+
import { createJobCacheFromCacheConfigs } from "../cache/createJobCache";
|
|
13
14
|
|
|
14
15
|
export const createNodeTestJobs = (
|
|
15
16
|
context: ComponentContext | WorkspaceContext,
|
|
@@ -55,7 +56,7 @@ export const createNodeTestJobs = (
|
|
|
55
56
|
cache: undefined, // audit does not need yarn install and no cache
|
|
56
57
|
script: [
|
|
57
58
|
`cd ${context.build.dir}`,
|
|
58
|
-
...(
|
|
59
|
+
...(ensureArrayOrNull(buildConfig.audit?.command) ?? [
|
|
59
60
|
context.packageManagerInfo.isClassic
|
|
60
61
|
? "yarn audit"
|
|
61
62
|
: "yarn npm audit --environment production", // yarn 2
|
|
@@ -76,12 +77,12 @@ export const createNodeTestJobs = (
|
|
|
76
77
|
name: "👮 lint",
|
|
77
78
|
...base,
|
|
78
79
|
image: buildConfig.lint?.jobImage ?? defaultImage,
|
|
79
|
-
cache: getNodeCache(context),
|
|
80
|
+
cache: createJobCacheFromCacheConfigs(context, getNodeCache(context)),
|
|
80
81
|
script: [
|
|
81
82
|
...ensureNodeVersion(context),
|
|
82
83
|
`cd ${context.build.dir}`,
|
|
83
84
|
...yarnInstall,
|
|
84
|
-
...(
|
|
85
|
+
...(ensureArrayOrNull(buildConfig.lint?.command) ?? ["yarn lint"]),
|
|
85
86
|
],
|
|
86
87
|
...createArtifactsConfig(
|
|
87
88
|
context.build.dir,
|
|
@@ -98,12 +99,12 @@ export const createNodeTestJobs = (
|
|
|
98
99
|
...base,
|
|
99
100
|
image:
|
|
100
101
|
buildConfig.test?.jobImage ?? getRunnerImage("jobs-testing-chrome"),
|
|
101
|
-
cache: getNodeCache(context),
|
|
102
|
+
cache: createJobCacheFromCacheConfigs(context, getNodeCache(context)),
|
|
102
103
|
script: [
|
|
103
104
|
...ensureNodeVersion(context),
|
|
104
105
|
`cd ${context.build.dir}`,
|
|
105
106
|
...yarnInstall,
|
|
106
|
-
...(
|
|
107
|
+
...(ensureArrayOrNull(buildConfig.test?.command) ?? ["yarn test"]),
|
|
107
108
|
],
|
|
108
109
|
...createArtifactsConfig(
|
|
109
110
|
context.build.dir,
|
package/src/build/node/yarn.ts
CHANGED
package/src/build/rails/test.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
type ComponentContext,
|
|
4
4
|
} from "../..";
|
|
5
5
|
import type { CatladderJob } from "../../types/jobs";
|
|
6
|
-
import {
|
|
6
|
+
import { ensureArrayOrNull, notNil } from "../../utils";
|
|
7
7
|
|
|
8
8
|
export const createRailsTestJobs = (
|
|
9
9
|
context: ComponentContext,
|
|
@@ -54,7 +54,7 @@ export const createRailsTestJobs = (
|
|
|
54
54
|
buildConfig.audit?.jobImage ?? buildConfig.jobImage ?? defaultImage,
|
|
55
55
|
script: [
|
|
56
56
|
`cd ${context.build.dir}`,
|
|
57
|
-
...(
|
|
57
|
+
...(ensureArrayOrNull(buildConfig.audit?.command) ?? [
|
|
58
58
|
"gem install bundler-audit",
|
|
59
59
|
"bundle audit check",
|
|
60
60
|
]),
|
|
@@ -75,7 +75,7 @@ export const createRailsTestJobs = (
|
|
|
75
75
|
script: [
|
|
76
76
|
`cd ${context.build.dir}`,
|
|
77
77
|
...bundlerInstall,
|
|
78
|
-
...(
|
|
78
|
+
...(ensureArrayOrNull(buildConfig.lint?.command) ?? [
|
|
79
79
|
"bundle exec rubocop",
|
|
80
80
|
]),
|
|
81
81
|
],
|
|
@@ -93,7 +93,7 @@ export const createRailsTestJobs = (
|
|
|
93
93
|
script: [
|
|
94
94
|
`cd ${context.build.dir}`,
|
|
95
95
|
...bundlerInstall,
|
|
96
|
-
...(
|
|
96
|
+
...(ensureArrayOrNull(buildConfig.test?.command) ?? [
|
|
97
97
|
"bundle exec rspec",
|
|
98
98
|
]),
|
|
99
99
|
],
|
package/src/build/sbom.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isStandaloneBuildConfig } from ".";
|
|
2
2
|
import type { ComponentContext } from "../types/context";
|
|
3
3
|
import type { CatladderJob } from "../types/jobs";
|
|
4
|
-
import {
|
|
4
|
+
import { ensureArrayOrNull } from "../utils";
|
|
5
5
|
|
|
6
6
|
export const SBOM_BUILD_JOB_NAME = "🧾 sbom";
|
|
7
7
|
export const SBOM_FILE = "__sbom.json";
|
|
@@ -29,7 +29,7 @@ export const createSbomBuildJob = (context: ComponentContext): CatladderJob => {
|
|
|
29
29
|
isStandaloneBuildConfig(buildConfig) &&
|
|
30
30
|
buildConfig.type === "custom" &&
|
|
31
31
|
buildConfig.sbom !== false
|
|
32
|
-
?
|
|
32
|
+
? ensureArrayOrNull(buildConfig.sbom?.command) ?? defaultScript
|
|
33
33
|
: defaultScript;
|
|
34
34
|
|
|
35
35
|
return {
|
package/src/build/types.ts
CHANGED
|
@@ -1,7 +1,42 @@
|
|
|
1
1
|
import type { Artifacts, EnvVars, GitlabJobImage } from "../types";
|
|
2
2
|
import type { Services } from "../types/gitlab-ci-yml";
|
|
3
3
|
|
|
4
|
-
import type { CatladderJob } from "../types/jobs";
|
|
4
|
+
import type { CatladderJob, CatladderJobCache } from "../types/jobs";
|
|
5
|
+
|
|
6
|
+
export type CacheConfigAdvanced = Omit<CatladderJobCache, "paths" | "key"> & {
|
|
7
|
+
/**
|
|
8
|
+
* if you set a key, the cache is scoped to the key. Be aware that there is a limit in gitlab of 4 caches.
|
|
9
|
+
*
|
|
10
|
+
* see https://gitlab.com/gitlab-org/gitlab/-/issues/421962
|
|
11
|
+
*/
|
|
12
|
+
key: Required<CatladderJobCache>["key"];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* whether the cache is scoped to the context (component or workspace) or the build directory.
|
|
16
|
+
*
|
|
17
|
+
* defaults to context
|
|
18
|
+
*/
|
|
19
|
+
scope?: "context" | "buildDir" | "global";
|
|
20
|
+
} & CacheConfigSimple;
|
|
21
|
+
|
|
22
|
+
export type CacheConfigSimple = {
|
|
23
|
+
/**
|
|
24
|
+
* paths to cache. All Paths are relative to the context dir.
|
|
25
|
+
*/
|
|
26
|
+
paths: string[];
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* whether paths are relative to the base dir. defaults to relative.
|
|
30
|
+
*/
|
|
31
|
+
pathMode?: "relative" | "absolute";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* custom base dir
|
|
35
|
+
*/
|
|
36
|
+
baseDir?: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type CacheConfig = CacheConfigSimple | CacheConfigAdvanced;
|
|
5
40
|
|
|
6
41
|
export type BuildConfigArtifactsReports = {
|
|
7
42
|
/**
|
|
@@ -13,6 +48,13 @@ export type BuildConfigArtifactsReports = {
|
|
|
13
48
|
junit?: string[];
|
|
14
49
|
};
|
|
15
50
|
|
|
51
|
+
export type WithCacheConfig = {
|
|
52
|
+
/*
|
|
53
|
+
cache config. All Paths are relative to the context dir.
|
|
54
|
+
*/
|
|
55
|
+
cache?: CacheConfig | CacheConfig[];
|
|
56
|
+
};
|
|
57
|
+
|
|
16
58
|
export type TestJobCustom = {
|
|
17
59
|
command?: string | string[];
|
|
18
60
|
jobImage?: GitlabJobImage;
|
|
@@ -87,6 +129,8 @@ export type BuildConfigBase = {
|
|
|
87
129
|
|
|
88
130
|
/**
|
|
89
131
|
* customize cache for the job
|
|
132
|
+
*
|
|
133
|
+
* @deprecated use cache
|
|
90
134
|
*/
|
|
91
135
|
jobCache?: CatladderJob["cache"];
|
|
92
136
|
|
|
@@ -98,7 +142,7 @@ export type BuildConfigBase = {
|
|
|
98
142
|
* custom image to use
|
|
99
143
|
*/
|
|
100
144
|
jobImage?: GitlabJobImage;
|
|
101
|
-
};
|
|
145
|
+
} & WithCacheConfig;
|
|
102
146
|
|
|
103
147
|
export type BuildConfigNodeBase = BuildConfigBase & {
|
|
104
148
|
/**
|
|
@@ -290,7 +334,7 @@ export type BuildConfigFromWorkspace = {
|
|
|
290
334
|
* by default "dist" and ".next" are allways included
|
|
291
335
|
*/
|
|
292
336
|
artifactsPaths?: string[];
|
|
293
|
-
};
|
|
337
|
+
} & WithCacheConfig;
|
|
294
338
|
export type BuildConfigStandalone =
|
|
295
339
|
| BuildConfigNode
|
|
296
340
|
| BuildConfigNodeStatic
|
|
@@ -351,7 +395,13 @@ export type WorkspaceBuildConfigBase = {
|
|
|
351
395
|
* use to display information in merge requests, pipeline views and security dashboards.
|
|
352
396
|
*/
|
|
353
397
|
artifactsReports?: BuildConfigArtifactsReports;
|
|
354
|
-
|
|
398
|
+
|
|
399
|
+
jobImage?: GitlabJobImage;
|
|
400
|
+
/**
|
|
401
|
+
* tags for the underlying job runner (e.g gitlab)
|
|
402
|
+
*/
|
|
403
|
+
jobTags?: string[];
|
|
404
|
+
} & WithCacheConfig;
|
|
355
405
|
|
|
356
406
|
export type WorkspaceBuildConfigNode = {
|
|
357
407
|
type: "node";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
Artifacts as GitlabCiArtifacts,
|
|
3
3
|
JobTemplate,
|
|
4
|
-
Cache,
|
|
4
|
+
Cache as GitlabJobCache,
|
|
5
5
|
Rules,
|
|
6
6
|
} from "./gitlab-ci-yml";
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ export { Retry, Image as GitlabJobImage } from "./gitlab-ci-yml";
|
|
|
9
9
|
|
|
10
10
|
// Reports won't show up on MRs until https://gitlab.com/groups/gitlab-org/-/epics/8205
|
|
11
11
|
export type Artifacts = GitlabCiArtifacts;
|
|
12
|
-
export type GitlabJobCache
|
|
12
|
+
export type { GitlabJobCache };
|
|
13
13
|
export type GitlabRule = Exclude<
|
|
14
14
|
Exclude<Rules, null>[number],
|
|
15
15
|
string | string[] // we only use the object version
|
package/src/types/index.ts
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CacheConfig } from "../build";
|
|
2
|
+
import { CacheConfigAdvanced, CacheConfigSimple } from "../build";
|
|
3
|
+
import type { CatladderJob } from "./jobs";
|
|
4
|
+
|
|
5
|
+
export type JobDefintion = Partial<
|
|
6
|
+
Omit<CatladderJob, "artifacts" | "cache">
|
|
7
|
+
> & {
|
|
8
|
+
cache?: CacheConfig[];
|
|
9
|
+
};
|
package/src/types/jobs.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import type { UnspecifiedEnvVars } from "..";
|
|
2
|
-
import type {
|
|
3
|
-
BashExpression,
|
|
4
|
-
StringOrBashExpression,
|
|
5
|
-
} from "../bash/BashExpression";
|
|
6
2
|
import type {
|
|
7
3
|
Artifacts,
|
|
4
|
+
GitlabEnvironment,
|
|
8
5
|
GitlabJobCache,
|
|
9
|
-
GitlabRule,
|
|
10
|
-
GitlabJobImage,
|
|
11
6
|
GitlabJobDef,
|
|
12
|
-
|
|
7
|
+
GitlabJobImage,
|
|
8
|
+
GitlabRule,
|
|
13
9
|
} from "./gitlab-types";
|
|
14
10
|
|
|
11
|
+
export type CatladderJobCache = GitlabJobCache;
|
|
15
12
|
export const BASE_STAGES = [
|
|
16
13
|
"setup",
|
|
17
14
|
"test",
|
|
@@ -84,7 +81,7 @@ export type CatladderJob<S = BaseStage> = {
|
|
|
84
81
|
/**
|
|
85
82
|
* cache config, we use here the same shape as gitlab itself
|
|
86
83
|
*/
|
|
87
|
-
cache?:
|
|
84
|
+
cache?: CatladderJobCache | CatladderJobCache[];
|
|
88
85
|
|
|
89
86
|
/**
|
|
90
87
|
* job artifacts, we also use gitlab shape here
|
package/src/utils/index.ts
CHANGED
|
@@ -6,9 +6,12 @@ export function notNil<TValue>(
|
|
|
6
6
|
return value !== null && value !== undefined;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const
|
|
9
|
+
export const ensureArrayOrNull = <T>(s: undefined | T | T[]): T[] | null =>
|
|
10
10
|
isNil(s) ? null : Array.isArray(s) ? s : [s];
|
|
11
11
|
|
|
12
|
+
export const ensureArray = <T>(s: undefined | T | T[]): T[] =>
|
|
13
|
+
ensureArrayOrNull(s) ?? [];
|
|
14
|
+
|
|
12
15
|
// see https://github.com/lodash/lodash/issues/5384
|
|
13
16
|
export const mergeWithMergingArrays = <A, B>(obj1: A, obj2: B): A & B => {
|
|
14
17
|
return mergeWith({}, obj1, obj2, (prop1, prop2) =>
|