-
Notifications
You must be signed in to change notification settings - Fork 5.5k
264 lines (227 loc) · 8.17 KB
/
test-packaging.yml
File metadata and controls
264 lines (227 loc) · 8.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
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
name: Test Packaging
on:
pull_request:
paths:
- 'packages/app-core/packaging/**'
- 'packages/core/**'
- 'plugins/*/typescript/**'
- 'packages/app-core/scripts/pack-upstreams.mjs'
- '.github/workflows/publish-packages.yml'
- '.github/workflows/test-packaging.yml'
push:
branches: [main]
paths:
- 'packages/app-core/packaging/**'
- 'packages/core/**'
- 'plugins/*/typescript/**'
workflow_dispatch:
concurrency:
group: test-packaging-${{ github.ref }}
cancel-in-progress: true
jobs:
validate:
name: Validate Packaging Configs
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.14"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
check-latest: false
- name: Install validation dependencies
run: pip install pyyaml build twine
- name: Run packaging validation suite
run: bash packages/app-core/packaging/test-packaging.sh
build-pypi:
name: Build & Test PyPI Package
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Check for PyPI package directory
id: pypi_check
run: |
if [[ -d packages/app-core/packaging/pypi ]]; then
echo "present=true" >> "$GITHUB_OUTPUT"
else
echo "present=false" >> "$GITHUB_OUTPUT"
echo "::notice::packages/app-core/packaging/pypi not present in this branch — skipping PyPI build"
fi
- name: Setup Python
if: steps.pypi_check.outputs.present == 'true'
uses: actions/setup-python@v6
with:
python-version: "3.14"
- name: Setup Node.js
if: steps.pypi_check.outputs.present == 'true'
uses: actions/setup-node@v4
with:
node-version: "24"
check-latest: false
- name: Build
if: steps.pypi_check.outputs.present == 'true'
working-directory: packages/app-core/packaging/pypi
run: |
pip install build
python -m build
- name: Check dist
if: steps.pypi_check.outputs.present == 'true'
working-directory: packages/app-core/packaging/pypi
run: |
pip install twine
twine check dist/*
- name: Install and test
if: steps.pypi_check.outputs.present == 'true'
working-directory: packages/app-core/packaging/pypi
run: |
pip install dist/*.whl
# Module import test
python -c "
import elizaos_app
print(f'elizaos_app {elizaos_app.__version__}')
assert elizaos_app.__version__
assert hasattr(elizaos_app, 'run')
assert hasattr(elizaos_app, 'ensure_runtime')
assert hasattr(elizaos_app, 'get_version')
"
# Loader unit tests
python -c "
from elizaos_app.loader import (
_parse_version,
_find_node,
_get_node_version,
_check_node,
ElizaOSAppError,
NodeNotFoundError,
RuntimeInstallError,
)
# Version parsing
assert _parse_version('v22.12.0') == (22, 12, 0)
assert _parse_version('v18.0.0') == (18, 0, 0)
assert _parse_version('v1.2.3-nightly') == (1, 2, 3)
assert _parse_version('not-a-version') is None
assert _parse_version('') is None
# Node detection (Node.js is installed in this runner)
node = _find_node()
assert node, 'Node not found on PATH'
ver = _get_node_version(node)
assert ver and ver >= (22, 0, 0), f'Node version too old: {ver}'
checked = _check_node()
assert checked == node
# Exception hierarchy
assert issubclass(NodeNotFoundError, ElizaOSAppError)
assert issubclass(RuntimeInstallError, ElizaOSAppError)
print('All loader unit tests passed')
"
# CLI entry point exists
which elizaos-app
build-pypi-matrix:
name: PyPI on Python ${{ matrix.python }}
runs-on: ubuntu-24.04
strategy:
matrix:
# PRs run a single Python version; pushes to main/develop run the
# full 3.9–3.13 matrix. Release publishing re-runs the full matrix.
python: ${{ github.event_name == 'pull_request' && fromJSON('["3.12"]') || fromJSON('["3.9", "3.10", "3.11", "3.12", "3.13"]') }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Check for PyPI package directory
id: pypi_check
run: |
if [[ -d packages/app-core/packaging/pypi ]]; then
echo "present=true" >> "$GITHUB_OUTPUT"
else
echo "present=false" >> "$GITHUB_OUTPUT"
echo "::notice::packages/app-core/packaging/pypi not present in this branch — skipping PyPI matrix build"
fi
- name: Setup Python ${{ matrix.python }}
if: steps.pypi_check.outputs.present == 'true'
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
- name: Setup Node.js
if: steps.pypi_check.outputs.present == 'true'
uses: actions/setup-node@v4
with:
node-version: "24"
check-latest: false
- name: Build and test
if: steps.pypi_check.outputs.present == 'true'
working-directory: packages/app-core/packaging/pypi
run: |
pip install build
python -m build
pip install dist/*.whl
python -c "import elizaos_app; print(f'OK: elizaos_app {elizaos_app.__version__} on Python ${{ matrix.python }}')"
pack-and-test-js:
name: Pack & Test JS Tarballs
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
check-latest: false
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.13"
- name: Install dependencies
run: bun install --ignore-scripts
- name: Materialize bun npm package binary
run: if [ -f node_modules/bun/install.js ]; then (cd node_modules/bun && node install.js); fi
- name: Pack upstream tarballs
run: node packages/app-core/scripts/pack-upstreams.mjs
- name: Verify tarball installation
run: |
set -euo pipefail
ARTIFACTS_DIR="artifacts"
tarballs=("$ARTIFACTS_DIR"/*.tgz)
if [ ! -f "${tarballs[0]}" ]; then
echo "::error::No tarballs found in $ARTIFACTS_DIR"
exit 1
fi
TEST_DIR=$(mktemp -d)
ROOT_DIR="$PWD"
install_paths=()
for tarball in "${tarballs[@]}"; do
install_paths+=("$ROOT_DIR/$tarball")
done
cd "$TEST_DIR"
echo '{"name":"tarball-test","private":true,"type":"module"}' > package.json
npm install "${install_paths[@]}" --ignore-scripts 2>&1
for tarball in "${tarballs[@]}"; do
echo "::group::Checking $(basename "$tarball")"
PKG_NAME=$(tar -xOf "$ROOT_DIR/$tarball" package/package.json | node -e "process.stdin.setEncoding('utf8'); let data = ''; process.stdin.on('data', chunk => data += chunk); process.stdin.on('end', () => console.log(JSON.parse(data).name));")
PKG_MANIFEST="node_modules/${PKG_NAME}/package.json"
test -f "$PKG_MANIFEST"
echo "Installed: $PKG_NAME"
echo "::endgroup::"
done
cd "$ROOT_DIR"
rm -rf "$TEST_DIR"
echo "All JS tarballs passed installation test"
- name: Upload tarball artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: js-tarballs
path: artifacts/*.tgz
retention-days: 7