@catladder/pipeline 1.83.0 → 1.83.2
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/index.js +7 -1
- package/dist/build/rails/build.js +41 -16
- package/dist/build/rails/index.d.ts +2 -2
- package/dist/build/types.d.ts +27 -0
- package/dist/bundles/catladder-gitlab/index.js +1 -1
- package/dist/constants.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1911 -0
- package/examples/rails-k8s-with-worker.ts +95 -0
- package/package.json +1 -1
- package/src/build/index.ts +7 -1
- package/src/build/rails/build.ts +17 -10
- package/src/build/rails/index.ts +2 -2
- package/src/build/types.ts +27 -0
|
@@ -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
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/rails/build.ts
CHANGED
|
@@ -1,27 +1,34 @@
|
|
|
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
|
+
// backwards compatabilty with CNB_ENV_VARS
|
|
16
|
+
// TODO: remove when all projects are migrated
|
|
17
|
+
const packEnvArgs = buildConfig.extraVars?.CNB_ENV_VARS?.split(" ").map(v => `--env '${v}'`)
|
|
18
|
+
?? Object.entries(cnbConf?.buildVars ?? {}).map(([k, v]) => `--env '${k}${v ? `=${v}` : ""}'`)
|
|
19
|
+
|
|
6
20
|
return [
|
|
7
21
|
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
|
-
},
|
|
22
|
+
variables: context.componentConfig.build.extraVars,
|
|
15
23
|
// custom script
|
|
16
24
|
script: [
|
|
17
25
|
gitlabDockerLogin,
|
|
18
26
|
`docker pull $DOCKER_CACHE_IMAGE || true`,
|
|
19
|
-
`wget --output-document=- https://github.com/buildpacks/pack/releases/download/v$
|
|
27
|
+
`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
28
|
`chmod +x /usr/local/bin/pack`,
|
|
21
29
|
// replace private git ssh gem sources with https to make bundler with credentials via env var work
|
|
22
30
|
`sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock`,
|
|
23
|
-
`
|
|
24
|
-
`pack build $DOCKER_IMAGE:$DOCKER_IMAGE_TAG --builder $CNB_BUILDER --publish --cache-image $DOCKER_CACHE_IMAGE $env_args $CNB_EXTRA_ARGS`,
|
|
31
|
+
`pack build "$DOCKER_IMAGE:$DOCKER_IMAGE_TAG" --builder '${cnbConf?.image}' --publish --cache-image "$DOCKER_CACHE_IMAGE" ${packEnvArgs.join(" ")} ${cnbConf?.packExtraArgs?.join(" ") ?? ""}`
|
|
25
32
|
],
|
|
26
33
|
}),
|
|
27
34
|
];
|
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/types.ts
CHANGED
|
@@ -118,6 +118,33 @@ export type BuildConfigCustom = BuildConfigBase & {
|
|
|
118
118
|
|
|
119
119
|
export type BuildConfigRails = BuildConfigBase & {
|
|
120
120
|
type: "rails";
|
|
121
|
+
cnbBuilder?: {
|
|
122
|
+
/**
|
|
123
|
+
* The Cloud Native Buildpacks builder image to use.
|
|
124
|
+
* See e.g. https://github.com/heroku/builder or others.
|
|
125
|
+
* Default: heroku/buildpacks:20
|
|
126
|
+
*/
|
|
127
|
+
image?: string;
|
|
128
|
+
/**
|
|
129
|
+
* The version of the Cloud Native Buildpacks pack command to use.
|
|
130
|
+
* See https://buildpacks.io/docs/tools/pack/
|
|
131
|
+
* Default: 0.28.0
|
|
132
|
+
*/
|
|
133
|
+
packVersion?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Additional command arguments passed to the pack command.
|
|
136
|
+
* See https://buildpacks.io/docs/tools/pack/
|
|
137
|
+
*/
|
|
138
|
+
packExtraArgs?: string[];
|
|
139
|
+
/**
|
|
140
|
+
* Variables needed for Bundler and Rails asset precompilation.
|
|
141
|
+
*
|
|
142
|
+
* Specify a key with the value `undefined` to inherit it from the EnvVars.
|
|
143
|
+
*
|
|
144
|
+
* See https://github.com/rails/rails/issues/32947
|
|
145
|
+
*/
|
|
146
|
+
buildVars?: Record<string, string | undefined>
|
|
147
|
+
}
|
|
121
148
|
};
|
|
122
149
|
|
|
123
150
|
export type BuildConfigStorybook = BuildConfigNodeBase & {
|