diff --git a/.githooks/pre-push b/.githooks/pre-push new file mode 100644 index 0000000..ef5ab57 --- /dev/null +++ b/.githooks/pre-push @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -euo pipefail +r="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"; cd "$r" +if [[ "${1:-}" == --install ]]; then chmod +x .githooks/pre-push; git config core.hooksPath .githooks; echo 'installed Zed pre-push hook'; exit 0; fi +[[ -f .zpkg.toml ]] || exit 0 +command -v zed >/dev/null || { echo 'zed CLI is required' >&2; exit 1; } +[[ -f .zpkg.lock ]] || { echo '.zpkg.lock is required; run zed install and commit it' >&2; exit 1; } +zed validate --require-lock +zed install +if ! git diff --quiet -- .zpkg.lock; then echo 'Zed dependency lock is stale relative to newest versions allowed by .zpkg.toml.' >&2; git --no-pager diff -- .zpkg.lock >&2 || true; exit 1; fi +zed install --frozen +zed build +if [[ -f Cargo.toml ]]; then if [[ -f Cargo.lock ]]; then zed develop --no-install -c 'cargo check --locked --all-targets'; else zed develop --no-install -c 'cargo check --all-targets'; fi; fi +if [[ -f go.mod ]]; then zed develop --no-install -c 'go test ./...'; fi +if [[ -f package.json ]]; then if [[ -f pnpm-lock.yaml ]]; then pm='corepack pnpm'; ins='corepack pnpm install --frozen-lockfile'; elif [[ -f package-lock.json ]]; then pm='npm'; ins='npm ci'; elif [[ -f yarn.lock ]]; then pm='corepack yarn'; ins='corepack yarn install --immutable'; else pm='npm'; ins='npm install --ignore-scripts'; fi; if node -e 'const p=require("./package.json");process.exit(p.scripts?.typecheck?0:1)'; then s=typecheck; elif node -e 'const p=require("./package.json");process.exit(p.scripts?.build?0:1)'; then s=build; else echo 'Node package has no typecheck/build script' >&2; exit 1; fi; zed develop --no-install -c "$ins && $pm run $s"; fi +if [[ -f pyproject.toml || -f setup.py ]]; then zed develop --no-install -c 'python3 -m compileall -q .'; fi +if [[ -f pom.xml ]]; then zed develop --no-install -c 'mvn -B -DskipTests compile'; fi +if [[ -f gradlew ]]; then zed develop --no-install -c './gradlew --no-daemon classes'; fi +p="${TMPDIR:-/tmp}/zed-latest-deps-pack-$$"; trap 'rm -rf "$p"' EXIT; mkdir -p "$p"; zed pack --out "$p" diff --git a/.github/workflows/zed-latest-deps.yml b/.github/workflows/zed-latest-deps.yml new file mode 100644 index 0000000..7a0a9cd --- /dev/null +++ b/.github/workflows/zed-latest-deps.yml @@ -0,0 +1,25 @@ +name: Zed latest dependency gate +on: [pull_request, workflow_dispatch] +permissions: {contents: read} +concurrency: + group: zed-latest-deps-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +jobs: + zed-latest-deps: + name: zed-latest-deps + runs-on: ubuntu-latest + timeout-minutes: 30 + env: {ZED_PKG_INTERACTIVE: "false", GITHUB_TOKEN: "${{ github.token }}"} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: {fetch-depth: 0, persist-credentials: false} + - name: Install pinned Zed CLI v0.3.0 + shell: bash + run: | + set -euo pipefail + a="$RUNNER_TEMP/zed.tar.gz"; d="$RUNNER_TEMP/zed-release" + curl --fail --location --retry 3 --retry-all-errors -o "$a" https://github.com/zed-pkg/zed-cli/releases/download/v0.3.0/zed-x86_64-unknown-linux-gnu.tar.gz + printf '%s %s\n' f87576bc289e43ed647902527e7be70566445d2f1fd11249f067ab35547d4b8a "$a" | sha256sum --check --strict + mkdir -p "$d" "$HOME/.local/bin"; tar -xzf "$a" -C "$d"; z="$(find "$d" -type f -name zed -perm -111 -print -quit)"; test -n "$z"; install -m 0755 "$z" "$HOME/.local/bin/zed"; echo "$HOME/.local/bin" >> "$GITHUB_PATH" + - run: zed --version + - run: bash .githooks/pre-push --ci