Skip to content

Commit 1fee2d6

Browse files
authored
ci: End to end automated tests (#5)
* On device test app * Add test runner * Add CI specific runner * Local server for serving payloads * Run tests in ci * Attempt to fix qemu launch * Another qemu fix
1 parent 0579070 commit 1fee2d6

40 files changed

Lines changed: 1365 additions & 4 deletions

.github/workflows/test.yml

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ on:
77
pull_request:
88

99
jobs:
10-
build:
10+
test:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout repository
1414
uses: actions/checkout@v4
1515

16-
- name: Install Node dependencies
17-
run: npm install
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: "22"
20+
cache: npm
1821

1922
- name: Cache Node dependencies
2023
uses: actions/cache@v4
@@ -24,8 +27,51 @@ jobs:
2427
restore-keys: |
2528
node-${{ runner.os }}-
2629
30+
- name: Install Pebble SDK system dependencies
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get install -y \
34+
libsdl2-2.0-0 \
35+
libglib2.0-0 \
36+
libpixman-1-0 \
37+
zlib1g \
38+
libsndio7.0 \
39+
qemu-system-data
40+
41+
- name: Set up uv
42+
uses: astral-sh/setup-uv@v5
43+
with:
44+
python-version: "3.13"
45+
enable-cache: true
46+
47+
- name: Install Pebble CLI
48+
run: uv tool install pebble-tool --python 3.13
49+
50+
- name: Add Pebble CLI to PATH
51+
run: echo "$HOME/.local/bin" >> "$GITHUB_PATH"
52+
53+
- name: Install Pebble SDK
54+
run: |
55+
pebble sdk install latest
56+
SDK_VERSION="$(ls -1 "${HOME}/.pebble-sdk/SDKs" | grep -E '^[0-9]' | sort -V | tail -1)"
57+
pebble sdk activate "${SDK_VERSION}"
58+
PC_BIOS="${HOME}/.pebble-sdk/SDKs/current/toolchain/lib/pc-bios"
59+
mkdir -p "${PC_BIOS}"
60+
ln -sfn /usr/share/qemu/keymaps "${PC_BIOS}/keymaps"
61+
62+
- name: Install Node dependencies
63+
run: npm install
64+
2765
- name: Type check
2866
run: npm run check-types
2967

3068
- name: Build CLI
3169
run: npm run build
70+
71+
- name: Install test-app dependencies
72+
working-directory: tests/test-app
73+
run: npm install
74+
75+
- name: Run end-to-end tests
76+
working-directory: tests/test-app
77+
run: npm run test

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ example/src/pkjs/
33
node_modules/
44
.DS_Store
55
.lock*
6-
bin/
6+
bin/
7+
ts-build/
8+
build/

tests/test-app/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# test-app
2+
3+
A Pebble watchapp/watchface written in C using the Pebble SDK.
4+
5+
## Building & running
6+
7+
```sh
8+
pebble build # build for all targetPlatforms
9+
pebble install --emulator emery # install on the emery emulator
10+
pebble install --phone <ip> # install to a paired phone
11+
```
12+
13+
## Target platforms
14+
15+
`targetPlatforms` in `package.json` controls which watches you build for. The
16+
modern Pebble hardware is **emery** (Pebble Time 2), **gabbro** (Pebble Round
17+
2), and **flint** (Pebble 2 Duo); the original Pebble platforms (aplite,
18+
basalt, chalk, diorite) are included by default for backwards compatibility.
19+
20+
## Project layout
21+
22+
```
23+
src/c/ C source for the watchapp
24+
src/pkjs/ PebbleKit JS (phone-side) source, if any
25+
worker_src/c/ Background worker source, if any
26+
resources/ Images, fonts, and other bundled resources
27+
package.json Project metadata (UUID, platforms, resources, message keys)
28+
wscript Build rules — usually no need to edit
29+
```
30+
31+
By default this project is configured as a watchapp. To make it a watchface,
32+
set `pebble.watchapp.watchface` to `true` in `package.json`.
33+
34+
## Documentation
35+
36+
Full SDK docs, tutorials, and API reference: <https://developer.repebble.com>

tests/test-app/package-lock.json

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/test-app/package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "test-app",
3+
"author": "MakeAwesomeHappen",
4+
"version": "1.0.0",
5+
"keywords": ["pebble-app"],
6+
"private": true,
7+
"dependencies": {},
8+
"devDependencies": {
9+
"pkts": "file:../.."
10+
},
11+
"scripts": {
12+
"build": "pkts build",
13+
"test": "node run-tests.mjs"
14+
},
15+
"pebble": {
16+
"displayName": "PKTS Test",
17+
"uuid": "0eb49fc7-d058-474d-b0af-9d15e299704d",
18+
"sdkVersion": "3",
19+
"enableMultiJS": true,
20+
"targetPlatforms": [
21+
"aplite",
22+
"basalt",
23+
"chalk",
24+
"diorite",
25+
"emery",
26+
"flint",
27+
"gabbro"
28+
],
29+
"watchapp": {
30+
"watchface": false
31+
},
32+
"messageKeys": [
33+
"run_test",
34+
"result",
35+
"status"
36+
],
37+
"resources": {
38+
"media": []
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)