Skip to content

Commit

Permalink
chore(ci): Add ci for PRs and publish steps
Browse files Browse the repository at this point in the history
  • Loading branch information
voliva committed Jan 13, 2025
1 parent 4964c3d commit d099480
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 813 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on:
pull_request:
merge_group:
workflow_dispatch:

jobs:
build:
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Install deps
run: pnpm install
- name: Build
run: pnpm build
- name: Lint
run: pnpm lint
- name: Test
run: pnpm test
72 changes: 72 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Publish

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- name: Setup Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: pnpm
registry-url: https://registry.npmjs.org
- name: Install deps
run: pnpm install
- name: Build
run: pnpm build
- name: Lint
run: pnpm lint
- name: Test
run: pnpm test
publish:
needs: [build]
runs-on: ubuntu-latest
strategy:
matrix:
value: [sdk-governance, sdk-ink]
steps:
- uses: actions/checkout@v4
- name: Check if version has been updated
id: check
uses: EndBug/version-check@v2
with:
diff-search: true
file-name: ./packages/${{ matrix.value }}/package.json
- uses: actions/cache@v3
if: steps.check.outputs.changed == 'true'
with:
path: .turbo
key: ${{ runner.os }}-20.x-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-20.x-turbo-
- uses: pnpm/action-setup@v3
if: steps.check.outputs.changed == 'true'
- name: Setup Node.js 20.x
if: steps.check.outputs.changed == 'true'
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: pnpm
registry-url: https://registry.npmjs.org
- name: Install deps
if: steps.check.outputs.changed == 'true'
run: pnpm install
- name: Build
if: steps.check.outputs.changed == 'true'
run: pnpm build
- name: Publish
if: steps.check.outputs.changed == 'true'
working-directory: packages/${{ matrix.value }}
run: |
pnpm publish --no-git-checks --access=public --tag latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_AUTOMATION_TOKEN }}
4 changes: 2 additions & 2 deletions packages/common-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
},
"license": "MIT",
"peerDependencies": {
"polkadot-api": ">=1.7.4",
"polkadot-api": "^1.8.1",
"rxjs": ">=7.8.1"
},
"devDependencies": {
"polkadot-api": "^1.7.4",
"polkadot-api": "^1.8.1",
"rxjs": "^7.8.1"
}
}
40 changes: 20 additions & 20 deletions packages/sdk-governance/src/referenda/chainConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const SpenderOrigin = {
SmallSpender: "SmallSpender",
MediumSpender: "MediumSpender",
BigSpender: "BigSpender",
} as const;
export type Origin = (typeof SpenderOrigin)[keyof typeof SpenderOrigin];
} as const
export type Origin = (typeof SpenderOrigin)[keyof typeof SpenderOrigin]

export const originToTrack: Record<Origin, string> = {
Treasurer: "treasurer",
Expand All @@ -15,25 +15,25 @@ export const originToTrack: Record<Origin, string> = {
SmallSpender: "small_spender",
MediumSpender: "medium_spender",
BigSpender: "big_spender",
};
}

const DOT_UNIT = 10_000_000_000n;
const DOT_UNIT = 10_000_000_000n
export const polkadotSpenderOrigin = (value: bigint): Origin | null => {
if (value <= 250n * DOT_UNIT) return SpenderOrigin.SmallTipper;
if (value <= 1_000n * DOT_UNIT) return SpenderOrigin.BigTipper;
if (value <= 10_000n * DOT_UNIT) return SpenderOrigin.SmallSpender;
if (value <= 100_000n * DOT_UNIT) return SpenderOrigin.MediumSpender;
if (value <= 1_000_000n * DOT_UNIT) return SpenderOrigin.BigSpender;
if (value <= 10_000_000n * DOT_UNIT) return SpenderOrigin.Treasurer;
return null;
};
if (value <= 250n * DOT_UNIT) return SpenderOrigin.SmallTipper
if (value <= 1_000n * DOT_UNIT) return SpenderOrigin.BigTipper
if (value <= 10_000n * DOT_UNIT) return SpenderOrigin.SmallSpender
if (value <= 100_000n * DOT_UNIT) return SpenderOrigin.MediumSpender
if (value <= 1_000_000n * DOT_UNIT) return SpenderOrigin.BigSpender
if (value <= 10_000_000n * DOT_UNIT) return SpenderOrigin.Treasurer
return null
}

const KSM_UNIT = 1_000_000_000_000n;
const KSM_UNIT = 1_000_000_000_000n
export const kusamaSpenderOrigin = (value: bigint): Origin | null => {
if (value <= 1n * KSM_UNIT) return SpenderOrigin.SmallTipper;
if (value <= 5n * KSM_UNIT) return SpenderOrigin.BigTipper;
if (value <= 333n * KSM_UNIT) return SpenderOrigin.SmallSpender;
if (value <= 3_333n * KSM_UNIT) return SpenderOrigin.MediumSpender;
if (value <= 33_333n * KSM_UNIT) return SpenderOrigin.BigSpender;
return SpenderOrigin.Treasurer;
};
if (value <= 1n * KSM_UNIT) return SpenderOrigin.SmallTipper
if (value <= 5n * KSM_UNIT) return SpenderOrigin.BigTipper
if (value <= 333n * KSM_UNIT) return SpenderOrigin.SmallSpender
if (value <= 3_333n * KSM_UNIT) return SpenderOrigin.MediumSpender
if (value <= 33_333n * KSM_UNIT) return SpenderOrigin.BigSpender
return SpenderOrigin.Treasurer
}
4 changes: 2 additions & 2 deletions packages/sdk-governance/src/referenda/descriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export type ReferendaTypesCurve = Enum<{
}
}>

export type ReferendaTrack = {
export type ReferendaTrackData = {
name: string
max_deciding: number
decision_deposit: bigint
Expand Down Expand Up @@ -183,7 +183,7 @@ type ReferendaSdkPallets = PalletsTypedef<
{},
{
Referenda: {
Tracks: PlainDescriptor<Array<[number, ReferendaTrack]>>
Tracks: PlainDescriptor<Array<[number, ReferendaTrackData]>>
}
}
>
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-governance/src/referenda/sdk-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Origin } from "./chainConfig"
import {
PolkadotRuntimeOriginCaller,
PreimagesBounded,
ReferendaTrack as ReferendaTrackDescriptor,
ReferendaTrackData,
ReferendaTypesCurve,
ReferendumInfo,
TraitsScheduleDispatchTime,
Expand Down Expand Up @@ -50,7 +50,7 @@ export interface TrackFunctionDetails {
}>
}
export type ReferendaTrack = Omit<
ReferendaTrackDescriptor,
ReferendaTrackData,
"min_approval" | "min_support"
> & {
minApproval: TrackFunctionDetails
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-governance/src/referenda/track.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { keyBy } from "@/util/keyBy"
import {
ReferendaSdkTypedApi,
ReferendaTrack as ReferendaTrackDescriptor,
ReferendaTrackData as ReferendaTrackDescriptor,
ReferendaTypesCurve,
} from "./descriptors"
import { ReferendaTrack, TrackFunctionDetails } from "./sdk-types"
Expand Down
3 changes: 2 additions & 1 deletion packages/sdk-ink/src/descriptor-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ export type InkSdkPallets = PalletsTypedef<
{
code_hash: FixedSizeBinary<32>
},
true
true,
never
>
}
},
Expand Down
Loading

0 comments on commit d099480

Please sign in to comment.