@catladder/pipeline 0.0.0-next-e7541a00 → 0.0.0-next-4e7c6848
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/backends/github/GithubBackend.d.ts +12 -0
- package/dist/backends/github/GithubBackend.js +435 -0
- package/dist/backends/github/ciVariables.d.ts +14 -0
- package/dist/backends/github/ciVariables.js +31 -0
- package/dist/backends/github/createGithubJobs.d.ts +17 -0
- package/dist/backends/github/createGithubJobs.js +285 -0
- package/dist/backends/github/githubReleaseJobs.d.ts +15 -0
- package/dist/backends/github/githubReleaseJobs.js +77 -0
- package/dist/backends/github/index.d.ts +2 -0
- package/dist/backends/github/index.js +26 -0
- package/dist/backends/github/scriptFunctions.d.ts +6 -0
- package/dist/backends/github/scriptFunctions.js +61 -0
- package/dist/backends/gitlab/GitlabBackend.d.ts +1 -0
- package/dist/backends/gitlab/GitlabBackend.js +17 -0
- package/dist/backends/index.d.ts +8 -2
- package/dist/backends/index.js +26 -2
- package/dist/backends/types.d.ts +7 -3
- package/dist/bash/ciVariables.js +4 -2
- package/dist/constants.js +1 -1
- package/dist/context/getReviewSlug.js +3 -1
- package/dist/pipeline/generatePipelineFiles.d.ts +6 -1
- package/dist/pipeline/generatePipelineFiles.js +70 -9
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +20 -0
- package/dist/types/github-types.d.ts +47 -0
- package/dist/types/github-types.js +9 -0
- package/dist/types/pipeline.d.ts +4 -3
- package/examples/__snapshots__/automatic-releases.test.ts.snap +1970 -0
- package/examples/__snapshots__/cloud-run-execute-script-on-deploy.test.ts.snap +1962 -0
- package/examples/__snapshots__/cloud-run-existing-image.test.ts.snap +764 -0
- package/examples/__snapshots__/cloud-run-health-check-defaults.test.ts.snap +1946 -0
- package/examples/__snapshots__/cloud-run-health-check-only-startup.test.ts.snap +1946 -0
- package/examples/__snapshots__/cloud-run-health-check.test.ts.snap +1946 -0
- package/examples/__snapshots__/cloud-run-http2.test.ts.snap +1946 -0
- package/examples/__snapshots__/cloud-run-llama.test.ts.snap +784 -0
- package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +1946 -0
- package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +1942 -0
- package/examples/__snapshots__/cloud-run-n8n.test.ts.snap +1069 -0
- package/examples/__snapshots__/cloud-run-nextjs.test.ts.snap +1970 -0
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +1946 -0
- package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +2046 -0
- package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +1946 -0
- package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +1963 -0
- package/examples/__snapshots__/cloud-run-service-custom-vpc-connector.test.ts.snap +2010 -0
- package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +2010 -0
- package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +1946 -0
- package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +1946 -0
- package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +2014 -0
- package/examples/__snapshots__/cloud-run-session-affinity.test.ts.snap +1946 -0
- package/examples/__snapshots__/cloud-run-storybook.test.ts.snap +1564 -0
- package/examples/__snapshots__/cloud-run-with-agents.test.ts.snap +1970 -0
- package/examples/__snapshots__/cloud-run-with-gpu.test.ts.snap +1946 -0
- package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +1946 -0
- package/examples/__snapshots__/cloud-run-with-sql-legacy-jobs.test.ts.snap +2277 -0
- package/examples/__snapshots__/cloud-run-with-sql-multiple-dbs.test.ts.snap +6327 -0
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +4150 -0
- package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +2373 -0
- package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +1952 -0
- package/examples/__snapshots__/cloud-run-worker-pool.test.ts.snap +1952 -0
- package/examples/__snapshots__/custom-build-job-with-tests.test.ts.snap +1718 -0
- package/examples/__snapshots__/custom-build-job.test.ts.snap +1412 -0
- package/examples/__snapshots__/custom-deploy.test.ts.snap +1508 -0
- package/examples/__snapshots__/custom-docker-file.test.ts.snap +1978 -0
- package/examples/__snapshots__/custom-envs.test.ts.snap +1402 -0
- package/examples/__snapshots__/custom-verify-job.test.ts.snap +2250 -0
- package/examples/__snapshots__/git-submodule.test.ts.snap +1946 -0
- package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +2293 -0
- package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +2365 -0
- package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +4453 -0
- package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +2489 -0
- package/examples/__snapshots__/local-dot-env.test.ts.snap +1878 -0
- package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +2417 -0
- package/examples/__snapshots__/modify-generated-files.test.ts.snap +836 -0
- package/examples/__snapshots__/modify-generated-yaml.test.ts.snap +836 -0
- package/examples/__snapshots__/multiline-var.test.ts.snap +7289 -0
- package/examples/__snapshots__/native-app.test.ts.snap +3170 -0
- package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +1946 -0
- package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +1954 -0
- package/examples/__snapshots__/override-secrets.test.ts.snap +2000 -0
- package/examples/__snapshots__/pipelines-config.test.ts.snap +3451 -0
- package/examples/__snapshots__/rails-k8s-with-worker.test.ts.snap +1898 -0
- package/examples/__snapshots__/referencing-other-vars.test.ts.snap +6441 -0
- package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +2132 -0
- package/examples/__snapshots__/workspace-api-www-turbo-cache.test.ts.snap +3016 -0
- package/examples/__snapshots__/workspace-api-www.test.ts.snap +2996 -0
- package/examples/__utils__/helpers.ts +19 -1
- package/examples/automatic-releases.test.ts +8 -1
- package/examples/cloud-run-execute-script-on-deploy.test.ts +8 -1
- package/examples/cloud-run-existing-image.test.ts +8 -1
- package/examples/cloud-run-health-check-defaults.test.ts +8 -1
- package/examples/cloud-run-health-check-only-startup.test.ts +8 -1
- package/examples/cloud-run-health-check.test.ts +8 -1
- package/examples/cloud-run-http2.test.ts +8 -1
- package/examples/cloud-run-llama.test.ts +8 -1
- package/examples/cloud-run-memory-limit.test.ts +8 -1
- package/examples/cloud-run-meteor-with-worker.test.ts +8 -1
- package/examples/cloud-run-n8n.test.ts +8 -1
- package/examples/cloud-run-nextjs.test.ts +8 -1
- package/examples/cloud-run-no-cpu-throttling.test.ts +8 -1
- package/examples/cloud-run-no-service.test.ts +8 -1
- package/examples/cloud-run-non-public.test.ts +8 -1
- package/examples/cloud-run-post-stop-job.test.ts +8 -1
- package/examples/cloud-run-service-custom-vpc-connector.test.ts +8 -1
- package/examples/cloud-run-service-custom-vpc.test.ts +8 -1
- package/examples/cloud-run-service-gen2.test.ts +8 -1
- package/examples/cloud-run-service-increase-timout.test.ts +8 -1
- package/examples/cloud-run-service-with-volumes.test.ts +8 -1
- package/examples/cloud-run-session-affinity.test.ts +8 -1
- package/examples/cloud-run-storybook.test.ts +8 -1
- package/examples/cloud-run-with-agents.test.ts +8 -1
- package/examples/cloud-run-with-gpu.test.ts +8 -1
- package/examples/cloud-run-with-ngnix.test.ts +8 -1
- package/examples/cloud-run-with-sql-legacy-jobs.test.ts +8 -1
- package/examples/cloud-run-with-sql-multiple-dbs.test.ts +8 -1
- package/examples/cloud-run-with-sql-reuse-db.test.ts +8 -1
- package/examples/cloud-run-with-sql.test.ts +8 -1
- package/examples/cloud-run-with-worker.test.ts +8 -1
- package/examples/cloud-run-worker-pool.test.ts +8 -1
- package/examples/custom-build-job-with-tests.test.ts +8 -1
- package/examples/custom-build-job.test.ts +8 -1
- package/examples/custom-deploy.test.ts +8 -1
- package/examples/custom-docker-file.test.ts +8 -1
- package/examples/custom-envs.test.ts +8 -1
- package/examples/custom-verify-job.test.ts +8 -1
- package/examples/git-submodule.test.ts +8 -1
- package/examples/kubernetes-application-customization.test.ts +8 -1
- package/examples/kubernetes-with-cloud-sql.test.ts +8 -1
- package/examples/kubernetes-with-jobs.test.ts +8 -1
- package/examples/kubernetes-with-mongodb.test.ts +8 -1
- package/examples/local-dot-env.test.ts +8 -1
- package/examples/meteor-kubernetes.test.ts +8 -1
- package/examples/modify-generated-files.test.ts +8 -1
- package/examples/modify-generated-yaml.test.ts +8 -1
- package/examples/multiline-var.test.ts +8 -1
- package/examples/native-app.test.ts +8 -1
- package/examples/node-build-with-custom-image.test.ts +8 -1
- package/examples/node-build-with-docker-additions.test.ts +8 -1
- package/examples/override-secrets.test.ts +8 -1
- package/examples/pipelines-config.test.ts +19 -0
- package/examples/pipelines-config.ts +34 -0
- package/examples/rails-k8s-with-worker.test.ts +8 -1
- package/examples/referencing-other-vars.test.ts +8 -1
- package/examples/wait-for-other-deploy.test.ts +8 -1
- package/examples/workspace-api-www-turbo-cache.test.ts +8 -1
- package/examples/workspace-api-www.test.ts +8 -1
- package/package.json +1 -1
- package/scripts/generate-examples-test.ts +4 -1
- package/src/backends/__tests__/getEnabledPipelineTypes.test.ts +39 -0
- package/src/backends/github/GithubBackend.ts +186 -0
- package/src/backends/github/ciVariables.ts +28 -0
- package/src/backends/github/createGithubJobs.ts +328 -0
- package/src/backends/github/githubReleaseJobs.ts +56 -0
- package/src/backends/github/index.ts +2 -0
- package/src/backends/github/scriptFunctions.ts +28 -0
- package/src/backends/gitlab/GitlabBackend.ts +5 -0
- package/src/backends/index.ts +23 -1
- package/src/backends/types.ts +7 -3
- package/src/bash/ciVariables.ts +2 -0
- package/src/context/getReviewSlug.ts +4 -0
- package/src/pipeline/generatePipelineFiles.ts +24 -7
- package/src/types/config.ts +24 -0
- package/src/types/github-types.ts +43 -0
- package/src/types/pipeline.ts +8 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Config } from "../../types";
|
|
2
|
+
import type { GithubWorkflow } from "../../types/github-types";
|
|
3
|
+
import type { PipelineBackend, PipelineFile } from "../types";
|
|
4
|
+
export declare class GithubBackend implements PipelineBackend {
|
|
5
|
+
readonly type: "github";
|
|
6
|
+
cleanup(): Promise<void>;
|
|
7
|
+
createFiles(config: Config): Promise<PipelineFile[]>;
|
|
8
|
+
/**
|
|
9
|
+
* all workflows keyed by file name, mainly for testing purposes
|
|
10
|
+
*/
|
|
11
|
+
createWorkflows(config: Config): Promise<Record<string, GithubWorkflow>>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __assign = this && this.__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) {
|
|
15
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
16
|
+
resolve(value);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) {
|
|
21
|
+
try {
|
|
22
|
+
step(generator.next(value));
|
|
23
|
+
} catch (e) {
|
|
24
|
+
reject(e);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function rejected(value) {
|
|
28
|
+
try {
|
|
29
|
+
step(generator["throw"](value));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
reject(e);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function step(result) {
|
|
35
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
36
|
+
}
|
|
37
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
var __generator = this && this.__generator || function (thisArg, body) {
|
|
41
|
+
var _ = {
|
|
42
|
+
label: 0,
|
|
43
|
+
sent: function () {
|
|
44
|
+
if (t[0] & 1) throw t[1];
|
|
45
|
+
return t[1];
|
|
46
|
+
},
|
|
47
|
+
trys: [],
|
|
48
|
+
ops: []
|
|
49
|
+
},
|
|
50
|
+
f,
|
|
51
|
+
y,
|
|
52
|
+
t,
|
|
53
|
+
g;
|
|
54
|
+
return g = {
|
|
55
|
+
next: verb(0),
|
|
56
|
+
"throw": verb(1),
|
|
57
|
+
"return": verb(2)
|
|
58
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
59
|
+
return this;
|
|
60
|
+
}), g;
|
|
61
|
+
function verb(n) {
|
|
62
|
+
return function (v) {
|
|
63
|
+
return step([n, v]);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function step(op) {
|
|
67
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
68
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
69
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
70
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
71
|
+
switch (op[0]) {
|
|
72
|
+
case 0:
|
|
73
|
+
case 1:
|
|
74
|
+
t = op;
|
|
75
|
+
break;
|
|
76
|
+
case 4:
|
|
77
|
+
_.label++;
|
|
78
|
+
return {
|
|
79
|
+
value: op[1],
|
|
80
|
+
done: false
|
|
81
|
+
};
|
|
82
|
+
case 5:
|
|
83
|
+
_.label++;
|
|
84
|
+
y = op[1];
|
|
85
|
+
op = [0];
|
|
86
|
+
continue;
|
|
87
|
+
case 7:
|
|
88
|
+
op = _.ops.pop();
|
|
89
|
+
_.trys.pop();
|
|
90
|
+
continue;
|
|
91
|
+
default:
|
|
92
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
93
|
+
_ = 0;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
97
|
+
_.label = op[1];
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
101
|
+
_.label = t[1];
|
|
102
|
+
t = op;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
if (t && _.label < t[2]) {
|
|
106
|
+
_.label = t[2];
|
|
107
|
+
_.ops.push(op);
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
if (t[2]) _.ops.pop();
|
|
111
|
+
_.trys.pop();
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
op = body.call(thisArg, _);
|
|
115
|
+
} catch (e) {
|
|
116
|
+
op = [6, e];
|
|
117
|
+
y = 0;
|
|
118
|
+
} finally {
|
|
119
|
+
f = t = 0;
|
|
120
|
+
}
|
|
121
|
+
if (op[0] & 5) throw op[1];
|
|
122
|
+
return {
|
|
123
|
+
value: op[0] ? op[1] : void 0,
|
|
124
|
+
done: true
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
var __read = this && this.__read || function (o, n) {
|
|
129
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
130
|
+
if (!m) return o;
|
|
131
|
+
var i = m.call(o),
|
|
132
|
+
r,
|
|
133
|
+
ar = [],
|
|
134
|
+
e;
|
|
135
|
+
try {
|
|
136
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
e = {
|
|
139
|
+
error: error
|
|
140
|
+
};
|
|
141
|
+
} finally {
|
|
142
|
+
try {
|
|
143
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
144
|
+
} finally {
|
|
145
|
+
if (e) throw e.error;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return ar;
|
|
149
|
+
};
|
|
150
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
151
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
152
|
+
if (ar || !(i in from)) {
|
|
153
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
154
|
+
ar[i] = from[i];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
158
|
+
};
|
|
159
|
+
var __values = this && this.__values || function (o) {
|
|
160
|
+
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
161
|
+
m = s && o[s],
|
|
162
|
+
i = 0;
|
|
163
|
+
if (m) return m.call(o);
|
|
164
|
+
if (o && typeof o.length === "number") return {
|
|
165
|
+
next: function () {
|
|
166
|
+
if (o && i >= o.length) o = void 0;
|
|
167
|
+
return {
|
|
168
|
+
value: o && o[i++],
|
|
169
|
+
done: !o
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
174
|
+
};
|
|
175
|
+
Object.defineProperty(exports, "__esModule", {
|
|
176
|
+
value: true
|
|
177
|
+
});
|
|
178
|
+
exports.GithubBackend = void 0;
|
|
179
|
+
var promises_1 = require("fs/promises");
|
|
180
|
+
var path_1 = require("path");
|
|
181
|
+
var createAllJobs_1 = require("../../pipeline/createAllJobs");
|
|
182
|
+
var config_1 = require("../../types/config");
|
|
183
|
+
var ciVariables_1 = require("./ciVariables");
|
|
184
|
+
var createGithubJobs_1 = require("./createGithubJobs");
|
|
185
|
+
var githubReleaseJobs_1 = require("./githubReleaseJobs");
|
|
186
|
+
var WORKFLOWS_FOLDER = ".github/workflows";
|
|
187
|
+
/**
|
|
188
|
+
* generated workflow files are prefixed so that cleanup never touches
|
|
189
|
+
* user-maintained workflows in the same folder
|
|
190
|
+
*/
|
|
191
|
+
var GENERATED_FILE_PREFIX = "catladder-";
|
|
192
|
+
var TRIGGER_WORKFLOWS = {
|
|
193
|
+
mr: {
|
|
194
|
+
name: "catladder review",
|
|
195
|
+
on: {
|
|
196
|
+
pull_request: {
|
|
197
|
+
types: ["opened", "synchronize", "reopened"]
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
concurrency: {
|
|
201
|
+
group: "catladder-review-${{ github.event.number }}",
|
|
202
|
+
"cancel-in-progress": true
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
mainBranch: {
|
|
206
|
+
name: "catladder main",
|
|
207
|
+
// TODO: make the default branch configurable
|
|
208
|
+
on: {
|
|
209
|
+
push: {
|
|
210
|
+
branches: ["main"]
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
taggedRelease: {
|
|
215
|
+
name: "catladder release",
|
|
216
|
+
on: {
|
|
217
|
+
push: {
|
|
218
|
+
tags: ["v*"]
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
var GithubBackend = /** @class */function () {
|
|
224
|
+
function GithubBackend() {
|
|
225
|
+
this.type = "github";
|
|
226
|
+
}
|
|
227
|
+
GithubBackend.prototype.cleanup = function () {
|
|
228
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
229
|
+
var entries;
|
|
230
|
+
return __generator(this, function (_a) {
|
|
231
|
+
switch (_a.label) {
|
|
232
|
+
case 0:
|
|
233
|
+
return [4 /*yield*/, (0, promises_1.readdir)(WORKFLOWS_FOLDER).catch(function () {
|
|
234
|
+
return [];
|
|
235
|
+
})];
|
|
236
|
+
case 1:
|
|
237
|
+
entries = _a.sent();
|
|
238
|
+
return [4 /*yield*/, Promise.all(entries.filter(function (file) {
|
|
239
|
+
return file.startsWith(GENERATED_FILE_PREFIX);
|
|
240
|
+
}).map(function (file) {
|
|
241
|
+
return (0, promises_1.unlink)((0, path_1.join)(WORKFLOWS_FOLDER, file));
|
|
242
|
+
}))];
|
|
243
|
+
case 2:
|
|
244
|
+
_a.sent();
|
|
245
|
+
return [2 /*return*/];
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
GithubBackend.prototype.createFiles = function (config) {
|
|
251
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
252
|
+
var workflows;
|
|
253
|
+
return __generator(this, function (_a) {
|
|
254
|
+
switch (_a.label) {
|
|
255
|
+
case 0:
|
|
256
|
+
return [4 /*yield*/, this.createWorkflows(config)];
|
|
257
|
+
case 1:
|
|
258
|
+
workflows = _a.sent();
|
|
259
|
+
return [2 /*return*/, Object.entries(workflows).map(function (_a) {
|
|
260
|
+
var _b = __read(_a, 2),
|
|
261
|
+
fileName = _b[0],
|
|
262
|
+
workflow = _b[1];
|
|
263
|
+
return {
|
|
264
|
+
path: (0, path_1.join)(WORKFLOWS_FOLDER, fileName),
|
|
265
|
+
content: workflow
|
|
266
|
+
};
|
|
267
|
+
})];
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* all workflows keyed by file name, mainly for testing purposes
|
|
274
|
+
*/
|
|
275
|
+
GithubBackend.prototype.createWorkflows = function (config) {
|
|
276
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
277
|
+
var workflows, reviewStopJobs, manualJobs, _loop_1, this_1, ALL_PIPELINE_TRIGGERS_1, ALL_PIPELINE_TRIGGERS_1_1, trigger, e_1_1;
|
|
278
|
+
var e_1, _a;
|
|
279
|
+
return __generator(this, function (_b) {
|
|
280
|
+
switch (_b.label) {
|
|
281
|
+
case 0:
|
|
282
|
+
workflows = {};
|
|
283
|
+
reviewStopJobs = {};
|
|
284
|
+
manualJobs = {};
|
|
285
|
+
_loop_1 = function (trigger) {
|
|
286
|
+
var allJobs, uploadProviderIds, jobs, releaseJobs;
|
|
287
|
+
return __generator(this, function (_c) {
|
|
288
|
+
switch (_c.label) {
|
|
289
|
+
case 0:
|
|
290
|
+
return [4 /*yield*/, (0, createAllJobs_1.createAllJobs)({
|
|
291
|
+
config: config,
|
|
292
|
+
trigger: trigger,
|
|
293
|
+
pipelineType: this_1.type
|
|
294
|
+
})];
|
|
295
|
+
case 1:
|
|
296
|
+
allJobs = _c.sent();
|
|
297
|
+
uploadProviderIds = (0, createGithubJobs_1.getUploadProviderIds)(allJobs);
|
|
298
|
+
jobs = {};
|
|
299
|
+
// NOTE: agent jobs are gitlab-only and skipped on github
|
|
300
|
+
__spreadArray(__spreadArray([], __read(allJobs.workspaces), false), __read(allJobs.components), false).forEach(function (_a) {
|
|
301
|
+
var context = _a.context,
|
|
302
|
+
contextJobs = _a.jobs;
|
|
303
|
+
return contextJobs.forEach(function (job) {
|
|
304
|
+
var _a = __read((0, createGithubJobs_1.makeGithubJob)(context, job, allJobs, uploadProviderIds), 2),
|
|
305
|
+
id = _a[0],
|
|
306
|
+
githubJob = _a[1];
|
|
307
|
+
if (isReviewStopJob(context, job)) {
|
|
308
|
+
reviewStopJobs[id] = githubJob;
|
|
309
|
+
} else if (isManualTaskJob(job)) {
|
|
310
|
+
manualJobs[id] = githubJob;
|
|
311
|
+
} else {
|
|
312
|
+
jobs[id] = githubJob;
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
if (trigger === "mainBranch") {
|
|
317
|
+
releaseJobs = (0, githubReleaseJobs_1.getGithubReleaseJobs)(config, Object.keys(jobs));
|
|
318
|
+
Object.assign(jobs, releaseJobs.main);
|
|
319
|
+
Object.assign(manualJobs, releaseJobs.manual);
|
|
320
|
+
}
|
|
321
|
+
if (Object.keys(jobs).length > 0) {
|
|
322
|
+
workflows["".concat(GENERATED_FILE_PREFIX).concat(workflowFileName(trigger))] = __assign(__assign({}, TRIGGER_WORKFLOWS[trigger]), {
|
|
323
|
+
env: ciVariables_1.GITHUB_INJECTED_WORKFLOW_ENV,
|
|
324
|
+
jobs: jobs
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
return [2 /*return*/];
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
this_1 = this;
|
|
332
|
+
_b.label = 1;
|
|
333
|
+
case 1:
|
|
334
|
+
_b.trys.push([1, 6, 7, 8]);
|
|
335
|
+
ALL_PIPELINE_TRIGGERS_1 = __values(config_1.ALL_PIPELINE_TRIGGERS), ALL_PIPELINE_TRIGGERS_1_1 = ALL_PIPELINE_TRIGGERS_1.next();
|
|
336
|
+
_b.label = 2;
|
|
337
|
+
case 2:
|
|
338
|
+
if (!!ALL_PIPELINE_TRIGGERS_1_1.done) return [3 /*break*/, 5];
|
|
339
|
+
trigger = ALL_PIPELINE_TRIGGERS_1_1.value;
|
|
340
|
+
return [5 /*yield**/, _loop_1(trigger)];
|
|
341
|
+
case 3:
|
|
342
|
+
_b.sent();
|
|
343
|
+
_b.label = 4;
|
|
344
|
+
case 4:
|
|
345
|
+
ALL_PIPELINE_TRIGGERS_1_1 = ALL_PIPELINE_TRIGGERS_1.next();
|
|
346
|
+
return [3 /*break*/, 2];
|
|
347
|
+
case 5:
|
|
348
|
+
return [3 /*break*/, 8];
|
|
349
|
+
case 6:
|
|
350
|
+
e_1_1 = _b.sent();
|
|
351
|
+
e_1 = {
|
|
352
|
+
error: e_1_1
|
|
353
|
+
};
|
|
354
|
+
return [3 /*break*/, 8];
|
|
355
|
+
case 7:
|
|
356
|
+
try {
|
|
357
|
+
if (ALL_PIPELINE_TRIGGERS_1_1 && !ALL_PIPELINE_TRIGGERS_1_1.done && (_a = ALL_PIPELINE_TRIGGERS_1.return)) _a.call(ALL_PIPELINE_TRIGGERS_1);
|
|
358
|
+
} finally {
|
|
359
|
+
if (e_1) throw e_1.error;
|
|
360
|
+
}
|
|
361
|
+
return [7 /*endfinally*/];
|
|
362
|
+
case 8:
|
|
363
|
+
if (Object.keys(reviewStopJobs).length > 0) {
|
|
364
|
+
workflows["".concat(GENERATED_FILE_PREFIX, "review-stop.yml")] = {
|
|
365
|
+
name: "catladder review stop",
|
|
366
|
+
on: {
|
|
367
|
+
pull_request: {
|
|
368
|
+
types: ["closed"]
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
env: ciVariables_1.GITHUB_INJECTED_WORKFLOW_ENV,
|
|
372
|
+
jobs: reviewStopJobs
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
if (Object.keys(manualJobs).length > 0) {
|
|
376
|
+
workflows["".concat(GENERATED_FILE_PREFIX, "manual.yml")] = {
|
|
377
|
+
name: "catladder manual tasks",
|
|
378
|
+
on: {
|
|
379
|
+
workflow_dispatch: {
|
|
380
|
+
inputs: {
|
|
381
|
+
job: {
|
|
382
|
+
description: "the task to run",
|
|
383
|
+
required: true,
|
|
384
|
+
type: "choice",
|
|
385
|
+
options: Object.keys(manualJobs)
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
env: ciVariables_1.GITHUB_INJECTED_WORKFLOW_ENV,
|
|
391
|
+
jobs: Object.fromEntries(Object.entries(manualJobs).map(function (_a) {
|
|
392
|
+
var _b = __read(_a, 2),
|
|
393
|
+
id = _b[0],
|
|
394
|
+
job = _b[1];
|
|
395
|
+
return [id, __assign(__assign({}, job), {
|
|
396
|
+
if: "${{ inputs.job == '".concat(id, "' }}")
|
|
397
|
+
})];
|
|
398
|
+
}))
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
return [2 /*return*/, workflows];
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
};
|
|
406
|
+
return GithubBackend;
|
|
407
|
+
}();
|
|
408
|
+
exports.GithubBackend = GithubBackend;
|
|
409
|
+
var workflowFileName = function (trigger) {
|
|
410
|
+
switch (trigger) {
|
|
411
|
+
case "mr":
|
|
412
|
+
return "review.yml";
|
|
413
|
+
case "mainBranch":
|
|
414
|
+
return "main.yml";
|
|
415
|
+
case "taggedRelease":
|
|
416
|
+
return "release.yml";
|
|
417
|
+
}
|
|
418
|
+
throw new Error("".concat(trigger, " is not supported"));
|
|
419
|
+
};
|
|
420
|
+
/**
|
|
421
|
+
* stop jobs of review environments run in their own workflow when the
|
|
422
|
+
* pull request is closed (the counterpart of gitlab's on_stop wiring)
|
|
423
|
+
*/
|
|
424
|
+
var isReviewStopJob = function (context, job) {
|
|
425
|
+
var _a;
|
|
426
|
+
return ((_a = job.environment) === null || _a === void 0 ? void 0 : _a.action) === "stop" && context.type === "component" && context.environment.envType === "review";
|
|
427
|
+
};
|
|
428
|
+
/**
|
|
429
|
+
* stop/rollback jobs of non-review environments have no automatic
|
|
430
|
+
* trigger; they are collected in a workflow_dispatch workflow
|
|
431
|
+
* (gitlab runs them as manual jobs inside the pipeline)
|
|
432
|
+
*/
|
|
433
|
+
var isManualTaskJob = function (job) {
|
|
434
|
+
return job.stage === "stop" || job.stage === "rollback";
|
|
435
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CiVariableName } from "../../bash/ciVariables";
|
|
2
|
+
/**
|
|
3
|
+
* how the github backend names the predefined CI variables.
|
|
4
|
+
*
|
|
5
|
+
* GITHUB_* variables are provided by github actions natively; the CL_*
|
|
6
|
+
* variables are injected by the {@link GithubBackend} itself (workflow or
|
|
7
|
+
* job level), because github has no direct counterpart.
|
|
8
|
+
*/
|
|
9
|
+
export declare const GITHUB_CI_VARIABLES: Record<CiVariableName, string>;
|
|
10
|
+
/**
|
|
11
|
+
* the workflow-level env the backend injects to provide the CL_*
|
|
12
|
+
* variables referenced by {@link GITHUB_CI_VARIABLES}
|
|
13
|
+
*/
|
|
14
|
+
export declare const GITHUB_INJECTED_WORKFLOW_ENV: Record<string, string>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GITHUB_INJECTED_WORKFLOW_ENV = exports.GITHUB_CI_VARIABLES = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* how the github backend names the predefined CI variables.
|
|
9
|
+
*
|
|
10
|
+
* GITHUB_* variables are provided by github actions natively; the CL_*
|
|
11
|
+
* variables are injected by the {@link GithubBackend} itself (workflow or
|
|
12
|
+
* job level), because github has no direct counterpart.
|
|
13
|
+
*/
|
|
14
|
+
exports.GITHUB_CI_VARIABLES = {
|
|
15
|
+
commitSha: "GITHUB_SHA",
|
|
16
|
+
jobToken: "CL_JOB_TOKEN",
|
|
17
|
+
jobImage: "CL_JOB_IMAGE",
|
|
18
|
+
registry: "CL_REGISTRY",
|
|
19
|
+
registryImage: "CL_REGISTRY_IMAGE"
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* the workflow-level env the backend injects to provide the CL_*
|
|
23
|
+
* variables referenced by {@link GITHUB_CI_VARIABLES}
|
|
24
|
+
*/
|
|
25
|
+
exports.GITHUB_INJECTED_WORKFLOW_ENV = {
|
|
26
|
+
CL_JOB_TOKEN: "${{ github.token }}",
|
|
27
|
+
CL_REGISTRY: "ghcr.io",
|
|
28
|
+
CL_REGISTRY_IMAGE: "ghcr.io/${{ github.repository }}",
|
|
29
|
+
// empty outside of pull request events
|
|
30
|
+
CL_PR_NUMBER: "${{ github.event.number }}"
|
|
31
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AllCatladderJobs } from "../../pipeline/createAllJobs";
|
|
2
|
+
import type { Context } from "../../types";
|
|
3
|
+
import type { GithubJob } from "../../types/github-types";
|
|
4
|
+
import type { CatladderJob } from "../../types/jobs";
|
|
5
|
+
export declare const githubJobId: (context: Context, jobName: string) => string;
|
|
6
|
+
type ResolvedNeed = {
|
|
7
|
+
id: string;
|
|
8
|
+
artifacts: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const resolveGithubNeeds: (context: Context, job: CatladderJob, allJobs: AllCatladderJobs) => ResolvedNeed[];
|
|
11
|
+
export declare const makeGithubJob: (context: Context, job: CatladderJob, allJobs: AllCatladderJobs, uploadProviderIds: Set<string>) => [id: string, githubJob: GithubJob];
|
|
12
|
+
/**
|
|
13
|
+
* the ids of all jobs whose artifacts are consumed by other jobs
|
|
14
|
+
* (they need an upload step)
|
|
15
|
+
*/
|
|
16
|
+
export declare const getUploadProviderIds: (allJobs: AllCatladderJobs) => Set<string>;
|
|
17
|
+
export {};
|