Skip to content

Commit ba5f67a

Browse files
Copilothotlong
andcommitted
Fix cleanup and add CI workflow for tests
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent fb07e51 commit ba5f67a

File tree

3 files changed

+83
-6
lines changed

3 files changed

+83
-6
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Test ObjectDocs Lifecycle
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test-quick:
12+
name: Quick Build Test
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20'
23+
24+
- name: Setup pnpm
25+
uses: pnpm/action-setup@v4
26+
with:
27+
version: 10
28+
29+
- name: Install dependencies
30+
run: pnpm install
31+
32+
- name: Run quick build test
33+
run: pnpm test:quick
34+
35+
- name: Upload test results
36+
if: always()
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: quick-test-results
40+
path: /tmp/test-*.log
41+
retention-days: 7
42+
if-no-files-found: ignore
43+
44+
test-full:
45+
name: Full Lifecycle Test
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
52+
- name: Setup Node.js
53+
uses: actions/setup-node@v4
54+
with:
55+
node-version: '20'
56+
57+
- name: Setup pnpm
58+
uses: pnpm/action-setup@v4
59+
with:
60+
version: 10
61+
62+
- name: Install dependencies
63+
run: pnpm install
64+
65+
- name: Run full lifecycle test
66+
run: pnpm test:site
67+
68+
- name: Upload server logs
69+
if: always()
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: full-test-results
73+
path: |
74+
/tmp/dev-server.log
75+
/tmp/start-server.log
76+
retention-days: 7
77+
if-no-files-found: ignore

test-quick.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ TEST_DIR="/tmp/objectdocs-quick-test-$(date +%s)"
3030
# Cleanup on exit
3131
cleanup() {
3232
if [ -d "$TEST_DIR" ]; then
33-
rm -rf "$TEST_DIR"
33+
rm -rf "$TEST_DIR" 2>/dev/null || true
3434
fi
3535
}
3636
trap cleanup EXIT
@@ -42,7 +42,7 @@ main() {
4242
mkdir -p "$TEST_DIR"
4343
cd "$TEST_DIR"
4444

45-
pnpm init -y
45+
echo "{}" > package.json
4646
print_success "Initialized project"
4747

4848
# Install CLI from workspace

test-site.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ cleanup() {
3434
# Kill any process using the test port
3535
lsof -ti:$PORT | xargs kill -9 2>/dev/null || true
3636

37-
# Remove test directory
37+
# Remove test directory (force recursive delete)
3838
if [ -d "$TEST_DIR" ]; then
39-
rm -rf "$TEST_DIR"
39+
rm -rf "$TEST_DIR" 2>/dev/null || true
4040
fi
4141

4242
echo -e "${BLUE}Cleanup complete${NC}"
@@ -133,8 +133,8 @@ main() {
133133
print_success "Created test directory: $TEST_DIR"
134134

135135
# Initialize package.json
136-
print_info "Running pnpm init..."
137-
pnpm init -y
136+
print_info "Creating package.json..."
137+
echo "{}" > package.json
138138
print_success "package.json created"
139139

140140
# Install @objectdocs/cli as dev dependency

0 commit comments

Comments
 (0)