'$npm_config_message'
parent
b9cf74b2e6
commit
6a4d3365e4
|
|
@ -1263,6 +1263,7 @@ const base64 = __webpack_require__(85848);
|
||||||
class Kubernetes {
|
class Kubernetes {
|
||||||
constructor(buildParameters, baseImage) {
|
constructor(buildParameters, baseImage) {
|
||||||
this.buildId = '';
|
this.buildId = '';
|
||||||
|
this.buildCorrelationId = '';
|
||||||
this.pvcName = '';
|
this.pvcName = '';
|
||||||
this.secretName = '';
|
this.secretName = '';
|
||||||
this.jobName = '';
|
this.jobName = '';
|
||||||
|
|
@ -1276,10 +1277,10 @@ class Kubernetes {
|
||||||
this.kubeConfig = kc;
|
this.kubeConfig = kc;
|
||||||
this.kubeClient = k8sApi;
|
this.kubeClient = k8sApi;
|
||||||
this.kubeClientBatch = k8sBatchApi;
|
this.kubeClientBatch = k8sBatchApi;
|
||||||
|
this.buildCorrelationId = Kubernetes.uuidv4();
|
||||||
this.namespace = 'default';
|
this.namespace = 'default';
|
||||||
this.buildParameters = buildParameters;
|
this.buildParameters = buildParameters;
|
||||||
this.baseImage = baseImage;
|
this.baseImage = baseImage;
|
||||||
this.setUniqueBuildId();
|
|
||||||
}
|
}
|
||||||
runBuild(buildId, stackName, image, commands, mountdir, workingdir, environment, secrets) {
|
runBuild(buildId, stackName, image, commands, mountdir, workingdir, environment, secrets) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
|
@ -1316,7 +1317,7 @@ class Kubernetes {
|
||||||
yield this.createSecret(defaultSecretsArray);
|
yield this.createSecret(defaultSecretsArray);
|
||||||
yield kubernetes_storage_1.default.createPersistentVolumeClaim(this.buildParameters, this.pvcName, this.kubeClient, this.namespace);
|
yield kubernetes_storage_1.default.createPersistentVolumeClaim(this.buildParameters, this.pvcName, this.kubeClient, this.namespace);
|
||||||
// run
|
// run
|
||||||
yield this.runJob(commands, image);
|
yield this.runJobInKubernetesPod(commands, image);
|
||||||
yield this.cleanup();
|
yield this.cleanup();
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|
@ -1338,41 +1339,9 @@ class Kubernetes {
|
||||||
run() {
|
run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info('Running Remote Builder on Kubernetes');
|
core.info('Running Remote Builder on Kubernetes');
|
||||||
const defaultSecretsArray = [
|
|
||||||
{
|
|
||||||
ParameterKey: 'GithubToken',
|
|
||||||
EnvironmentVariable: 'GITHUB_TOKEN',
|
|
||||||
ParameterValue: this.buildParameters.githubToken,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ParameterKey: 'UNITY_LICENSE',
|
|
||||||
EnvironmentVariable: 'UNITY_LICENSE',
|
|
||||||
ParameterValue: process.env.UNITY_LICENSE || '',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ParameterKey: 'ANDROID_KEYSTORE_BASE64',
|
|
||||||
EnvironmentVariable: 'ANDROID_KEYSTORE_BASE64',
|
|
||||||
ParameterValue: this.buildParameters.androidKeystoreBase64,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ParameterKey: 'ANDROID_KEYSTORE_PASS',
|
|
||||||
EnvironmentVariable: 'ANDROID_KEYSTORE_PASS',
|
|
||||||
ParameterValue: this.buildParameters.androidKeystorePass,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ParameterKey: 'ANDROID_KEYALIAS_PASS',
|
|
||||||
EnvironmentVariable: 'ANDROID_KEYALIAS_PASS',
|
|
||||||
ParameterValue: this.buildParameters.androidKeyaliasPass,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
try {
|
try {
|
||||||
// setup
|
|
||||||
yield this.createSecret(defaultSecretsArray);
|
|
||||||
yield kubernetes_storage_1.default.createPersistentVolumeClaim(this.buildParameters, this.pvcName, this.kubeClient, this.namespace);
|
|
||||||
// run
|
|
||||||
yield this.runCloneJob();
|
yield this.runCloneJob();
|
||||||
yield this.runBuildJob();
|
yield this.runBuildJob();
|
||||||
yield this.cleanup();
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.error(error);
|
core.error(error);
|
||||||
|
|
@ -1529,10 +1498,41 @@ class Kubernetes {
|
||||||
job.spec.backoffLimit = 1;
|
job.spec.backoffLimit = 1;
|
||||||
return job;
|
return job;
|
||||||
}
|
}
|
||||||
runJob(command, image) {
|
runJobInKubernetesPod(command, image) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
this.setUniqueBuildId();
|
this.setUniqueBuildId();
|
||||||
|
const defaultSecretsArray = [
|
||||||
|
{
|
||||||
|
ParameterKey: 'GithubToken',
|
||||||
|
EnvironmentVariable: 'GITHUB_TOKEN',
|
||||||
|
ParameterValue: this.buildParameters.githubToken,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ParameterKey: 'UNITY_LICENSE',
|
||||||
|
EnvironmentVariable: 'UNITY_LICENSE',
|
||||||
|
ParameterValue: process.env.UNITY_LICENSE || '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ParameterKey: 'ANDROID_KEYSTORE_BASE64',
|
||||||
|
EnvironmentVariable: 'ANDROID_KEYSTORE_BASE64',
|
||||||
|
ParameterValue: this.buildParameters.androidKeystoreBase64,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ParameterKey: 'ANDROID_KEYSTORE_PASS',
|
||||||
|
EnvironmentVariable: 'ANDROID_KEYSTORE_PASS',
|
||||||
|
ParameterValue: this.buildParameters.androidKeystorePass,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ParameterKey: 'ANDROID_KEYALIAS_PASS',
|
||||||
|
EnvironmentVariable: 'ANDROID_KEYALIAS_PASS',
|
||||||
|
ParameterValue: this.buildParameters.androidKeyaliasPass,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
// setup
|
||||||
|
yield this.createSecret(defaultSecretsArray);
|
||||||
|
yield kubernetes_storage_1.default.createPersistentVolumeClaim(this.buildParameters, this.pvcName, this.kubeClient, this.namespace);
|
||||||
|
//run
|
||||||
const jobSpec = this.getJobSpec(command, image);
|
const jobSpec = this.getJobSpec(command, image);
|
||||||
core.info('Creating build job');
|
core.info('Creating build job');
|
||||||
yield this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
|
yield this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
|
||||||
|
|
@ -1540,8 +1540,9 @@ class Kubernetes {
|
||||||
yield kubernetes_storage_1.default.watchUntilPVCNotPending(this.kubeClient, this.pvcName, this.namespace);
|
yield kubernetes_storage_1.default.watchUntilPVCNotPending(this.kubeClient, this.pvcName, this.namespace);
|
||||||
core.info('PVC Bound');
|
core.info('PVC Bound');
|
||||||
this.setPodNameAndContainerName(yield this.getPod());
|
this.setPodNameAndContainerName(yield this.getPod());
|
||||||
core.info('Watching pod and streaming logs');
|
core.info('Watching pod until running');
|
||||||
yield this.watchUntilPodRunning();
|
yield this.watchUntilPodRunning();
|
||||||
|
core.info('Pod running, streaming logs');
|
||||||
yield this.streamLogs();
|
yield this.streamLogs();
|
||||||
yield this.cleanup();
|
yield this.cleanup();
|
||||||
}
|
}
|
||||||
|
|
@ -1568,7 +1569,7 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
runCloneJob() {
|
runCloneJob() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
yield this.runJob([
|
yield this.runJobInKubernetesPod([
|
||||||
'/bin/ash',
|
'/bin/ash',
|
||||||
'-c',
|
'-c',
|
||||||
`apk update;
|
`apk update;
|
||||||
|
|
@ -1587,7 +1588,7 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
runBuildJob() {
|
runBuildJob() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
yield this.runJob([
|
yield this.runJobInKubernetesPod([
|
||||||
'bin/bash',
|
'bin/bash',
|
||||||
'-c',
|
'-c',
|
||||||
`ls
|
`ls
|
||||||
|
|
@ -1615,7 +1616,7 @@ class Kubernetes {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
yield async_wait_until_1.waitUntil(() => __awaiter(this, void 0, void 0, function* () {
|
yield async_wait_until_1.waitUntil(() => __awaiter(this, void 0, void 0, function* () {
|
||||||
(yield this.getPodStatusPhase()) !== 'Pending';
|
(yield this.getPodStatusPhase()) !== 'Pending';
|
||||||
}));
|
}), 500000);
|
||||||
const phase = yield this.getPodStatusPhase();
|
const phase = yield this.getPodStatusPhase();
|
||||||
if (phase === 'Running') {
|
if (phase === 'Running') {
|
||||||
core.info('Pod no longer pending');
|
core.info('Pod no longer pending');
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -11,7 +11,9 @@
|
||||||
"build": "tsc && ncc build lib --source-map --license licenses.txt",
|
"build": "tsc && ncc build lib --source-map --license licenses.txt",
|
||||||
"lint": "prettier --check \"src/**/*.{js,ts}\" && eslint src/**/*.ts",
|
"lint": "prettier --check \"src/**/*.{js,ts}\" && eslint src/**/*.ts",
|
||||||
"format": "prettier --write \"src/**/*.{js,ts}\"",
|
"format": "prettier --write \"src/**/*.{js,ts}\"",
|
||||||
"test": "jest"
|
"test": "jest",
|
||||||
|
"commit": "yarn build && git add . && git commit -m '$npm_config_message' -q",
|
||||||
|
"push": "yarn build && git add . && git commit -m '$npm_config_message' -q && git push"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
private kubeClient: k8s.CoreV1Api;
|
private kubeClient: k8s.CoreV1Api;
|
||||||
private kubeClientBatch: k8s.BatchV1Api;
|
private kubeClientBatch: k8s.BatchV1Api;
|
||||||
private buildId: string = '';
|
private buildId: string = '';
|
||||||
|
private buildCorrelationId: string = '';
|
||||||
private buildParameters: BuildParameters;
|
private buildParameters: BuildParameters;
|
||||||
private baseImage: any;
|
private baseImage: any;
|
||||||
private pvcName: string = '';
|
private pvcName: string = '';
|
||||||
|
|
@ -36,11 +37,11 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
this.kubeClient = k8sApi;
|
this.kubeClient = k8sApi;
|
||||||
this.kubeClientBatch = k8sBatchApi;
|
this.kubeClientBatch = k8sBatchApi;
|
||||||
|
|
||||||
|
this.buildCorrelationId = Kubernetes.uuidv4();
|
||||||
|
|
||||||
this.namespace = 'default';
|
this.namespace = 'default';
|
||||||
this.buildParameters = buildParameters;
|
this.buildParameters = buildParameters;
|
||||||
this.baseImage = baseImage;
|
this.baseImage = baseImage;
|
||||||
|
|
||||||
this.setUniqueBuildId();
|
|
||||||
}
|
}
|
||||||
async runBuild(
|
async runBuild(
|
||||||
buildId: string,
|
buildId: string,
|
||||||
|
|
@ -91,7 +92,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
);
|
);
|
||||||
|
|
||||||
// run
|
// run
|
||||||
await this.runJob(commands, image);
|
await this.runJobInKubernetesPod(commands, image);
|
||||||
|
|
||||||
await this.cleanup();
|
await this.cleanup();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -114,48 +115,9 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
|
|
||||||
async run() {
|
async run() {
|
||||||
core.info('Running Remote Builder on Kubernetes');
|
core.info('Running Remote Builder on Kubernetes');
|
||||||
const defaultSecretsArray: RemoteBuilderSecret[] = [
|
|
||||||
{
|
|
||||||
ParameterKey: 'GithubToken',
|
|
||||||
EnvironmentVariable: 'GITHUB_TOKEN',
|
|
||||||
ParameterValue: this.buildParameters.githubToken,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ParameterKey: 'UNITY_LICENSE',
|
|
||||||
EnvironmentVariable: 'UNITY_LICENSE',
|
|
||||||
ParameterValue: process.env.UNITY_LICENSE || '',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ParameterKey: 'ANDROID_KEYSTORE_BASE64',
|
|
||||||
EnvironmentVariable: 'ANDROID_KEYSTORE_BASE64',
|
|
||||||
ParameterValue: this.buildParameters.androidKeystoreBase64,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ParameterKey: 'ANDROID_KEYSTORE_PASS',
|
|
||||||
EnvironmentVariable: 'ANDROID_KEYSTORE_PASS',
|
|
||||||
ParameterValue: this.buildParameters.androidKeystorePass,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ParameterKey: 'ANDROID_KEYALIAS_PASS',
|
|
||||||
EnvironmentVariable: 'ANDROID_KEYALIAS_PASS',
|
|
||||||
ParameterValue: this.buildParameters.androidKeyaliasPass,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
try {
|
try {
|
||||||
// setup
|
|
||||||
await this.createSecret(defaultSecretsArray);
|
|
||||||
await KubernetesStorage.createPersistentVolumeClaim(
|
|
||||||
this.buildParameters,
|
|
||||||
this.pvcName,
|
|
||||||
this.kubeClient,
|
|
||||||
this.namespace,
|
|
||||||
);
|
|
||||||
|
|
||||||
// run
|
|
||||||
await this.runCloneJob();
|
await this.runCloneJob();
|
||||||
await this.runBuildJob();
|
await this.runBuildJob();
|
||||||
|
|
||||||
await this.cleanup();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.error(error);
|
core.error(error);
|
||||||
core.error(JSON.stringify(error.response, undefined, 4));
|
core.error(JSON.stringify(error.response, undefined, 4));
|
||||||
|
|
@ -311,9 +273,47 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
return job;
|
return job;
|
||||||
}
|
}
|
||||||
|
|
||||||
async runJob(command: string[], image: string) {
|
async runJobInKubernetesPod(command: string[], image: string) {
|
||||||
try {
|
try {
|
||||||
this.setUniqueBuildId();
|
this.setUniqueBuildId();
|
||||||
|
const defaultSecretsArray: RemoteBuilderSecret[] = [
|
||||||
|
{
|
||||||
|
ParameterKey: 'GithubToken',
|
||||||
|
EnvironmentVariable: 'GITHUB_TOKEN',
|
||||||
|
ParameterValue: this.buildParameters.githubToken,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ParameterKey: 'UNITY_LICENSE',
|
||||||
|
EnvironmentVariable: 'UNITY_LICENSE',
|
||||||
|
ParameterValue: process.env.UNITY_LICENSE || '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ParameterKey: 'ANDROID_KEYSTORE_BASE64',
|
||||||
|
EnvironmentVariable: 'ANDROID_KEYSTORE_BASE64',
|
||||||
|
ParameterValue: this.buildParameters.androidKeystoreBase64,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ParameterKey: 'ANDROID_KEYSTORE_PASS',
|
||||||
|
EnvironmentVariable: 'ANDROID_KEYSTORE_PASS',
|
||||||
|
ParameterValue: this.buildParameters.androidKeystorePass,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ParameterKey: 'ANDROID_KEYALIAS_PASS',
|
||||||
|
EnvironmentVariable: 'ANDROID_KEYALIAS_PASS',
|
||||||
|
ParameterValue: this.buildParameters.androidKeyaliasPass,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// setup
|
||||||
|
await this.createSecret(defaultSecretsArray);
|
||||||
|
await KubernetesStorage.createPersistentVolumeClaim(
|
||||||
|
this.buildParameters,
|
||||||
|
this.pvcName,
|
||||||
|
this.kubeClient,
|
||||||
|
this.namespace,
|
||||||
|
);
|
||||||
|
|
||||||
|
//run
|
||||||
const jobSpec = this.getJobSpec(command, image);
|
const jobSpec = this.getJobSpec(command, image);
|
||||||
core.info('Creating build job');
|
core.info('Creating build job');
|
||||||
await this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
|
await this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
|
||||||
|
|
@ -321,8 +321,9 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
await KubernetesStorage.watchUntilPVCNotPending(this.kubeClient, this.pvcName, this.namespace);
|
await KubernetesStorage.watchUntilPVCNotPending(this.kubeClient, this.pvcName, this.namespace);
|
||||||
core.info('PVC Bound');
|
core.info('PVC Bound');
|
||||||
this.setPodNameAndContainerName(await this.getPod());
|
this.setPodNameAndContainerName(await this.getPod());
|
||||||
core.info('Watching pod and streaming logs');
|
core.info('Watching pod until running');
|
||||||
await this.watchUntilPodRunning();
|
await this.watchUntilPodRunning();
|
||||||
|
core.info('Pod running, streaming logs');
|
||||||
await this.streamLogs();
|
await this.streamLogs();
|
||||||
await this.cleanup();
|
await this.cleanup();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -347,7 +348,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
async runCloneJob() {
|
async runCloneJob() {
|
||||||
await this.runJob(
|
await this.runJobInKubernetesPod(
|
||||||
[
|
[
|
||||||
'/bin/ash',
|
'/bin/ash',
|
||||||
'-c',
|
'-c',
|
||||||
|
|
@ -368,7 +369,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
async runBuildJob() {
|
async runBuildJob() {
|
||||||
await this.runJob(
|
await this.runJobInKubernetesPod(
|
||||||
[
|
[
|
||||||
'bin/bash',
|
'bin/bash',
|
||||||
'-c',
|
'-c',
|
||||||
|
|
@ -396,7 +397,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
async watchUntilPodRunning() {
|
async watchUntilPodRunning() {
|
||||||
await waitUntil(async () => {
|
await waitUntil(async () => {
|
||||||
(await this.getPodStatusPhase()) !== 'Pending';
|
(await this.getPodStatusPhase()) !== 'Pending';
|
||||||
});
|
}, 500000);
|
||||||
const phase = await this.getPodStatusPhase();
|
const phase = await this.getPodStatusPhase();
|
||||||
if (phase === 'Running') {
|
if (phase === 'Running') {
|
||||||
core.info('Pod no longer pending');
|
core.info('Pod no longer pending');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue