From 37483c9f259a2b3c837507c1c3c62cbf2773ac3f Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Fri, 29 Mar 2024 01:26:36 +0900 Subject: [PATCH] ci: Generate workflow (#45) --- .github/workflows/generate.yaml | 36 +++++++++++++++++++++++++++++++++ networks.schema.json | 18 +++++++++++++---- package.json | 4 ++-- src/types.ts | 3 +-- 4 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/generate.yaml diff --git a/.github/workflows/generate.yaml b/.github/workflows/generate.yaml new file mode 100644 index 0000000..07ff30d --- /dev/null +++ b/.github/workflows/generate.yaml @@ -0,0 +1,36 @@ +name: Generated Files are Updated +on: + pull_request: + branches: + - "*" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Node.js environment + uses: actions/setup-node@v2 + with: + node-version: "16" + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y jq unzip + yarn install + + - name: Generate Files + run: | + yarn generate + + - name: Check for changes + run: | + if git diff --exit-code --ignore-space-change --ignore-all-space --ignore-cr-at-eol -- pkg src; then + echo "Generated files are up-to-date." + else + echo "::error::Generated files are not up-to-date. Please run 'yarn generate' locally and commit any changes." + exit 1 + fi diff --git a/networks.schema.json b/networks.schema.json index 1b1a2d6..5d6fa43 100644 --- a/networks.schema.json +++ b/networks.schema.json @@ -29,7 +29,8 @@ "required": [ "url", "type" - ] + ], + "additionalProperties": false } }, "patternProperties": { @@ -43,7 +44,14 @@ "type": "string" }, "bech32_prefix": { - "type": "string" + "type": "string", + "nullable": true + }, + "chain_aliases": { + "type": "array", + "items": { + "type": "string" + } }, "fees": { "type": "object", @@ -141,7 +149,8 @@ "denom": { "type": "string" } - } + }, + "nullable": true }, "api": { "type": "array", @@ -153,7 +162,8 @@ "required": [ "chain_id", "chain_name" - ] + ], + "additionalProperties": false } } } \ No newline at end of file diff --git a/package.json b/package.json index 889f190..c301798 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,11 @@ "scripts": { "output": "npx ts-node scripts/output.ts", "validate": "npx ts-node scripts/validate.ts", - "build": "rm -rf dist && yarn generate:types && tsc", + "build": "rm -rf dist && yarn generate && tsc", "lint:fix": "npx eslint . --ext .js,.ts --fix", "lint": "npx eslint . --ext .js,.ts", "prepublishOnly": "npm run build", - "generate:types": "npx json-schema-to-typescript networks.schema.json > src/types.ts" + "generate": "npx json-schema-to-typescript networks.schema.json > src/types.ts" }, "keywords": [], "author": "", diff --git a/src/types.ts b/src/types.ts index aeb32c1..61c8727 100644 --- a/src/types.ts +++ b/src/types.ts @@ -25,6 +25,7 @@ export interface NetworksSchema { chain_id: number; chain_name: string; bech32_prefix?: string; + chain_aliases?: string[]; fees?: { assets?: { denom: string; @@ -56,11 +57,9 @@ export interface NetworksSchema { [k: string]: unknown; }; api?: Api[]; - [k: string]: unknown; }; } export interface Api { url: string; type: ApiType; - [k: string]: unknown; }