Skip to content

Commit

Permalink
Fix CI and Build outputs (#364)
Browse files Browse the repository at this point in the history
* build and CI refinements

---------

Co-authored-by: kwrobel.eth <[email protected]>
  • Loading branch information
notrab and djstrong authored Aug 26, 2024
1 parent d6aff4f commit 1e677da
Show file tree
Hide file tree
Showing 27 changed files with 249 additions and 272 deletions.
9 changes: 9 additions & 0 deletions .changeset/selfish-toys-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@namehash/nameguard-react": minor
"@namehash/nameguard": minor
"@namehash/namekit-react": minor
"@namehash/nameguard-js": minor
"@namehash/ens-utils": minor
---

build changes
12 changes: 11 additions & 1 deletion .github/workflows/nameguard-end-to-end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,19 @@ jobs:
if: needs.check_changes.outputs.api_changed > 0
run: curl http://0.0.0.0:8000/inspect-name/mainnet/test.eth

- name: Set NAMEGUARD_API_URI
id: set_api_uri
env:
PRODUCTION_NAMEGUARD_API_URI: ${{ vars.PRODUCTION_NAMEGUARD_API_URI }}
run: |
if [ "${{ needs.check_changes.outputs.api_changed }}" -gt 0 ]; then
echo "NAMEGUARD_API_URI=http://0.0.0.0:8000" >> $GITHUB_ENV
else
echo "NAMEGUARD_API_URI=$PRODUCTION_NAMEGUARD_API_URI" >> $GITHUB_ENV
fi
- name: Run tests
env:
PROVIDER_URI_MAINNET: ${{ secrets.PROVIDER_URI_MAINNET }}
PROVIDER_URI_SEPOLIA: ${{ secrets.PROVIDER_URI_SEPOLIA }}
NAMEGUARD_API_URI: ${{ needs.check_changes.outputs.api_changed > 0 && 'http://0.0.0.0:8000' || '' }}
run: pnpm test --filter ./packages/nameguard-sdk
57 changes: 30 additions & 27 deletions .github/workflows/typescript-packages-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: TypeScript Packages - Unit Tests
name: TypeScript Packages - Unit

on:
push:
Expand All @@ -13,47 +13,50 @@ on:
- "packages/**"

jobs:
check_changes:
runs-on: ubuntu-latest
outputs:
sdk_only_changed: ${{ steps.check.outputs.sdk_only_changed }}
steps:
- uses: actions/checkout@v4

- name: Check for SDK-only changes
id: check
run: |
git fetch origin ${{ github.base_ref }}
API_CHANGED=$(git diff --name-only origin/${{ github.base_ref }} HEAD | grep "^api/nameguard/" | wc -l)
SDK_CHANGED=$(git diff --name-only origin/${{ github.base_ref }} HEAD | grep "^packages/nameguard-sdk/" | wc -l)
if [ $API_CHANGED -eq 0 ] && [ $SDK_CHANGED -gt 0 ]; then
echo "sdk_only_changed=true" >> $GITHUB_OUTPUT
else
echo "sdk_only_changed=false" >> $GITHUB_OUTPUT
fi
build:
runs-on: ubuntu-latest
test:
strategy:
fail-fast: false
matrix:
package:
- "ens-utils"
- "nameguard-sdk"
- "nameguard-js"
- "nameguard-react"
- "nameguard-sdk"
- "namekit-react"

name: Test ${{ matrix.package }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Install Dependencies
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Build ${{ matrix.package }}
run: pnpm --filter ./packages/${{ matrix.package }} build
- name: Build
run: pnpm build

- name: Test ${{ matrix.package }}
if: matrix.package != 'nameguard-sdk' || needs.check_changes.outputs.sdk_only_changed == 'true'
run: pnpm --filter ./packages/${{ matrix.package }} test
3 changes: 0 additions & 3 deletions apps/namehashlabs.org/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,5 @@
"tailwindcss": "3.4.3",
"typescript": "5.4.5",
"vitest": "^1.6.0"
},
"engines": {
"node": "18.x"
}
}
2 changes: 2 additions & 0 deletions internal/seo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@namekit/tsconfig/base.json",
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
Expand Down
26 changes: 26 additions & 0 deletions internal/tsconfig/base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Base",
"compilerOptions": {
"target": "es2022",
"module": "es2022",
"allowJs": true,
"moduleDetection": "force",
"sourceMap": true,
"composite": false,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"isolatedModules": true,
"moduleResolution": "node",
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
"skipLibCheck": true,
"strict": true,
"downlevelIteration": true
},
"exclude": ["node_modules"]
}
22 changes: 22 additions & 0 deletions internal/tsconfig/nextjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Next.js",
"extends": "./base.json",
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["src", "next-env.d.ts"],
"exclude": ["node_modules"]
}
10 changes: 10 additions & 0 deletions internal/tsconfig/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@namekit/tsconfig",
"version": "0.0.0",
"private": true,
"files": [
"base.json",
"nextjs.json",
"react.json"
]
}
1 change: 1 addition & 0 deletions packages/ens-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"viem": "2.9.3"
},
"devDependencies": {
"@namekit/tsconfig": "workspace:*",
"tsup": "8.0.2",
"typescript": "5.3.3",
"vite": "5.1.7",
Expand Down
17 changes: 4 additions & 13 deletions packages/ens-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@namekit/tsconfig/base.json",
"compilerOptions": {
"target": "ES2020",
"lib": ["ES2020", "dom"],
"module": "ES2020",
"moduleResolution": "node",
"strict": true,
"sourceMap": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"outDir": "./dist",
"rootDir": "./src",
},
"exclude": ["node_modules"]
"module": "ES2020"
}
}
8 changes: 2 additions & 6 deletions packages/ens-utils/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { defineConfig } from "tsup";

