Skip to content

Commit

Permalink
Merge branch 'main' into localnet-authenticated-call
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Oct 29, 2024
2 parents 7f4ca35 + aa4a53a commit 3a4074b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/release-to-discord.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:

jobs:
github-releases-to-discord:
if: "! contains(github.event.release.tag_name, '-')"
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -13,9 +14,7 @@ jobs:
with:
webhook_url: ${{ secrets.WEBHOOK_URL }}
color: "2105893"
username: "Release Changelog"
content: "||@everyone||"
footer_title: "Changelog"
footer_timestamp: true
username: "New Release: Localnet"
max_description: "4096"
reduce_headings: true
avatar_url: "https://raw.githubusercontent.com/zeta-chain/docs/refs/heads/main/public/img/icons/zetachain/square/white-on-green.png"
1 change: 1 addition & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "./packages/tasks/src/localnet";
import "./packages/tasks/src/stop";
import "./packages/tasks/src/check";

import { HardhatUserConfig } from "hardhat/config";

Expand Down
32 changes: 32 additions & 0 deletions packages/tasks/src/check.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { task, types } from "hardhat/config";
import fs from "fs";
import ansis from "ansis";

const LOCALNET_PID_FILE = "./localnet.pid";

const localnetCheck = async (args: any) => {
await new Promise((resolve) => setTimeout(resolve, args.delay * 1000));

if (!fs.existsSync(LOCALNET_PID_FILE)) {
console.log(ansis.red("Localnet is not running (PID file missing)."));
process.exit(1);
}

const pid = fs.readFileSync(LOCALNET_PID_FILE, "utf-8").trim();

try {
process.kill(Number(pid), 0);
console.log(ansis.green(`Localnet is running (PID: ${pid}).`));
process.exit(0);
} catch (err) {
console.log(ansis.yellow(`Localnet process (PID: ${pid}) is not running.`));
process.exit(1);
}
};

export const localnetCheckTask = task(
"localnet-check",
"Check if localnet is running"
)
.addParam("delay", "Seconds to wait before checking localnet", 3, types.int)
.setAction(localnetCheck);
1 change: 1 addition & 0 deletions packages/tasks/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { localnetTask } from "./localnet";
export { localnetStopTask } from "./stop";
export { localnetCheckTask } from "./check";

0 comments on commit 3a4074b

Please sign in to comment.