Skip to content

Commit 9ee9bd9

Browse files
committed
feat: update TypeScript configuration and add CI/CD workflows
- Removed outDir and rootDir from tsconfig.json - Added GitHub Actions CI workflow for testing and building - Created publish workflow for npm packages on version tags - Implemented release workflow for version bumping and GitHub releases - Added comprehensive testing guide in TESTING.md - Developed unit and integration tests for DevlogManager - Created quick test scripts for manual testing of the devlog system - Configured Vitest for testing with coverage reporting
1 parent cd02d83 commit 9ee9bd9

File tree

16 files changed

+2186
-12
lines changed

16 files changed

+2186
-12
lines changed

.github/workflows/ci.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [18, 20]
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
26+
- name: Setup pnpm
27+
uses: pnpm/action-setup@v4
28+
with:
29+
version: 9
30+
run_install: false
31+
32+
- name: Get pnpm store directory
33+
shell: bash
34+
run: |
35+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
36+
37+
- name: Setup pnpm cache
38+
uses: actions/cache@v4
39+
with:
40+
path: ${{ env.STORE_PATH }}
41+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
42+
restore-keys: |
43+
${{ runner.os }}-pnpm-store-
44+
45+
- name: Install dependencies
46+
run: pnpm install --frozen-lockfile
47+
48+
- name: Lint (if available)
49+
run: pnpm lint || echo "No lint script found"
50+
continue-on-error: true
51+
52+
- name: Build packages
53+
run: pnpm build
54+
55+
- name: Run tests
56+
run: pnpm test
57+
58+
- name: Check types
59+
run: pnpm --filter @devlog/types build
60+
61+
build-check:
62+
runs-on: ubuntu-latest
63+
64+
steps:
65+
- name: Checkout code
66+
uses: actions/checkout@v4
67+
68+
- name: Setup Node.js
69+
uses: actions/setup-node@v4
70+
with:
71+
node-version: '18'
72+
73+
- name: Setup pnpm
74+
uses: pnpm/action-setup@v4
75+
with:
76+
version: 9
77+
run_install: false
78+
79+
- name: Install dependencies
80+
run: pnpm install --frozen-lockfile
81+
82+
- name: Build all packages
83+
run: pnpm build
84+
85+
- name: Verify build artifacts
86+
run: |
87+
# Check that build artifacts exist
88+
[ -f "packages/mcp-server/build/index.js" ] || { echo "MCP server build failed"; exit 1; }
89+
[ -f "packages/types/build/index.js" ] || { echo "Types build failed"; exit 1; }
90+
[ -f "packages/types/build/index.d.ts" ] || { echo "Types declaration build failed"; exit 1; }
91+
echo "All build artifacts verified!"
92+
93+
- name: Test package installation
94+
run: |
95+
# Test that packages can be packed
96+
cd packages/mcp-server && npm pack
97+
cd ../types && npm pack

