diff --git a/.github/workflows/validate_modified_targets.yml b/.github/workflows/validate_modified_targets.yml index de0240907..bb2445117 100644 --- a/.github/workflows/validate_modified_targets.yml +++ b/.github/workflows/validate_modified_targets.yml @@ -17,29 +17,40 @@ jobs: - name: Checkout repository uses: actions/checkout@v5 with: + # Checkout the base branch but fetch all history to avoid a second fetch call ref: ${{ github.base_ref }} - fetch-depth: 1 + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v6 with: - python-version: '3.13' + python-version: "3.13" - name: Install Poetry uses: abatilo/actions-poetry@v4 with: - poetry-version: 'latest' + poetry-version: "latest" - name: Install dependencies run: | poetry install --no-interaction --with dev - - name: Drop in place updated manifest from base + - name: Prepare JSON versions for comparison run: | - cp sherlock_project/resources/data.json data.json.base - git fetch origin pull/${{ github.event.pull_request.number }}/head:pr --depth=1 - git show pr:sherlock_project/resources/data.json > sherlock_project/resources/data.json - cp sherlock_project/resources/data.json data.json.head + # Fetch only the PR's branch head (single network call in this step) + git fetch origin pull/${{ github.event.pull_request.number }}/head:pr + + # Find the merge-base commit between the target branch and the PR branch + MERGE_BASE=$(git merge-base origin/${{ github.base_ref }} pr) + echo "Comparing PR head against merge-base commit: $MERGE_BASE" + + # Safely extract the file from the PR's head and the merge-base commit + git show pr:sherlock_project/resources/data.json > data.json.head + git show $MERGE_BASE:sherlock_project/resources/data.json > data.json.base + + # CRITICAL FIX: Overwrite the checked-out data.json with the one from the PR + # This ensures that pytest runs against the new, updated file. + cp data.json.head sherlock_project/resources/data.json - name: Discover modified targets id: discover-modified @@ -47,8 +58,16 @@ jobs: CHANGED=$( python - <<'EOF' import json - with open("data.json.base") as f: base = json.load(f) - with open("data.json.head") as f: head = json.load(f) + import sys + try: + with open("data.json.base") as f: base = json.load(f) + with open("data.json.head") as f: head = json.load(f) + except FileNotFoundError as e: + print(f"Error: Could not find {e.filename}", file=sys.stderr) + sys.exit(1) + except json.JSONDecodeError as e: + print(f"Error: Could not decode JSON from a file - {e}", file=sys.stderr) + sys.exit(1) changed = [] for k, v in head.items(): @@ -63,6 +82,8 @@ jobs: echo -e ">>> Changed targets: \n$(echo $CHANGED | tr ',' '\n')" echo "changed_targets=$CHANGED" >> "$GITHUB_OUTPUT" + # --- The rest of the steps below are unchanged --- + - name: Validate modified targets if: steps.discover-modified.outputs.changed_targets != '' continue-on-error: true diff --git a/sherlock_project/resources/data.json b/sherlock_project/resources/data.json index 1f0e34225..c13f9d9e1 100644 --- a/sherlock_project/resources/data.json +++ b/sherlock_project/resources/data.json @@ -259,7 +259,8 @@ "username_claimed": "blue" }, "Blitz Tactics": { - "errorType": "status_code", + "errorMsg": "That page doesn't exist", + "errorType": "message", "url": "https://blitztactics.com/{}", "urlMain": "https://blitztactics.com/", "username_claimed": "Lance5500" @@ -278,14 +279,7 @@ "urlMain": "https://bsky.app/", "username_claimed": "mcuban" }, - "BoardGameGeek": { - "errorType": "message", - "regexCheck": "^[a-zA-Z0-9_]*$", - "errorMsg": "User not found", - "url": "https://boardgamegeek.com/user/{}", - "urlMain": "https://boardgamegeek.com", - "username_claimed": "blue" - }, + "BongaCams": { "errorType": "status_code", "isNSFW": true, @@ -299,6 +293,14 @@ "urlMain": "https://www.bookcrossing.com/", "username_claimed": "blue" }, + "BoardGameGeek": { + "errorMsg": "\"isValid\":true", + "errorType": "message", + "url": "https://boardgamegeek.com/user/{}", + "urlMain": "https://boardgamegeek.com/", + "urlProbe": "https://api.geekdo.com/api/accounts/validate/username?username={}", + "username_claimed": "blue" + }, "BraveCommunity": { "errorType": "status_code", "url": "https://community.brave.com/u/{}/", @@ -2320,6 +2322,12 @@ "urlMain": "https://discourse.wicg.io/", "username_claimed": "stefano" }, + "Wakatime": { + "errorType": "status_code", + "url": "https://wakatime.com/@{}", + "urlMain": "https://wakatime.com/", + "username_claimed": "blue" + }, "Warrior Forum": { "errorType": "status_code", "url": "https://www.warriorforum.com/members/{}.html", @@ -2865,13 +2873,6 @@ "urlMain": "https://znanylekarz.pl", "username_claimed": "janusz-nowak" }, - "Bluesky": { - "errorType": "status_code", - "url": "https://bsky.app/profile/{}.bsky.social", - "urlProbe": "https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor={}.bsky.social", - "urlMain": "https://bsky.app/", - "username_claimed": "mcuban" - }, "Platzi": { "errorType": "status_code", "errorCode": 404,