Skip to content

Commit

Permalink
fix: daily test (#3815)
Browse files Browse the repository at this point in the history
Description
---
Run `git reset --hard` before `git pull` to ensure the pull succeed.

How Has This Been Tested?
---
`node cron_jobs.js`
  • Loading branch information
Cifko committed Feb 17, 2022
1 parent 7c0a4b1 commit 815ba8e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
23 changes: 18 additions & 5 deletions applications/daily_tests/cron_jobs.js
Expand Up @@ -123,6 +123,10 @@ ${logLines.join("\n")}

async function main() {
console.log("👩‍💻 Updating repo...");
await git.reset(__dirname).catch((err) => {
console.error("🚨 Failed to do git reset --hard");
console.error(err);
});
await git.pull(__dirname).catch((err) => {
console.error("🚨 Failed to update git repo");
console.error(err);
Expand All @@ -136,11 +140,20 @@ async function main() {
).start();
new CronJob("30 1 * * *", () => runBaseNodeSyncTest(SyncType.Pruned)).start();
new CronJob("0 0 * * *", () =>
git.pull(__dirname).catch((err) => {
failed("Failed to update git repo");
console.error(err);
return Promise.resolve(null);
})
git
.reset(__dirname)
.catch((err) => {
console.error("🚨 Failed to do git reset --hard");
console.error(err);
return Promise.resolve(null);
})
.then(
git.pull(__dirname).catch((err) => {
failed("Failed to update git repo");
console.error(err);
return Promise.resolve(null);
})
)
).start();

console.log("⏱ Cron jobs started.");
Expand Down
6 changes: 4 additions & 2 deletions applications/daily_tests/helpers.js
Expand Up @@ -154,10 +154,10 @@ async function monitorProcessOutput({
}

const git = {
pull(cwd = null) {
command(params, cwd = null) {
cwd = cwd || process.cwd();
return new Promise((resolve, reject) => {
let ps = spawn("git", ["pull", "--rebase"], { cwd });
let ps = spawn("git", params, { cwd });
ps.stdout.on("data", (buf) => {
console.log(buf.toString());
});
Expand All @@ -173,6 +173,8 @@ const git = {
});
});
},
reset: (cwd = null) => git.command(["reset", "--hard"], cwd),
pull: (cwd = null) => git.command(["pull", "--rebase"], cwd),
};

module.exports = {
Expand Down

0 comments on commit 815ba8e

Please sign in to comment.