-
Notifications
You must be signed in to change notification settings - Fork 3
182 lines (151 loc) · 4.61 KB
/
Copy pathsdk-ci.yml
File metadata and controls
182 lines (151 loc) · 4.61 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
name: SDK CI
on:
push:
branches: [main]
paths:
- "sdks/**"
- ".github/workflows/sdk-ci.yml"
pull_request:
branches: [main]
paths:
- "sdks/**"
- ".github/workflows/sdk-ci.yml"
jobs:
python-sdk:
name: Python SDK — Lint, Type, Test, Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: sdks/python
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
cache-dependency-path: sdks/python/pyproject.toml
- name: Install
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]" build
- name: Ruff lint
run: ruff check .
- name: Ruff format check
run: ruff format --check .
- name: mypy
run: mypy mailcue
- name: pytest
run: pytest -q
- name: Build sdist + wheel
run: python -m build
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: python-sdk-dist
path: sdks/python/dist/*
retention-days: 7
node-sdk:
name: Node SDK — Lint, Type, Test, Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: sdks/node
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
cache-dependency-path: sdks/node/package-lock.json
- name: Install
run: npm ci
- name: ESLint
run: npm run lint
- name: TypeScript
run: npm run typecheck
- name: Vitest
run: npm run test
- name: Build
run: npm run build
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: node-sdk-dist
path: sdks/node/dist/*
retention-days: 7
e2e:
name: SDK E2E — Live MailCue
runs-on: ubuntu-latest
needs: [python-sdk, node-sdk]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- uses: actions/setup-node@v6
with:
node-version: 22
- name: Build mailcue image
run: docker build -t mailcue:e2e .
- name: Start mailcue
run: |
docker run -d --name mailcue \
-p 8088:80 \
-p 25:25 -p 587:587 \
-p 143:143 -p 993:993 \
-e MAILCUE_DOMAIN=mailcue.local \
-e MAILCUE_ADMIN_USER=admin \
-e MAILCUE_ADMIN_PASSWORD=mailcue \
mailcue:e2e
- name: Wait for /health
run: |
for i in $(seq 1 90); do
if curl -sf http://localhost:8088/api/v1/health > /dev/null; then
echo "mailcue ready after ${i}s"
exit 0
fi
sleep 2
done
echo "mailcue did not become healthy in 180s"
docker logs mailcue --tail 200
exit 1
- name: Provision API key
id: provision
run: |
TOKEN=$(curl -sf -X POST http://localhost:8088/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"mailcue"}' | python -c "import sys,json;print(json.load(sys.stdin)['access_token'])")
API_KEY=$(curl -sf -X POST http://localhost:8088/api/v1/auth/api-keys \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"sdk-e2e"}' | python -c "import sys,json;d=json.load(sys.stdin);print(d.get('key') or d.get('api_key') or d.get('plaintext') or '')")
if [ -z "$API_KEY" ]; then
echo "Failed to provision API key"
exit 1
fi
echo "::add-mask::$API_KEY"
echo "key=$API_KEY" >> "$GITHUB_OUTPUT"
- name: Install Python SDK
working-directory: sdks/python
run: |
python -m pip install --upgrade pip
pip install -e .
- name: Run Python E2E
env:
MAILCUE_API_KEY: ${{ steps.provision.outputs.key }}
run: python sdks/_e2e/python_e2e.py
- name: Build Node SDK
working-directory: sdks/node
run: |
npm ci
npm run build
- name: Run Node E2E
env:
MAILCUE_API_KEY: ${{ steps.provision.outputs.key }}
run: node sdks/_e2e/node_e2e.mjs
- name: Container logs on failure
if: failure()
run: docker logs mailcue --tail 400
- name: Stop mailcue
if: always()
run: docker rm -f mailcue || true