Skip to content

feat(ops): fix Github action to publish on NPM #45

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

Merged
Merged
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
1 change: 0 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
27 changes: 27 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#! /bin/sh

GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'

echo "🪜 Incrementing version number"
npm version patch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For your case of releasing a TS SDK that's a major/minor, we temporarily add the right level we want to release, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There hasn't been any traction to the idea of bumping to minor so for the moment we'll only be releasing patches i think


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 🎸"
6 changes: 6 additions & 0 deletions tests/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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: [
{
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/openai.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ describe('OpenAI Instrumentation', () => {
});
});

await new Promise((resolve) => setTimeout(resolve, 1000));

const {
data: [step]
} = await client.api.getSteps({
Expand All @@ -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();
Expand Down Expand Up @@ -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);
});
});
Loading