Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ updates:
directory: /
schedule:
interval: monthly
# Let new action releases age a week before adopting them.
cooldown:
default-days: 7
groups:
actions:
patterns:
Expand Down
44 changes: 3 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,20 @@
name: CI

# Pull requests only: main requires squash merges of up-to-date branches, so the
# merged tree is the one this workflow already tested.
on:
# No paths-ignore here: "Build and test" is a required check, so it must report on
# every pull request. Docs-only pull requests skip the job instead (see `changes`).
pull_request:
push:
branches:
- main
paths-ignore:
- "**.md"
- "docs/**"

concurrency:
group: ci-${{ github.event_name }}-${{ github.ref }}
group: ci-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
changes:
name: Detect changes
if: github.event_name == 'pull_request'
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
pull-requests: read
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
# Only GitHub-owned actions are allowed in this repository, so filter with the gh CLI.
- name: Filter changed paths
id: filter
shell: bash
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
files=$(gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/files" --jq '.[].filename')
code=false
while IFS= read -r file; do
case "$file" in
*.md | docs/* | "") ;;
*) code=true ;;
esac
done <<< "$files"
echo "code=$code" >> "$GITHUB_OUTPUT"

check:
name: Build and test
needs: changes
# A skipped job still satisfies the required check, so docs-only pull requests can merge.
# Skip only when the filter ran and found no code changes; any other outcome runs the build.
if: ${{ !cancelled() && !(needs.changes.result == 'success' && needs.changes.outputs.code == 'false') }}
runs-on: macos-26
timeout-minutes: 15
steps:
Expand Down
45 changes: 4 additions & 41 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ concurrency:

env:
TARGET: aarch64-apple-darwin
EXPECTED_ARCH: arm64
MINIMUM_MACOS: "26.0"

jobs:
build:
Expand Down Expand Up @@ -63,41 +61,20 @@ jobs:
clang --version
xcrun --show-sdk-version

# make test also checks the version, architecture, and deployment target.
- name: Build and test
run: make all test

- name: Verify and package binary
- name: Package binary
shell: bash
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
binary="build/ferry"
test -x "$binary"

binary_archs="$(lipo -archs "$binary")"
test "$binary_archs" = "$EXPECTED_ARCH" || {
echo "Expected $EXPECTED_ARCH binary, got $binary_archs" >&2
exit 1
}

minos="$(otool -l "$binary" | awk '$1 == "minos" { print $2; exit }')"
test "$minos" = "$MINIMUM_MACOS" || {
echo "Expected minimum macOS $MINIMUM_MACOS, got $minos" >&2
exit 1
}

otool -L "$binary" | grep -q "/AppKit.framework/" || {
echo "The binary must link AppKit" >&2
exit 1
}

test "$("$binary" --version)" = "ferry $VERSION"

package_dir="$RUNNER_TEMP/package-$TARGET"
dist_dir="$RUNNER_TEMP/dist-$TARGET"
mkdir -p "$package_dir" "$dist_dir"
install -m 0755 "$binary" "$package_dir/ferry"
install -m 0755 build/ferry "$package_dir/ferry"
install -m 0644 LICENSE "$package_dir/LICENSE"

archive="ferry-v$VERSION-$TARGET.tar.gz"
Expand Down Expand Up @@ -242,9 +219,6 @@ jobs:
brew install softmaxe/release-test/ferry
brew test softmaxe/release-test/ferry

installed_archs="$(lipo -archs "$(brew --prefix ferry)/bin/ferry")"
test "$installed_archs" = "$EXPECTED_ARCH"

tap-sync:
name: Update Homebrew tap
needs:
Expand Down Expand Up @@ -298,23 +272,12 @@ jobs:
fi

install -m 0644 ../formula/ferry.rb Formula/ferry.rb

status_paths="$(git status --porcelain=v1 --untracked-files=all | awk '{ print $2 }' | LC_ALL=C sort -u)"
if [[ -n "$status_paths" && "$status_paths" != "Formula/ferry.rb" ]]; then
echo "Unexpected Homebrew tap changes:" >&2
git status --short >&2
exit 1
fi

git add Formula/ferry.rb
if git diff --cached --quiet; then
echo "Formula/ferry.rb is already current"
exit 0
fi

git diff --cached --check
test "$(git diff --cached --name-only)" = "Formula/ferry.rb"
git diff --cached -- Formula/ferry.rb
git diff --cached

git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
VERSION = 0.0.1

ARCH = arm64
MACOS_MIN = 26.0

CC ?= clang
CFLAGS ?= -O2
CFLAGS += -Wall -Wextra -fno-objc-arc -arch arm64 \
-mmacosx-version-min=26.0 -DFERRY_VERSION='"$(VERSION)"'
CFLAGS += -Wall -Wextra -fno-objc-arc -arch $(ARCH) \
-mmacosx-version-min=$(MACOS_MIN) -DFERRY_VERSION='"$(VERSION)"'
# AppKit is linked although no AppKit API is called: the window server ignores
# the bridged move operation from processes that have not loaded it.
FRAMEWORKS = -framework AppKit -framework ApplicationServices \
Expand All @@ -22,6 +25,7 @@ $(BIN): src/ferry.m Makefile

test: $(BIN)
tests/cli.sh $(BIN) $(VERSION)
tests/binary.sh $(BIN) $(ARCH) $(MACOS_MIN)

# Requires a live desktop and Accessibility; temporarily switches Spaces.
test-follow: $(BIN) build/follow-test
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ make test
make install PREFIX="$HOME/.local"
```

`make test` checks the command-line interface only. It does not move windows.
`make test` checks the command-line interface and the built binary's architecture,
deployment target, and linked frameworks. It does not move windows.
`make test-follow` runs the live desktop regression for background `--window`
commands. It requires Accessibility and two normal Spaces on the active display,
creates temporary test windows, and temporarily switches Spaces. It closes the
Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ make test
make install PREFIX="$HOME/.local"
```

`make test` 只检查命令行接口,不会移动窗口。`make test-follow` 针对后台 `--window` 命令运行真实桌面回归测试。它需要辅助功能权限,且当前显示器上有两个普通 Space;测试会创建临时测试窗口并临时切换 Space,结束后关闭测试窗口并恢复原来的 App。
`make test` 只检查命令行接口和构建产物的架构、最低系统版本及链接的框架,不会移动窗口。`make test-follow` 针对后台 `--window` 命令运行真实桌面回归测试。它需要辅助功能权限,且当前显示器上有两个普通 Space;测试会创建临时测试窗口并临时切换 Space,结束后关闭测试窗口并恢复原来的 App。

### 升级和卸载

Expand Down
30 changes: 30 additions & 0 deletions tests/binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
# Build output tests: the shipped binary must match the architecture and
# deployment target in the Makefile and link AppKit.

set -euo pipefail

binary="${1:?usage: tests/binary.sh <binary> <arch> <minimum-macos>}"
arch="${2:?usage: tests/binary.sh <binary> <arch> <minimum-macos>}"
minimum_macos="${3:?usage: tests/binary.sh <binary> <arch> <minimum-macos>}"
failures=0

check() {
local name="$1" expected="$2" actual="$3"

if [[ "$actual" != "$expected" ]]; then
echo "FAIL: $name: expected $expected, got $actual" >&2
failures=$((failures + 1))
else
echo "ok: $name"
fi
}

check "architecture" "$arch" "$(lipo -archs "$binary")"
check "minimum macOS" "$minimum_macos" "$(otool -l "$binary" | awk '$1 == "minos" { print $2; exit }')"
check "links AppKit" "yes" "$(otool -L "$binary" | grep -q '/AppKit.framework/' && echo yes || echo no)"

if ((failures)); then
echo "$failures test(s) failed" >&2
exit 1
fi
Loading