Skip to content

Commit 08f5ca9

Browse files
committed
ci(pr-validation): shallow checkouts and scoped app.validate
The PR validation comment cloned TechAPI's full history twice (head and base) and ran app.validate over every record. Check both out at depth 1, deepen the head only to the merge base, fetch the pinned base at depth 1, and validate just the changed records. integrity_check still scans both trees; it is population-based and needs its own scoping. Refs GetTechAPI/TechAPI#350
1 parent a20ebb1 commit 08f5ca9

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎.github/workflows/techapi-pr-validation-comment.yml‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,25 @@ jobs:
7373
repository: GetTechAPI/TechAPI
7474
ref: ${{ env.TECHAPI_HEAD_SHA }}
7575
path: TechAPI
76-
fetch-depth: 0
76+
# Shallow; deepened to the merge base in the next-but-one step.
77+
fetch-depth: 1
7778

7879
- name: Checkout TechAPI PR base
7980
uses: actions/checkout@v4
8081
with:
8182
repository: GetTechAPI/TechAPI
8283
ref: ${{ env.TECHAPI_BASE_SHA }}
8384
path: TechAPI-base
84-
fetch-depth: 0
85+
fetch-depth: 1
8586

8687
- name: Pin PR base to the merge base
8788
shell: bash
8889
run: |
89-
git -C TechAPI fetch --no-tags origin "$TECHAPI_BASE_SHA"
90+
git -C TechAPI fetch --no-tags --depth=100 origin "$TECHAPI_BASE_SHA"
91+
# Fall back to full history only if the PR branched from far back.
92+
git -C TechAPI merge-base "$TECHAPI_BASE_SHA" HEAD >/dev/null 2>&1 || git -C TechAPI fetch --no-tags --unshallow origin
9093
base_sha="$(git -C TechAPI merge-base "$TECHAPI_BASE_SHA" HEAD)"
91-
git -C TechAPI-base fetch --no-tags origin "$base_sha"
94+
git -C TechAPI-base fetch --no-tags --depth=1 origin "$base_sha"
9295
git -C TechAPI-base checkout --detach "$base_sha"
9396
echo "TECHAPI_DIFF_BASE=$base_sha" >> "$GITHUB_ENV"
9497
@@ -161,7 +164,7 @@ jobs:
161164
set +e
162165
{
163166
echo "## app.validate"
164-
python -m app.validate
167+
python -m app.validate --changed-since "$TECHAPI_DIFF_BASE"
165168
echo "app_validate_status=$?"
166169
} > validation.log 2>&1
167170
app_status=$(grep "app_validate_status=" validation.log | tail -n 1 | cut -d= -f2)

0 commit comments

Comments
 (0)