HOTFIX: fix precommit for main (#18863)

* HOTFIX: fix precommit (#18854)

* fix precommit

* avoid moving package.json

---------

Co-authored-by: = <=>

* fix yarn-lock-check precommit

---------

Co-authored-by: = <=>
This commit is contained in:
Raphael Speyer 2024-03-26 17:55:20 +11:00 committed by GitHub
parent e09d7c3d6e
commit f7faf1e1f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 10 deletions

View File

@ -11,14 +11,14 @@ repos:
- id: hlint
name: hlint
language: system
entry: "hlint -j"
entry: "hlint -j --hint=sdk/.hlint.yaml"
require_serial: true
types: [haskell]
- id: scalafmt
name: scalafmt
language: system
require_serial: true
entry: "scalafmt --respect-project-filters"
entry: "scalafmt --config=sdk/.scalafmt.conf --respect-project-filters"
types: [scala]
- id: javafmt
name: javafmt
@ -30,14 +30,14 @@ repos:
name: buildifier
language: system
require_serial: true
entry: "bazel run //:buildifier-pre-commit -- -mode=fix -v=true"
entry: "bash -c 'cd sdk/; bazel run //:buildifier-pre-commit -- -mode=fix -v=true'"
types: [bazel]
- id: pprettier
name: pprettier
language: system
require_serial: true
# NB: we need to pass a single argument which ends up in $0 when invoking bash -c
entry: "bash -c 'yarn install --silent && yarn run pprettier --write \"$@\"' bash"
entry: "bash -c 'yarn install --silent && files=(\"$@\") && yarn run --cwd=sdk pprettier --write ${files[@]##sdk/}' bash"
types_or: [ts, tsx]
- id: copyrights
name: copyright headers
@ -50,13 +50,13 @@ repos:
name: platform-independence-check
language: system
pass_filenames: false
entry: "pre-commit/platform-independence-check.sh"
entry: "sdk/pre-commit/platform-independence-check.sh"
- id: yarn-lock-check
name: yarn-lock-check
language: system
pass_filenames: false
files: ^(package.json|yarn.lock)$
entry: "pre-commit/yarn-lock-check.sh"
pass_filenames: true
files: ^sdk/(package.json|yarn.lock)$
entry: "sdk/pre-commit/yarn-lock-check.sh"
- id: mainonly
name: main only
description: Check for changes under packages with targets tagged with main-only

View File

@ -5,11 +5,13 @@
set -euo pipefail
TMP_DIR=$(mktemp -d)
cp package.json yarn.lock $TMP_DIR
trap 'rm -rf -- "$TMP_DIR"' EXIT
cp sdk/package.json sdk/yarn.lock $TMP_DIR
(cd $TMP_DIR; yarn install --silent > /dev/null)
if ! diff yarn.lock $TMP_DIR/yarn.lock; then
if ! diff -u sdk/yarn.lock $TMP_DIR/yarn.lock; then
echo "FAIL: yarn.lock could not satisfy package.json" 1>&2
echo "FAIL: yarn.lock requires all of the above changes" 1>&2
exit 1