-
Notifications
You must be signed in to change notification settings - Fork 0
192 lines (155 loc) · 5.03 KB
/
Copy pathci.yml
File metadata and controls
192 lines (155 loc) · 5.03 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lint:
name: Lint & Type Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Run Biome
run: pnpm run check
- name: Type check
run: pnpm run type-check
test:
name: Test Suite
needs: lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Run tests
run: pnpm run test:run
- name: Run tests with coverage
run: pnpm run test:coverage
- name: Coverage Summary
run: |
# Run tests with coverage and capture output
TEST_OUTPUT=$(pnpm run test:coverage 2>&1)
echo "## 📊 Test Coverage Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Extract test results
TEST_COUNT=$(echo "$TEST_OUTPUT" | grep -o '[0-9]\+ passed' | head -1 | grep -o '[0-9]\+')
OVERALL_COVERAGE=$(echo "$TEST_OUTPUT" | grep "All files" | awk '{print $3}')
# Add coverage table
echo "| File | Statements | Branches | Functions | Lines |" >> $GITHUB_STEP_SUMMARY
echo "|------|------------|----------|-----------|-------|" >> $GITHUB_STEP_SUMMARY
# Parse coverage and add to summary
echo "$TEST_OUTPUT" | grep -E "^\s*(All files|[a-z-]+\.ts)" | while read line; do
if [[ $line == *"All files"* ]]; then
echo "| **Overall** | $(echo $line | awk '{print $3}') | $(echo $line | awk '{print $4}') | $(echo $line | awk '{print $5}') | $(echo $line | awk '{print $6}') |" >> $GITHUB_STEP_SUMMARY
elif [[ $line == *.ts* ]]; then
filename=$(echo $line | awk '{print $1}')
echo "| $filename | $(echo $line | awk '{print $3}') | $(echo $line | awk '{print $4}') | $(echo $line | awk '{print $5}') | $(echo $line | awk '{print $6}') |" >> $GITHUB_STEP_SUMMARY
fi
done
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ **${TEST_COUNT} tests passed** with **${OVERALL_COVERAGE} overall coverage**" >> $GITHUB_STEP_SUMMARY
test-e2e:
name: E2E Test with github-typescript
needs: lint
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
deployments: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
# Install scripts dependencies (including local utils via file:../../)
- name: Setup scripts dependencies
run: |
cd .github/scripts
pnpm install
# Run the example script through the published wrapper
- name: Run E2E test via github-typescript
uses: tkstang/github-typescript@v1
with:
working-directory: .github/scripts
ts-file: example.ts
node-version: "22"
args: |
{
"testMessage": "Hello E2E Test!",
"testLabels": ["e2e-test", "automated"],
"testBranch": "main"
}
build:
name: Build
runs-on: ubuntu-latest
needs: [lint, test, test-e2e]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm run build
- name: Check build artifacts
run: |
ls -la dist/
test -f dist/index.js
test -f dist/index.d.ts
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: dist/
publish-dry-run:
name: Publish (Dry Run)
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm run build
- name: Publish dry run
run: pnpm publish --dry-run