# runmacos

> شغّل سكربت shell على جهاز بناء سحابي بنظام macOS، مع مصدر المشروع أو بدونه، واستعد الملفات التي تحددها.

Source: https://air.build/ar/docs/cli/runmacos/

يشغّل `runmacos` سكربت Bash واحدًا على جهاز بناء بنظام macOS مزوّد بـ Xcode، انطلاقًا من بيئة الفريق. لا يحتاج إلى `airbuild.yaml`. استخدمه لأي شيء لا تستطيع البيئة المعزولة فعله وحدها: التحقق من إصداري macOS وXcode، أو تشغيل `swift test`، أو تشغيل أدوات تطبيق macOS.

وهو **للفرق السحابية فقط**. في فريق Mac يتوقف برسالة `runmacos is only available in cloud Teams; local Teams provide runtest.`

## الصيغة

```bash
runmacos [<project-id>] [--source <directory>] [--output <relative-path>]... --command '<shell script>' [--environment ID] [--no-cache]
runmacos --follow [--run ID]    # reattach; starts nothing
runmacos --cancel [--run ID]
runmacos --list-environments
runmacos --help
```

## الخيارات

| الخيار | القيمة | الافتراضي | ما يفعله |
| --- | --- | --- | --- |
| `--command` | سكربت shell | مطلوب | سكربت Bash المراد تشغيله. يعمل في الجذر المرفوع مع `-e -o pipefail`. |
| `<project-id>` | UUID | لا شيء | يرفع هذا المشروع ويعمل في جذره. |
| `--source` | مجلد | لا شيء | يرفع هذا المجلد بدلًا منه. نسبي إلى مجلدك الحالي. إن مُرِّر الاثنان، فـ `--source` هو ما يُرفع. |
| `--output` | مسار نسبي | لا شيء | ملف أو مجلد يُعاد. كرّره لأكثر من واحد. |
| `--environment` | معرّف من `--list-environments` | الافتراضية | التشغيل على بيئة بناء أخرى (إصدار macOS وXcode). |
| `--no-cache` | — | التخزين المؤقت مفعّل | يعمل دون ذاكرات جهاز البناء المؤقتة ولا يحفظ شيئًا. |
| `--follow` | — | — | يعيد الاتصال بتشغيل جارٍ، في أي وضع. في تشغيل منتهٍ يخبرك بذلك ويعيد عرض مخرجاته المحفوظة. |
| `--run` | معرّف التشغيل | التشغيل الجاري، وإلا فالأحدث | مع `--follow` أو `--cancel`. |
| `--cancel` | — | — | يطلب إيقاف التشغيل؛ وينتظر حتى 30 ثانية للتأكيد. |
| `--list-environments` | — | — | يسرد بيئات البناء. |

دون معرّف مشروع أو `--source`، يعمل السكربت في مجلد فارغ ولا يُرفع أي مصدر؛ ومع ذلك تُرسل حزمة صغيرة فيها الأمر وأدواته المساعدة. لا يقبل `runmacos` الخيارات `--platform` و`--sign` و`--unsigned` و`--script` و`--additional-options`.

## على جهاز البناء

- `airbuild-xcode` موجود في `PATH`. أول `airbuild-xcode install` أو `test` في التشغيل يعيد مجلد DerivedData الخاص بالمشروع، ويحفظه التشغيل بعد السكربت؛ أما `archive` و`xcodebuild` المجرد فلا يحصلان على شيء. راجع [airbuild-xcode](https://air.build/ar/docs/cli/airbuild-xcode/).
- `airbuild-cache` موجود في `PATH` للاحتفاظ بملفات أخرى بين التشغيلات. كل ما يستعيده السكربت يُحفظ من جديد بعد انتهائه، في كل مرة. راجع [airbuild-cache](https://air.build/ar/docs/cli/airbuild-cache/).
- Node وnpm وpnpm مثبتة.
- لا تتوفر أي مواد توقيع.

## المخرجات المطلوبة

يجب أن يكون كل `--output` مسارًا محددًا نسبيًا إلى مجلد العمل: دون مسارات مطلقة، أو `..`، أو أحرف بدل، أو روابط رمزية، أو ملفات خاصة، ودون مسار داخل مسار آخر. السكربت الفاشل يعيد مع ذلك المخرجات الموجودة، مع رمز خروجه غير الصفري. والسكربت الناجح الذي لا يكتب أحد المخرجات المعلنة يفشل برمز الخروج `65`.

## المخرجات

```text
• Build started in the Environment. Run: <run-id>
• It runs to completion even if this command is interrupted (reattach with: runmacos --follow --run <run-id>).
Airbuild remote execution
… the script's output …
✓ Command succeeded in <time>.

✓ Command finished.
  Build: <build-id>
  Artifact: <path to the collected outputs>
```

دون `--output` يطبع `No outputs requested; skipping artifact download.`

## تشغيل عدة أوامر

لـ `runmacos` خانته الخاصة، منفصلة عن `runbuild` و`runtest` و`runlinux`. يمكن تشغيل عدة عمليات `runmacos` في وقت واحد. يطبع بدء التشغيل معرّفه؛ وحين تجري عدة تشغيلات يحتاج `--follow` و`--cancel` إلى `--run ID` (أو إلى معرّف مشروع لا يستخدمه إلا واحد منها). الضغط على Ctrl-C يفصل العرض فقط.

## رموز الخروج

| الرمز | المعنى |
| --- | --- |
| `0` | نجح السكربت وكُتبت كل المخرجات. |
| `1` | تعذّر بدء التشغيل أو فُقد. |
| `2` | خيار خاطئ، أو `--command` مفقود؛ لم يُشغَّل شيء. |
| `65` | أحد المخرجات المعلنة مفقود أو لا يمكن تصديره. |
| `130` | أُلغي، أو فُصل بـ Ctrl-C. |
| غير ذلك | رمز الخروج الخاص بالسكربت. |

## الأخطاء

| الرسالة | ما العمل |
| --- | --- |
| `--command requires a nonempty shell script and is only available with runmacos and runlinux.` | مرّر سكربتًا. |
| `--output requires a working-directory-relative path and is only available with runmacos and runlinux.` | أعطِ مسارًا نسبيًا. |
| `--platform takes a platform (…) and is only available with runbuild and runtest.` | احذف `--platform`. |
| `runmacos does not accept build or signing options.` | احذف `--sign` / `--unsigned`. |
| `--follow and --cancel cannot submit a command, outputs, or test options.` | لا تمرّر الأمر عند المتابعة أو الإلغاء. |
| `Declared output was not produced: <path>` | اجعل السكربت يكتبه، أو احذف `--output`. |
| `The command failed and its output files could not be downloaded.` | شغّله من جديد؛ رمز الخروج هو رمز السكربت. |
| `N runmacos executions are running; choose one with --run.` | مرّر أحد معرّفات التشغيل التي يعرضها. |
| `This Team's Environment is already running N runmacos executions, the limit.` | انتظر انتهاء أحدها، أو تابع أحدها. |

## أمثلة

```bash
# What the builder has, no source uploaded
runmacos --command 'xcodebuild -version; swift --version'
```

```bash
# Run a package's tests in the Project
runmacos 3f6c1a2e-8b4d-4f0a-9c1e-2d7b5a6e9f10 --command 'swift test'
```

```bash
# Build a worktree and bring back a report
runmacos --source ../feature-branch --output build/report.txt \
  --command 'mkdir -p build && swift build 2>&1 | tee build/report.txt'
```
