-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (73 loc) · 2.63 KB
/
Copy pathci.yml
File metadata and controls
86 lines (73 loc) · 2.63 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
name: CI
# Trigger workflow on pull requests to main branch
on:
pull_request:
branches:
- main
# Set permissions for CI and PR comments
permissions:
contents: read
pull-requests: write
jobs:
# CI job to verify build and run tests
ci:
name: Build and Test
runs-on: ubuntu-latest
steps:
# Step 1: Checkout repository code
- name: Checkout
uses: actions/checkout@v4
# Step 2: Setup Node.js 20.19.0 with npm caching
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.19.0"
cache: "npm"
# Step 3: Install dependencies using npm ci for clean, reproducible installs
- name: Install dependencies
run: npm ci
# Step 4: Verify snapshot files exist before running tests
- name: Verify Snapshot Files
run: |
echo "Checking for snapshot files..."
SNAPSHOT_DIR="src/lib/docker-compose/__tests__/__verify__/__snapshots__"
if [ ! -d "$SNAPSHOT_DIR" ]; then
echo "Error: Snapshot directory not found at $SNAPSHOT_DIR"
exit 1
fi
SNAPSHOT_COUNT=$(find "$SNAPSHOT_DIR" -name "*.snap" | wc -l)
echo "Found $SNAPSHOT_COUNT snapshot file(s):"
ls -la "$SNAPSHOT_DIR"/*.snap
if [ "$SNAPSHOT_COUNT" -eq 0 ]; then
echo "Error: No snapshot files found in $SNAPSHOT_DIR"
exit 1
fi
echo "Snapshot files verified successfully."
# Step 5: Build project and verify TypeScript compilation
- name: Build
run: npm run build
# Step 6: Run test suite using vitest
- name: Test
run: npm test
# Step 7: Report test results with PR comment
- name: Comment PR with test results
if: always()
uses: actions/github-script@v7
with:
script: |
const outcome = '${{ job.status }}';
const emoji = outcome === 'success' ? '✅' : '❌';
const message = `${emoji} CI check result: **${outcome === 'success' ? 'Passed' : 'Failed'}**
**Workflow**: CI
**Status**: ${outcome}
**Branch**: ${{ github.head_ref }}
**Commit**: ${{ github.sha }}
${outcome === 'success' ?
'All tests passed and build completed successfully.' :
'Please check the logs for details and fix any issues before merging.'}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
});