summaryrefslogtreecommitdiff
path: root/worker/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'worker/scripts')
-rwxr-xr-xworker/scripts/ansible_playbook22
-rwxr-xr-xworker/scripts/build_image12
-rwxr-xr-xworker/scripts/fetch_code8
-rwxr-xr-xworker/scripts/run_pipeline31
4 files changed, 35 insertions, 38 deletions
diff --git a/worker/scripts/ansible_playbook b/worker/scripts/ansible_playbook
index 062680d..d24cbb6 100755
--- a/worker/scripts/ansible_playbook
+++ b/worker/scripts/ansible_playbook
@@ -14,12 +14,12 @@ const args: AnsiblePlaybookJobProps = {
path: getRequiredEnv("path"),
playbooks: getRequiredEnv("playbooks"),
};
-const logger = loggerWithPrefix(() =>
- `[${new Date().toISOString()}] [ansible_playbook.'${args.playbooks}']`
-);
+const logger = loggerWithPrefix(() => `[ansible_playbook."${args.playbooks}"]`);
const run = async () => {
- logger.log("Starting Ansible playbook job");
+ logger.log(
+ "starting ansible playbook job~ (⑅˘꒳˘) let's configure all the things!",
+ );
const bitwardenSession = new BitwardenSession();
const secretFiles = await Promise.all(
@@ -30,7 +30,7 @@ const run = async () => {
.then(async ({ notes: recoveredSecret }) => {
const tempFile = await Deno.makeTempFile();
await Deno.writeTextFile(tempFile, recoveredSecret);
- logger.log(secretName, "stored at", tempFile);
+ logger.log(secretName, "safely tucked away at", tempFile, "(˘ω˘)");
return tempFile;
})
),
@@ -52,27 +52,31 @@ const run = async () => {
"willhallonline/ansible:latest",
...playbookCmd.split(" "),
];
- logger.log("deploying...", deployCmd);
+ logger.log("running ansible magic~ (◕ᴗ◕✿)", deployCmd);
await getStdout(deployCmd);
} finally {
await Promise.allSettled(
[bitwardenSession.close()].concat(
secretFiles.map((p) => {
- logger.log(`cleanup`, p);
+ logger.log(`tidying up`, p, "keeping things neat and tidy~");
return Deno.remove(p);
}),
),
);
}
- logger.log("ansible playbook job completed");
+ logger.log("ansible playbook job all done! servers are happy now (。•̀ᴗ-)✧");
};
if (import.meta.main) {
try {
await run();
} catch (e) {
- logger.error("womp womp D:", e);
+ logger.error(
+ "oh nyo! ansible had a problem",
+ e,
+ "maybe next time? (´。﹏。`)",
+ );
throw e;
}
}
diff --git a/worker/scripts/build_image b/worker/scripts/build_image
index 07c07c9..a4dcdf4 100755
--- a/worker/scripts/build_image
+++ b/worker/scripts/build_image
@@ -27,16 +27,16 @@ const logger = loggerWithPrefix(() =>
);
const run = async () => {
- logger.log("Starting Docker image build job");
+ logger.log("starting docker image build job~ (⑅˘꒳˘) let's make something cute!");
const bitwardenSession = new BitwardenSession();
const { username: registryUsername, password: registryPassword } =
(await bitwardenSession.getItem<LoginItem>(args.registry))?.login ?? {};
if (!(registryUsername && registryPassword)) {
- throw new Error("where's the login info bruh");
+ throw new Error("oh nyo! can't find the login info (。•́︿•̀。)");
}
- logger.log(`Logging in to Docker registry: ${args.registry}`);
+ logger.log(`logging in to docker registry: ${args.registry} (˘ω˘)`);
await getStdout(
[
"docker",
@@ -63,7 +63,7 @@ const run = async () => {
`${args.context}`,
];
- logger.log(`building`, tag, buildCmd);
+ logger.log(`building image~ (◕ᴗ◕✿)`, tag, buildCmd);
await getStdout(
buildCmd,
{
@@ -77,7 +77,7 @@ const run = async () => {
"push",
tag,
];
- logger.log(`pushing`, pushCmd);
+ logger.log(`sending image to registry~ (>ᴗ<)`, pushCmd);
await getStdout(pushCmd);
};
@@ -85,7 +85,7 @@ if (import.meta.main) {
try {
await run();
} catch (e) {
- logger.error("womp womp D:", e);
+ logger.error("oh nyo! something went wrong with the build (´。﹏。`)", e);
throw e;
}
}
diff --git a/worker/scripts/fetch_code b/worker/scripts/fetch_code
index d3af763..83a5612 100755
--- a/worker/scripts/fetch_code
+++ b/worker/scripts/fetch_code
@@ -2,18 +2,18 @@
export LOG_PREFIX="[fetch_code $remote @ $checkout -> $path]"
-log "fetch!"
+log "getting the codez~ time to fetch!"
git clone "$remote" "$path"
if [ ! $? -eq 0 ]; then
- log "D: failed to clone"
+ log "oh nyo! couldn't clone the repo"
exit 1
fi
cd "$path"
-log "checkout $checkout"
+log "switching to $checkout like a good kitty~"
git reset --hard "$checkout"
if [ ! $? -eq 0 ]; then
- log "D: can't reset to $checkout"
+ log "ouchie! can't reset to $checkout"
cd -
exit 1
fi
diff --git a/worker/scripts/run_pipeline b/worker/scripts/run_pipeline
index 9991001..abb13b3 100755
--- a/worker/scripts/run_pipeline
+++ b/worker/scripts/run_pipeline
@@ -1,11 +1,11 @@
#!/usr/bin/env -S deno run --allow-env --allow-net --allow-run --allow-read --allow-write
-import { type Job, PipelineImpl } from "@liz-ci/model";
+import { PipelineImpl } from "@liz-ci/model";
import {
getRequiredEnv,
getStdout,
+ invalidExecutionEntriesOf,
loggerWithPrefix,
- validateIdentifier,
} from "@liz-ci/utils";
const pipelinePath = getRequiredEnv("pipeline");
@@ -13,39 +13,32 @@ const logger = loggerWithPrefix(() =>
`[${new Date().toISOString()}] [run_pipeline.${pipelinePath}]`
);
-const jobValidForExecution = (job: Job) => {
- return Object
- .entries(job.arguments)
- .filter((e) => {
- if (e.every(validateIdentifier)) return true;
- logger.error(`job of type ${job.type} has invalid args ${e}`);
- return false;
- })
- .length === 0;
-};
-
const run = async () => {
- logger.log("starting pipeline execution");
+ logger.log("starting pipeline execution~ time to work hard!");
const stages = await (Deno.readTextFile(pipelinePath))
.then(PipelineImpl.from)
.then((pipeline) => pipeline.getStages());
for (const stage of stages) {
- logger.log("executing stage", stage);
+ logger.log("executing stage. do your best little stage :>", stage);
await Promise.all(
stage.parallelJobs.map(async (job, jobIdx) => {
- logger.log(`executing job ${jobIdx}`, job);
- if (!jobValidForExecution(job)) throw new Error("invalid job");
+ logger.log(`let's do this little job ok!! ${jobIdx}`, job);
+ const invalidArgs = invalidExecutionEntriesOf(job.arguments);
+ if (invalidArgs.length) {
+ logger.error(`oh nooes`, invalidArgs);
+ throw new Error("invalid job arguments");
+ }
const result = await getStdout(job.type, { env: job.arguments });
- logger.log(jobIdx, "outputs", { result });
+ logger.log(jobIdx, "brought something to you! look :D", { result });
}),
);
}
- logger.log("ok! yay!");
+ logger.log("all done! everything worked! yay~ (⑅˘꒳˘)");
};
if (import.meta.main) {