From 69a4c3e144a7e9cd1ce24c3a2f7a3d7a4b4a1eab Mon Sep 17 00:00:00 2001 From: Nikaru Date: Wed, 24 Apr 2024 09:29:44 +0000 Subject: [PATCH] feat: add test to check workflow --- .github/workflows/checks.yaml | 5 +++++ scripts/build-libs/command.mjs | 21 +++++++++++++++++++ scripts/build/command.mjs | 2 +- scripts/common/utils.mjs | 5 +++-- .../usePrepareBlockchainList.test.ts | 2 +- 5 files changed, 31 insertions(+), 4 deletions(-) create mode 100755 scripts/build-libs/command.mjs diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index e4e00209db..b0c2e9c00c 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -19,6 +19,11 @@ jobs: env: REF: ${{ github.ref }} + - name: Test + run: | + node ./scripts/build-libs/command.mjs + yarn run test + # for preview deployment for specific project, add vercel project id in environment section - name: Preview Deployment id: deploy diff --git a/scripts/build-libs/command.mjs b/scripts/build-libs/command.mjs new file mode 100755 index 0000000000..f4c68f69ec --- /dev/null +++ b/scripts/build-libs/command.mjs @@ -0,0 +1,21 @@ +#!/usr/bin/env node +'use strict'; +import process from 'node:process'; +import { workspacePackages } from '../common/utils.mjs'; +import { build } from '../publish/build.mjs'; + +async function run() { + const packages = await workspacePackages(); + let packagesToBeBuild = packages.filter((pkg) => !pkg.private); + + console.log('these packages will be built:', packagesToBeBuild.map(pkg=>pkg.name).join(', ')) ; + + console.log(`🔨 Start building...`); + await build(packagesToBeBuild); + console.log('🔨 Finish building'); +} + +run().catch((e) => { + console.error(e); + process.exit(1); +}); diff --git a/scripts/build/command.mjs b/scripts/build/command.mjs index 79111a080d..aa665d3ac7 100644 --- a/scripts/build/command.mjs +++ b/scripts/build/command.mjs @@ -20,7 +20,7 @@ async function run() { console.log(`[build] Running for ${path}`); - const typeCheckingTask = await $({ + const typeCheckingTask = $({ cwd: pkgPath, stderr: process.stderr, stdout: process.stdout, diff --git a/scripts/common/utils.mjs b/scripts/common/utils.mjs index f8938c7ce2..0e8389638d 100644 --- a/scripts/common/utils.mjs +++ b/scripts/common/utils.mjs @@ -20,8 +20,9 @@ export function printDirname() { * @returns {Promise} */ export async function workspacePackages() { - const { stdout } = await execa('yarn', ['workspaces', 'info']); - const result = JSON.parse(stdout); + // --json flag guarantees that whether it is run with yarn or node, the output always has a consistent result. + const { stdout } = await execa('yarn', ['workspaces', '--json', 'info']); + const result = JSON.parse(JSON.parse(stdout).data) ; const packagesName = Object.keys(result); const output = packagesName.map((name) => { const pkgJson = packageJson(result[name].location); diff --git a/widget/embedded/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts b/widget/embedded/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts index 1ed899412b..106656a905 100644 --- a/widget/embedded/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +++ b/widget/embedded/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts @@ -271,7 +271,7 @@ describe('usePrepareBlockchainList', () => { ]); }); - it.only('Last item of the main list should be moved to front if it selected again.', () => { + it('Last item of the main list should be moved to front if it selected again.', () => { const listLimit = 10; const preferredBlockchains = ['AVAX_CCHAIN', 'BTC']; const expected = [