From 97caf78a61022f16061f5eeb53f27052935101d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonah=20Br=C3=BCchert?= Date: Fri, 16 Feb 2024 23:10:21 +0100 Subject: [PATCH] ci: Fix detecting changed files --- .github/workflows/test-import.yml | 8 ++++---- ci/fetch-feeds.py | 12 ++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-import.yml b/.github/workflows/test-import.yml index 976a8305..18509327 100644 --- a/.github/workflows/test-import.yml +++ b/.github/workflows/test-import.yml @@ -10,10 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v3 - - name: Fetch submodules - run: git submodule update --init --checkout --remote + uses: actions/checkout@v4 + - name: Fetch branches and submodules + run: git fetch --unshallow && 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 + - name: Verify that new feeds can be downloaded and parsed run: docker run -v $PWD:/transitous -w /transitous transitous ci/fetch-feeds.py merge-request diff --git a/ci/fetch-feeds.py b/ci/fetch-feeds.py index f2083cdc..e82b45e7 100755 --- a/ci/fetch-feeds.py +++ b/ci/fetch-feeds.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later import sys +import os from pathlib import Path import subprocess @@ -20,9 +21,16 @@ for feed in feed_dir.glob("*.json"): subprocess.check_call(["./src/fetch.py", str(feed.absolute())]) case "merge-request": + # Silence warnings about different ownerships inside and outside of the + # container on actions + subprocess.check_call( + ["git", "config", "--global", + "--add", "safe.directory", os.getcwd()]) + + # Find all files that were changed in the latest commit changed_files = subprocess.check_output( - ["git", "diff", "--name-only", "-r", "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")]