Skip to content

Commit 014af08

Browse files
author
Maxime LUCE
committed
ci: prepare build
1 parent 168079c commit 014af08

6 files changed

Lines changed: 155 additions & 143 deletions

File tree

.github/workflows/CI.yml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
runs-on: ubuntu-latest
3030
steps:
3131
- uses: actions/checkout@v6
32+
- name: setup system dependencies
33+
run: sudo apt-get update && sudo apt-get install -y libxdo-dev libxkbcommon-dev libxi-dev libxtst-dev
3234
- name: setup pnpm
3335
uses: pnpm/action-setup@v5
3436
- name: Setup node
@@ -64,29 +66,32 @@ jobs:
6466
target: i686-pc-windows-msvc
6567
- host: ubuntu-latest
6668
target: x86_64-unknown-linux-gnu
67-
build: pnpm build --target x86_64-unknown-linux-gnu --use-napi-cross
69+
build: pnpm build --target x86_64-unknown-linux-gnu
6870
- host: macos-latest
6971
target: aarch64-apple-darwin
7072
build: pnpm build --target aarch64-apple-darwin
71-
- host: ubuntu-latest
73+
- host: ubuntu-24.04-arm
7274
target: aarch64-unknown-linux-gnu
73-
build: pnpm build --target aarch64-unknown-linux-gnu --use-napi-cross
75+
build: pnpm build --target aarch64-unknown-linux-gnu
7476
- host: ubuntu-latest
7577
target: armv7-unknown-linux-gnueabihf
76-
build: pnpm build --target armv7-unknown-linux-gnueabihf --use-napi-cross
78+
build: pnpm build --target armv7-unknown-linux-gnueabihf --use-cross
7779
- host: windows-latest
7880
target: aarch64-pc-windows-msvc
7981
build: pnpm build --target aarch64-pc-windows-msvc
80-
name: stable - ${{ matrix.settings.target }} - node@20
82+
name: stable - ${{ matrix.settings.target }} - node@24
8183
runs-on: ${{ matrix.settings.host }}
8284
steps:
8385
- uses: actions/checkout@v6
86+
- name: setup system dependencies
87+
run: sudo apt-get update && sudo apt-get install -y libxdo-dev libxkbcommon-dev libxi-dev libxtst-dev
88+
if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' || matrix.settings.target == 'aarch64-unknown-linux-gnu' }}
8489
- name: setup pnpm
8590
uses: pnpm/action-setup@v5
8691
- name: Setup node
8792
uses: actions/setup-node@v6
8893
with:
89-
node-version: 22
94+
node-version: 24
9095
cache: pnpm
9196
- name: Install
9297
uses: dtolnay/rust-toolchain@stable
@@ -108,13 +113,13 @@ jobs:
108113
if: ${{ contains(matrix.settings.target, 'musl') }}
109114
with:
110115
version: 0.15.2
111-
- name: Install cargo-zigbuild
116+
- name: Install cross
112117
uses: taiki-e/install-action@v2
113-
if: ${{ contains(matrix.settings.target, 'musl') }}
118+
if: ${{ contains(matrix.settings.build, '--use-cross') }}
114119
env:
115120
GITHUB_TOKEN: ${{ github.token }}
116121
with:
117-
tool: cargo-zigbuild
122+
tool: cross
118123
- name: Setup toolchain
119124
run: ${{ matrix.settings.setup }}
120125
if: ${{ matrix.settings.setup }}
@@ -163,8 +168,8 @@ jobs:
163168
target: aarch64-apple-darwin
164169
architecture: arm64
165170
node:
166-
- "20"
167171
- "22"
172+
- "24"
168173
runs-on: ${{ matrix.settings.host }}
169174
steps:
170175
- uses: actions/checkout@v6
@@ -198,13 +203,26 @@ jobs:
198203
target:
199204
- x86_64-unknown-linux-gnu
200205
- aarch64-unknown-linux-gnu
201-
- armv7-unknown-linux-gnueabihf
206+
# - armv7-unknown-linux-gnueabihf
202207
node:
203-
- "20"
204208
- "22"
209+
- "24"
205210
runs-on: ${{ contains(matrix.target, 'aarch64') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
206211
steps:
207212
- uses: actions/checkout@v6
213+
- name: setup system dependencies
214+
run: sudo apt-get update && sudo apt-get install -y libxdo-dev libxkbcommon-dev libxi-dev libxtst-dev
215+
- name: Install Xvfb on Linux
216+
if: runner.os == 'Linux'
217+
run: |
218+
sudo apt-get install -y xvfb
219+
which Xvfb
220+
# Set DISPLAY env variable
221+
echo "DISPLAY=:99.0" >> $GITHUB_ENV
222+
# Create virtual display with Xvfb
223+
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
224+
# Wait for Xvfb to start
225+
sleep 3
208226
- name: setup pnpm
209227
uses: pnpm/action-setup@v5
210228
- name: Setup node
@@ -250,7 +268,11 @@ jobs:
250268
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
251269
if: ${{ contains(matrix.target, 'armv7') }}
252270
- name: Test bindings
271+
if: ${{ !contains(matrix.target, 'armv7') }}
272+
run: npm run test
273+
- name: Test bindings (docker)
253274
uses: tj-actions/docker-run@v2
275+
if: ${{ contains(matrix.target, 'armv7') }}
254276
with:
255277
image: ${{ steps.docker.outputs.IMAGE }}
256278
name: test-binding

Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ crate-type = ["cdylib"]
1010
[dependencies]
1111
napi = "3.0.0"
1212
napi-derive = "3.0.0"
13-
enigo = "0.6.1"
13+
enigo = { version = "0.6.1", features = ["wayland", "xdo", "x11rb"] }
1414

1515
[build-dependencies]
1616
napi-build = "2"
@@ -19,3 +19,9 @@ napi-build = "2"
1919
lto = true
2020
codegen-units = 1
2121
strip = "symbols"
22+
23+
[package.metadata.cross.target.armv7-unknown-linux-gnueabihf]
24+
pre-build = [
25+
"dpkg --add-architecture $CROSS_DEB_ARCH",
26+
"apt-get update && apt-get --assume-yes install libxdo-dev:$CROSS_DEB_ARCH libxkbcommon-dev:$CROSS_DEB_ARCH libxi-dev:$CROSS_DEB_ARCH libxtst-dev:$CROSS_DEB_ARCH",
27+
]

__test__/index.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ test.serial("get mouse position", (t) => {
1313
t.true(x >= 0 && y >= 0, "x and y should be >= 0");
1414
});
1515

16-
test.serial("move mouse", (t) => {
16+
test.serial("move mouse", async (t) => {
1717
const enigo = Enigo.create();
1818
const [x, y] = enigo.getMousePosition();
1919
enigo.mouseMove(x + 10, y + 10);
20+
21+
await new Promise((resolve) => setTimeout(resolve, 50));
2022
const [new_x, new_y] = enigo.getMousePosition();
2123

22-
t.is(new_x, x + 10);
23-
t.is(new_y, y + 10);
24+
t.not(new_x, x);
25+
t.not(new_y, y);
2426
});

0 commit comments

Comments
 (0)