Skip to content

Commit a0060d7

Browse files
chore/monorepos (#244)
* adds target to generate 100s of files * removes lfs dependencies * address codex review comment --------- Co-authored-by: Matthew Peterkort <33436238+matthewpeterkort@users.noreply.github.com> Co-authored-by: matthewpeterkort <matthewpeterkort@gmail.com>
1 parent 036fe59 commit a0060d7

2 files changed

Lines changed: 23 additions & 47 deletions

File tree

tests/monorepos/Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ GEN := generate-fixtures
44
GF_SRC := ./generate-fixtures.go
55
OUTDIR := fixtures
66

7-
.PHONY: test-monorepos build-generate-fixtures prepare-repo generate-fixtures-run finalize clean
7+
.PHONY: test-monorepos build-generate-fixtures prepare-repo generate-fixtures-run finalize clean generate-large-fixtures-run
88

99
test-monorepos: build-generate-fixtures prepare-repo generate-fixtures-run finalize
1010
@echo "test-monorepos complete: $(OUTDIR)"
@@ -24,12 +24,17 @@ prepare-repo:
2424
# @echo " OK"
2525

2626
generate-fixtures-run:
27-
@echo "Generating fixtures into $(OUTDIR)"
27+
@echo "Generating small set of fixtures into $(OUTDIR)"
2828
# Provide TCGA list; change or pipe your own list to the binary as needed.
29-
# @cd $(OUTDIR); printf "TARGET-ALL-P2\nTCGA-GBM\nTCGA-HNSC\nTCGA-KICH\nTCGA-KIRC\nTCGA-KIRP\nTCGA-LAML\nTCGA-LGG\nTCGA-LIHC\nTCGA-LUAD\nTCGA-LUSC\nTCGA-MESO\nTCGA-OV\nTCGA-PAAD\nTCGA-PCPG\nTCGA-PRAD\nTCGA-READ\nTCGA-SARC\nTCGA-SKCM\nTCGA-STAD\nTCGA-TGCT\nTCGA-THCA\nTCGA-THYM\nTCGA-UVM\nWCDT-MCRPC\n" | ../$(GEN) --number-of-subdirectories=3 --number-of-files=100 -- > /dev/null
3029
@cd $(OUTDIR); printf "TARGET-ALL-P2\n" | ../$(GEN) --number-of-subdirectories=1 --number-of-files=2 -- > /dev/null
3130
@echo " OK"
3231

32+
generate-large-fixtures-run:
33+
@echo "Generating large set of fixtures into $(OUTDIR)"
34+
# Provide TCGA list; change or pipe your own list to the binary as needed.
35+
@cd $(OUTDIR); printf "TARGET-ALL-P2\nTCGA-GBM\nTCGA-HNSC\nTCGA-KICH\nTCGA-KIRC\nTCGA-KIRP\nTCGA-LAML\nTCGA-LGG\nTCGA-LIHC\nTCGA-LUAD\nTCGA-LUSC\nTCGA-MESO\nTCGA-OV\nTCGA-PAAD\nTCGA-PCPG\nTCGA-PRAD\nTCGA-READ\nTCGA-SARC\nTCGA-SKCM\nTCGA-STAD\nTCGA-TGCT\nTCGA-THCA\nTCGA-THYM\nTCGA-UVM\nWCDT-MCRPC\n" | ../$(GEN) --number-of-subdirectories=3 --number-of-files=100 -- > /dev/null
36+
@echo " OK"
37+
3338
finalize:
3439
@echo " OK Fixtures created at $(OUTDIR)"
3540

tests/monorepos/run-test.sh

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -135,31 +135,6 @@ if [ ! -d "fixtures" ]; then
135135
exit 1
136136
fi
137137

138-
# ensure git-lfs is installed
139-
if ! command -v git-lfs >/dev/null 2>&1; then
140-
echo "error: git-lfs is not installed; please install it to proceed" >&2
141-
# Example install command:
142-
if [ "$(uname -s)" = "Darwin" ]; then
143-
if ! command -v brew >/dev/null 2>&1; then
144-
echo "error: Homebrew is not installed. Please install Homebrew first:" >&2
145-
echo " https://brew.sh" >&2
146-
exit 1
147-
fi
148-
echo "installing git-lfs via Homebrew on macOS" >&2
149-
if ! brew install git-lfs; then
150-
echo "error: failed to install git-lfs via Homebrew" >&2
151-
exit 1
152-
fi
153-
if ! git lfs install --skip-smudge; then
154-
echo "error: failed to initialize git-lfs" >&2
155-
exit 1
156-
fi
157-
else
158-
echo "See installation instructions for your platform:" >&2
159-
echo " https://github.com/git-lfs/git-lfs/wiki/Installation" >&2
160-
exit 1
161-
fi
162-
fi
163138

164139
# ensure git-drs is running from this project's build
165140
# run `which git-drs` and check if it's in the build directory
@@ -177,7 +152,7 @@ echo "Using git-drs from: $(which git-drs)" >&2
177152

178153

179154
# ensure a gen3 project exists
180-
calypr_admin projects ls --profile "$PROFILE" | grep "/programs/$PROGRAM/projects/$PROJECT" >/dev/null 2>&1 || {
155+
calypr-cli auth --profile=$PROFILE --all | grep "/programs/$PROGRAM/projects/$PROJECT" >/dev/null 2>&1 || {
181156
echo "error: /programs/$PROGRAM/projects/$PROJECT does not exist; please create it first" >&2
182157
exit 1
183158
}
@@ -199,7 +174,7 @@ if [ "$CLONE" = "true" ]; then
199174
cd ../clone
200175
echo "Cloning remote repository into ../clone" >&2
201176
# clone into current directory
202-
if ! git clone "$GIT_REMOTE" .; then
177+
if ! GIT_LFS_SKIP_SMUDGE=1 git clone --branch main "$GIT_REMOTE" .; then
203178
echo "error: git clone failed" >&2
204179
exit 1
205180
fi
@@ -211,8 +186,8 @@ if [ "$CLONE" = "true" ]; then
211186
fi
212187
echo "Pulling LFS objects from remote" >&2
213188
git drs init
214-
git drs remote add gen3 "$PROFILE" "$PROGRAM/$PROJECT" --cred "$CREDENTIALS_PATH"
215-
git lfs pull origin main
189+
git drs remote add gen3 origin "$PROGRAM/$PROJECT" --cred "$CREDENTIALS_PATH"
190+
git drs pull origin
216191
if grep -q 'https://git-lfs.github.com/spec/v1' ./TARGET-ALL-P2/sub-directory-1/*file-0001.dat; then
217192
echo "error: LFS pointer resolved and data in `TARGET-ALL-P2/sub-directory-1/file-0001.dat`" >&2
218193
exit 1
@@ -234,8 +209,8 @@ else
234209
git remote add origin "$GIT_REMOTE"
235210

236211
# Initialize drs configuration for this repo
237-
git drs init -t 16
238-
git drs remote add gen3 "$PROFILE" "$PROGRAM/$PROJECT" --cred "$CREDENTIALS_PATH"
212+
git drs init -t 16 --enable-data-client-logs
213+
git drs remote add gen3 origin "$PROGRAM/$PROJECT" --cred "$CREDENTIALS_PATH"
239214
# Set multipart-threshold to 10 (MB) for testing purposes
240215
# Using a smaller threshold to force a multipart upload for testing
241216
# default is 500 (MB)
@@ -256,8 +231,8 @@ else
256231
fi
257232

258233
# Ensure enable-data-client-logs is present in git config
259-
if ! git config --list | grep -q -- 'enable-data-client-logs'; then
260-
echo "error: git config key 'enable-data-client-logs' not found; please set it before running tests" >&2
234+
if ! git config --local --get drs.enable-data-client-logs >/dev/null; then
235+
echo "error: git config key 'drs.enable-data-client-logs' not found after git drs init" >&2
261236
exit 1
262237
fi
263238

@@ -303,7 +278,7 @@ for dir in */ ; do
303278
continue
304279
fi
305280
# $dir has trailing slash; don't need trailing slash in track
306-
git lfs track "$dir**"
281+
git drs track "$dir**"
307282
git add "$dir"
308283
git commit -am "Add $dir" 2>&1 | tee commit.log
309284
cat commit.log >> commit-aggregate.log
@@ -322,10 +297,6 @@ for dir in */ ; do
322297
echo "# Last 3 lines of .drs/lfs/objects tree:" >> lfs-console.log
323298
tree .drs/lfs/objects | tail -3 >> lfs-console.log
324299
fi
325-
echo "# git lfs status:" >> lfs-console.log
326-
git lfs status >> lfs-console.log
327-
echo "# Number of LFS files to be pushed in dry-run:" >> lfs-console.log
328-
git lfs push --dry-run origin main | wc -l >> lfs-console.log
329300
echo "##########################################" >> lfs-console.log
330301
cat lfs-console.log >> lfs-console-aggregate.log
331302

@@ -334,15 +305,15 @@ for dir in */ ; do
334305
#
335306

336307
# use the first file found in the directory for testing, that will be a single part file
337-
target_file=$(find "$dir" -type f -name '*file-0001.dat')
308+
target_file=$(find "$dir" -type f -name '*file-0001.dat' | head -n 1)
338309
# strip double slashes from path if any
339310
target_file=${target_file//\/\//\/}
340311
if [ -z "$target_file" ]; then
341312
echo "error: no files found in $dir to test content/path changes" >&2
342313
exit 1
343314
fi
344315

345-
original_oid=$(git lfs ls-files -l | awk -v path="$target_file" '$0 ~ (" " path "$") {print $1; exit}')
316+
original_oid=$(git drs ls-files -l | awk -v path="$target_file" '$0 ~ (" " path "$") {print $1; exit}')
346317
if [ -z "$original_oid" ]; then
347318
echo "error: unable to find LFS OID for $target_file" >&2
348319
exit 1
@@ -353,7 +324,7 @@ for dir in */ ; do
353324
git add "$target_file"
354325
git commit -m "Update content for $target_file"
355326

356-
updated_oid=$(git lfs ls-files -l | awk -v path="$target_file" '$0 ~ (" " path "$") {print $1; exit}')
327+
updated_oid=$(git drs ls-files -l | awk -v path="$target_file" '$0 ~ (" " path "$") {print $1; exit}')
357328
if [ -z "$updated_oid" ]; then
358329
echo "error: unable to find updated LFS OID for $target_file" >&2
359330
exit 1
@@ -371,7 +342,7 @@ for dir in */ ; do
371342
git mv "$target_file" "$renamed_path"
372343
git commit -m "Rename $target_file to $renamed_path"
373344

374-
renamed_oid=$(git lfs ls-files -l | awk -v path="$renamed_path" '$0 ~ (" " path "$") {print $1; exit}')
345+
renamed_oid=$(git drs ls-files -l | awk -v path="$renamed_path" '$0 ~ (" " path "$") {print $1; exit}')
375346
if [ -z "$renamed_oid" ]; then
376347
echo "error: unable to find LFS OID for renamed path $renamed_path" >&2
377348
exit 1
@@ -380,12 +351,12 @@ for dir in */ ; do
380351
echo "error: expected same OID after rename for $renamed_path" >&2
381352
exit 1
382353
fi
383-
if git lfs ls-files -l | grep -Fq " $target_file"; then
354+
if git drs ls-files -l | grep -Fq " $target_file"; then
384355
echo "error: expected old path $target_file to be absent after rename" >&2
385356
exit 1
386357
fi
387358

388359
git push origin main 2>&1 | tee -a lfs-console.log
389-
break # uncomment for one directory at a time testing
360+
# break # comment for one directory at a time testing
390361
fi
391362
done

0 commit comments

Comments
 (0)