-
Notifications
You must be signed in to change notification settings - Fork 181
feat: modernize sdk/core build pipeline #875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
be8e11f
6c5c28b
c6cecb7
10f016f
0892585
8c146f0
f89ad33
8bb6a90
da19a09
cf38a07
ca7b3b7
f0b7d2e
3deab93
88c6583
ca53484
96a156a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| name: SDK Core CI | ||
|
|
||
| on: | ||
| push: | ||
| paths: | ||
| - "sdk/core/**" | ||
| - ".github/workflows/sdk-core-ci.yml" | ||
| pull_request: | ||
| paths: | ||
| - "sdk/core/**" | ||
| - ".github/workflows/sdk-core-ci.yml" | ||
|
|
||
| jobs: | ||
| # Build dependencies once and cache for other jobs | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Dependencies | ||
| uses: ./.github/actions/yarn-install | ||
|
|
||
| - name: Build dependencies | ||
| shell: bash | ||
| run: | | ||
| yarn workspace @selfxyz/common build | ||
| yarn workspace @selfxyz/contracts build | ||
| cd sdk/core && yarn generate-typechain | ||
| yarn workspace @selfxyz/core build | ||
|
|
||
| - name: Cache build artifacts | ||
| uses: actions/cache/save@v4 | ||
| with: | ||
| path: | | ||
| common/dist | ||
| contracts/artifacts | ||
| contracts/cache | ||
| sdk/core/dist | ||
| sdk/core/.tsbuildinfo | ||
| sdk/core/node_modules/.cache | ||
| common/node_modules/.cache | ||
| sdk/core/src/typechain-types | ||
| key: sdk-core-build-${{ github.sha }} | ||
|
|
||
| # Quality checks job | ||
| quality-checks: | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| defaults: | ||
| run: | ||
| working-directory: ./sdk/core | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Dependencies | ||
| uses: ./.github/actions/yarn-install | ||
|
|
||
| - name: Restore build artifacts | ||
| uses: actions/cache/restore@v4 | ||
| with: | ||
| path: | | ||
| common/dist | ||
| contracts/artifacts | ||
| contracts/cache | ||
| sdk/core/dist | ||
| sdk/core/.tsbuildinfo | ||
| sdk/core/node_modules/.cache | ||
| common/node_modules/.cache | ||
| sdk/core/src/typechain-types | ||
| key: sdk-core-build-${{ github.sha }} | ||
| fail-on-cache-miss: true | ||
|
|
||
| - name: Generate typechain types (if needed) | ||
| run: yarn generate-typechain | ||
|
|
||
| - name: Copy ABI files | ||
| run: yarn copy-abi | ||
|
|
||
| - name: Lint | ||
| run: yarn lint | ||
|
|
||
| - name: Type check | ||
| run: yarn types | ||
|
|
||
| - name: Test build output | ||
| run: | | ||
| echo "Testing ESM import..." | ||
| node -e "import('@selfxyz/core').then(m => console.log('✅ ESM import successful')).catch(e => console.error('❌ ESM import failed:', e.message))" | ||
|
|
||
| echo "Testing CJS require..." | ||
| node -e "try { const m = require('@selfxyz/core'); console.log('✅ CJS require successful'); } catch(e) { console.error('❌ CJS require failed:', e.message); }" | ||
|
|
||
| - name: Verify exports | ||
| run: | | ||
| echo "Verifying package exports..." | ||
| node -e " | ||
| const pkg = require('./package.json'); | ||
| console.log('Package exports:', JSON.stringify(pkg.exports, null, 2)); | ||
| console.log('Main:', pkg.main); | ||
| console.log('Module:', pkg.module); | ||
| console.log('Types:', pkg.types); | ||
| " |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| module.exports = { | ||
| root: true, | ||
| env: { | ||
| node: true, | ||
| es6: true, | ||
| }, | ||
| parser: '@typescript-eslint/parser', | ||
| parserOptions: { | ||
| ecmaVersion: 2021, | ||
| sourceType: 'module', | ||
| ecmaFeatures: { jsx: false }, | ||
| }, | ||
| extends: [ | ||
| 'eslint:recommended', | ||
| 'plugin:@typescript-eslint/recommended', | ||
| 'plugin:import/recommended', | ||
| 'plugin:import/typescript', | ||
| ], | ||
| plugins: ['simple-import-sort', 'import', 'sort-exports'], | ||
| ignorePatterns: [ | ||
| 'node_modules/', | ||
| 'dist/', | ||
| '*.js.map', | ||
| '*.d.ts', | ||
| 'typechain-types/', | ||
| 'src/abi/', | ||
| 'scripts/', | ||
| ], | ||
| settings: { | ||
| 'import/resolver': { | ||
| typescript: { | ||
| alwaysTryTypes: true, | ||
| project: './tsconfig.json', | ||
| }, | ||
| }, | ||
| }, | ||
| rules: { | ||
| 'import/order': 'off', | ||
| 'no-duplicate-imports': 'off', | ||
| 'simple-import-sort/imports': [ | ||
| 'error', | ||
| { | ||
| groups: [['^node:'], ['^node:.*/'], ['^[a-zA-Z]'], ['^@selfxyz/'], ['^[./]']], | ||
| }, | ||
| ], | ||
| 'sort-exports/sort-exports': [ | ||
| 'error', | ||
| { sortDir: 'asc', ignoreCase: false, sortExportKindFirst: 'type' }, | ||
| ], | ||
| '@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }], | ||
| 'import/first': 'error', | ||
| 'import/newline-after-import': 'error', | ||
| 'import/no-duplicates': 'error', | ||
| 'no-restricted-syntax': [ | ||
| 'error', | ||
| { | ||
| selector: 'ExportAllDeclaration', | ||
| message: 'export * is forbidden. Use selective exports for better tree shaking.', | ||
| }, | ||
| ], | ||
| '@typescript-eslint/no-explicit-any': 'warn', | ||
| '@typescript-eslint/no-unused-vars': [ | ||
| 'error', | ||
| { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, | ||
| ], | ||
| '@typescript-eslint/ban-types': 'warn', | ||
| '@typescript-eslint/no-namespace': 'warn', | ||
| '@typescript-eslint/ban-ts-comment': 'warn', | ||
| }, | ||
| overrides: [ | ||
| { | ||
| files: ['*.cjs'], | ||
| env: { | ||
| node: true, | ||
| commonjs: true, | ||
| es6: true, | ||
| }, | ||
| parserOptions: { | ||
| ecmaVersion: 2020, | ||
| sourceType: 'script', | ||
| }, | ||
| rules: { | ||
| '@typescript-eslint/no-var-requires': 'off', | ||
| 'no-undef': 'off', | ||
| }, | ||
| }, | ||
| ], | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,23 @@ | ||
| import { SelfBackendVerifier } from './src/SelfBackendVerifier.js'; | ||
| import { countryCodes } from '@selfxyz/common/constants'; | ||
| import { countries, countryCodes } from '@selfxyz/common/constants'; | ||
| import { getUniversalLink } from '@selfxyz/common/utils/appType'; | ||
| import { countries } from '@selfxyz/common/constants'; | ||
| import type { AttestationId, VerificationResult, VerificationConfig } from 'src/types/types.js'; | ||
| import type { IConfigStorage } from 'src/store/interface.js'; | ||
| import { DefaultConfigStore } from 'src/store/DefaultConfigStore.js'; | ||
| import { AllIds } from 'src/utils/constants.js'; | ||
| import { InMemoryConfigStore } from 'src/store/InMemoryConfigStore.js'; | ||
|
|
||
| import { SelfBackendVerifier } from './src/SelfBackendVerifier.js'; | ||
| import { DefaultConfigStore } from './src/store/DefaultConfigStore.js'; | ||
| import { InMemoryConfigStore } from './src/store/InMemoryConfigStore.js'; | ||
| import type { IConfigStorage } from './src/store/interface.js'; | ||
| import type { AttestationId, VerificationConfig, VerificationResult } from './src/types/types.js'; | ||
| import { AllIds } from './src/utils/constants.js'; | ||
|
|
||
| export { | ||
| SelfBackendVerifier, | ||
| countryCodes, | ||
| getUniversalLink, | ||
| countries, | ||
| AllIds, | ||
| AttestationId, | ||
| IConfigStorage, | ||
| DefaultConfigStore, | ||
| IConfigStorage, | ||
| InMemoryConfigStore, | ||
| AllIds, | ||
| VerificationResult, | ||
| SelfBackendVerifier, | ||
| VerificationConfig, | ||
| VerificationResult, | ||
| countries, | ||
| countryCodes, | ||
| getUniversalLink, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,29 +17,96 @@ | |||||
| "type": "module", | ||||||
| "exports": { | ||||||
| ".": { | ||||||
| "import": { | ||||||
| "types": "./dist/index.d.ts", | ||||||
| "default": "./dist/index.js" | ||||||
| }, | ||||||
| "require": { | ||||||
| "types": "./dist/index.d.cts", | ||||||
| "default": "./dist/index.cjs" | ||||||
| } | ||||||
| } | ||||||
| "types": "./dist/esm/index.d.ts", | ||||||
| "import": "./dist/esm/index.js", | ||||||
| "require": "./dist/cjs/index.cjs" | ||||||
| }, | ||||||
| "./SelfBackendVerifier": { | ||||||
| "types": "./dist/esm/src/SelfBackendVerifier.d.ts", | ||||||
| "import": "./dist/esm/src/SelfBackendVerifier.js", | ||||||
| "require": "./dist/cjs/src/SelfBackendVerifier.cjs" | ||||||
| }, | ||||||
| "./errors": { | ||||||
| "types": "./dist/esm/src/errors.d.ts", | ||||||
| "import": "./dist/esm/src/errors.js", | ||||||
| "require": "./dist/cjs/src/errors.cjs" | ||||||
| }, | ||||||
| "./store/DefaultConfigStore": { | ||||||
| "types": "./dist/esm/src/store/DefaultConfigStore.d.ts", | ||||||
| "import": "./dist/esm/src/store/DefaultConfigStore.js", | ||||||
| "require": "./dist/cjs/src/store/DefaultConfigStore.cjs" | ||||||
| }, | ||||||
| "./store/InMemoryConfigStore": { | ||||||
| "types": "./dist/esm/src/store/InMemoryConfigStore.d.ts", | ||||||
| "import": "./dist/esm/src/store/InMemoryConfigStore.js", | ||||||
| "require": "./dist/cjs/src/store/InMemoryConfigStore.cjs" | ||||||
| }, | ||||||
| "./store/interface": { | ||||||
| "types": "./dist/esm/src/store/interface.d.ts", | ||||||
| "import": "./dist/esm/src/store/interface.js", | ||||||
| "require": "./dist/cjs/src/store/interface.cjs" | ||||||
| }, | ||||||
| "./types": { | ||||||
| "types": "./dist/esm/src/types/types.d.ts", | ||||||
| "import": "./dist/esm/src/types/types.js", | ||||||
| "require": "./dist/cjs/src/types/types.cjs" | ||||||
| }, | ||||||
| "./utils": { | ||||||
| "types": "./dist/esm/src/utils/utils.d.ts", | ||||||
| "import": "./dist/esm/src/utils/utils.js", | ||||||
| "require": "./dist/cjs/src/utils/utils.cjs" | ||||||
| }, | ||||||
| "./utils/constants": { | ||||||
| "types": "./dist/esm/src/utils/constants.d.ts", | ||||||
| "import": "./dist/esm/src/utils/constants.js", | ||||||
| "require": "./dist/cjs/src/utils/constants.cjs" | ||||||
| }, | ||||||
| "./utils/hash": { | ||||||
| "types": "./dist/esm/src/utils/hash.d.ts", | ||||||
| "import": "./dist/esm/src/utils/hash.js", | ||||||
| "require": "./dist/cjs/src/utils/hash.cjs" | ||||||
| }, | ||||||
| "./utils/id": { | ||||||
| "types": "./dist/esm/src/utils/id.d.ts", | ||||||
| "import": "./dist/esm/src/utils/id.js", | ||||||
| "require": "./dist/cjs/src/utils/id.cjs" | ||||||
| }, | ||||||
| "./utils/proof": { | ||||||
| "types": "./dist/esm/src/utils/proof.d.ts", | ||||||
| "import": "./dist/esm/src/utils/proof.js", | ||||||
| "require": "./dist/cjs/src/utils/proof.cjs" | ||||||
| }, | ||||||
| "./typechain-types": { | ||||||
| "types": "./dist/esm/src/typechain-types/index.d.ts", | ||||||
| "import": "./dist/esm/src/typechain-types/index.js", | ||||||
| "require": "./dist/cjs/src/typechain-types/index.cjs" | ||||||
| }, | ||||||
| "./typechain-types/*": { | ||||||
| "types": "./dist/esm/src/typechain-types/*.d.ts", | ||||||
| "import": "./dist/esm/src/typechain-types/*.js", | ||||||
| "require": "./dist/cjs/src/typechain-types/*.cjs" | ||||||
| }, | ||||||
| "./abi/*": "./src/abi/*" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider the implications of exposing source ABI files directly. The alias - "./abi/*": "./src/abi/*"
+ "./abi/*": "./dist/esm/src/abi/*"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| }, | ||||||
| "main": "dist/index.cjs", | ||||||
| "module": "dist/index.js", | ||||||
| "types": "dist/index.d.cts", | ||||||
| "main": "dist/cjs/index.cjs", | ||||||
| "module": "dist/esm/index.js", | ||||||
| "types": "dist/esm/index.d.ts", | ||||||
| "files": [ | ||||||
| "dist" | ||||||
| ], | ||||||
| "scripts": { | ||||||
| "build": "typechain --target ethers-v6 --node16-modules --out-dir src/typechain-types src/abi/**.json && tsup index.ts --format cjs,esm --dts --clean --sourcemap", | ||||||
| "build": "tsup && yarn build:types && yarn postbuild", | ||||||
| "postbuild": "node ./scripts/postBuild.mjs", | ||||||
| "build:deps": "yarn workspaces foreach --from @selfxyz/core --topological-dev --recursive run build", | ||||||
| "build:types": "tsc -p tsconfig.json --emitDeclarationOnly", | ||||||
| "build:watch": "tsup --watch", | ||||||
| "copy-abi": "bash scripts/copyAbi.sh", | ||||||
| "format": "prettier --write .", | ||||||
| "generate-typechain": "typechain --target ethers-v6 --out-dir src/typechain-types ../../contracts/artifacts/contracts/**/*.json", | ||||||
| "install-sdk": "yarn workspaces focus @selfxyz/core", | ||||||
| "lint": "prettier --check .", | ||||||
| "lint": "eslint . --ext .ts,.tsx,.js,.jsx,.cjs,.mjs", | ||||||
| "lint:fix": "eslint . --ext .ts,.tsx,.js,.jsx,.cjs,.mjs --fix", | ||||||
| "nice": "yarn format && yarn lint:fix", | ||||||
| "prepublishOnly": "npm run build", | ||||||
| "publish": "yarn npm publish --access public", | ||||||
| "types": "yarn build" | ||||||
|
|
@@ -67,7 +134,14 @@ | |||||
| "@types/node-forge": "^1.3.5", | ||||||
| "@types/pako": "^2.0.3", | ||||||
| "@types/snarkjs": "^0.7.8", | ||||||
| "@typescript-eslint/eslint-plugin": "^7.0.0", | ||||||
| "@typescript-eslint/parser": "^7.0.0", | ||||||
| "axios": "^1.7.2", | ||||||
| "eslint": "^8.57.0", | ||||||
| "eslint-import-resolver-typescript": "^3.6.1", | ||||||
| "eslint-plugin-import": "^2.29.1", | ||||||
| "eslint-plugin-simple-import-sort": "^12.0.0", | ||||||
| "eslint-plugin-sort-exports": "^0.8.0", | ||||||
transphorm marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| "prettier": "^3.3.3", | ||||||
| "ts-loader": "^9.5.1", | ||||||
| "ts-node": "^10.9.2", | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.