OverviewFilesCommitsIssuesDocsReleasesPeers

godot-keet / .pear-git / ci.yaml

86 lines · yaml ref:
steps:
  - name: write-version
    run: |
      # CI runs in a `git archive | tar -x` extraction with no .git/ directory,
      # so `git rev-list` returns empty — the orchestrator injects git metadata
      # via env vars. Fall back to git only for local runs.
      COUNT="${GIT_COMMIT_COUNT:-$(git rev-list --count HEAD 2>/dev/null || echo 0)}"
      SHORT="${GIT_COMMIT_SHORT:-$(git rev-parse --short HEAD 2>/dev/null || echo unknown)}"
      BUILD_TS=$(date -u +%Y%m%d-%H%M)
      echo "v${COUNT}-${BUILD_TS}-${SHORT}" > version.txt
      sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"0.${COUNT}.0\"/" package.json
  - name: export-godot
    # Export into a subdirectory so build/linux/godot-keet is a DIRECTORY
    # holding the binary + .pck + native .so files. stage-fat-tree copies this
    # dir under by-arch/<host>/build/linux/; the launcher resolves it via
    # resolveBuildDir() and runs build/linux/godot-keet/godot-keet.
    run: mkdir -p build/linux/godot-keet && godot4 --headless --export-release "Linux" build/linux/godot-keet/godot-keet; test -f build/linux/godot-keet/godot-keet
    timeout: 180
  - name: install-public-deps
    run: npm install --production --ignore-scripts
    timeout: 120
  - name: overlay-private-deps
    # npm install resolves public deps (bare-*, framed-stream, etc.) from
    # package-lock.json. rsync --ignore-existing fills in private deps from
    # keet-cli without overwriting npm's versions (npm-resolved wins).
    # Private deps: 25 @holepunchto/* packages + ~190 unscoped transitive deps
    # (keet-identity-key, bip39-mnemonic, autobase, etc.)
    run: rsync -a --ignore-existing /storage/projects/code/hypercore-kb/hyper-fleeky/keet-cli/node_modules/ node_modules/
  - name: copy-keet-daemon
    # Our modified keet-daemon with hyper-social routes (meta, graph, registry, topic, dm-shares).
    # Must overwrite keet-cli's version since rsync already copied it.
    run: rm -rf node_modules/keet-daemon && cp -r /storage/projects/code/hypercore-kb/hyper-fleeky/packages/keet-daemon node_modules/keet-daemon
  - name: verify-deps
    # Prove all critical imports resolve before staging.
    run: |
      FAIL=0
      for mod in @holepunchto/keet-core-hyperdb keet-daemon framed-stream b4a hypercore-crypto corestore hyperswarm hypercore keet-identity-key bip39-mnemonic; do
        if [ ! -d "node_modules/$mod" ]; then echo "MISSING: $mod"; FAIL=1; fi
      done
      test $FAIL -eq 0 && echo "All critical deps present" || exit 1
  - name: tune-rocksdb-memory
    run: sed -i 's/maxWriteBufferNumber = 2/maxWriteBufferNumber = 1/' node_modules/rocksdb-native/lib/column-family.js && sed -i 's/maxOpenFiles = -1/maxOpenFiles = 256/' node_modules/rocksdb-native/lib/state.js
  - name: stage-fat-tree
    # Multi-arch layout for pgh content-addressed install: host-independent
    # files (index.js, daemon, node_modules) at the stage root, platform
    # binaries under by-arch/<host>/build/linux/godot-keet/. The rootTree
    # references all arches; `pgh app install`'s skipPath drops foreign
    # by-arch/<other-host>/ during materialize so each user only fetches their
    # own host's binaries. Replaces the old pear-runtime by-arch/<host>/app/<name>
    # mirror layout (which clean-root'd index.js off the tree root — incompatible
    # with pgh's root-entry expectation). Arch names match Bare.arch (x64, arm64).
    run: |
      RAW=$(uname -m)
      case "$RAW" in x86_64) ARCH=x64 ;; aarch64) ARCH=arm64 ;; *) ARCH="$RAW" ;; esac
      HOST="linux-${ARCH}"
      STAGE=stage
      rm -rf "$STAGE"
      mkdir -p "$STAGE/by-arch/${HOST}/build/linux/godot-keet"

      # Host-independent at top level
      cp index.js package.json version.txt flatten-node-modules.cjs "$STAGE/"
      cp -r daemon "$STAGE/"
      cp -r node_modules "$STAGE/"

      # Host-specific: godot binary + pck + native GDExtension .so (deref symlinks)
      cp -L build/linux/godot-keet/godot-keet "$STAGE/by-arch/${HOST}/build/linux/godot-keet/"
      cp -L build/linux/godot-keet/godot-keet.pck "$STAGE/by-arch/${HOST}/build/linux/godot-keet/" 2>/dev/null; true
      cp -L build/linux/godot-keet/*.so* "$STAGE/by-arch/${HOST}/build/linux/godot-keet/" 2>/dev/null; true
  - name: strip-foreign-prebuilds
    run: |
      RAW=$(uname -m)
      case "$RAW" in x86_64) ARCH=x64 ;; aarch64) ARCH=arm64 ;; *) ARCH="$RAW" ;; esac
      HOST="linux-${ARCH}"
      TARGET="stage/node_modules"
      if [ -d "$TARGET" ]; then
        BEFORE=$(du -sm "$TARGET" | cut -f1)
        find "$TARGET" -path "*/prebuilds/*" -mindepth 1 -maxdepth 1 -type d ! -name "$HOST" -exec rm -rf {} +
        AFTER=$(du -sm "$TARGET" | cut -f1)
        echo "Stripped foreign prebuilds: ${BEFORE}MB -> ${AFTER}MB (saved $((BEFORE - AFTER))MB)"
      fi
  - name: pgh-publish
    run: |
      cd stage
      pgh publish . --accept-conflict "automated CI publish; dep version splits + non-deterministic builds inherited from per-app lockfiles across the pgh ecosystem"
    timeout: 300