Skip to content

Commit

Permalink
refactor: ♻️ Update api-augment ci (#2964)
Browse files Browse the repository at this point in the history
* refactor: ♻️ Update api-augment ci

---------

Co-authored-by: Andrea Giacobino <[email protected]>
Co-authored-by: Pablo Labarta <[email protected]>
  • Loading branch information
3 people authored Oct 28, 2024
1 parent 527a930 commit 35a788b
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 81 deletions.
51 changes: 18 additions & 33 deletions .github/workflows/publish-typescript-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ name: Publish Typescript API
on:
workflow_dispatch:
inputs:
sha:
description: full sha to build the npm package from
TargetSHA:
description: full sha of commit to publish ApiAugment from
required: true
DryRun:
description: Dry run mode
required: false
default: "false"

jobs:
publish-typescript-api:
Expand All @@ -13,43 +17,24 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.sha }}
- name: Use Node.js
ref: ${{ github.event.inputs.TargetSHA }}
- 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: 20.10.0
- name: Build typescript API
- name: Build Typescript Augment API package
run: |
cd typescript-api
npm install
npm run build
pnpm i
pnpm build
- name: Publish typescript API
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
package: typescript-api/build/package.json

update-polkadot-js-for-tests-and-tools:
runs-on: ubuntu-latest
needs: ["publish-typescript-api"]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.sha }}
- name: Use pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.10.0
- name: Upgrade polkadotjs for tests
run: |
cd test
pnpm install @polkadot/api@latest
- name: Upgrade polkadotjs for tools
run: |
cd tools
npm install @polkadot/api@latest
package: typescript-api/package.json
dry-run: ${{ github.event.inputs.DryRun }}
32 changes: 19 additions & 13 deletions .github/workflows/upgrade-typescript-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,26 @@ on:
spec_version:
description: runtime spec version (ex. 1601)
required: true
dry_run:
description: Dry Run - do not create PR
required: false
type: boolean
default: false

jobs:
upgrading-typescript-api:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: runtime-${{ github.event.inputs.spec_version }}
- name: Retrieve moonbeam binary
run: |
DOCKER_TAG="moonbeamfoundation/moonbeam:runtime-${{ github.event.inputs.spec_version }}"
# Clear the dummy container if it wasn't properly cleaned up
docker rm -f dummy 2> /dev/null
docker create -ti --name dummy $DOCKER_TAG bash
mkdir -p build
docker cp dummy:/moonbeam/moonbeam build/moonbeam
docker rm -f dummy
docker rm -f rtRelease 2> /dev/null
docker create -ti --name rtRelease $DOCKER_TAG bash
mkdir -p target/release
docker cp rtRelease:/moonbeam/moonbeam target/release/moonbeam
docker rm -f rtRelease
- name: Use Node.js
uses: actions/setup-node@v4
with:
Expand All @@ -31,26 +33,30 @@ jobs:
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Upgrade polkadotjs for moonbeam-types-bundle
run: |
cd moonbeam-types-bundle
pnpm install
- name: Upgrade polkadotjs for typescript-api
run: |
cd typescript-api
pnpm install
pnpm run build
- name: regenerate typescript api with new runtime metadata
run: |
cd typescript-api
./scripts/runtime-upgrade.sh ${{ github.event.inputs.spec_version }}
- name: Create Pull Request
if: ${{ !inputs.dry_run }}
uses: peter-evans/create-pull-request@v7
with:
base: master
branch: "typescript-api-${{ github.event.inputs.spec_version }}"
commit-message: typescript API v0.${{ github.event.inputs.spec_version }}.0
draft: true

title: "Upgrade typescript API for runtime-${{ github.event.inputs.spec_version }}"
reviewers: "moonsong-coredev"
labels: "B0-silent,D2-notlive"
- name: Display changes (Dry Run)
if: ${{ inputs.dry_run }}
run: |
git diff
echo "Dry run completed. Changes were not committed or pushed."
2 changes: 1 addition & 1 deletion docker/moonbeam.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ FROM docker.io/library/ubuntu:20.04 AS builder
RUN apt-get update && apt-get install -y ca-certificates && update-ca-certificates

FROM debian:bookworm-slim
LABEL maintainer "alan@purestake.com"
LABEL maintainer="alan@moonsonglabs.com"
LABEL description="Binary for Moonbeam Collator"

RUN useradd -m -u 1000 -U -s /bin/sh -d /moonbeam moonbeam && \
Expand Down
2 changes: 1 addition & 1 deletion typescript-api/src/moonbeam/interfaces/definitions.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as empty } from "./moon/definitions";
export { default as moon } from "./moon/definitions";
2 changes: 1 addition & 1 deletion typescript-api/src/moonriver/interfaces/definitions.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as empty } from "./moon/definitions";
export { default as moon } from "./moon/definitions";
2 changes: 1 addition & 1 deletion typescript-api/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"moonbase": ["moonbase/src"]
}
},
"exclude": ["node_modules","dist", "scripts"]
"exclude": ["node_modules", "dist", "scripts"]
}
50 changes: 19 additions & 31 deletions typescript-api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
{
"extends":"./tsconfig.base.json",
"compilerOptions": {
"incremental": true,
"rootDir": "src",
"outDir": "dist",
"baseUrl": "./",
"paths": {
"@storagehub/api-augment/*": [
"src/*"
],
"@polkadot/api/augment": [
"src/interfaces/augment-api.ts"
],
"@polkadot/types/augment": [
"src/interfaces/augment-types.ts"
],
"@polkadot/types/lookup": [
"src/interfaces/types-lookup.ts"
]
},
"noEmit": false,
"declaration": true,
"declarationDir": "dist/types",
"allowImportingTsExtensions": false,
},
"exclude": [
"node_modules",
"dist",
"scripts"
],
"extends": "./tsconfig.base.json",
"compilerOptions": {
"incremental": true,
"rootDir": "src",
"outDir": "dist",
"baseUrl": "./",
"paths": {
"@storagehub/api-augment/*": ["src/*"],
"@polkadot/api/augment": ["src/interfaces/augment-api.ts"],
"@polkadot/types/augment": ["src/interfaces/augment-types.ts"],
"@polkadot/types/lookup": ["src/interfaces/types-lookup.ts"]
},
"noEmit": false,
"declaration": true,
"declarationDir": "dist/types",
"allowImportingTsExtensions": false
},
"exclude": ["node_modules", "dist", "scripts"],
"references": [
{
"path": "./src/moonbeam"
Expand All @@ -40,4 +28,4 @@
"path": "./src/moonbase"
}
]
}
}

0 comments on commit 35a788b

Please sign in to comment.