Skip to content

Commit

Permalink
chore: workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
joepegler committed Aug 23, 2024
1 parent 6013394 commit 4164966
Show file tree
Hide file tree
Showing 18 changed files with 53 additions and 64 deletions.
3 changes: 3 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ runs:
- name: Set up Bun
uses: oven-sh/setup-bun@v1

- name: Set up foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install dependencies
shell: bash
run: bun install --frozen-lockfile
Expand Down
3 changes: 3 additions & 0 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ runs:
- name: Set up Bun
uses: oven-sh/setup-bun@v1

- name: Set up foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install dependencies
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Build
uses: ./.github/actions/build
6 changes: 4 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ jobs:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4


- name: Install dependencies
uses: ./.github/actions/install-dependencies

- name: Run the tests
run: bun run test
run: bun run test --coverage
env:
E2E_PRIVATE_KEY_ONE: ${{ secrets.E2E_PRIVATE_KEY_ONE }}
BUNDLER_URL: https://api.pimlico.io/v2/84532/rpc?apikey=pim_im13GpaqtMDSiJFhXMxcVn
CHAIN_ID: 84532
CI: true

- name: report coverage
uses: davelosert/vitest-coverage-report-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
deploy-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: git config --global user.email "gh@runner.com"
- run: git config --global user.name "gh-runner"

Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/playground.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@ jobs:
group: ${{ github.workflow }}-${{ github.ref }}-playground
cancel-in-progress: true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: 22

- uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/install-dependencies

- name: Run the account tests
run: RUN_PLAYGROUND=true bun run test:ci -t=Playground
- name: Run the playground
run: bun run test -t=playground
env:
E2E_PRIVATE_KEY_ONE: ${{ secrets.E2E_PRIVATE_KEY_ONE }}
BUNDLER_URL: https://api.pimlico.io/v2/84532/rpc?apikey=pim_im13GpaqtMDSiJFhXMxcVn
CHAIN_ID: 84532
RUN_PLAYGROUND: true
CI: true
2 changes: 1 addition & 1 deletion .github/workflows/pr-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: pr lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/install-dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/size-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@ jobs:
group: ${{ github.workflow }}-${{ github.ref }}-unit-tests
cancel-in-progress: true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: 22

- uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/install-dependencies

- name: Run the account tests
run: bun run test:ci
- name: Run the tests
run: bun run test
env:
E2E_PRIVATE_KEY_ONE: ${{ secrets.E2E_PRIVATE_KEY_ONE }}
BUNDLER_URL: https://api.pimlico.io/v2/84532/rpc?apikey=pim_im13GpaqtMDSiJFhXMxcVn
CHAIN_ID: 84532
CI: true
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,10 @@
"dev": "bun link && concurrently \"bun run esm:watch\" \"bun run cjs:watch\" \"bun run esm:watch:aliases\" \"bun run cjs:watch:aliases\"",
"build": "bun run clean && bun run build:cjs && bun run build:esm && bun run build:types",
"clean": "rimraf ./dist/_esm ./dist/_cjs ./dist/_types ./dist/tsconfig",
"test": "vitest dev -c ./tests/vitest.config.ts",
"test": "vitest -c ./tests/vitest.config.ts",
"test:watch": "bun run test dev",
"playground": "RUN_PLAYGROUND=true bun run test -t=Playground",
"playground:watch": "RUN_PLAYGROUND=true bun run test -t=Playground --watch",
"test:watch": "bun run test --watch",
"test:coverage": "CI=true vitest -c ./tests/vitest.config.ts --coverage",
"test:ci": "CI=true vitest -c ./tests/vitest.config.ts",
"size": "size-limit",
"docs": "typedoc --tsconfig ./tsconfig/tsconfig.esm.json",
"docs:deploy": "bun run docs && gh-pages -d docs",
Expand Down
17 changes: 0 additions & 17 deletions tests/globalSetup.ts

This file was deleted.

5 changes: 3 additions & 2 deletions tests/instances/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import {
fundAndDeploy,
getTestAccount,
initNetwork,
killNetwork,
toTestClient
} from "../test.utils"
Expand All @@ -23,7 +24,7 @@ import type {
NetworkConfig,
NetworkConfigWithBundler
} from "../test.utils"
import { type TestFileNetworkType, aaTest, toNetwork } from "../testSetup"
import type { TestFileNetworkType } from "../testSetup"

const NETWORK_TYPE: TestFileNetworkType = "LOCAL"

