Skip to content

Commit 2f68d2d

Browse files
committed
chore: add ci/cd pipeline integrated with changeset with auto-publishing.
1 parent afb3d66 commit 2f68d2d

File tree

6 files changed

+196
-1
lines changed

6 files changed

+196
-1
lines changed

.github/workflows/ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches-ignore:
9+
- main
10+
11+
jobs:
12+
build-and-test:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: 18
25+
26+
- name: Install pnpm
27+
uses: pnpm/action-setup@v2
28+
with:
29+
version: 8.9.0
30+
31+
- name: Install dependencies
32+
run: pnpm install
33+
34+
- name: Build
35+
run: pnpm build
36+
37+
- name: Test
38+
run: pnpm test
39+
40+
- name: Check for changeset
41+
run: |
42+
# Only run this check on pull requests
43+
if [[ $GITHUB_EVENT_NAME == 'pull_request' ]]; then
44+
# Check if there are any changes to source files
45+
if git diff --name-only origin/main HEAD | grep -q '^src/'; then
46+
echo "Changes detected in src directory. Checking for changeset..."
47+
# This will exit with non-zero if a changeset is needed but not present
48+
pnpm changeset status
49+
else
50+
echo "No changes to src directory detected. Skipping changeset check."
51+
fi
52+
else
53+
echo "Not a pull request. Skipping changeset check."
54+
fi

.github/workflows/release.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
id-token: write
12+
13+
jobs:
14+
release:
15+
name: Release
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v3
25+
with:
26+
node-version: 18
27+
registry-url: 'https://registry.npmjs.org'
28+
29+
- name: Install pnpm
30+
uses: pnpm/action-setup@v2
31+
with:
32+
version: 8.9.0
33+
34+
- name: Get pnpm store directory
35+
shell: bash
36+
run: |
37+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV
38+
39+
- name: Setup pnpm cache
40+
uses: actions/cache@v3
41+
with:
42+
path: ${{ env.STORE_PATH }}
43+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
44+
restore-keys: |
45+
${{ runner.os }}-pnpm-store-
46+
47+
- name: Install dependencies
48+
run: pnpm install --frozen-lockfile
49+
50+
- name: Run tests
51+
run: pnpm test
52+
53+
- name: Build
54+
run: pnpm build
55+
56+
- name: Create and publish release
57+
id: changesets
58+
uses: changesets/action@v1
59+
with:
60+
publish: pnpm publish -r
61+
commit: 'chore: version packages'
62+
title: 'chore: version packages'
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
66+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

COMMIT_CONVENTION.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Commit Message Convention
2+
3+
This project follows the [Conventional Commits](https://www.conventionalcommits.org/) specification for commit messages. This helps automatically determine version numbers and generate changelogs.
4+
5+
## Format
6+
7+
```
8+
<type>(<scope>): <description>
9+
10+
[optional body]
11+
12+
[optional footer(s)]
13+
```
14+
15+
### Types
16+
17+
- `feat!:` or `fix!:` - Breaking change (triggers major version bump)
18+
- `feat:` - A new feature (triggers minor version bump)
19+
- `fix:` - A bug fix (triggers patch version bump)
20+
- `docs:` - Documentation only changes
21+
- `style:` - Changes that do not affect the meaning of the code
22+
- `refactor:` - A code change that neither fixes a bug nor adds a feature
23+
- `perf:` - A code change that improves performance
24+
- `test:` - Adding missing tests or correcting existing tests
25+
- `chore:` - Changes to the build process or auxiliary tools
26+
27+
### Examples
28+
29+
```
30+
feat(api): add new endpoint for user authentication
31+
32+
This new endpoint allows users to authenticate using OAuth2.
33+
34+
BREAKING CHANGE: `auth` endpoint now requires OAuth2 token
35+
```
36+
37+
```
38+
fix(database): resolve connection timeout issue
39+
40+
Increased connection timeout from 5s to 15s
41+
```
42+
43+
```
44+
docs: update README with new API documentation
45+
```
46+
47+
## Changelog Generation
48+
49+
Commit messages are used to:
50+
1. Automatically determine the next version number
51+
2. Generate changelog entries
52+
3. Create GitHub releases
53+
54+
The process is automated through GitHub Actions and uses changesets for release management.

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,26 @@ These examples showcase MyCoder's ability to handle complex software development
124124

125125
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for our development workflow, coding guidelines, and testing procedures.
126126

127+
## Development Workflow
128+
129+
### Commit Messages
130+
131+
This project uses [Conventional Commits](https://www.conventionalcommits.org/) for commit messages. See [COMMIT_CONVENTION.md](COMMIT_CONVENTION.md) for detailed guidelines.
132+
133+
### CI/CD Pipeline
134+
135+
The project uses GitHub Actions for continuous integration and deployment:
136+
137+
- **Non-main branches**: Automatically builds and tests the code
138+
- **Main branch**: Automatically creates releases and publishes to npm
139+
140+
The release process is managed using [changesets](https://github.com/changesets/changesets) which:
141+
1. Determines version bumps based on commit messages
142+
2. Generates changelogs
143+
3. Creates GitHub releases
144+
4. Publishes to npm
145+
146+
127147
## License
128148

129149
MIT License

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"format": "prettier --write \"src/**/*.*\"",
2727
"test": "vitest run",
2828
"test:watch": "vitest",
29+
"test:ci": "vitest --run --coverage",
2930
"changeset": "changeset",
3031
"version": "changeset version",
3132
"prepublishOnly": "pnpm run clean && pnpm run build && pnpm run test"

src/core/toolAgent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ export const toolAgent = async (
239239
.map((c) => (c as TextContent).text)
240240
.join("\\n");
241241
if (assistantMessage) {
242-
logger.debug("Assistant message:", assistantMessage);
242+
logger.info(assistantMessage);
243243
}
244244

245245
const { sequenceCompleted, completionResult } = await executeTools(

0 commit comments

Comments
 (0)