.github/workflows/publish.yml

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
name: Publish to NPM
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version to publish (patch, minor, major, or specific version like 1.2.3)'
11+
required: true
12+
default: 'patch'
13+
type: choice
14+
options:
15+
- patch
16+
- minor
17+
- major
18+
packages:
19+
description: 'Packages to publish (comma-separated: mcp-server,types or leave empty for all)'
20+
required: false
21+
type: string
22+
23+
jobs:
24+
publish:
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: write
28+
id-token: write
29+
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
token: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Setup Node.js
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: '18'
41+
registry-url: 'https://registry.npmjs.org'
42+
43+
- name: Setup pnpm
44+
uses: pnpm/action-setup@v4
45+
with:
46+
version: 9
47+
run_install: false
48+
49+
- name: Get pnpm store directory
50+
shell: bash
51+
run: |
52+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
53+
54+
- name: Setup pnpm cache
55+
uses: actions/cache@v4
56+
with:
57+
path: ${{ env.STORE_PATH }}
58+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
59+
restore-keys: |
60+
${{ runner.os }}-pnpm-store-
61+
62+
- name: Install dependencies
63+
run: pnpm install --frozen-lockfile
64+
65+
- name: Build packages
66+
run: pnpm build
67+
68+
- name: Run tests
69+
run: pnpm test
70+
71+
- name: Configure git
72+
run: |
73+
git config --local user.email "[email protected]"
74+
git config --local user.name "GitHub Action"
75+
76+
- name: Determine version bump
77+
id: version
78+
run: |
79+
if [ "${{ github.event_name }}" == "push" ] && [[ "${{ github.ref }}" == refs/tags/* ]]; then
80+
VERSION="${{ github.ref_name }}"
81+
VERSION="${VERSION#v}" # Remove 'v' prefix
82+
echo "version=$VERSION" >> $GITHUB_OUTPUT
83+
echo "bump=false" >> $GITHUB_OUTPUT
84+
else
85+
VERSION="${{ github.event.inputs.version }}"
86+
echo "version=$VERSION" >> $GITHUB_OUTPUT
87+
echo "bump=true" >> $GITHUB_OUTPUT
88+
fi
89+
90+
- name: Determine packages to publish
91+
id: packages
92+
run: |
93+
if [ -n "${{ github.event.inputs.packages }}" ]; then
94+
PACKAGES="${{ github.event.inputs.packages }}"
95+
else
96+
PACKAGES="mcp-server,types"
97+
fi
98+
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
99+
100+
- name: Version bump packages
101+
if: steps.version.outputs.bump == 'true'
102+
run: |
103+
IFS=',' read -ra PACKAGE_ARRAY <<< "${{ steps.packages.outputs.packages }}"
104+
for pkg in "${PACKAGE_ARRAY[@]}"; do
105+
pkg=$(echo "$pkg" | xargs) # trim whitespace
106+
if [ "$pkg" == "mcp-server" ]; then
107+
cd packages/mcp-server
108+
npm version ${{ steps.version.outputs.version }} --no-git-tag-version
109+
cd ../..
110+
elif [ "$pkg" == "types" ]; then
111+
cd packages/types
112+
npm version ${{ steps.version.outputs.version }} --no-git-tag-version
113+
cd ../..
114+
fi
115+
done
116+
117+
- name: Set specific version for packages
118+
if: steps.version.outputs.bump == 'false'
119+
run: |
120+
IFS=',' read -ra PACKAGE_ARRAY <<< "${{ steps.packages.outputs.packages }}"
121+
for pkg in "${PACKAGE_ARRAY[@]}"; do
122+
pkg=$(echo "$pkg" | xargs) # trim whitespace
123+
if [ "$pkg" == "mcp-server" ]; then
124+
cd packages/mcp-server
125+
npm version ${{ steps.version.outputs.version }} --no-git-tag-version --allow-same-version
126+
cd ../..
127+
elif [ "$pkg" == "types" ]; then
128+
cd packages/types
129+
npm version ${{ steps.version.outputs.version }} --no-git-tag-version --allow-same-version
130+
cd ../..
131+
fi
132+
done
133+
134+
- name: Rebuild after version update
135+
run: pnpm build
136+
137+
- name: Publish packages
138+
env:
139+
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
140+
run: |
141+
IFS=',' read -ra PACKAGE_ARRAY <<< "${{ steps.packages.outputs.packages }}"
142+
for pkg in "${PACKAGE_ARRAY[@]}"; do
143+
pkg=$(echo "$pkg" | xargs) # trim whitespace
144+
if [ "$pkg" == "mcp-server" ]; then
145+
echo "Publishing @devlog/mcp-server..."
146+
cd packages/mcp-server
147+
npm publish --access public
148+
cd ../..
149+
elif [ "$pkg" == "types" ]; then
150+
echo "Publishing @devlog/types..."
151+
cd packages/types
152+
npm publish --access public
153+
cd ../..
154+
fi
155+
done
156+
157+
- name: Commit version changes
158+
if: steps.version.outputs.bump == 'true'
159+
run: |
160+
git add .
161+
git commit -m "chore: bump version to ${{ steps.version.outputs.version }}" || echo "No changes to commit"
162+
git push origin main
163+
164+
- name: Create GitHub release
165+
if: steps.version.outputs.bump == 'true'
166+
uses: actions/create-release@v1
167+
env:
168+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
169+
with:
170+
tag_name: v${{ steps.version.outputs.version }}
171+
release_name: Release v${{ steps.version.outputs.version }}
172+
body: |
173+
## Changes
174+
175+
Published packages: ${{ steps.packages.outputs.packages }}
176+
177+
### Packages
178+
- @devlog/mcp-server@${{ steps.version.outputs.version }}
179+
- @devlog/types@${{ steps.version.outputs.version }}
180+
draft: false
181+
prerelease: false

0 commit comments

Comments
 (0)