Skip to content

Commit f3f13ac

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

6 files changed

Lines changed: 263 additions & 251 deletions

File tree

.github/workflows/CI.yml

Lines changed: 142 additions & 120 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
@@ -53,40 +55,43 @@ jobs:
5355
fail-fast: false
5456
matrix:
5557
settings:
56-
- host: macos-latest
57-
target: x86_64-apple-darwin
58-
build: pnpm build --target x86_64-apple-darwin
59-
- host: windows-latest
60-
build: pnpm build --target x86_64-pc-windows-msvc
61-
target: x86_64-pc-windows-msvc
62-
- host: windows-latest
63-
build: pnpm build --target i686-pc-windows-msvc
64-
target: i686-pc-windows-msvc
65-
- host: ubuntu-latest
66-
target: x86_64-unknown-linux-gnu
67-
build: pnpm build --target x86_64-unknown-linux-gnu --use-napi-cross
68-
- host: macos-latest
69-
target: aarch64-apple-darwin
70-
build: pnpm build --target aarch64-apple-darwin
71-
- host: ubuntu-latest
72-
target: aarch64-unknown-linux-gnu
73-
build: pnpm build --target aarch64-unknown-linux-gnu --use-napi-cross
58+
# - host: macos-latest
59+
# target: x86_64-apple-darwin
60+
# build: pnpm build --target x86_64-apple-darwin
61+
# - host: windows-latest
62+
# build: pnpm build --target x86_64-pc-windows-msvc
63+
# target: x86_64-pc-windows-msvc
64+
# - host: windows-latest
65+
# build: pnpm build --target i686-pc-windows-msvc
66+
# target: i686-pc-windows-msvc
67+
# - host: ubuntu-latest
68+
# target: x86_64-unknown-linux-gnu
69+
# build: pnpm build --target x86_64-unknown-linux-gnu
70+
# - host: macos-latest
71+
# target: aarch64-apple-darwin
72+
# build: pnpm build --target aarch64-apple-darwin
73+
# - host: ubuntu-24.04-arm
74+
# target: aarch64-unknown-linux-gnu
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
77-
- host: windows-latest
78-
target: aarch64-pc-windows-msvc
79-
build: pnpm build --target aarch64-pc-windows-msvc
80-
name: stable - ${{ matrix.settings.target }} - node@20
78+
build: pnpm build --target armv7-unknown-linux-gnueabihf --use-cross
79+
# - host: windows-latest
80+
# target: aarch64-pc-windows-msvc
81+
# build: pnpm build --target aarch64-pc-windows-msvc
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 }}
@@ -145,49 +150,49 @@ jobs:
145150
name: bindings-${{ matrix.settings.target }}
146151
path: "*.wasm"
147152
if-no-files-found: error
148-
test-macOS-windows-binding:
149-
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
150-
needs:
151-
- build
152-
strategy:
153-
fail-fast: false
154-
matrix:
155-
settings:
156-
- host: windows-latest
157-
target: x86_64-pc-windows-msvc
158-
architecture: x64
159-
- host: macos-latest
160-
target: x86_64-apple-darwin
161-
architecture: x64
162-
- host: macos-latest
163-
target: aarch64-apple-darwin
164-
architecture: arm64
165-
node:
166-
- "20"
167-
- "22"
168-
runs-on: ${{ matrix.settings.host }}
169-
steps:
170-
- uses: actions/checkout@v6
171-
- name: setup pnpm
172-
uses: pnpm/action-setup@v5
173-
- name: Setup node
174-
uses: actions/setup-node@v6
175-
with:
176-
node-version: ${{ matrix.node }}
177-
cache: pnpm
178-
architecture: ${{ matrix.settings.architecture }}
179-
- name: Install dependencies
180-
run: pnpm install
181-
- name: Download artifacts
182-
uses: actions/download-artifact@v8
183-
with:
184-
name: bindings-${{ matrix.settings.target }}
185-
path: .
186-
- name: List packages
187-
run: ls -R .
188-
shell: bash
189-
- name: Test bindings
190-
run: pnpm test
153+
# test-macOS-windows-binding:
154+
# name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
155+
# needs:
156+
# - build
157+
# strategy:
158+
# fail-fast: false
159+
# matrix:
160+
# settings:
161+
# - host: windows-latest
162+
# target: x86_64-pc-windows-msvc
163+
# architecture: x64
164+
# - host: macos-latest
165+
# target: x86_64-apple-darwin
166+
# architecture: x64
167+
# - host: macos-latest
168+
# target: aarch64-apple-darwin
169+
# architecture: arm64
170+
# node:
171+
# - "22"
172+
# - "24"
173+
# runs-on: ${{ matrix.settings.host }}
174+
# steps:
175+
# - uses: actions/checkout@v6
176+
# - name: setup pnpm
177+
# uses: pnpm/action-setup@v5
178+
# - name: Setup node
179+
# uses: actions/setup-node@v6
180+
# with:
181+
# node-version: ${{ matrix.node }}
182+
# cache: pnpm
183+
# architecture: ${{ matrix.settings.architecture }}
184+
# - name: Install dependencies
185+
# run: pnpm install
186+
# - name: Download artifacts
187+
# uses: actions/download-artifact@v8
188+
# with:
189+
# name: bindings-${{ matrix.settings.target }}
190+
# path: .
191+
# - name: List packages
192+
# run: ls -R .
193+
# shell: bash
194+
# - name: Test bindings
195+
# run: pnpm test
191196
test-linux-binding:
192197
name: Test ${{ matrix.target }} - node@${{ matrix.node }}
193198
needs:
@@ -196,15 +201,28 @@ jobs:
196201
fail-fast: false
197202
matrix:
198203
target:
199-
- x86_64-unknown-linux-gnu
200-
- aarch64-unknown-linux-gnu
204+
# - x86_64-unknown-linux-gnu
205+
# - aarch64-unknown-linux-gnu
201206
- 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,55 +268,59 @@ 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
257279
options: "-v ${{ steps.docker.outputs.PNPM_STORE_PATH }}:${{ steps.docker.outputs.PNPM_STORE_PATH }} -v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} --platform ${{ steps.docker.outputs.PLATFORM }}"
258-
args: npm run test
259-
publish:
260-
name: Publish
261-
runs-on: ubuntu-latest
262-
needs:
263-
- lint
264-
- test-macOS-windows-binding
265-
- test-linux-binding
266-
steps:
267-
- uses: actions/checkout@v6
268-
- name: setup pnpm
269-
uses: pnpm/action-setup@v5
270-
- name: Setup node
271-
uses: actions/setup-node@v6
272-
with:
273-
node-version: 22
274-
cache: pnpm
275-
- name: Install dependencies
276-
run: pnpm install
277-
- name: Download all artifacts
278-
uses: actions/download-artifact@v8
279-
with:
280-
path: artifacts
281-
- name: create npm dirs
282-
run: pnpm napi create-npm-dirs
283-
- name: Move artifacts
284-
run: pnpm artifacts
285-
- name: List packages
286-
run: ls -R ./npm
287-
shell: bash
288-
- name: Publish
289-
run: |
290-
npm config set provenance true
291-
if git log -1 --pretty=%B | grep "^v\?[0-9]\+\.[0-9]\+\.[0-9]\+$";
292-
then
293-
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
294-
npm publish --access public
295-
elif git log -1 --pretty=%B | grep "^v\?[0-9]\+\.[0-9]\+\.[0-9]\+";
296-
then
297-
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
298-
npm publish --tag next --access public
299-
else
300-
echo "Not a release, skipping publish"
301-
fi
302-
env:
303-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
304-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
280+
args: sudo apt-get update && sudo apt-get install -y libxdo-dev libxkbcommon-dev libxi-dev libxtst-dev && npm run test
281+
# publish:
282+
# name: Publish
283+
# runs-on: ubuntu-latest
284+
# needs:
285+
# - lint
286+
# - test-macOS-windows-binding
287+
# - test-linux-binding
288+
# steps:
289+
# - uses: actions/checkout@v6
290+
# - name: setup pnpm
291+
# uses: pnpm/action-setup@v5
292+
# - name: Setup node
293+
# uses: actions/setup-node@v6
294+
# with:
295+
# node-version: 22
296+
# cache: pnpm
297+
# - name: Install dependencies
298+
# run: pnpm install
299+
# - name: Download all artifacts
300+
# uses: actions/download-artifact@v8
301+
# with:
302+
# path: artifacts
303+
# - name: create npm dirs
304+
# run: pnpm napi create-npm-dirs
305+
# - name: Move artifacts
306+
# run: pnpm artifacts
307+
# - name: List packages
308+
# run: ls -R ./npm
309+
# shell: bash
310+
# - name: Publish
311+
# run: |
312+
# npm config set provenance true
313+
# if git log -1 --pretty=%B | grep "^v\?[0-9]\+\.[0-9]\+\.[0-9]\+$";
314+
# then
315+
# echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
316+
# npm publish --access public
317+
# elif git log -1 --pretty=%B | grep "^v\?[0-9]\+\.[0-9]\+\.[0-9]\+";
318+
# then
319+
# echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
320+
# npm publish --tag next --access public
321+
# else
322+
# echo "Not a release, skipping publish"
323+
# fi
324+
# env:
325+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
326+
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

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)