Repository navigation
164 lines (148 loc) · 5.97 KB
/
Copy pathci.yml
File metadata and controls
164 lines (148 loc) · 5.97 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
name: CI
on:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]
# Cancel in-progress runs for the same branch/PR when a new push arrives.
# This avoids wasting CI minutes on now-superseded commits.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- run: npm ci
- run: npm run lint
- run: npm run migrate:check
# Reject PRs that embed invalid Stellar keys or wrong field names in
# the example curl/Postman files. Refs issue #1428.
- run: npm run examples:validate
test:
runs-on: ubuntu-latest
strategy:
matrix:
# Test against supported Node.js LTS versions (aligned with package.json engines field)
node-version: ['20.x', '22.x']
name: Test on Node.js ${{ matrix.node-version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: ENCRYPTION_KEY=0000000000000000000000000000000000000000000000000000000000000000 API_KEYS=ci_key npm run predeploy:check
- run: npm run test:coverage:ci
- run: npm run check-coverage
- run: npm run openapi:check
- run: npm run check:no-json-persistence
- run: npm run changelog:check
- run: npm audit --audit-level=high
# ── Coverage diff: download base branch artifact (best-effort) ────────
- name: Download base branch coverage artifact
if: github.event_name == 'pull_request'
uses: actions/download-artifact@v4
with:
name: coverage-base-node-${{ matrix.node-version }}
path: coverage/base
continue-on-error: true
# ── Coverage diff: copy base lcov to expected path ─────────────────────
- name: Prepare base lcov for diff
if: github.event_name == 'pull_request'
run: |
if [ -f coverage/base/lcov.info ]; then
cp coverage/base/lcov.info coverage/base-lcov.info
echo "Base lcov found — will compute delta."
else
echo "No base lcov available — diff will show head-only data."
# Create an empty placeholder so the diff script runs without error
touch coverage/base-lcov.info
fi
# ── Coverage diff: generate markdown comment ───────────────────────────
- name: Generate coverage diff comment
if: github.event_name == 'pull_request'
run: |
node scripts/check-coverage.js \
--diff \
--base=coverage/base-lcov.info \
--head=coverage/lcov.info \
--output=coverage/diff-comment.md
# ── Coverage diff: post or update sticky PR comment ────────────────────
- name: Post coverage diff as PR comment
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const commentPath = 'coverage/diff-comment.md';
if (!fs.existsSync(commentPath)) {
console.log('No diff comment file found — skipping.');
return;
}
const body = fs.readFileSync(commentPath, 'utf8');
const MARKER = '<!-- coverage-diff-comment -->';
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
per_page: 100
});
const existing = comments.find(c => c.body && c.body.includes(MARKER));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body
});
console.log(`Updated existing coverage comment (id=${existing.id}).`);
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});
console.log('Created new coverage comment.');
}
# ── Artifacts ─────────────────────────────────────────────────────────
- name: Upload coverage reports to artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report-node-${{ matrix.node-version }}
path: coverage/
retention-days: 30
# Save LCOV as a base artifact so future PRs can diff against it.
# Only upload on pushes to the default branch (not on PRs), so the
# artifact represents the true merged-base coverage.
- name: Save coverage as base artifact
if: github.event_name == 'push'
uses: actions/upload-artifact@v4
with:
name: coverage-base-node-${{ matrix.node-version }}
path: coverage/lcov.info
retention-days: 90
smoke:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- run: npm ci
- run: npm run test:smoke
env:
NODE_ENV: test
MOCK_STELLAR: 'true'
API_KEYS: smoke-test-key
ENCRYPTION_KEY: test_encryption_key_fixed_32bytes_hex_value_here_00