Something went wrong. Try again.
Something went wrong. Try again.
4.9 kB · 135 lines
Shell
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136#!/usr/bin/env bash## Run the GitLab build pipeline on this machine, in the pinned builder# container:## make all## This mirrors the jobs in .gitlab-ci.yml: the test job, every cross-compiled# node target (with its desktop package), both Android APKs, the macOS desktop# app, and iOS. Artifacts land in bin/ as the CI jobs leave them; the iOS# archive stays on the macOS machine that builds it.## The tag-only release/upload jobs (npm, GitLab release, deb, Homebrew) are# deliberately not run: they publish and need CI credentials.## iOS is the one job that cannot run on Linux. Set MAC_HOST (and optionally# MAC_REPO) to dispatch it to a macOS machine with the same checkout; otherwise# it is reported as skipped. Set ALL_STRICT=1 to make skips fatal.## A fresh checkout is assumed, like a CI runner. `make all` reconfigures# build-linux-amd64 for the static release build; the test job uses# build-test-linux-amd64 so the two native builds do not fight.set -euo pipefail
cd "$(dirname "$0")/.."REPO="$PWD"TEST_BUILDDIR="${TEST_BUILDDIR:-build-test-linux-amd64}"SKIPPED=()
step() { printf '\n==> %s\n' "$*"}
if [ "$(uname -s)" != "Linux" ]; then echo "make all runs the Linux pipeline; run it on Linux (or in the builder container)." >&2 exit 1fi
. hack/lib/container.sh
# ---------------------------------------------------------------------------# test job# ---------------------------------------------------------------------------step "version and frontends"run make version# Build the embedded bundles from the current source; `make dev` would reuse a# stale dist directory left by a previous branch.run make app
step "test (dev build and Go tests)"# Separate build directory: the release target below wants a static# build-linux-amd64, while dev/tests want a shared one.run make dev BUILDDIR="$TEST_BUILDDIR"run env STREAMPLACE_TEST_COUNT=1 make dev-test BUILDDIR="$TEST_BUILDDIR"
step "lexicons are up to date"# `make ci-lexicons` compares the whole tree with git, which fails on any# unrelated local edit. Check instead that running the generator does not# change the tree, which is the invariant CI is protecting.tree_state() { { git diff --binary; git status --porcelain; } | git hash-object --stdin}LEXICON_STATE="$(tree_state)"run make lexiconsif [ "$(tree_state)" != "$LEXICON_STATE" ]; then echo "lexicons are out of date; run make lexicons and commit the generated files" >&2 git diff exit 1fi
# ---------------------------------------------------------------------------# node jobs: build the target, then its desktop package and distro package# ---------------------------------------------------------------------------target() { local target="$1" step "$target" run make "$target" # test-vod only runs on the build host, so in CI it is a no-op for the # cross-compiled jobs. Here the linux-amd64 binary exists, so run it once. if [ "$target" = "linux-amd64" ]; then run make test-vod fi run make "desktop-$target" run make "pkg-$target"}
target linux-amd64target linux-arm64target windows-amd64target darwin-amd64target darwin-arm64
# ---------------------------------------------------------------------------# android jobs# ---------------------------------------------------------------------------# `make app` above already ran `expo prebuild`, so build the bundles directly.# The ci-android-* targets also upload to the GitLab package registry, which# needs CI_JOB_TOKEN and fails on a local machine.step "android-debug"run make android-debug
step "android-release"run make android-release
# ---------------------------------------------------------------------------# macOS desktop app (packages and signs with rcodesign on Linux)# ---------------------------------------------------------------------------step "desktop-darwin"run make desktop-darwin-linux
# ---------------------------------------------------------------------------# iOS: requires Xcode, so it stays on macOS# ---------------------------------------------------------------------------if [ -n "${MAC_HOST:-}" ]; then step "ios on $MAC_HOST" COMMIT="$(git rev-parse HEAD)" MAC_REPO="${MAC_REPO:-$REPO}" # The remote checkout must be at the same commit; --make all does not push. ssh "$MAC_HOST" "cd '$MAC_REPO' && test \"\$(git rev-parse HEAD)\" = '$COMMIT' && make version install app ios"else SKIPPED+=("build-ios: needs macOS; set MAC_HOST=user@host (and MAC_REPO=/path/to/checkout)")fi
# ---------------------------------------------------------------------------# report# ---------------------------------------------------------------------------printf '\n'if [ "${#SKIPPED[@]}" -gt 0 ]; then printf 'skipped (cannot run on this host):\n' printf ' - %s\n' "${SKIPPED[@]}" if [ "${ALL_STRICT:-0}" = "1" ]; then exit 1 fifiecho "make all: done"