File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 branches-ignore :
99 - ' q/*/**'
1010
11+ pull_request :
12+ branches-ignore :
13+ - ' q/*/**'
14+
1115env :
1216 # Secrets
1317 azurebackend_AZURE_STORAGE_ACCESS_KEY : >-
8084 steps :
8185 - name : Checkout
8286 uses : actions/checkout@v4
87+ with :
88+ fetch-depth : 0
8389 - uses : actions/setup-node@v4
8490 with :
8591 node-version : ' 22'
8995 run : yarn global add typescript@4.9.5
9096 - name : install dependencies
9197 run : yarn install --frozen-lockfile --network-concurrency 1
98+ - name : Prettier (changed files)
99+ run : scripts/format-changed.sh
100+ env :
101+ BASE_SHA : ${{ github.event.pull_request.base.sha }}
102+ BASE_REF : ${{ github.event.pull_request.base.ref }}
103+ if : ${{ github.event_name == 'pull_request' }}
92104 - uses : actions/setup-python@v5
93105 with :
94106 python-version : ' 3.9'
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ ROOT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) /.." && pwd) "
5+ cd " $ROOT_DIR "
6+
7+ BASE_SHA=" ${BASE_SHA:- } "
8+ BASE_REF=" ${BASE_REF:- ${GITHUB_BASE_REF:- } } "
9+ DEFAULT_BASE=" ${DEFAULT_BASE:- origin/ main} "
10+
11+ if [[ -n " $BASE_SHA " ]]; then
12+ DIFF_BASE=" $BASE_SHA "
13+ elif [[ -n " $BASE_REF " ]]; then
14+ DIFF_BASE=" origin/${BASE_REF# origin/ } "
15+ else
16+ DIFF_BASE=" $DEFAULT_BASE "
17+ fi
18+
19+ if ! git rev-parse --verify " ${DIFF_BASE} ^{commit}" > /dev/null 2>&1 ; then
20+ git fetch --no-tags --prune --depth=1 origin " ${DIFF_BASE# origin/ } " > /dev/null 2>&1 || true
21+ fi
22+
23+ if ! git rev-parse --verify " ${DIFF_BASE} ^{commit}" > /dev/null 2>&1 ; then
24+ echo " Base ref ${DIFF_BASE} not found; skipping Prettier check." >&2
25+ exit 0
26+ fi
27+
28+ mapfile -t CHANGED < <( git diff --name-only " ${DIFF_BASE} ...HEAD" --diff-filter=ACMRT \
29+ | grep -E ' \\.(js|cjs|mjs|ts|tsx|json|ya?ml|md)$' || true)
30+
31+ if [[ ${# CHANGED[@]} -eq 0 ]]; then
32+ echo " No supported files changed; skipping Prettier check."
33+ exit 0
34+ fi
35+
36+ echo " Running Prettier check on ${# CHANGED[@]} file(s):"
37+ printf ' - %s\n' " ${CHANGED[@]} "
38+
39+ yarn run --silent prettier --check " ${CHANGED[@]} "
You can’t perform that action at this time.
0 commit comments