diff --git a/.github/workflows/merge_queue.yml b/.github/workflows/merge_queue.yml index 5010d766f..35f13c7ca 100644 --- a/.github/workflows/merge_queue.yml +++ b/.github/workflows/merge_queue.yml @@ -12,7 +12,7 @@ concurrency: jobs: checks: name: Run health check and unit tests - runs-on: ubuntu-latest + runs-on: ledgerhq-device-sdk steps: - uses: actions/checkout@v4 @@ -25,4 +25,4 @@ jobs: - name: Tests id: unit-tests if: ${{ steps.health-check.conclusion == 'success' }} - run: pnpm test + run: pnpm test -- -- --maxWorkers=50% diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 93c652893..04293c013 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -51,10 +51,10 @@ jobs: - name: Tests id: unit-tests if: ${{ steps.health-check.conclusion == 'success' }} - run: pnpm test:coverage -- --max-warnings=0 + run: pnpm test:coverage -- --maxWorkers=50% - uses: sonarsource/sonarqube-scan-action@v4 - if: ${{ steps.unit-tests.conclusion == 'success' && github.actor != 'dependabot[bot]' && github.event.pull_request.head.repo.fork == 'false' }} + if: ${{ steps.unit-tests.conclusion == 'success' && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }} env: SONAR_TOKEN: ${{ secrets.PUBLIC_GREEN_SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.PUBLIC_SONAR_HOST_URL }} diff --git a/.github/workflows/update_toolchain.yml b/.github/workflows/update_toolchain.yml index 307ea4147..8ae5d842f 100644 --- a/.github/workflows/update_toolchain.yml +++ b/.github/workflows/update_toolchain.yml @@ -52,7 +52,7 @@ jobs: - name: Tests id: unit-tests if: steps.changes.outputs.status > 0 && success() - run: pnpm test:coverage -- --max-warnings=0 + run: pnpm test:coverage -- --maxWorkers=50% - name: Create PR if: steps.changes.outputs.status > 0 && success() diff --git a/package.json b/package.json index 6b84439c7..1bc3676eb 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "private": true, "license": "Apache-2.0", "scripts": { + "clean": "rimraf -g **/.turbo **/.next **/coverage", "build": "turbo run build", "build:libs": "turbo run build --filter=./packages/**", "dev": "turbo run dev", diff --git a/packages/device-management-kit/jest.config.ts b/packages/device-management-kit/jest.config.ts index c6a529255..74ed7a246 100644 --- a/packages/device-management-kit/jest.config.ts +++ b/packages/device-management-kit/jest.config.ts @@ -11,6 +11,7 @@ const config: JestConfigWithTsJest = { preset: "@ledgerhq/jest-config-dsdk", setupFiles: ["/jest.setup.ts"], testPathIgnorePatterns: ["/lib/esm", "/lib/cjs"], + modulePathIgnorePatterns: ["/lib/esm", "/lib/cjs"], collectCoverageFrom: [ "src/**/*.ts", "!src/**/*.stub.ts", diff --git a/packages/device-management-kit/src/internal/device-session/service/DefaultDeviceSessionService.test.ts b/packages/device-management-kit/src/internal/device-session/service/DefaultDeviceSessionService.test.ts index 728541b39..404e4093a 100644 --- a/packages/device-management-kit/src/internal/device-session/service/DefaultDeviceSessionService.test.ts +++ b/packages/device-management-kit/src/internal/device-session/service/DefaultDeviceSessionService.test.ts @@ -38,47 +38,44 @@ describe("DefaultDeviceSessionService", () => { ); }); + afterEach(() => { + deviceSession.close(); + }); + it("should have an empty sessions list", () => { expect(sessionService.getDeviceSessions()).toEqual([]); - deviceSession.close(); }); it("should add a deviceSession", () => { sessionService.addDeviceSession(deviceSession); - deviceSession.close(); expect(sessionService.getDeviceSessions()).toEqual([deviceSession]); }); it("should not add a deviceSession if it already exists", () => { sessionService.addDeviceSession(deviceSession); sessionService.addDeviceSession(deviceSession); - deviceSession.close(); expect(sessionService.getDeviceSessions()).toEqual([deviceSession]); }); it("should remove a deviceSession", () => { sessionService.addDeviceSession(deviceSession); - deviceSession.close(); sessionService.removeDeviceSession(deviceSession.id); expect(sessionService.getDeviceSessions()).toEqual([]); }); it("should not remove a deviceSession if it does not exist", () => { - deviceSession.close(); sessionService.removeDeviceSession(deviceSession.id); expect(sessionService.getDeviceSessions()).toEqual([]); }); it("should get a deviceSession", () => { sessionService.addDeviceSession(deviceSession); - deviceSession.close(); expect(sessionService.getDeviceSessionById(deviceSession.id)).toEqual( Either.of(deviceSession), ); }); it("should not get a deviceSession if it does not exist", () => { - deviceSession.close(); expect(sessionService.getDeviceSessionById(deviceSession.id)).toEqual( Left(new DeviceSessionNotFound()), ); @@ -86,7 +83,6 @@ describe("DefaultDeviceSessionService", () => { it("should get all sessions", () => { sessionService.addDeviceSession(deviceSession); - deviceSession.close(); expect(sessionService.getDeviceSessions()).toEqual([deviceSession]); }); @@ -94,7 +90,6 @@ describe("DefaultDeviceSessionService", () => { expect(sessionService.sessionsObs).toBeInstanceOf( Observable, ); - deviceSession.close(); }); it("should emit new session", (done) => { @@ -106,7 +101,6 @@ describe("DefaultDeviceSessionService", () => { }, }); sessionService.addDeviceSession(deviceSession); - deviceSession.close(); }); it("should emit previous added session", () => { @@ -124,7 +118,6 @@ describe("DefaultDeviceSessionService", () => { emittedSessions.push(emittedDeviceSession); }, }); - deviceSession.close(); lastDeviceSession.close(); expect(emittedSessions).toEqual([deviceSession, lastDeviceSession]); subscription.unsubscribe(); diff --git a/packages/device-management-kit/src/internal/discovery/use-case/ConnectUseCase.test.ts b/packages/device-management-kit/src/internal/discovery/use-case/ConnectUseCase.test.ts index cdeb03f85..87c60167d 100644 --- a/packages/device-management-kit/src/internal/discovery/use-case/ConnectUseCase.test.ts +++ b/packages/device-management-kit/src/internal/discovery/use-case/ConnectUseCase.test.ts @@ -57,6 +57,12 @@ describe("ConnectUseCase", () => { managerApi = new DefaultManagerApiService(managerApiDataSource); }); + afterEach(() => { + for (const session of sessionService.getDeviceSessions()) { + sessionService.removeDeviceSession(session.id); + } + }); + afterAll(() => { jest.restoreAllMocks(); }); @@ -94,5 +100,6 @@ describe("ConnectUseCase", () => { device: stubDiscoveredDevice, }); expect(sessionId).toBe(fakeSessionId); + sessionService.removeDeviceSession(sessionId); }); }); diff --git a/packages/flipper-plugin-client/jest.config.ts b/packages/flipper-plugin-client/jest.config.ts index e707da060..c92979750 100644 --- a/packages/flipper-plugin-client/jest.config.ts +++ b/packages/flipper-plugin-client/jest.config.ts @@ -4,6 +4,7 @@ import type { JestConfigWithTsJest } from "ts-jest"; const config: JestConfigWithTsJest = { preset: "@ledgerhq/jest-config-dsdk", testPathIgnorePatterns: ["/lib/esm", "/lib/cjs"], + modulePathIgnorePatterns: ["/lib/esm", "/lib/cjs"], collectCoverageFrom: [ "src/**/*.ts", "!src/**/*.stub.ts", diff --git a/packages/signer/context-module/jest.config.ts b/packages/signer/context-module/jest.config.ts index eeaaf2c1c..94638a5bf 100644 --- a/packages/signer/context-module/jest.config.ts +++ b/packages/signer/context-module/jest.config.ts @@ -11,6 +11,7 @@ const config: JestConfigWithTsJest = { preset: "@ledgerhq/jest-config-dsdk", setupFiles: ["/jest.setup.ts"], testPathIgnorePatterns: ["/lib/esm", "/lib/cjs"], + modulePathIgnorePatterns: ["/lib/esm", "/lib/cjs"], collectCoverageFrom: [ "src/**/*.ts", "!src/**/*.stub.ts", diff --git a/packages/signer/signer-btc/jest.config.ts b/packages/signer/signer-btc/jest.config.ts index eeaaf2c1c..94638a5bf 100644 --- a/packages/signer/signer-btc/jest.config.ts +++ b/packages/signer/signer-btc/jest.config.ts @@ -11,6 +11,7 @@ const config: JestConfigWithTsJest = { preset: "@ledgerhq/jest-config-dsdk", setupFiles: ["/jest.setup.ts"], testPathIgnorePatterns: ["/lib/esm", "/lib/cjs"], + modulePathIgnorePatterns: ["/lib/esm", "/lib/cjs"], collectCoverageFrom: [ "src/**/*.ts", "!src/**/*.stub.ts", diff --git a/packages/signer/signer-eth/jest.config.ts b/packages/signer/signer-eth/jest.config.ts index 92277f0eb..525574abd 100644 --- a/packages/signer/signer-eth/jest.config.ts +++ b/packages/signer/signer-eth/jest.config.ts @@ -11,6 +11,7 @@ const config: JestConfigWithTsJest = { preset: "@ledgerhq/jest-config-dsdk", setupFiles: ["/jest.setup.ts"], testPathIgnorePatterns: ["/lib/esm", "/lib/cjs"], + modulePathIgnorePatterns: ["/lib/esm", "/lib/cjs"], collectCoverageFrom: [ "src/**/*.ts", "!src/**/*.stub.ts", diff --git a/packages/signer/signer-solana/jest.config.ts b/packages/signer/signer-solana/jest.config.ts index 92277f0eb..525574abd 100644 --- a/packages/signer/signer-solana/jest.config.ts +++ b/packages/signer/signer-solana/jest.config.ts @@ -11,6 +11,7 @@ const config: JestConfigWithTsJest = { preset: "@ledgerhq/jest-config-dsdk", setupFiles: ["/jest.setup.ts"], testPathIgnorePatterns: ["/lib/esm", "/lib/cjs"], + modulePathIgnorePatterns: ["/lib/esm", "/lib/cjs"], collectCoverageFrom: [ "src/**/*.ts", "!src/**/*.stub.ts", diff --git a/packages/signer/signer-utils/jest.config.ts b/packages/signer/signer-utils/jest.config.ts index 92277f0eb..525574abd 100644 --- a/packages/signer/signer-utils/jest.config.ts +++ b/packages/signer/signer-utils/jest.config.ts @@ -11,6 +11,7 @@ const config: JestConfigWithTsJest = { preset: "@ledgerhq/jest-config-dsdk", setupFiles: ["/jest.setup.ts"], testPathIgnorePatterns: ["/lib/esm", "/lib/cjs"], + modulePathIgnorePatterns: ["/lib/esm", "/lib/cjs"], collectCoverageFrom: [ "src/**/*.ts", "!src/**/*.stub.ts", diff --git a/packages/transport-mock/jest.config.ts b/packages/transport-mock/jest.config.ts index e707da060..c92979750 100644 --- a/packages/transport-mock/jest.config.ts +++ b/packages/transport-mock/jest.config.ts @@ -4,6 +4,7 @@ import type { JestConfigWithTsJest } from "ts-jest"; const config: JestConfigWithTsJest = { preset: "@ledgerhq/jest-config-dsdk", testPathIgnorePatterns: ["/lib/esm", "/lib/cjs"], + modulePathIgnorePatterns: ["/lib/esm", "/lib/cjs"], collectCoverageFrom: [ "src/**/*.ts", "!src/**/*.stub.ts", diff --git a/turbo.json b/turbo.json index 22ffdaaf4..b1b152f86 100644 --- a/turbo.json +++ b/turbo.json @@ -8,20 +8,16 @@ "inputs": ["src/**/*.ts", "index.ts"] }, "lint": { - "dependsOn": ["build"], - "outputs": [] + "dependsOn": ["build"] }, "lint:fix": { - "dependsOn": ["build"], - "outputs": [] + "dependsOn": ["build"] }, "prettier": { - "dependsOn": ["^prettier"], - "outputs": [] + "dependsOn": ["^prettier"] }, "prettier:fix": { - "dependsOn": ["^prettier:fix"], - "outputs": [] + "dependsOn": ["^prettier:fix"] }, "dev": { "cache": false, @@ -29,17 +25,21 @@ }, "test": { "dependsOn": ["^build"], - "outputs": [], - "inputs": ["src/**/*.ts", "tests/**/*.ts"] + "inputs": ["src/**/*.ts"] }, "test:coverage": { "dependsOn": ["^build"], "outputs": ["coverage/**"], - "inputs": ["src/**/*.ts", "tests/**/*.ts"] + "inputs": ["src/**/*.ts"] }, "typecheck": { - "dependsOn": ["^build", "^typecheck"], - "outputs": [] + "dependsOn": ["^build", "^typecheck"] + }, + "@ledgerhq/device-management-kit-sample#typecheck": { + "dependsOn": ["build", "^typecheck"] + }, + "@ledgerhq/ledger-dmk-docs#typecheck": { + "dependsOn": ["build", "^typecheck"] }, "health-check": { "dependsOn": ["build", "prettier", "lint", "typecheck"]