forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (99 loc) · 3.17 KB
/
Copy pathci.yml
File metadata and controls
118 lines (99 loc) · 3.17 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
name: CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
strategy:
matrix:
node-version: [20, 22, 24]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm ci
- run: npm run typecheck
- run: npm run lint
- run: npm run format:check
- run: npm run test
example:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run example
- name: Lint
run: npm run lint
- name: Format check
run: npm run format:check
- name: Typecheck
run: npm run typecheck
- name: Typecheck Examples
run: npm run typecheck:examples
- name: Test
run: npm run test -- --coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./coverage/coverage-final.json
flags: unittests
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./coverage/coverage-final.json
fail_ci_if_error: false
if: matrix.node-version == '20'
- name: Upload coverage to Codecov
if: matrix.node-version == 22
uses: codecov/codecov-action@v5
with:
files: ./coverage/coverage-final.json
fail_ci_if_error: true
use_oidc: true
- name: Build
run: npm run build
- name: Verify npm pack contents
run: |
PACK_CONTENTS=$(npm pack --dry-run --json)
echo "$PACK_CONTENTS" | jq -e '.[0].files | map(.path) | sort' > /tmp/pack-files.json
# Expected files: package.json, README.md, LICENSE, and dist/**
# Fail if src/, tests/, coverage/, .env, or other dev artifacts are present
UNEXPECTED=$(jq -r '.[] | select(
test("^package\\.json$") or
test("^README\\.md$") or
test("^LICENSE$") or
test("^dist/")
| not)' /tmp/pack-files.json)
if [ -n "$UNEXPECTED" ]; then
echo "::error::Unexpected files in npm tarball:"
echo "$UNEXPECTED"
exit 1
fi
# Verify essential files are present
ESSENTIAL_MISSING=$(echo '["package.json","README.md","LICENSE"]' | jq -r '.[]' | while read f; do
if ! jq -e ".[] | select(. == \"$f\")" /tmp/pack-files.json > /dev/null 2>&1; then
echo "$f"
fi
done)
if [ -n "$ESSENTIAL_MISSING" ]; then
echo "::error::Missing essential files in npm tarball:"
echo "$ESSENTIAL_MISSING"
exit 1
fi
echo "✅ npm pack contents verified successfully"