export default defineConfig({
entry: ["src/index.ts"],
splitting: true,
sourcemap: false,
format: ["esm"],
clean: true,
dts: true,
treeshake: true,
skipNodeModulesBundle: true,
target: [
"chrome123",
"edge122",
Expand All @@ -15,7 +14,4 @@ export default defineConfig({
"safari17",
"node20",
],
format: ["esm"],
skipNodeModulesBundle: true,
external: ["node_modules"],
});
5 changes: 3 additions & 2 deletions packages/nameguard-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@
"test": "vitest"
},
"devDependencies": {
"@namekit/tsconfig": "workspace:*",
"@types/node": "^20.6.2",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"vitest": "1.4.0"
},
"dependencies": {
"@namehash/nameguard": "workspace:*",
"@namehash/ens-utils": "workspace:*",
"@adraffy/ens-normalize": "1.10.1",
"@namehash/ens-utils": "workspace:*",
"@namehash/nameguard": "workspace:*",
"text-segmentation": "1.0.3",
"viem": "2.9.3",
"whatwg-fetch": "3.6.19"
Expand Down
1 change: 1 addition & 0 deletions packages/nameguard-js/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { createClient } from "./nameguard-js";
2 changes: 1 addition & 1 deletion packages/nameguard-js/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { createClient, NameGuardJSOptions } from "./nameguard-js";
export { createClient, type NameGuardJSOptions } from "./nameguard-js";
10 changes: 6 additions & 4 deletions packages/nameguard-js/src/nameguard-js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
SecurePrimaryNameResult,
NameGuardOptions,
DEFAULT_COMPUTE_NAMEGUARD_REPORT,
Network,
} from "@namehash/nameguard";
import { securePrimaryName as securePrimaryNameImpl } from "./securePrimaryName";

Expand All @@ -24,11 +25,11 @@ class NameGuardJS extends NameGuard {
const chainId = this.publicClient.chain?.id;
if (this.network === "mainnet" && chainId !== 1) {
throw new Error(
`Network mismatch: expected mainnet (chain id 1), but got chain id ${chainId}.`
`Network mismatch: expected mainnet (chain id 1), but got chain id ${chainId}.`,
);
} else if (this.network === "sepolia" && chainId !== 11155111) {
throw new Error(
`Network mismatch: expected sepolia (chain id 11155111), but got chain id ${chainId}.`
`Network mismatch: expected sepolia (chain id 11155111), but got chain id ${chainId}.`,
);
} else if (this.network !== "mainnet" && this.network !== "sepolia") {
throw new Error(`Unsupported network: ${this.network}.`);
Expand All @@ -37,9 +38,10 @@ class NameGuardJS extends NameGuard {

public override getSecurePrimaryName(
address: string,
options?: SecurePrimaryNameOptions
options?: SecurePrimaryNameOptions,
): Promise<SecurePrimaryNameResult> {
const computeNameGuardReport = options?.computeNameGuardReport || DEFAULT_COMPUTE_NAMEGUARD_REPORT;
const computeNameGuardReport =
options?.computeNameGuardReport || DEFAULT_COMPUTE_NAMEGUARD_REPORT;
if (computeNameGuardReport) {
return super.getSecurePrimaryName(address, options);
}
Expand Down
Loading

0 comments on commit 1e677da

Please sign in to comment.