-
Notifications
You must be signed in to change notification settings - Fork 0
321 lines (268 loc) · 11.9 KB
/
Copy pathcross-platform-tests.yml
File metadata and controls
321 lines (268 loc) · 11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
name: Cross-Platform Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
# Allow only one concurrent deployment per ref
concurrency:
group: "cross-platform-${{ github.ref }}"
cancel-in-progress: true
jobs:
filesystem-tests:
name: Test on ${{ matrix.os }} (Node ${{ matrix.node-version }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [22.x, 24.x]
include:
# Extended test matrix with specific filesystem scenarios
- os: ubuntu-latest
node-version: 22.x
filesystem-case: sensitive
test-symlinks: true
test-type: "Linux case-sensitive"
- os: windows-latest
node-version: 22.x
filesystem-case: insensitive
test-symlinks: false
test-type: "Windows case-insensitive"
- os: macos-latest
node-version: 22.x
filesystem-case: insensitive
test-symlinks: true
test-type: "macOS case-insensitive"
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v7
# pnpm must be on PATH before setup-node: its cache integration runs `pnpm store path` and fails if the package manager is not installed yet.
- name: Setup pnpm
run: corepack enable
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Detect filesystem capabilities
id: filesystem
run: |
echo "🔍 Detecting filesystem capabilities on ${{ matrix.os }}..."
# Create test directory
mkdir -p fs-test
cd fs-test
# Test case sensitivity
echo "testing case sensitivity" > testfile.txt
echo "testing case sensitivity uppercase" > TESTFILE.TXT
if [ -f "testfile.txt" ] && [ -f "TESTFILE.TXT" ]; then
CASE_COUNT=$(ls testfile.txt TESTFILE.TXT 2>/dev/null | wc -l || echo "0")
if [ "$CASE_COUNT" -eq "2" ]; then
echo "case-sensitive=true" >> $GITHUB_OUTPUT
echo "✅ Filesystem is case-sensitive"
else
echo "case-sensitive=false" >> $GITHUB_OUTPUT
echo "✅ Filesystem is case-insensitive"
fi
else
echo "case-sensitive=false" >> $GITHUB_OUTPUT
echo "✅ Filesystem is case-insensitive (file collision detected)"
fi
# Test symbolic link support
echo "original file" > original.txt
if ln -s original.txt symlink.txt 2>/dev/null; then
if [ -L symlink.txt ]; then
echo "symlinks=true" >> $GITHUB_OUTPUT
echo "✅ Symbolic links supported"
else
echo "symlinks=false" >> $GITHUB_OUTPUT
echo "❌ Symbolic links not supported"
fi
else
echo "symlinks=false" >> $GITHUB_OUTPUT
echo "❌ Symbolic links not supported (ln command failed)"
fi
# Test path separators and special characters
if echo "test content" > "file with spaces.txt" 2>/dev/null; then
echo "spaces-in-filenames=true" >> $GITHUB_OUTPUT
echo "✅ Spaces in filenames supported"
else
echo "spaces-in-filenames=false" >> $GITHUB_OUTPUT
echo "❌ Spaces in filenames not supported"
fi
cd ..
shell: bash
- name: Set test environment variables
run: |
echo "MARKMV_TEST_OS=${{ matrix.os }}" >> $GITHUB_ENV
echo "MARKMV_TEST_CASE_SENSITIVE=${{ steps.filesystem.outputs.case-sensitive }}" >> $GITHUB_ENV
echo "MARKMV_TEST_SUPPORTS_SYMLINKS=${{ steps.filesystem.outputs.symlinks }}" >> $GITHUB_ENV
echo "MARKMV_TEST_FILESYSTEM_CASE_SENSITIVE=${{ steps.filesystem.outputs.case-sensitive }}" >> $GITHUB_ENV
echo "MARKMV_TEST_SUPPORTS_SYMLINKS=${{ steps.filesystem.outputs.symlinks }}" >> $GITHUB_ENV
echo "MARKMV_TEST_NODE_VERSION=${{ matrix.node-version }}" >> $GITHUB_ENV
shell: bash
- name: Create cross-platform test files
run: |
echo "📁 Creating test files for cross-platform testing..."
# Create test markdown files with various path scenarios
mkdir -p test-data/cross-platform
cd test-data/cross-platform
# Standard files
echo "# Test Document 1" > doc1.md
echo "# Test Document 2" > doc2.md
# Files with different cases (for case sensitivity testing)
echo "# Lowercase Document" > lowercase.md
echo "# Uppercase Document" > UPPERCASE.md || echo "Case collision detected"
# Files with spaces and special characters
echo "# Document with Spaces" > "document with spaces.md"
echo "# Document with-dashes" > "document-with-dashes.md"
echo "# Document_with_underscores" > "document_with_underscores.md"
# Create subdirectories
mkdir -p subdirectory/nested
echo "# Nested Document" > subdirectory/nested/nested-doc.md
# Create links between documents
echo "[Link to doc2](./doc2.md)" >> doc1.md
echo "[Link to nested](./subdirectory/nested/nested-doc.md)" >> doc1.md
cd ../..
echo "✅ Cross-platform test files created"
ls -la test-data/cross-platform/
shell: bash
- name: Build project
run: pnpm run build
- name: Run cross-platform tests
run: |
echo "🧪 Running cross-platform tests..."
echo "OS: ${{ matrix.os }}"
echo "Node: ${{ matrix.node-version }}"
echo "Case Sensitive: ${{ steps.filesystem.outputs.case-sensitive }}"
echo "Symlinks: ${{ steps.filesystem.outputs.symlinks }}"
# Run tests with cross-platform environment
pnpm run test:run
env:
MARKMV_TEST_CROSS_PLATFORM: "true"
- name: Test CLI with cross-platform paths
run: |
echo "🔧 Testing CLI with cross-platform file paths..."
cd test-data/cross-platform
# Test basic file operations
echo "Testing file listing..."
node ../../dist/cli.js index --json . || echo "Index command failed"
# Test file moving with different path styles
if [ "${{ runner.os }}" = "Windows" ]; then
echo "Testing Windows-style paths..."
# Test with backslashes and forward slashes
node ../../dist/cli.js move "doc1.md" "moved\\doc1.md" --dry-run || echo "Windows move test failed"
else
echo "Testing Unix-style paths..."
# Test with forward slashes
node ../../dist/cli.js move "doc1.md" "moved/doc1.md" --dry-run || echo "Unix move test failed"
fi
cd ../..
shell: bash
- name: Test case sensitivity behavior
if: steps.filesystem.outputs.case-sensitive == 'true'
run: |
echo "🔍 Testing case-sensitive filesystem behavior..."
cd test-data/cross-platform
# Verify case-sensitive files exist separately
if [ -f "lowercase.md" ] && [ -f "UPPERCASE.md" ]; then
echo "✅ Case-sensitive files coexist"
# Test CLI handles case-sensitive files correctly
node ../../dist/cli.js index --json . | grep -i "lowercase.md"
node ../../dist/cli.js index --json . | grep -i "UPPERCASE.md"
else
echo "❌ Expected case-sensitive files not found"
ls -la
fi
cd ../..
shell: bash
- name: Test case insensitivity behavior
if: steps.filesystem.outputs.case-sensitive == 'false'
run: |
echo "🔍 Testing case-insensitive filesystem behavior..."
cd test-data/cross-platform
# On case-insensitive filesystems, uppercase file should overwrite lowercase
if [ -f "UPPERCASE.md" ] || [ -f "lowercase.md" ]; then
echo "✅ Case-insensitive behavior confirmed"
# Test CLI handles case-insensitive files correctly
node ../../dist/cli.js index --format json .
else
echo "❌ No test files found for case-insensitive testing"
ls -la
fi
cd ../..
shell: bash
- name: Test symbolic links
if: steps.filesystem.outputs.symlinks == 'true'
run: |
echo "🔗 Testing symbolic link behavior..."
cd test-data/cross-platform
# Create symbolic links
ln -s doc1.md link-to-doc1.md
ln -s subdirectory link-to-subdirectory
# Test CLI handles symbolic links
echo "Testing CLI with symbolic links..."
node ../../dist/cli.js index --format json . || echo "Symlink index test failed"
# Verify symbolic links are recognized
if [ -L "link-to-doc1.md" ]; then
echo "✅ File symbolic link created successfully"
fi
if [ -L "link-to-subdirectory" ]; then
echo "✅ Directory symbolic link created successfully"
fi
cd ../..
shell: bash
- name: Generate platform test report
run: |
echo "## 🖥️ Cross-Platform Test Results" >> $GITHUB_STEP_SUMMARY
echo "**Platform:** ${{ matrix.os }}" >> $GITHUB_STEP_SUMMARY
echo "**Node Version:** ${{ matrix.node-version }}" >> $GITHUB_STEP_SUMMARY
echo "**Test Type:** ${{ matrix.test-type || 'Standard' }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Filesystem Capabilities" >> $GITHUB_STEP_SUMMARY
echo "- **Case Sensitive:** ${{ steps.filesystem.outputs.case-sensitive }}" >> $GITHUB_STEP_SUMMARY
echo "- **Symbolic Links:** ${{ steps.filesystem.outputs.symlinks }}" >> $GITHUB_STEP_SUMMARY
echo "- **Spaces in Filenames:** ${{ steps.filesystem.outputs.spaces-in-filenames }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Test summary
if [ "${{ job.status }}" = "success" ]; then
echo "✅ **Status:** All tests passed" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Status:** Some tests failed" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
shell: bash
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: cross-platform-test-results-${{ matrix.os }}-${{ matrix.node-version }}
path: |
test-data/
fs-test/
retention-days: 7
# Summary job that waits for all platform tests
cross-platform-summary:
needs: filesystem-tests
runs-on: ubuntu-latest
if: always()
steps:
- name: Generate overall summary
run: |
echo "# 🌐 Cross-Platform Testing Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.filesystem-tests.result }}" = "success" ]; then
echo "✅ **Overall Result:** All cross-platform tests passed" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Overall Result:** Some cross-platform tests failed" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "📋 **Tested Platforms:**" >> $GITHUB_STEP_SUMMARY
echo "- Ubuntu (Linux) - Case-sensitive filesystem" >> $GITHUB_STEP_SUMMARY
echo "- Windows - Case-insensitive filesystem" >> $GITHUB_STEP_SUMMARY
echo "- macOS - Case-insensitive filesystem" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "🔧 **Node.js Versions:** 20.x, 22.x" >> $GITHUB_STEP_SUMMARY
shell: bash