@catladder/pipeline 0.0.0-fix-command-710f75f1 → 0.0.0-fix-error-sql-db-delete-a719775a
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/custom/buildJob.js +1 -0
- package/dist/build/docker.d.ts +4 -18
- package/dist/build/docker.js +15 -9
- package/dist/build/index.js +7 -1
- package/dist/build/rails/build.js +37 -16
- package/dist/build/rails/index.d.ts +2 -2
- package/dist/build/rails/test.js +1 -2
- package/dist/build/types.d.ts +36 -4
- package/dist/bundles/catladder-gitlab/index.js +543 -218
- package/dist/constants.js +1 -1
- package/dist/context/getEnvironment.js +1 -0
- package/dist/context/getEnvironmentContext.js +5 -3
- package/dist/context/getEnvironmentVariables.d.ts +5 -1
- package/dist/context/getEnvironmentVariables.js +7 -2
- package/dist/deploy/base.js +1 -1
- package/dist/deploy/cloudRun/index.js +14 -6
- package/dist/deploy/custom/deployJob.js +6 -3
- package/dist/deploy/index.d.ts +2 -1
- package/dist/deploy/kubernetes/additionalSecretKeys.d.ts +3 -1
- package/dist/deploy/kubernetes/additionalSecretKeys.js +5 -1
- package/dist/deploy/kubernetes/deployJob.js +4 -4
- package/dist/deploy/kubernetes/kubeValues.d.ts +1 -0
- package/dist/deploy/kubernetes/kubeValues.js +9 -6
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +1 -0
- package/dist/deploy/types/custom.d.ts +2 -1
- package/dist/deploy/types/googleCloudRun.d.ts +5 -1
- package/dist/deploy/types/kubernetes.d.ts +9 -0
- package/dist/pipeline/createAllJobs.d.ts +8 -0
- package/dist/pipeline/createAllJobs.js +164 -0
- package/dist/pipeline/createChildPipeline.js +24 -48
- package/dist/pipeline/createJobsForComponent.d.ts +3 -0
- package/dist/pipeline/{createJobs.js → createJobsForComponent.js} +8 -105
- 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 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +3 -3
- package/dist/types/context.d.ts +3 -1
- package/dist/types/environmentContext.d.ts +7 -0
- package/dist/types/gitlab-types.d.ts +5 -1
- package/dist/types/jobs.d.ts +9 -2
- package/dist/utils/gitlab.js +1 -1
- package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +32 -32
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +32 -32
- package/examples/__snapshots__/cloud-run-non-public.ts.snap +32 -32
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +3116 -0
- package/examples/__snapshots__/cloud-run-with-sql.ts.snap +64 -64
- package/examples/__snapshots__/custom-build-job.ts.snap +32 -32
- package/examples/__snapshots__/custom-deploy.ts.snap +1384 -0
- package/examples/__snapshots__/kubernetes-application-customization.ts.snap +2280 -0
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +2204 -0
- package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +24 -24
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1911 -0
- package/examples/cloud-run-with-sql-reuse-db.ts +54 -0
- package/examples/custom-deploy.ts +25 -0
- package/examples/kubernetes-application-customization.ts +57 -0
- package/examples/kubernetes-with-cloud-sql-legacy.ts +33 -0
- package/examples/rails-k8s-with-worker.ts +95 -0
- package/package.json +1 -1
- package/src/build/custom/buildJob.ts +1 -0
- package/src/build/docker.ts +13 -6
- package/src/build/index.ts +7 -1
- package/src/build/node/cache.ts +2 -2
- package/src/build/rails/build.ts +20 -10
- package/src/build/rails/index.ts +2 -2
- package/src/build/rails/test.ts +43 -39
- package/src/build/types.ts +40 -5
- package/src/config/configruedEnvs.ts +2 -8
- package/src/context/getEnvironment.ts +1 -0
- package/src/context/getEnvironmentContext.ts +6 -6
- package/src/context/getEnvironmentVariables.ts +9 -4
- package/src/deploy/base.ts +1 -1
- package/src/deploy/cloudRun/deployJob.ts +1 -1
- package/src/deploy/cloudRun/index.ts +12 -4
- package/src/deploy/custom/deployJob.ts +9 -1
- package/src/deploy/index.ts +4 -1
- package/src/deploy/kubernetes/additionalSecretKeys.ts +1 -1
- package/src/deploy/kubernetes/deployJob.ts +2 -1
- package/src/deploy/kubernetes/kubeValues.ts +7 -5
- package/src/deploy/types/custom.ts +2 -1
- package/src/deploy/types/googleCloudRun.ts +6 -1
- package/src/deploy/types/kubernetes.ts +11 -1
- package/src/pipeline/createAllJobs.ts +38 -0
- package/src/pipeline/createChildPipeline.ts +6 -22
- package/src/pipeline/createJobsForComponent.ts +64 -0
- package/src/pipeline/gitlab/createGitlabJobs.ts +149 -0
- package/src/pipeline/index.ts +1 -1
- package/src/types/context.ts +3 -1
- package/src/types/environmentContext.ts +7 -0
- package/src/types/gitlab-types.ts +10 -3
- package/src/types/jobs.ts +11 -2
- package/src/utils/gitlab.ts +1 -1
- package/dist/pipeline/createJobs.d.ts +0 -3
- package/dist/pipeline/gitlab/makeGitlabJob.d.ts +0 -10
- package/dist/pipeline/gitlab/makeGitlabJob.js +0 -44
- package/src/pipeline/createJobs.ts +0 -199
- package/src/pipeline/gitlab/makeGitlabJob.ts +0 -23
|
@@ -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,25 @@
|
|
|
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: "node",
|
|
12
|
+
},
|
|
13
|
+
deploy: {
|
|
14
|
+
type: "custom",
|
|
15
|
+
requiresDocker: true,
|
|
16
|
+
script: ["echo 'would deploy'"],
|
|
17
|
+
stopScript: ["echo 'would stop'"],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
it("matches snapshot", async () => {
|
|
24
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
25
|
+
});
|
|
@@ -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,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: "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
|
+
cloudsql: {
|
|
23
|
+
enabled: true,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
it("matches snapshot", async () => {
|
|
32
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
33
|
+
});
|
|
@@ -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
|
+
});
|
package/package.json
CHANGED
|
@@ -29,6 +29,7 @@ export const createCustomBuildJobs = (context: Context): CatladderJob[] => {
|
|
|
29
29
|
variables: {
|
|
30
30
|
...RUNNER_BUILD_VARIABLES,
|
|
31
31
|
},
|
|
32
|
+
cache: buildConfig.jobCache,
|
|
32
33
|
services: buildConfig.jobServices,
|
|
33
34
|
script: [...(ensureArray(buildConfig.buildCommand) ?? [])],
|
|
34
35
|
artifacts: {
|
package/src/build/docker.ts
CHANGED
|
@@ -45,20 +45,24 @@ export const requiresDockerBuild = (context: Context) => {
|
|
|
45
45
|
return false;
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
+
const getDockerBaseVariables = () => ({
|
|
49
|
+
DOCKER_HOST: "tcp://0.0.0.0:2375",
|
|
50
|
+
DOCKER_TLS_CERTDIR: "",
|
|
51
|
+
DOCKER_DRIVER: "overlay2",
|
|
52
|
+
DOCKER_BUILDKIT: "1", // see https://docs.docker.com/develop/develop-images/build_enhancements/
|
|
53
|
+
});
|
|
54
|
+
|
|
48
55
|
export const getDockerBuildVariables = (context: Context) => {
|
|
49
56
|
return {
|
|
50
57
|
...DOCKER_RUNNER_BUILD_VARIABLES,
|
|
51
|
-
DOCKER_BUILDKIT: "1", // see https://docs.docker.com/develop/develop-images/build_enhancements/
|
|
52
58
|
DOCKERFILE_ADDITIONS:
|
|
53
59
|
context.componentConfig.build.docker?.additionsBegin?.join("\n"),
|
|
54
60
|
DOCKERFILE_ADDITIONS_END:
|
|
55
61
|
context.componentConfig.build.docker?.additionsEnd?.join("\n"),
|
|
56
62
|
APP_DIR: context.componentConfig.dir,
|
|
57
|
-
DOCKER_HOST: "tcp://0.0.0.0:2375",
|
|
58
|
-
DOCKER_TLS_CERTDIR: "",
|
|
59
|
-
DOCKER_DIR: ".", // relative to componentdir
|
|
60
63
|
|
|
61
|
-
|
|
64
|
+
DOCKER_DIR: ".", // relative to componentdir
|
|
65
|
+
...getDockerBaseVariables(),
|
|
62
66
|
|
|
63
67
|
...getDockerImageVariables(context),
|
|
64
68
|
};
|
|
@@ -74,7 +78,7 @@ export const getDockerJobBaseProps = (context: Context) => {
|
|
|
74
78
|
command: ["--tls=false"],
|
|
75
79
|
},
|
|
76
80
|
],
|
|
77
|
-
variables:
|
|
81
|
+
variables: getDockerBaseVariables(),
|
|
78
82
|
};
|
|
79
83
|
};
|
|
80
84
|
export const createDockerBuildJobBase = (
|
|
@@ -89,6 +93,9 @@ export const createDockerBuildJobBase = (
|
|
|
89
93
|
...getDockerJobBaseProps(context),
|
|
90
94
|
script: script || [],
|
|
91
95
|
},
|
|
96
|
+
{
|
|
97
|
+
variables: getDockerBuildVariables(context),
|
|
98
|
+
},
|
|
92
99
|
def
|
|
93
100
|
);
|
|
94
101
|
};
|
package/src/build/index.ts
CHANGED
|
@@ -51,6 +51,12 @@ export const BUILD_TYPES: BuildTypes = {
|
|
|
51
51
|
},
|
|
52
52
|
rails: {
|
|
53
53
|
jobs: createRailsJobs,
|
|
54
|
-
defaults: () => ({
|
|
54
|
+
defaults: () => ({
|
|
55
|
+
startCommand: "/cnb/process/web",
|
|
56
|
+
cnbBuilder: {
|
|
57
|
+
image: "heroku/buildpacks:20",
|
|
58
|
+
packVersion: "0.28.0",
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
55
61
|
},
|
|
56
62
|
};
|
package/src/build/node/cache.ts
CHANGED
|
@@ -31,8 +31,8 @@ export const getNodeModulesCache = (
|
|
|
31
31
|
const componentIsInWorkspace =
|
|
32
32
|
context.packageManagerInfo?.componentIsInWorkspace;
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
// We intentionally do not use the contents of yarn.lock as a cache key, as yarn install should always guarantee that the files are updated, but it can still use part of the cache if not all packages are up-to-date.
|
|
35
|
+
// It would slow down all pipelines whenever one adds a new dependency as it will need to download all node_modules again.
|
|
36
36
|
return [
|
|
37
37
|
{
|
|
38
38
|
// if component is in a shared workspace, use workspace cache. use individual cache else
|
package/src/build/rails/build.ts
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
import type { Context } from "../..";
|
|
2
|
+
import { isOfBuildType } from "../types";
|
|
2
3
|
import type { CatladderJob } from "../../types/jobs";
|
|
3
4
|
import { createDockerBuildJobBase, gitlabDockerLogin } from "../docker";
|
|
4
5
|
|
|
5
6
|
export const createRailsBuildJobs = (context: Context): CatladderJob[] => {
|
|
7
|
+
const buildConfig = context.componentConfig.build;
|
|
8
|
+
if (!isOfBuildType(buildConfig, "rails")) {
|
|
9
|
+
// should not happen
|
|
10
|
+
throw new Error("build type is not rails");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const cnbConf = buildConfig.cnbBuilder;
|
|
14
|
+
|
|
15
|
+
const packEnvArgs = Object.entries(cnbConf?.buildVars ?? {})
|
|
16
|
+
.map(([k, v]) => `--env '${k}${v ? `=${v}` : ""}'`)
|
|
17
|
+
.join(" ");
|
|
18
|
+
|
|
6
19
|
return [
|
|
7
20
|
createDockerBuildJobBase(context, {
|
|
8
|
-
variables:
|
|
9
|
-
CNB_BUILDER: "heroku/buildpacks:18",
|
|
10
|
-
CNB_ENV_VARS: "BUNDLE_GIT__PANTER__CH",
|
|
11
|
-
CNB_EXTRA_ARGS: "",
|
|
12
|
-
CNB_PACK_VERSION: "0.20.0",
|
|
13
|
-
...context.componentConfig.build.extraVars,
|
|
14
|
-
},
|
|
21
|
+
variables: context.componentConfig.build.extraVars,
|
|
15
22
|
// custom script
|
|
16
23
|
script: [
|
|
17
24
|
gitlabDockerLogin,
|
|
18
25
|
`docker pull $DOCKER_CACHE_IMAGE || true`,
|
|
19
|
-
`wget --output-document=- https://github.com/buildpacks/pack/releases/download/v$
|
|
26
|
+
`wget --output-document=- https://github.com/buildpacks/pack/releases/download/v${cnbConf?.packVersion}/pack-v${cnbConf?.packVersion}-linux.tgz | tar -zx --directory /usr/local/bin pack`,
|
|
20
27
|
`chmod +x /usr/local/bin/pack`,
|
|
21
28
|
// replace private git ssh gem sources with https to make bundler with credentials via env var work
|
|
22
29
|
`sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock`,
|
|
23
|
-
`
|
|
24
|
-
|
|
30
|
+
`pack build "$DOCKER_IMAGE:$DOCKER_IMAGE_TAG" --builder '${
|
|
31
|
+
cnbConf?.image
|
|
32
|
+
}' --publish --cache-image "$DOCKER_CACHE_IMAGE" ${packEnvArgs} ${
|
|
33
|
+
cnbConf?.packExtraArgs?.join(" ") ?? ""
|
|
34
|
+
}`,
|
|
25
35
|
],
|
|
26
36
|
}),
|
|
27
37
|
];
|
package/src/build/rails/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Context } from "../../types";
|
|
2
|
-
import { CatladderJob } from "../../types/jobs";
|
|
1
|
+
import type { Context } from "../../types";
|
|
2
|
+
import type { CatladderJob } from "../../types/jobs";
|
|
3
3
|
import { createRailsBuildJobs } from "./build";
|
|
4
4
|
import { createRailsTestJobs } from "./test";
|
|
5
5
|
|
package/src/build/rails/test.ts
CHANGED
|
@@ -17,66 +17,70 @@ export const createRailsTestJobs = (context: Context): CatladderJob[] => {
|
|
|
17
17
|
envMode: "none",
|
|
18
18
|
};
|
|
19
19
|
const defaultImage = "docker.io/ruby";
|
|
20
|
-
const bundlerCacheDir = "tmp/cache"
|
|
20
|
+
const bundlerCacheDir = "tmp/cache";
|
|
21
21
|
const bundlerInstall = [
|
|
22
22
|
`bundle config set path '${bundlerCacheDir}'`,
|
|
23
|
-
"bundle install -j $(nproc)"
|
|
24
|
-
]
|
|
23
|
+
"bundle install -j $(nproc)",
|
|
24
|
+
];
|
|
25
25
|
const bundlerCache = {
|
|
26
26
|
key: {
|
|
27
27
|
files: ["Gemfile.lock"],
|
|
28
|
-
prefix: "$CI_JOB_IMAGE" // a changed image might have different OS libraries which no longer work with the cached gems
|
|
28
|
+
prefix: "$CI_JOB_IMAGE", // a changed image might have different OS libraries which no longer work with the cached gems
|
|
29
29
|
},
|
|
30
|
-
paths: [bundlerCacheDir]
|
|
31
|
-
}
|
|
30
|
+
paths: [bundlerCacheDir],
|
|
31
|
+
};
|
|
32
32
|
const auditJob: CatladderJob | null =
|
|
33
33
|
buildConfig.audit !== false
|
|
34
34
|
? {
|
|
35
|
-
|
|
35
|
+
name: "🛡 audit",
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
...base,
|
|
38
|
+
cache: undefined, // audit does not need bundle install and no cache
|
|
39
|
+
image: buildConfig.audit?.jobImage ?? defaultImage,
|
|
40
|
+
script: [
|
|
41
|
+
`cd ${context.componentConfig.dir}`,
|
|
42
|
+
...(ensureArray(buildConfig.audit?.command) ?? [
|
|
43
|
+
"gem install bundler-audit",
|
|
44
|
+
"bundle audit check",
|
|
45
|
+
]),
|
|
46
|
+
],
|
|
47
|
+
allow_failure: true,
|
|
48
|
+
}
|
|
49
49
|
: null;
|
|
50
50
|
|
|
51
51
|
const lintJob: CatladderJob | null =
|
|
52
52
|
buildConfig.lint !== false
|
|
53
53
|
? {
|
|
54
|
-
|
|
54
|
+
name: "👮 lint",
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
...base,
|
|
57
|
+
cache: bundlerCache,
|
|
58
|
+
image: buildConfig.lint?.jobImage ?? defaultImage,
|
|
59
|
+
script: [
|
|
60
|
+
`cd ${context.componentConfig.dir}`,
|
|
61
|
+
...bundlerInstall,
|
|
62
|
+
...(ensureArray(buildConfig.lint?.command) ?? [
|
|
63
|
+
"bundle exec rubocop",
|
|
64
|
+
]),
|
|
65
|
+
],
|
|
66
|
+
}
|
|
65
67
|
: null;
|
|
66
68
|
const testJob: CatladderJob | null =
|
|
67
69
|
buildConfig.test !== false
|
|
68
70
|
? {
|
|
69
|
-
|
|
71
|
+
name: "🧪 test",
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
...base,
|
|
74
|
+
cache: bundlerCache,
|
|
75
|
+
image: buildConfig.test?.jobImage ?? defaultImage,
|
|
76
|
+
script: [
|
|
77
|
+
`cd ${context.componentConfig.dir}`,
|
|
78
|
+
...bundlerInstall,
|
|
79
|
+
...(ensureArray(buildConfig.test?.command) ?? [
|
|
80
|
+
"bundle exec rspec",
|
|
81
|
+
]),
|
|
82
|
+
],
|
|
83
|
+
}
|
|
80
84
|
: null;
|
|
81
85
|
return [auditJob, lintJob, testJob].filter(notNil);
|
|
82
86
|
};
|
package/src/build/types.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { GitlabJobService } from "../types";
|
|
1
|
+
import type { GitlabJobImage, GitlabJobService } from "../types";
|
|
2
|
+
|
|
3
|
+
import type { CatladderJob } from "../types/jobs";
|
|
2
4
|
|
|
3
5
|
export type BuildConfigBase = {
|
|
4
6
|
/**
|
|
@@ -29,7 +31,7 @@ export type BuildConfigBase = {
|
|
|
29
31
|
| false
|
|
30
32
|
| {
|
|
31
33
|
command?: string | string[];
|
|
32
|
-
jobImage?:
|
|
34
|
+
jobImage?: GitlabJobImage;
|
|
33
35
|
};
|
|
34
36
|
|
|
35
37
|
/**
|
|
@@ -39,7 +41,7 @@ export type BuildConfigBase = {
|
|
|
39
41
|
| false
|
|
40
42
|
| {
|
|
41
43
|
command?: string | string[];
|
|
42
|
-
jobImage?:
|
|
44
|
+
jobImage?: GitlabJobImage;
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
/**
|
|
@@ -49,7 +51,7 @@ export type BuildConfigBase = {
|
|
|
49
51
|
| false
|
|
50
52
|
| {
|
|
51
53
|
command?: string | string[];
|
|
52
|
-
jobImage?:
|
|
54
|
+
jobImage?: GitlabJobImage;
|
|
53
55
|
};
|
|
54
56
|
|
|
55
57
|
/**
|
|
@@ -70,7 +72,7 @@ export type BuildConfigBase = {
|
|
|
70
72
|
* eg. `["dist/test-results/TEST-*.xml", "dist/rspec.xml", ...]`
|
|
71
73
|
*/
|
|
72
74
|
junit?: string[];
|
|
73
|
-
}
|
|
75
|
+
};
|
|
74
76
|
};
|
|
75
77
|
|
|
76
78
|
export type BuildConfigNodeBase = BuildConfigBase;
|
|
@@ -113,11 +115,44 @@ export type BuildConfigCustom = BuildConfigBase & {
|
|
|
113
115
|
type: "custom";
|
|
114
116
|
jobImage: string;
|
|
115
117
|
jobServices?: GitlabJobService[];
|
|
118
|
+
|
|
116
119
|
docker: BuildConfigCustomDocker;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* customize cache for the job
|
|
123
|
+
*/
|
|
124
|
+
jobCache?: CatladderJob["cache"];
|
|
117
125
|
};
|
|
118
126
|
|
|
119
127
|
export type BuildConfigRails = BuildConfigBase & {
|
|
120
128
|
type: "rails";
|
|
129
|
+
cnbBuilder?: {
|
|
130
|
+
/**
|
|
131
|
+
* The Cloud Native Buildpacks builder image to use.
|
|
132
|
+
* See e.g. https://github.com/heroku/builder or others.
|
|
133
|
+
* Default: heroku/buildpacks:20
|
|
134
|
+
*/
|
|
135
|
+
image?: string;
|
|
136
|
+
/**
|
|
137
|
+
* The version of the Cloud Native Buildpacks pack command to use.
|
|
138
|
+
* See https://buildpacks.io/docs/tools/pack/
|
|
139
|
+
* Default: 0.28.0
|
|
140
|
+
*/
|
|
141
|
+
packVersion?: string;
|
|
142
|
+
/**
|
|
143
|
+
* Additional command arguments passed to the pack command.
|
|
144
|
+
* See https://buildpacks.io/docs/tools/pack/
|
|
145
|
+
*/
|
|
146
|
+
packExtraArgs?: string[];
|
|
147
|
+
/**
|
|
148
|
+
* Variables needed for Bundler and Rails asset precompilation.
|
|
149
|
+
*
|
|
150
|
+
* Specify a key with the value `undefined` to inherit it from the EnvVars.
|
|
151
|
+
*
|
|
152
|
+
* See https://github.com/rails/rails/issues/32947
|
|
153
|
+
*/
|
|
154
|
+
buildVars?: Record<string, string | undefined>;
|
|
155
|
+
};
|
|
121
156
|
};
|
|
122
157
|
|
|
123
158
|
export type BuildConfigStorybook = BuildConfigNodeBase & {
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
EnvType,
|
|
4
|
-
PipelineTrigger} from "../types";
|
|
5
|
-
import {
|
|
6
|
-
DEFAULT_ENV_TYPES,
|
|
7
|
-
getEnvTypesByTrigger
|
|
8
|
-
} from "../types";
|
|
1
|
+
import type { Config, EnvType, PipelineTrigger } from "../types";
|
|
2
|
+
import { DEFAULT_ENV_TYPES, getEnvTypesByTrigger } from "../types";
|
|
9
3
|
|
|
10
4
|
const getConfiguredAndDefaultEnvs = (
|
|
11
5
|
config: Config,
|