Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Cache nimble
id: cache-nimble
uses: actions/cache@v4
uses: actions/cache@v6
with:
path: ~/.nimble
key: ${{ runner.os }}-${{ runner.arch }}-nimble-v2-${{ hashFiles('*.nimble') }}
Expand Down Expand Up @@ -51,6 +51,8 @@ jobs:

- run: nimble build -d:debug -Y --verbose
if: runner.os != 'Linux'
env:
MACOSX_DEPLOYMENT_TARGET: '11.0'

- run: nimble build -d:debug --verbose --passL:-static
if: runner.os == 'Linux'
Expand All @@ -62,29 +64,53 @@ jobs:

- run: |
mv native_main native_main-x86
nimble build --verbose -d:debug -Y '--passC:"-target arm64-apple-macos11"' '--passL:"-target arm64-apple-macos11"'
nimble build --verbose -d:debug -Y --cpu:arm64 '--passC:"-target arm64-apple-macos11"' '--passL:"-target arm64-apple-macos11"'
mv native_main native_main-arm64
lipo -create -output native_main native_main-x86 native_main-arm64
if: runner.os == 'macOS'

# - run: nimble test -Y

- name: Test native messenger
shell: bash
run: |
if [ "$RUNNER_OS" = Windows ]; then
python test_native_main.py ./native_main
else
python3 test_native_main.py ./native_main
fi

- name: Archive production artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: native_main-${{ runner.os }}
path: native_main

- name: Archive production artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
if: runner.os == 'Linux'
with:
name: native_main-armhf-${{ runner.os }}
path: native_main-armhf

- name: Archive production artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
if: runner.os == 'Linux'
with:
name: native_main-arm64-${{ runner.os }}
path: native_main-arm64

test_macos_arm64:
name: test (macos-15 arm64)
needs: compile
runs-on: macos-15
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
name: native_main-macOS
- name: Test universal artifact natively
run: |
test "$(uname -m)" = arm64
file native_main
lipo -archs native_main
chmod +x native_main
python3 test_native_main.py ./native_main
33 changes: 33 additions & 0 deletions .github/workflows/diagnose_macos_arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: diagnose macOS arm64 releases

on:
pull_request:
branches:
- '*'
workflow_dispatch:

permissions:
contents: read

jobs:
test_release:
name: test release ${{ matrix.version }}
strategy:
fail-fast: false
matrix:
version: ['0.4.1', '0.5.0']
runs-on: macos-15
steps:
- uses: actions/checkout@v7
- name: Download release
run: |
curl --fail --location --show-error \
--output native_main \
"https://github.com/tridactyl/native_messenger/releases/download/${{ matrix.version }}/native_main-macOS"
- name: Test release natively
run: |
test "$(uname -m)" = arm64
file native_main
lipo -archs native_main
chmod +x native_main
python3 test_native_main.py ./native_main
41 changes: 35 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Cache nimble
id: cache-nimble
uses: actions/cache@v4
uses: actions/cache@v6
with:
path: ~/.nimble
key: ${{ runner.os }}-${{ runner.arch }}-nimble-v2-${{ hashFiles('*.nimble') }}
Expand Down Expand Up @@ -50,6 +50,8 @@ jobs:

- run: nimble build -d:danger -d:release --opt:speed -Y --verbose
if: runner.os != 'Linux'
env:
MACOSX_DEPLOYMENT_TARGET: '11.0'

- run: nimble build -d:danger -d:release --opt:speed -Y --verbose --passL:-static
if: runner.os == 'Linux'
Expand All @@ -61,11 +63,20 @@ jobs:

- run: |
mv native_main native_main-x86
nimble build --verbose -d:danger -d:release --opt:speed -Y '--passC:"-target arm64-apple-macos11"' '--passL:"-target arm64-apple-macos11"'
nimble build --verbose -d:danger -d:release --opt:speed -Y --cpu:arm64 '--passC:"-target arm64-apple-macos11"' '--passL:"-target arm64-apple-macos11"'
mv native_main native_main-arm64
lipo -create -output native_main native_main-x86 native_main-arm64
if: runner.os == 'macOS'

- name: Test native messenger
shell: bash
run: |
if [ "$RUNNER_OS" = Windows ]; then
python test_native_main.py ./native_main
else
python3 test_native_main.py ./native_main
fi

- name: Stage release assets
shell: bash
run: |
Expand All @@ -77,20 +88,38 @@ jobs:
fi

- name: Upload release artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: release-${{ runner.os }}
path: release/
if-no-files-found: error

release:
test_macos_arm64:
name: test release (macos-15 arm64)
needs: compile
runs-on: macos-15
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
name: release-macOS
path: release
- name: Test universal artifact natively
run: |
test "$(uname -m)" = arm64
file release/native_main-macOS
lipo -archs release/native_main-macOS
chmod +x release/native_main-macOS
python3 test_native_main.py release/native_main-macOS

release:
needs: [compile, test_macos_arm64]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download release artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8
with:
pattern: release-*
path: release
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
native_main.py
native_main
native_main.exe
__pycache__/
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ Three options:

# Testing

DIY testing:
Build the messenger and run the native messaging protocol tests:

```
./gen_native_message.py cmd..getconfigpath | ./native_main | cut -b4- | jq 'walk( if type == "object" then with_entries(select(.value != null)) else . end)'
```sh
./compile_and_test.sh
```

Swap `native_main` for the old `native_main.py` messenger to check compat.
The tests can also be run against an existing binary with `python3 test_native_main.py PATH_TO_NATIVE_MAIN`.
14 changes: 4 additions & 10 deletions compile_and_test.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#!/usr/bin/env bash
set -o pipefail
set -e
nimble build -d:debug
chmod +x native_main
cp native_main ~/.local/share/tridactyl/native_main
time printf '%c\0\0\0{"cmd": "run", "command": "echo $PATH"}' 39 | ./native_main
time printf '%c\0\0\0{"cmd": "version"}' 39 | ./native_main
# time printf '%c\0\0\0{"cmd": "read", "file": "$HOME/test"}' 39 | ./native_main
# time printf '%c\0\0\0{"cmd": "version"}' 39 | ~/.local/share/tridactyl/native_main.py # approx 100ms
# time printf '%c\0\0\0{"cmd": "run", "command": "echo $PATH"}' 39 | ~/.local/share/tridactyl/native_main.py # approx 100ms
set -euo pipefail

nimble build -d:debug -Y
python3 test_native_main.py ./native_main
Loading
Loading