Skip to content

fix(scripts): DNS ドリフト検査が読む秘密のパスを直す (#590) #1489

fix(scripts): DNS ドリフト検査が読む秘密のパスを直す (#590)

fix(scripts): DNS ドリフト検査が読む秘密のパスを直す (#590) #1489

Workflow file for this run

name: CI
# gh 非依存な CI 本体。ビルド対象/チェックはすべて om.yaml + flake 出力に宣言し、
# ここは「Nix を入れて om ci を回すだけ」の薄いプロバイダアダプタに留める。
# 同じ `om ci run` は Forgejo / GitLab / ローカルでもそのまま使える。
on:
push:
branches: [main]
paths:
- 'nix/**'
- 'configs/**'
- 'secrets/**'
- 'scripts/**'
- 'docs/NIXOS_*.md'
- 'Justfile'
- '.statix.toml'
- '.gitleaks.toml'
- 'om.yaml'
- '.github/actions/setup-nix/**'
- '.github/workflows/ci.yml'
pull_request:
paths:
- 'nix/**'
- 'configs/**'
- 'secrets/**'
- 'scripts/**'
- 'docs/NIXOS_*.md'
- 'Justfile'
- '.statix.toml'
- '.gitleaks.toml'
- 'om.yaml'
- '.github/actions/setup-nix/**'
- '.github/workflows/ci.yml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
# Which systems this run has to build. Pushes to main always build every system; a pull
# request narrows it only when every path it touches names one side unambiguously
# (scripts/ci-plan-systems.sh, with its own --demo self-check). The default is everything,
# because almost anything under nix/modules or configs reaches every host.
plan:
runs-on: ubuntu-24.04
outputs:
systems: ${{ steps.plan.outputs.systems }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
fetch-depth: 0
- id: plan
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
systems=$(git diff --name-only "origin/${{ github.base_ref }}...HEAD" \
| ./scripts/ci-plan-systems.sh)
else
systems=$(./scripts/ci-plan-systems.sh </dev/null)
fi
echo "systems=$systems" >>"$GITHUB_OUTPUT"
echo "building for: $systems"
om-ci:
name: om ci (${{ matrix.system }})
needs: plan
strategy:
# 1 system が落ちたら残りを即キャンセルして無駄な CI 時間/課金を抑える。
# 全 system の失敗を一度に見たいときは workflow_dispatch で cold-build を回す。
fail-fast: true
# system -> runner の対応だけがプロバイダ固有。main では omnix が各 system の全出力
# (packages/checks/darwin+nixos configs/home activationPackage) を回し、PR では
# 日常機だけの pr-gate を作る。system に依らないリンタ類は下の checks ジョブに分離。
matrix:
system: ${{ fromJSON(needs.plan.outputs.systems) }}
include:
- system: x86_64-linux
runner: ubuntu-24.04
pr_runner: ubuntu-24.04
# darwin だけ自前ランナー (macmini)。動機は「macos-14 が遅い」ではなく、遅さの
# 中身が転送だと分かったこと。
#
# 2026-09-10 の実測: 420s のジョブのうち 346s が nix build (pr-gate) で、その中身は
# 「6 derivations will be built / 6119 paths will be fetched (12.2 GiB, 展開 34.3 GiB)」。
# 実際に建てていたのは 6 個で、残りはキャッシュから落としていただけ。しかも数分後に
# 捨てられるランナーの上に展開している。store が残る機械では、この 346s は消える。
#
# nix-fast-build --skip-cached で転送だけ止める案は先に試して落ちた。内側の
# nix-eval-jobs が自前の nix を抱えていて git input の narHash が外側と食い違い
# (CI では checkout が detached HEAD なので `could not read HEAD ref` が出る)、
# path: で渡すとフレークがリポジトリ根の configs/ を参照している構造と噛み合わない。
# 素の nix にも「実体化はするがクロージャは落とさない」動作は無い。
#
# 2026-09-01 に一度試して戻したときの 7 つの穴 (SSH 越しのユーザー作成 / config.sh と
# run.sh の位置 / launchd の EX_CONFIG / 登録トークンの権限 / actionlint がカスタム
# ラベルを知らない / node24 / cachix) は hosts/macmini-ci-runner.nix 側で埋めてある。
# 戻したのはこの一行だけだった。
#
# macmini は AI 常駐 (ComfyUI / Hermes / 文字起こし) と同居する。載せるのは pull
# request だけで、そちらは store が温まっていれば転送も計算もほとんど無い。重い方
# (main の om ci run) は GitHub に残す — 下の runs-on を参照。
- system: aarch64-darwin
runner: macos-14
pr_runner: macmini
# Pull requests go to the self-hosted runner, main goes to GitHub's.
#
# The split follows what the two events actually cost. A pull request builds `pr-gate`, which
# is dominated by transfer — 12.2 GiB on darwin, 3.7 GiB on linux, against six derivations
# actually built — so a machine whose store persists skips nearly all of it (measured
# 2026-09-10: 346s to 18s). `om ci run` on main is the opposite: it builds every output for
# the system, including the closures and VM tests no pull request touches, and it is what
# fills cachix. That is real work, and it belongs on a machine that exists to be spent rather
# than on one running things people depend on.
runs-on: ${{ github.event_name == 'pull_request' && matrix.pr_runner || matrix.runner }}
timeout-minutes: 90
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
fetch-depth: 0 # gitleaks detect が全履歴を走査するため必須
# cachix (gapul-dotfiles) を pull+push。token があるジョブ (owner の push/main)
# は build 出力を push し、以降の run と各実機 dev で共有する。fork PR は
# secret 不可なので pull のみ。詳細は setup-nix/action.yml を参照。
- uses: ./.github/actions/setup-nix
with:
cachix-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
mocopi-deploy-key: ${{ secrets.MOCOPI_DEPLOY_KEY }}
# PR は日常機だけを検証する (packages.<system>.pr-gate)。omnix は subflake の全出力を
# 作る仕様で出力を選べないため、PR 用の部分集合は flake 側の集約パッケージで表現し、
# ここでは素の nix build で叩く。macmini closure / NixOS 群 / VM テストは下の main
# 側で作られ、cachix もそこで埋まる。
- name: nix build (pr-gate)
if: github.event_name == 'pull_request'
run: |
nix --accept-flake-config build ./nix#packages.${{ matrix.system }}.pr-gate \
--no-link --print-build-logs
# omnix 本体は om.cachix.org から取得 (--accept-flake-config)。ソースビルドしない。
- name: om ci run
if: github.event_name != 'pull_request'
run: |
nix --accept-flake-config run github:juspay/omnix/v1.3.2 -- \
ci run \
--systems "${{ matrix.system }}" \
--extra-access-tokens ${{ secrets.GITHUB_TOKEN }} \
-- --accept-flake-config
# system に依らない検査 (lint / gitleaks / generated-drift)。om ci の build/flake-check は
# om.yaml の checks 構成側で無効にしてあるので、ここは custom step だけを回す。
# 独立ジョブにしているのは、どの system ジョブに相乗りさせても、そのジョブがそのまま
# CI 全体の長い棒になるため (実測: darwin へ載せると 7m、x86_64-linux へ載せると 6m)。
checks:
name: checks (lint / gitleaks / generated)
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
fetch-depth: 0 # gitleaks detect が全履歴を走査するため必須
- uses: ./.github/actions/setup-nix
with:
cachix-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
mocopi-deploy-key: ${{ secrets.MOCOPI_DEPLOY_KEY }}
- name: om ci run (checks)
run: |
nix --accept-flake-config run github:juspay/omnix/v1.3.2 -- \
ci run .#checks \
--systems x86_64-linux \
--extra-access-tokens ${{ secrets.GITHUB_TOKEN }} \
-- --accept-flake-config