Expand All @@ -42,7 +43,7 @@ describe("account", () => {
let recipientSmartAccountAddress: Hex

beforeAll(async () => {
network = await toNetwork(NETWORK_TYPE)
network = await initNetwork()

const testConfig: Partial<NexusSmartAccountConfig> = {
factoryAddress: network.deployment.k1FactoryAddress,
Expand Down
7 changes: 2 additions & 5 deletions tests/instances/bundler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ import {
import {
fundAndDeploy,
getTestAccount,
initNetwork,
killNetwork,
toTestClient
} from "../test.utils"
import type { MasterClient, NetworkConfig } from "../test.utils"
import { type TestFileNetworkType, toNetwork } from "../testSetup"

const NETWORK_TYPE: TestFileNetworkType = "LOCAL"

describe("bundler", () => {
let network: NetworkConfig
Expand All @@ -38,8 +36,7 @@ describe("bundler", () => {
let recipientSmartAccountAddress: Hex

beforeAll(async () => {
network = await toNetwork(NETWORK_TYPE)

network = await initNetwork()
const testConfig: Partial<NexusSmartAccountConfig> = {
factoryAddress: network.deployment.k1FactoryAddress,
k1ValidatorAddress: network.deployment.k1ValidatorAddress
Expand Down
6 changes: 2 additions & 4 deletions tests/instances/hook.module.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ import {
import {
fundAndDeploy,
getTestAccount,
initNetwork,
killNetwork,
toTestClient
} from "../test.utils"
import type { MasterClient, NetworkConfig } from "../test.utils"
import { type TestFileNetworkType, toNetwork } from "../testSetup"

const NETWORK_TYPE: TestFileNetworkType = "LOCAL"

describe("hook.module", () => {
let network: NetworkConfig
Expand All @@ -38,7 +36,7 @@ describe("hook.module", () => {
let recipientSmartAccountAddress: Hex

beforeAll(async () => {
network = await toNetwork(NETWORK_TYPE)
network = await initNetwork()

const testConfig: Partial<NexusSmartAccountConfig> = {
factoryAddress: network.deployment.k1FactoryAddress,
Expand Down
6 changes: 2 additions & 4 deletions tests/instances/modules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ import {
import {
fundAndDeploy,
getTestAccount,
initNetwork,
killNetwork,
toTestClient
} from "../test.utils"
import type { MasterClient, NetworkConfig } from "../test.utils"
import { type TestFileNetworkType, toNetwork } from "../testSetup"

const NETWORK_TYPE: TestFileNetworkType = "LOCAL"

describe("modules", () => {
let network: NetworkConfig
Expand All @@ -38,7 +36,7 @@ describe("modules", () => {
let recipientSmartAccountAddress: Hex

beforeAll(async () => {
network = await toNetwork(NETWORK_TYPE)
network = await initNetwork()

const testConfig: Partial<NexusSmartAccountConfig> = {
factoryAddress: network.deployment.k1FactoryAddress,
Expand Down
18 changes: 15 additions & 3 deletions tests/test.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ export const killNetwork = (ids: number[]) =>
Promise.all(
ids.map(async (id) => {
const instance = allInstances.get(id)

if (instance) {
await instance.stop()
allInstances.delete(id)
Expand All @@ -98,6 +97,7 @@ export const killNetwork = (ids: number[]) =>
)

export const initNetwork = async (): Promise<NetworkConfigWithBundler> => {
console.log(1)
const configuredChain = await initAnvilPayload()
const bundlerConfig = await initBundlerInstance({
rpcUrl: configuredChain.rpcUrl
Expand Down Expand Up @@ -143,18 +143,24 @@ export const toBundlerInstance = async ({
export const toConfiguredAnvil = async ({
rpcPort
}: { rpcPort: number }): Promise<AnvilPayload> => {
console.log("toConfiguredAnvil", rpcPort)

const instance = anvil({
hardfork: "Paris",
chainId: anvilChain.id,
port: rpcPort
// forkUrl: "https://base-sepolia.gateway.tenderly.co/2oxlNZ7oiNCUpXzrWFuIHx"
})

console.log("toConfiguredAnvil", 1)

await instance.start()
console.log("toConfiguredAnvil", 2)
const deployment = await deploy(rpcPort)
console.log("toConfiguredAnvil", 3)
return { instance, deployment }
}

export const initAnvilPayload = async (): Promise<AnvilDto> => {
console.log(2)
const rpcPort = await getPort()
const rpcUrl = `http://localhost:${rpcPort}`
const chain = getTestChainFromPort(rpcPort)
Expand Down Expand Up @@ -396,6 +402,8 @@ type Deployment = {
}

const deploy = async (rpcPort: number): Promise<Deployment> => {
console.log("deploy", rpcPort)

const DETERMINISTIC_DEPLOYER = "0x4e59b44847b379578588920ca78fbf26c0b4956c"
const chain = getTestChainFromPort(rpcPort)
const account = getTestAccount()
Expand All @@ -420,6 +428,8 @@ const deploy = async (rpcPort: number): Promise<Deployment> => {
})
])

console.log("deploy 2")

const bootstrapHash = await testClient.deployContract({
bytecode: deployedContracts.Bootstrap.bytecode as Hex,
abi: BootstrapAbi
Expand Down Expand Up @@ -452,6 +462,8 @@ const deploy = async (rpcPort: number): Promise<Deployment> => {
args: [account.address]
})

console.log("deploy 4")

const receipts = await Promise.all([
testClient.waitForTransactionReceipt({ hash: bootstrapHash }),
testClient.waitForTransactionReceipt({ hash: nexusHash }),
Expand Down
7 changes: 1 addition & 6 deletions tests/testSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type NetworkConfigWithTestClients = NetworkConfigWithBundler & {
fundedTestClients: FundedTestClients
}

export const aaTest = test.extend<{
export const scopedTest = test.extend<{
config: NetworkConfigWithTestClients
}>({
// biome-ignore lint/correctness/noEmptyPattern: Needed in vitest :/
Expand All @@ -24,8 +24,3 @@ export const aaTest = test.extend<{
])
}
})

export type TestFileNetworkType = "LOCAL" | "GLOBAL"
export const toNetwork = async (networkType: TestFileNetworkType) =>
// @ts-ignore
await (networkType === "GLOBAL" ? inject("globalNetwork") : initNetwork())
8 changes: 1 addition & 7 deletions tests/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,8 @@ export default defineConfig({
}
},
include: ["tests/**/*.test.ts"],
globalSetup: [join(__dirname, "./globalSetup.ts")],
sequence: {
concurrent: false
},
fileParallelism: true,
environment: "node",
testTimeout: 60_000,
hookTimeout: 45_000,
pool: "forks"
hookTimeout: 60_000
}
})

0 comments on commit 4164966

Please sign in to comment.