@@ -93,7 +93,7 @@ echo "qa-changed: checking packages: ${packages[*]}"
9393
9494arch_files=()
9595for file in " ${changed_files[@]} " ; do
96- if [[ " $file " =~ ^pi-packages/pi-[^/]+/.* \. tsx? $ ]]; then
96+ if [[ -f " $ROOT_DIR / $file " && " $file " =~ ^pi-packages/pi-[^/]+/.* \. tsx? $ ]]; then
9797 arch_files+=(" $file " )
9898 fi
9999done
@@ -114,7 +114,61 @@ if ! command -v jq >/dev/null 2>&1; then
114114 exit 1
115115fi
116116
117+ existing_packages=()
118+ removed_packages=()
119+ for pkg in " ${packages[@]} " ; do
120+ if [[ -f " $ROOT_DIR /pi-packages/$pkg /package.json" ]]; then
121+ existing_packages+=(" $pkg " )
122+ else
123+ removed_packages+=(" $pkg " )
124+ fi
125+ done
126+
127+ if [[ ${# removed_packages[@]} -gt 0 ]]; then
128+ echo " qa-changed: skipping removed packages: ${removed_packages[*]} "
129+ fi
130+ packages=(" ${existing_packages[@]} " )
131+
132+ run_integration=0
133+ if [[ $run_all -eq 1 ]]; then
134+ run_integration=1
135+ else
136+ for file in " ${changed_files[@]} " ; do
137+ if [[ " $file " == pi-packages/tests/* || " $file " == pi-packages/package.json ]]; then
138+ run_integration=1
139+ break
140+ fi
141+ if [[ " $file " == pi-packages/bun.lock && ${# packages[@]} -gt 0 ]]; then
142+ run_integration=1
143+ break
144+ fi
145+ done
146+ fi
147+
148+ if [[ ${# packages[@]} -eq 0 && $run_integration -eq 0 ]]; then
149+ echo " qa-changed: no remaining packages or integration tests to check"
150+ exit 0
151+ fi
152+
117153echo " qa-changed: ensuring workspace deps are installed"
154+ symlinked_node_modules=()
155+ while IFS= read -r -d ' ' link_path; do
156+ link_target=" $( readlink " $link_path " ) "
157+ symlinked_node_modules+=(" $link_path =$link_target " )
158+ rm -f " $link_path "
159+ done < <( find " $ROOT_DIR /pi-packages" -mindepth 2 -maxdepth 2 -type l -name node_modules -print0)
160+
161+ restore_symlinked_node_modules () {
162+ local record link_path link_target
163+ for record in " ${symlinked_node_modules[@]} " ; do
164+ link_path=" ${record%% =* } "
165+ link_target=" ${record#* =} "
166+ rm -rf " $link_path "
167+ ln -s " $link_target " " $link_path "
168+ done
169+ }
170+ trap restore_symlinked_node_modules EXIT
171+
118172(
119173 cd " $ROOT_DIR /pi-packages"
120174 bun install --frozen-lockfile --silent
@@ -128,10 +182,6 @@ has_script() {
128182
129183for pkg in " ${packages[@]} " ; do
130184 pkg_dir=" $ROOT_DIR /pi-packages/$pkg "
131- if [[ ! -f " $pkg_dir /package.json" ]]; then
132- echo " error: package not found: $pkg " >&2
133- exit 1
134- fi
135185
136186 if has_script " $pkg_dir " typecheck; then
137187 echo " qa-changed: $pkg -> typecheck"
@@ -144,18 +194,6 @@ for pkg in "${packages[@]}"; do
144194 fi
145195done
146196
147- run_integration=0
148- if [[ $run_all -eq 1 ]]; then
149- run_integration=1
150- else
151- for file in " ${changed_files[@]} " ; do
152- if [[ " $file " == pi-packages/tests/* || " $file " == pi-packages/package.json || " $file " == pi-packages/bun.lock ]]; then
153- run_integration=1
154- break
155- fi
156- done
157- fi
158-
159197if [[ $run_integration -eq 1 ]]; then
160198 echo " qa-changed: running pi-packages integration tests"
161199 (cd " $ROOT_DIR /pi-packages" && bun run --silent test:integration)
0 commit comments