mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 02:19:28 +00:00
Merge pull request #66 from shumaiOne/feature/test-local-release-in-ci
ci: test local release and CLI execution in CI
This commit is contained in:
@@ -42,3 +42,10 @@ jobs:
|
||||
|
||||
- name: Test
|
||||
run: bun run test
|
||||
|
||||
- name: Test Local Release
|
||||
run: |
|
||||
bun run release:local --skip-check --out /tmp/shumai-local-release --force
|
||||
cd /tmp/shumai-local-release/node
|
||||
npx shumai-agent
|
||||
npx shumai-transcode
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { temporalWorkflow } from './bun-temporal-plugin'
|
||||
import * as worker from '@temporalio/worker'
|
||||
|
||||
vi.mock('@temporalio/worker', () => ({
|
||||
bundleWorkflowCode: vi.fn().mockResolvedValue({ code: 'mock-code', sourceMap: '' })
|
||||
}))
|
||||
|
||||
describe('temporalWorkflow plugin', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('should register onLoad and configure webpackConfigHook with @temporalio/workflow alias', async () => {
|
||||
const plugin = temporalWorkflow()
|
||||
|
||||
let onLoadCallback: ((...args: unknown[]) => unknown) | null = null
|
||||
|
||||
const mockBuild = {
|
||||
onResolve: vi.fn(),
|
||||
onLoad: vi.fn((opts, callback) => {
|
||||
onLoadCallback = callback
|
||||
})
|
||||
}
|
||||
|
||||
// Run setup
|
||||
// @ts-ignore
|
||||
plugin.setup(mockBuild)
|
||||
|
||||
expect(onLoadCallback).toBeDefined()
|
||||
|
||||
// Trigger onLoad callback
|
||||
await onLoadCallback!({ path: 'dummy-path' })
|
||||
|
||||
// Verify bundleWorkflowCode was called
|
||||
expect(worker.bundleWorkflowCode).toHaveBeenCalled()
|
||||
|
||||
// Webpack's configuration type is complex and varies across versions.
|
||||
// We cast it to any here to allow indexing the config aliases dynamically.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const callArgs = vi.mocked(worker.bundleWorkflowCode).mock.calls[0][0] as any
|
||||
expect(callArgs.webpackConfigHook).toBeDefined()
|
||||
|
||||
// Invoke the hook with a dummy config
|
||||
const config = { resolve: { alias: {} } }
|
||||
const updatedConfig = callArgs.webpackConfigHook(config)
|
||||
|
||||
// Check that aliases are set
|
||||
expect(updatedConfig.resolve.alias['@shumai/workflow-core']).toBeDefined()
|
||||
expect(updatedConfig.resolve.alias['@temporalio/workflow']).toBeDefined()
|
||||
})
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
import { bundleWorkflowCode } from '@temporalio/worker'
|
||||
import type { BunPlugin } from 'bun'
|
||||
import { resolve } from 'node:path'
|
||||
import { resolve, dirname } from 'node:path'
|
||||
|
||||
export interface TemporalWorkflowPluginOptions {
|
||||
/** Query param identifier. Default: 'workflow' */
|
||||
@@ -47,6 +47,9 @@ export function temporalWorkflow(options: TemporalWorkflowPluginOptions = {}): B
|
||||
...config.resolve.alias,
|
||||
'@shumai/workflow-core':
|
||||
require.resolve('@shumai/workflow-core/src/workflow-utils.ts'),
|
||||
'@temporalio/workflow': dirname(
|
||||
require.resolve('@temporalio/workflow/package.json'),
|
||||
),
|
||||
}
|
||||
console.log('Webpack config aliases:', config.resolve.alias)
|
||||
if (originalHook) {
|
||||
|
||||
Reference in New Issue
Block a user