Skip to content

Commit

Permalink
chore(ci): enable typegen_check (#3145)
Browse files Browse the repository at this point in the history
* add cron workflow for updating rust/typescript bindings

* install pnpm

* make binary executable

* finalize changes
  • Loading branch information
RomarQ authored Jan 22, 2025
1 parent 8545c94 commit 1a0c3d4
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 4 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/update-typescript-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Update Rust/TS bindings

on:
workflow_dispatch:
schedule:
- cron: "0 5 * * *" # Runs every day at 5:00 AM UTC

jobs:
build:
runs-on:
labels: bare-metal
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Local build new Node
uses: ./.github/workflow-templates/cargo-build
- name: Upload Node
uses: actions/upload-artifact@v4
with:
name: moonbeam
path: build

update-typescript-api:
needs: build
runs-on: moonbeam-release-medium
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Node
uses: actions/download-artifact@v4
with:
name: moonbeam
path: target/release
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: "test/.nvmrc"
cache: pnpm
registry-url: https://registry.npmjs.org/
- name: Run Typegen
run: |
chmod uog+x target/release/moonbeam
pnpm i
cd test
pnpm typegen
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
base: master
branch: "update-typescript-api-${{ github.run_id }}"
commit-message: "Update Rust/TS bindings"
draft: true
title: "Update Rust/TS bindings"
reviewers: "moonsong-coredev"
labels: "B0-silent,D2-notlive"
8 changes: 4 additions & 4 deletions typescript-api/scripts/scrapeMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const CHAINS = ["moonbase", "moonriver", "moonbeam"];
const fetchMetadata = async (port = 9933) => {
const maxRetries = 60;
const sleepTime = 500;
const url = `http://localhost:${port}`;
const url = `http://127.0.0.1:${port}`;
const payload = {
id: "1",
jsonrpc: "2.0",
Expand Down Expand Up @@ -75,7 +75,7 @@ async function main() {
const metadata = await fetchMetadata();
fs.writeFileSync(`metadata-${chain}.json`, JSON.stringify(metadata, null, 2));
console.log(`✅ Metadata for ${chain} written to metadata-${chain}.json`);
nodes[chain].kill();
nodes[chain]?.kill();
await new Promise((resolve) => setTimeout(resolve, 2000));
} catch (error) {
console.error(`❌ Error getting metadata for ${chain}`);
Expand All @@ -86,7 +86,7 @@ async function main() {

process.on("SIGINT", () => {
for (const chain of CHAINS) {
nodes[chain].kill();
nodes[chain]?.kill();
}
process.exit();
});
Expand All @@ -98,6 +98,6 @@ main()
})
.finally(() => {
for (const chain of CHAINS) {
nodes[chain].kill();
nodes[chain]?.kill();
}
});

0 comments on commit 1a0c3d4

Please sign in to comment.