From d05e4eda54b754b01625bd15ab5bead0ea5e9c82 Mon Sep 17 00:00:00 2001 From: VasilevNStas Date: Mon, 29 Jun 2026 19:57:29 +0300 Subject: [PATCH] #276 portable readlink -f via abspath function readlink -f is not available on macOS by default (only Linux/GNU coreutils). This breaks local development on macOS for anyone testing entry.sh changes. Replace it with a portable abspath function that: - Resolves symlinks (same as readlink -f) - Works on both Linux and macOS - Uses only POSIX commands and basic bash (cd + pwd -P) The while-loop handles chains of symlinks, making it equivalent to readlink -f behaviour. Note: entry.sh runs in Linux Docker containers in production, so readlink -f worked there. This fix improves the developer experience for macOS users without changing production behaviour. --- README.md | 14 ++++++++------ entry.sh | 11 ++++++++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cf5f5a0..bfe11f7 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ based on business rules. Judges run in cycles until no new facts are produced. ## Project Structure -``` +```text judges//.rb — judge implementation, auto-discovered judges//.yml — YAML test for the judge (data-driven) lib/ — shared Ruby libraries @@ -41,7 +41,7 @@ bundle exec rake mkdir judges/hello-world ``` -2. Write the judge logic in `judges/hello-world/hello-world.rb`: +1. Write the judge logic in `judges/hello-world/hello-world.rb`: ```ruby # frozen_string_literal: true @@ -56,7 +56,7 @@ Fbe.fb.query('(and (exists hi) (absent hello))').each do |f| end ``` -3. Write a YAML test in `judges/hello-world/hello-world.yml`: +1. Write a YAML test in `judges/hello-world/hello-world.yml`: ```yaml # SPDX-FileCopyrightText: Copyright (c) 2024-2026 Zerocracy @@ -74,13 +74,13 @@ expected: - /fb/f[_id=1]/hello ``` -4. Run the judge YAML tests: +1. Run the judge YAML tests: ```bash bundle exec judges test --no-log --disable live --lib lib judges ``` -5. Run the full build: +1. Run the full build: ```bash bundle exec rake @@ -90,13 +90,15 @@ If everything is clean, your judge is ready. ## Commands + | Command | Purpose | -|---------|---------| +| ------- | ------- | | `bundle exec rake` | Full build (test + judges + rubocop) | | `bundle exec rake test` | Ruby unit tests only | | `bundle exec judges test --no-log --disable live --lib lib judges` | Judge YAML tests | | `bundle exec rubocop` | Code style check | | `docker build -t swarm .` | Build Docker image (requires Dockerfile) | + ## How to Contribute diff --git a/entry.sh b/entry.sh index 3d60e2c..54ca6a8 100755 --- a/entry.sh +++ b/entry.sh @@ -27,7 +27,16 @@ if ! command -v judges &>/dev/null; then exit 1 fi -self=$(dirname "$(readlink -f "$0")") +# Portable abspath: resolves symlinks, works on Linux and macOS +abspath() { + local target="$1" + while [ -L "${target}" ]; do + target=$(readlink "${target}") + done + cd "$(dirname "${target}")" 2>/dev/null && pwd -P +} + +self=$(abspath "$0") judges update --summary --max-cycles=3 --no-log \ --option "id=${id}" --lib "${self}/lib" "${self}/judges" "${home}/base.fb"