From ca8a1f67b19cb4e655afa32d45e7b88e08e76291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonah=20Br=C3=BCchert?= Date: Fri, 16 Feb 2024 23:15:53 +0100 Subject: [PATCH] ci: Fetch full history for comparing to main --- .github/workflows/test-import.yml | 7 +++++-- ci/fetch-feeds.py | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-import.yml b/.github/workflows/test-import.yml index 976a8305..fd2260cf 100644 --- a/.github/workflows/test-import.yml +++ b/.github/workflows/test-import.yml @@ -11,8 +11,11 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3 - - name: Fetch submodules - run: git submodule update --init --checkout --remote + with: + # Pull history, needed to compare changed files + fetch-depth: 2 + - name: Fetch branches and submodules + run: git fetch --all && git submodule update --init --checkout --remote - name: Build docker images run: docker build -t transitous . -f ci/container/Containerfile - name: Verify that new feeds can be downloaded diff --git a/ci/fetch-feeds.py b/ci/fetch-feeds.py index b1029265..e0b96b7f 100755 --- a/ci/fetch-feeds.py +++ b/ci/fetch-feeds.py @@ -20,9 +20,10 @@ for feed in feed_dir.glob("*.json"): subprocess.check_call(["./src/fetch.py", str(feed.absolute())]) case "merge-request": + # Find all files that were changed in the latest commit changed_files = subprocess.check_output( - ["git", "diff", "--name-only", "HEAD^1", "HEAD"]) \ - .decode().splitlines() + ["git", "diff", "--name-only", "origin/main", "HEAD"]) \ + .decode().splitlines() changed_feeds = [f for f in changed_files if f.startswith("feeds/") and f.endswith(".json")]