Skip to content
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

🏗️ chore: Beta release v4 #1175

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ playwright/.cache

**/ethereum-wallet-mock/cypress
**/metamask/cypress

### Cacheless

**/metamask/downloads
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"**/test-results",
"**/playwright-report",
"**/.cache-synpress",
"**/.vitepress/cache"
"**/.vitepress/cache",
"**/downloads"
]
},
"formatter": {
Expand Down
9 changes: 1 addition & 8 deletions docs/docs/platform-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
While in **alpha**, the compatibility of Synpress is limited, but we're working hard to support more frameworks and platforms as soon as possible.
:::

Synpress, in its current state, is only compatible with Playwright (>=1.39.0) and requires Node 18+. Synpress is compatible with MacOS and Linux.
Synpress, in its current state, is only compatible with Playwright (>=1.39.0) and requires Node 18+. Synpress is compatible with MacOS, Windows, and Linux.

## Supported CI Providers

Expand All @@ -17,10 +17,3 @@ See the [CI](./guides/ci) section for more information about how to set up Synpr
:::

- [GitHub Actions](https://github.com/features/actions)

## Windows

Currently, Synpress is not compatible with Windows. In the meantime, we recommend using WSL.
::: tip NOTE
If you're knowledgeable about working with Windows and the Node.js environment, and you'd like to help us make Synpress compatible with Windows, please reach out to us on our Discord.
:::
1 change: 1 addition & 0 deletions packages/cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"types:check": "tsc --noEmit"
},
"dependencies": {
"app-root-path": "3.1.0",
"axios": "1.6.7",
"chalk": "5.3.0",
"commander": "12.0.0",
Expand Down
13 changes: 0 additions & 13 deletions packages/cache/src/cli/cliEntrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os from 'node:os'
import path from 'node:path'
import chalk from 'chalk'
import { Command } from 'commander'
Expand Down Expand Up @@ -50,18 +49,6 @@ export const cliEntrypoint = async () => {
console.log({ cacheDir: walletSetupDir, ...flags, headless: Boolean(process.env.HEADLESS) ?? false }, '\n')
}

if (os.platform() === 'win32') {
console.log(
[
chalk.redBright('🚨 Sorry, Windows is currently not supported. Please use WSL instead! 🚨'),
chalk.gray(
'If you want to give it a crack over a hot cup of coffee and add Windows support yourself, please get in touch with the team on Discord so we can offer some guidance! 😇'
)
].join('\n')
)
process.exit(1)
}

const compiledWalletSetupDirPath = await compileWalletSetupFunctions(walletSetupDir, flags.debug)

// TODO: We should be using `prepareExtension` function from the wallet itself!
Expand Down
58 changes: 33 additions & 25 deletions packages/cache/src/cli/compileWalletSetupFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import path from 'node:path'
import path, { posix, win32 } from 'node:path'
import { glob } from 'glob'
import { build } from 'tsup'
import { ensureCacheDirExists } from '../ensureCacheDirExists'
import { FIXES_BANNER } from './compilationFixes'

const OUT_DIR_NAME = 'wallet-setup-dist'

const createGlobPattern = (walletSetupDir: string) => path.join(walletSetupDir, '**', '*.setup.{ts,js,mjs}')

export async function compileWalletSetupFunctions(walletSetupDir: string, debug: boolean) {
const outDir = path.join(ensureCacheDirExists(), OUT_DIR_NAME)

const globPattern = createGlobPattern(walletSetupDir)
const fileList = await glob(globPattern)
// Use a normalized glob pattern
const globPattern = path.join(walletSetupDir, '**', '*.setup.{ts,js,mjs}')

// Use glob to find files, ensuring proper path handling
const fileList: string[] = await glob(globPattern, { absolute: false, windowsPathsNoEscape: true })

if (debug) {
console.log('[DEBUG] Found the following wallet setup files:')
Expand All @@ -29,27 +30,34 @@ export async function compileWalletSetupFunctions(walletSetupDir: string, debug:
)
}

await build({
name: 'cli-build',
silent: true,
entry: fileList,
clean: true,
outDir,
format: 'esm',
splitting: true,
sourcemap: false,
config: false,
// TODO: Make this list configurable.
external: ['@synthetixio/synpress', '@playwright/test', 'playwright-core', 'esbuild', 'tsup'],
banner: {
js: FIXES_BANNER
},
esbuildOptions(options) {
// TODO: In this step, if the debug file is present, we should modify `console.log` so it prints from which file the log is coming from.
// We're dropping `console.log` and `debugger` statements because they do not play nicely with the Playwright Test Runner.
options.drop = debug ? [] : ['console', 'debugger']
}
const normalized = fileList.map((file) => {
return file.split(win32.sep).join(posix.sep)
})

try {
await build({
name: 'cli-build',
silent: true,
entry: normalized,
clean: true,
outDir,
format: 'esm',
splitting: true,
sourcemap: false,
config: false,
// TODO: Make this list configurable.
external: ['@synthetixio/synpress', '@playwright/test', 'playwright-core', 'esbuild', 'tsup'],
banner: {
js: FIXES_BANNER
},
esbuildOptions(options) {
// TODO: In this step, if the debug file is present, we should modify `console.log` so it prints from which file the log is coming from.
// We're dropping `console.log` and `debugger` statements because they do not play nicely with the Playwright Test Runner.
options.drop = debug ? [] : ['console', 'debugger']
}
})
} catch (e) {
console.log('error within compile', e)
}
return outDir
}
3 changes: 0 additions & 3 deletions packages/cache/src/createCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ import { triggerCacheCreation } from './utils/triggerCacheCreation'

export async function createCache(walletSetupDirPath: string, downloadExtension: () => Promise<string>, force = false) {
const setupFunctions = await getUniqueWalletSetupFunctions(walletSetupDirPath)

const cacheCreationPromises = await triggerCacheCreation(setupFunctions, downloadExtension, force)

if (cacheCreationPromises.length === 0) {
console.log('No new setup functions to cache. Exiting...')
return
}

// TODO: This line has no unit test. Not sure how to do it. Look into it later.
await Promise.all(cacheCreationPromises)

Expand Down
2 changes: 1 addition & 1 deletion packages/cache/src/defineWalletSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getWalletSetupFuncHash } from './utils/getWalletSetupFuncHash'
// TODO: Should we export this type in the `release` package?
export type WalletSetupFunction = (context: BrowserContext, walletPage: Page) => Promise<void>

// TODO: This runs at least twice. Should we cache it somehow?
// This runs once for each setup file on building cache and setting up fixtures, then it runs once for each worker on e2e:test. Should we cache it somehow?
/**
* This function is used to define how a wallet should be set up.
* Based on the contents of this function, a browser with the wallet extension is set up and cached so that it can be used by the tests later.
Expand Down
1 change: 0 additions & 1 deletion packages/cache/src/utils/getWalletSetupFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ export async function getWalletSetupFiles(walletSetupDirPath: string) {
].join('\n')
)
}

return fileList
}
4 changes: 2 additions & 2 deletions packages/cache/src/utils/importWalletSetupFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const WalletSetupModule = z.object({
})

export async function importWalletSetupFile(walletSetupFilePath: string) {
const walletSetupModule = await import(walletSetupFilePath)

const fileToImport = process.platform === 'win32' ? `file:\\\\\\${walletSetupFilePath}` : walletSetupFilePath
const walletSetupModule = await import(fileToImport)
const result = WalletSetupModule.safeParse(walletSetupModule)
if (!result.success) {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"types:check": "tsc --noEmit"
},
"devDependencies": {
"@synthetixio/synpress-tsconfig": "0.0.1-alpha.7",
"@synthetixio/synpress-tsconfig": "workspace:*",
"@types/node": "20.11.17",
"rimraf": "5.0.5",
"tsup": "8.0.2",
Expand Down
63 changes: 58 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
},
"dependencies": {
"@synthetixio/ethereum-wallet-mock": "0.0.1-alpha.7",
"@synthetixio/synpress-cache": "0.0.1-alpha.7",
"@synthetixio/synpress-core": "0.0.1-alpha.7",
"@synthetixio/synpress-cache": "workspace:*",
"@synthetixio/synpress-core": "workspace:*",
"@synthetixio/synpress-metamask": "0.0.1-alpha.7"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions wallets/metamask/environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ declare global {
interface ProcessEnv {
CI: boolean
HEADLESS: boolean
USE_CACHE: string
}
}
}
Expand Down
Loading
Loading