From 536209fcbd2b8a7afe3b9525b3dc38dda570fe92 Mon Sep 17 00:00:00 2001 From: shannonwells Date: Thu, 15 Aug 2024 11:04:56 -0700 Subject: [PATCH 1/4] Generate types.json, include with augment-api and release artifacts. --- .github/workflows/release.yml | 9 ++++++++- js/api-augment/package.json | 3 ++- js/api-augment/scripts/generate.mjs | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 js/api-augment/scripts/generate.mjs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 20a2209e36..f76296d063 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -411,7 +411,8 @@ jobs: - name: Output Metadata run: ${{env.BIN_DIR}}/${{env.RELEASE_BIN_FILENAME}} export-metadata --chain=frequency-paseo-local --tmp ./js/api-augment/metadata.json - name: Build - run: npm run build + run: | + npm run build working-directory: js/api-augment - name: Upload Dist Dir uses: actions/upload-artifact@v4 @@ -718,6 +719,12 @@ jobs: pattern: artifacts-*-${{github.run_id}} path: /tmp merge-multiple: true + - name: Download api-augment artifacts + id: download-js + uses: actions/download-artifact@v4 + with: + name: js-api-augment-${{github.run_id}}/js/api-augment/json + path: /tmp/polkadot-api-types-json - name: List Downloaded Artifacts working-directory: /tmp run: | diff --git a/js/api-augment/package.json b/js/api-augment/package.json index 4571042f70..c198371dd1 100644 --- a/js/api-augment/package.json +++ b/js/api-augment/package.json @@ -21,7 +21,8 @@ "prepackage": "cp CONTRIBUTING.md README.md ../../LICENSE ./dist", "prebuild": "npm run generate", "build": "tsc -p ./tsconfig.types.json && tsc -p ./tsconfig.cjs.json && tsc -p ./tsconfig.esm.json", - "postbuild": "npm run package", + "build:types-json": "node scripts/generate.mjs", + "postbuild": "npm run package && npm run build:types-json", "fetch:local": "curl -H \"Content-Type: application/json\" -d '{\"id\":\"1\", \"jsonrpc\":\"2.0\", \"method\": \"state_getMetadata\", \"params\":[]}' http://localhost:9944 -o ./metadata.json", "generate:defs": "node --import=tsx/esm node_modules/.bin/polkadot-types-from-defs --package @frequency-chain/api-augment --input ./interfaces --endpoint ./metadata.json", "generate:meta": "node --import=tsx/esm node_modules/.bin/polkadot-types-from-chain --package @frequency-chain/api-augment --endpoint ./metadata.json --output ./interfaces", diff --git a/js/api-augment/scripts/generate.mjs b/js/api-augment/scripts/generate.mjs new file mode 100644 index 0000000000..6691f2c0b1 --- /dev/null +++ b/js/api-augment/scripts/generate.mjs @@ -0,0 +1,15 @@ +import { types } from '../dist/esm/index.js'; +import fs from 'fs'; +import path from 'path'; +import { fileURLToPath } from 'url'; +import { dirname } from 'path'; + +// Get the filename from the URL +const __filename = fileURLToPath(import.meta.url); +// Get the directory name from the filename +const __dirname = dirname(__filename); +const outdir = path.join(__dirname, '../dist/json/'); + +fs.mkdirSync(outdir, { recursive: true }); + +fs.writeFileSync(path.join(outdir, 'types.json'), JSON.stringify(types, null, 4)); From bd2666ea7e138eac4fbd9df6af52836c2e8ce4b0 Mon Sep 17 00:00:00 2001 From: shannonwells Date: Wed, 9 Oct 2024 10:11:07 -0700 Subject: [PATCH 2/4] inline npm run build command --- .github/workflows/release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f76296d063..d1280ea767 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -411,8 +411,7 @@ jobs: - name: Output Metadata run: ${{env.BIN_DIR}}/${{env.RELEASE_BIN_FILENAME}} export-metadata --chain=frequency-paseo-local --tmp ./js/api-augment/metadata.json - name: Build - run: | - npm run build + run: npm run build working-directory: js/api-augment - name: Upload Dist Dir uses: actions/upload-artifact@v4 From b960929222873f1f728fe350ac3c018e23f38198 Mon Sep 17 00:00:00 2001 From: Wil Wade Date: Wed, 9 Oct 2024 21:39:01 +0000 Subject: [PATCH 3/4] Update polkadot-js-tools --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d1280ea767..cfbe165523 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -540,7 +540,7 @@ jobs: docker run -d --rm --net=net-${{env.RELEASE_BRANCH_NAME}} \ -v `pwd`:/app \ --name test-node \ - ubuntu:22.04 \ + ubuntu:24.04 \ /bin/sh -c "chmod +x /app/${{env.TEST_BIN_FILENAME}} && /app/${{env.TEST_BIN_FILENAME}} \ --chain=frequency-bench \ --rpc-external \ @@ -559,7 +559,7 @@ jobs: docker run -d --rm --net=net-${{env.RELEASE_BRANCH_NAME}} \ -v `pwd`:/app \ --name ref-node \ - ubuntu:22.04 \ + ubuntu:24.04 \ /bin/sh -c "chmod +x /app/${{env.REF_BIN_FILENAME}} && /app/${{env.REF_BIN_FILENAME}} \ --chain=frequency-bench \ --rpc-external \ @@ -585,7 +585,7 @@ jobs: - name: Compare Metadata timeout-minutes: 10 run: | - CMD="docker run --pull always --net=net-${{env.RELEASE_BRANCH_NAME}} jacogr/polkadot-js-tools:0.57.1 metadata ws://ref-node:9944 ws://test-node:9944" + CMD="docker run --pull always --net=net-${{env.RELEASE_BRANCH_NAME}} jacogr/polkadot-js-tools:0.59.1 metadata ws://ref-node:9944 ws://test-node:9944" echo -e "Running:\n$CMD" $CMD >> ${{env.OUTPUT_DIR}}/${{env.OUTPUT_FILENAME}} cat ${{env.OUTPUT_DIR}}/${{env.OUTPUT_FILENAME}} | egrep -n -i '' From bdf1a61a89e91f8ac0b47c33cdf694ddd49660e1 Mon Sep 17 00:00:00 2001 From: Wil Wade Date: Thu, 10 Oct 2024 14:57:19 +0000 Subject: [PATCH 4/4] Switch chain type to remove the bench part --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cfbe165523..105887e1b4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -542,7 +542,7 @@ jobs: --name test-node \ ubuntu:24.04 \ /bin/sh -c "chmod +x /app/${{env.TEST_BIN_FILENAME}} && /app/${{env.TEST_BIN_FILENAME}} \ - --chain=frequency-bench \ + --chain=frequency \ --rpc-external \ --rpc-cors=all \ --rpc-methods=Unsafe \ @@ -561,7 +561,7 @@ jobs: --name ref-node \ ubuntu:24.04 \ /bin/sh -c "chmod +x /app/${{env.REF_BIN_FILENAME}} && /app/${{env.REF_BIN_FILENAME}} \ - --chain=frequency-bench \ + --chain=frequency \ --rpc-external \ --rpc-cors=all \ --rpc-methods=Unsafe \