From e62d7732ff1a44cd1149dfa6c92942c954d22c3c Mon Sep 17 00:00:00 2001 From: Damien BUTY Date: Thu, 18 Jul 2024 09:21:19 +0200 Subject: [PATCH 1/2] feat(ci): add release script and fix github publish action --- .github/workflows/publish.yaml | 1 - package-lock.json | 4 ++-- package.json | 5 +++-- release.sh | 27 +++++++++++++++++++++++++++ tests/api.test.ts | 6 ++++++ tests/integration/openai.test.ts | 6 ++++-- 6 files changed, 42 insertions(+), 7 deletions(-) create mode 100755 release.sh diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 94864a3..6a582e5 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -12,7 +12,6 @@ jobs: needs: [tests] steps: - uses: actions/checkout@v4 - # Setup .npmrc file to publish to npm - uses: actions/setup-node@v3 with: node-version: '19.x' diff --git a/package-lock.json b/package-lock.json index 0cccf5d..8f4b98e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@literalai/client", - "version": "0.0.510", + "version": "0.0.511", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@literalai/client", - "version": "0.0.510", + "version": "0.0.511", "license": "Apache-2.0", "dependencies": { "axios": "^1.6.2", diff --git a/package.json b/package.json index f7f7fc7..55c2d6b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@literalai/client", - "version": "0.0.510", + "version": "0.0.511", "description": "", "exports": { ".": { @@ -15,7 +15,8 @@ "scripts": { "build": "tsup ./src", "test": "jest --detectOpenHandles --runInBand --watchAll=false", - "prepare": "husky install" + "prepare": "husky install", + "release": "./release.sh" }, "author": "Literal AI", "license": "Apache-2.0", diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..3f25437 --- /dev/null +++ b/release.sh @@ -0,0 +1,27 @@ +#! /bin/sh + +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' + +echo "🪜 Incrementing version number" +npm version patch + +NEW_VERSION=$(npm pkg get version | tr -d '"') + +echo "🌿 Creating release branch for v$NEW_VERSION" +git checkout -b release/$NEW_VERSION +git add . +git commit -m "chore: bump to $NEW_VERSION" +git push origin release/$NEW_VERSION + +echo +echo +echo -e "----------------------------------------" +echo -e "|| ${GREEN} Your release is ready for review ${NC} ||" +echo -e "----------------------------------------" +echo -e "1️⃣ Go to ${YELLOW}https://github.com/Chainlit/typescript-client/compare/main...release/$NEW_VERSION${NC}" +echo -e "2️⃣ Create a pull request and merge it to main" +echo -e "3️⃣ Go to ${YELLOW}https://github.com/Chainlit/typescript-client/actions/workflows/publish.yaml${NC}" +echo -e "4️⃣ Click on 'Run workflow'" +echo -e "5️⃣ Rock'n'roll 🎸" \ No newline at end of file diff --git a/tests/api.test.ts b/tests/api.test.ts index 490573f..0522925 100644 --- a/tests/api.test.ts +++ b/tests/api.test.ts @@ -182,6 +182,8 @@ describe('End to end tests for the SDK', function () { }) .send(); + await new Promise((resolve) => setTimeout(resolve, 1000)); + const fetchedStep = await client.api.getStep(step.id!); expect(fetchedStep?.id).toBe(step.id); expect(fetchedStep?.error).toBe('test'); @@ -214,6 +216,8 @@ describe('End to end tests for the SDK', function () { }) .send(); + await new Promise((resolve) => setTimeout(resolve, 1000)); + const fetchedStep = await client.api.getStep(step.id!); expect(fetchedStep?.id).toBe(step.id); expect(fetchedStep?.error).toBe('test'); @@ -241,6 +245,8 @@ describe('End to end tests for the SDK', function () { throw new Error('Step id is null'); } + await new Promise((resolve) => setTimeout(resolve, 1000)); + const steps = await client.api.getSteps({ filters: [ { diff --git a/tests/integration/openai.test.ts b/tests/integration/openai.test.ts index 652e48e..4391961 100644 --- a/tests/integration/openai.test.ts +++ b/tests/integration/openai.test.ts @@ -290,6 +290,8 @@ describe('OpenAI Instrumentation', () => { }); }); + await new Promise((resolve) => setTimeout(resolve, 1000)); + const { data: [step] } = await client.api.getSteps({ @@ -305,7 +307,7 @@ describe('OpenAI Instrumentation', () => { expect(step?.threadId).toBe(threadId); expect(step?.parentId).toBe(parentId); - }); + }, 30_000); it("doesn't mix up threads and steps", async () => { const testId = uuidv4(); @@ -399,6 +401,6 @@ describe('OpenAI Instrumentation', () => { expect(firstGeneration?.parentId).toEqual(firstStep?.id); expect(secondGeneration?.threadId).toEqual(secondThreadId); expect(secondGeneration?.parentId).toEqual(secondStep?.id); - }, 30000); + }, 30_000); }); }); From 06c78f21116cb521631a6cd8016703041a730c4c Mon Sep 17 00:00:00 2001 From: Damien BUTY Date: Thu, 18 Jul 2024 10:58:04 +0200 Subject: [PATCH 2/2] chore: fix version number --- package-lock.json | 4 ++-- package.json | 2 +- release.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8f4b98e..0cccf5d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@literalai/client", - "version": "0.0.511", + "version": "0.0.510", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@literalai/client", - "version": "0.0.511", + "version": "0.0.510", "license": "Apache-2.0", "dependencies": { "axios": "^1.6.2", diff --git a/package.json b/package.json index 55c2d6b..3340d0e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@literalai/client", - "version": "0.0.511", + "version": "0.0.510", "description": "", "exports": { ".": { diff --git a/release.sh b/release.sh index 3f25437..4864420 100755 --- a/release.sh +++ b/release.sh @@ -24,4 +24,4 @@ echo -e "1️⃣ Go to ${YELLOW}https://github.com/Chainlit/typescript-client/c echo -e "2️⃣ Create a pull request and merge it to main" echo -e "3️⃣ Go to ${YELLOW}https://github.com/Chainlit/typescript-client/actions/workflows/publish.yaml${NC}" echo -e "4️⃣ Click on 'Run workflow'" -echo -e "5️⃣ Rock'n'roll 🎸" \ No newline at end of file +echo -e "5️⃣ Rock'n'roll 🎸"