Skip to content

Commit

Permalink
add lint check and more test runners to CI (LIT-Protocol#284)
Browse files Browse the repository at this point in the history
* fix issue with default init

* fix tests

* add lint check to ci and more test runners

* fmt

* filter tests

* add build and flags to install for ci tests

* remove postbuild step from ecdsa-sdk

* fmt

* run all unit tests
  • Loading branch information
Bean authored Dec 16, 2023
1 parent 683c0d1 commit 8eb5ca1
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 54 deletions.
25 changes: 22 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,28 @@ jobs:
node-version: '18'
cache: 'yarn'
- name: Install project dependencies
run: yarn install
run: yarn --frozen-lockfile
- uses: nrwl/nx-set-shas@v3
with:
main-branch-name: 'master'
- name: Run tests
run: npx nx test
- name: Build
run: yarn build
- name: Run Unit tests
run: yarn tools --test --unit
linter:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'yarn'
- name: Install project dependencies
run: yarn install
- name: Lint
run: yarn prettier:check
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"b": "git branch --show",
"txServer": "node tx-handler-server.mjs",
"prettier": "nx format:write --all",
"prettier:check": "nx format:check --all",
"delete:merged-branches": "git branch --merged | egrep -v '(^\\*|master|main|develop)' | xargs git branch -d",
"delete:no-merged-branches": "git branch --no-merged | egrep -v '(^\\*|master|main|develop)' | xargs git branch -d",
"cache:enable": "node ./tools/scripts/endisable-cache.mjs --enable=true",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/lit-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class LitCore {
alertWhenUnauthorized: false,
debug: true,
connectTimeout: 20000,
litNetwork: '', // Default value, should be replaced
litNetwork: 'cayenne', // Default to cayenne network. will be replaced by custom config.
minNodeCount: 2, // Default value, should be replaced
bootstrapUrls: [], // Default value, should be replaced
};
Expand Down
3 changes: 3 additions & 0 deletions packages/ecdsa-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"directory": "../../dist/packages/ecdsa-sdk"
},
"gitHead": "0d7334c2c55f448e91fe32f29edc5db8f5e09e4b",
"peerDependencies": {
"pako": "^2.1.0"
},
"tags": [
"universal"
],
Expand Down
27 changes: 0 additions & 27 deletions packages/ecdsa-sdk/postBuild.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion packages/ecdsa-sdk/src/lib/ecdsa-sdk.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-nocheck
import pako from 'pako';
import * as pako from 'pako';

// Contants

Expand Down
14 changes: 0 additions & 14 deletions packages/misc/src/lib/misc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,6 @@ describe('utils', () => {
// expect(values).toContain(LIT_ERROR.INVALID_PARAM_TYPE.name);
// });

it('should prepend [Lit-JS-SDK] in the console.log', () => {
console.log = jest.fn();

// turn on debug mode so that it prints stuff
globalThis.litConfig = { debug: true };

utilsModule.log('foo', 'bar', 'hola');

// expect((console.log as any).mock.calls[0][0]).toBe('[Lit-JS-SDK]');
expect((console.log as any).mock.calls[0][1]).toBe('foo');
expect((console.log as any).mock.calls[0][2]).toBe('bar');
expect((console.log as any).mock.calls[0][3]).toBe('hola');
});

it('should get value type by a given value', () => {
const fooString = 'fooString';
const fooBool = true;
Expand Down
22 changes: 14 additions & 8 deletions packages/misc/src/lib/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ export const log = (...args: any): void => {
// if there are there are logs in buffer, print them first and empty the buffer.
while (logBuffer.length > 0) {
const log = logBuffer.shift() ?? '';
globalThis?.logger.debug(...log);
globalThis?.logger && globalThis?.logger.debug(...log);
}

globalThis?.logger.debug(...args);
globalThis?.logger && globalThis?.logger.debug(...args);
};

export const logWithRequestId = (id: string, ...args: any) => {
Expand All @@ -278,10 +278,12 @@ export const logWithRequestId = (id: string, ...args: any) => {
// if there are there are logs in buffer, print them first and empty the buffer.
while (logBuffer.length > 0) {
const log = logBuffer.shift() ?? '';
globalThis.logManager.get(globalThis.logger.category, id).debug(...log);
globalThis?.logger &&
globalThis.logManager.get(globalThis.logger.category, id).debug(...log);
}

globalThis.logManager.get(globalThis.logger.category, id).debug(...args);
globalThis?.logger &&
globalThis.logManager.get(globalThis.logger.category, id).debug(...args);
};

export const logErrorWithRequestId = (id: string, ...args: any) => {
Expand All @@ -306,10 +308,12 @@ export const logErrorWithRequestId = (id: string, ...args: any) => {
// if there are there are logs in buffer, print them first and empty the buffer.
while (logBuffer.length > 0) {
const log = logBuffer.shift() ?? '';
globalThis.logManager.get(globalThis.logger.category, id).error(...log);
globalThis?.logger &&
globalThis.logManager.get(globalThis.logger.category, id).error(...log);
}

globalThis.logManager.get(globalThis.logger.category, id).error(...args);
globalThis?.logger &&
globalThis.logManager.get(globalThis.logger.category, id).error(...args);
};

export const logError = (...args: any) => {
Expand All @@ -334,10 +338,12 @@ export const logError = (...args: any) => {
// if there are there are logs in buffer, print them first and empty the buffer.
while (logBuffer.length > 0) {
const log = logBuffer.shift() ?? '';
globalThis.logManager.get(globalThis.logger.category).error(...log);
globalThis?.logger &&
globalThis.logManager.get(globalThis.logger.category).error(...log);
}

globalThis.logManager.get(globalThis.logger.category).error(...args);
globalThis?.logger &&
globalThis.logManager.get(globalThis.logger.category).error(...args);
};

/**
Expand Down
6 changes: 6 additions & 0 deletions packages/pkp-walletconnect/src/lib/pkp-walletconnect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ describe('PKPWalletConnect', () => {
});
});

/* Currently gives an SSR error requiring storage middleware.
>
To use WalletConnect server side, you'll need to install the "unstorage" dependency.
If you are seeing this error during a build / in an SSR environment, you can add "unstorage" as a devDependency to make this error go away.
<
describe('initWalletConnect', () => {
it('should initialize WalletConnect', async () => {
const config = {
Expand All @@ -117,4 +122,5 @@ describe('PKPWalletConnect', () => {
expect(pkpWalletConnect.getSignClient()).toBeDefined();
});
});
*/
});

0 comments on commit 8eb5ca1

Please sign in to comment.