From deea7ff487d42b26035186a315555a4342f7fc8f Mon Sep 17 00:00:00 2001 From: Mark Street Date: Mon, 11 Sep 2023 21:20:38 +0100 Subject: [PATCH] 19 --- .github/workflows/ci.yaml | 7 ++----- matrix.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 374ab93..5b17ec6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,7 +20,6 @@ jobs: uses: actions/checkout@v3 - name: Create list of changed files - id: changed-files run: | # See https://github.community/t/check-pushed-file-changes-with-git-diff-tree-in-github-actions/17220/10 if [ $GITHUB_BASE_REF ]; then @@ -34,14 +33,12 @@ jobs: export DIFF=$( git diff --name-only ${{ github.event.before }} $GITHUB_SHA ) echo "Diff between ${{ github.event.before }} and $GITHUB_SHA" fi - echo "$DIFF" - # Escape newlines (replace \n with ,) - echo "diff=$( echo "$DIFF" | sed ':a;N;$!ba;s/\n/,/g' )" >> $GITHUB_OUTPUT + echo "$DIFF" | tee changed_files.txt - name: Create matrix of images to generate id: create-matrix run: | - echo "matrix=$(python3 matrix.py ${{ steps.changed-files.outputs.diff }})" >> $GITHUB_OUTPUT + echo "matrix=$(python3 matrix.py)" >> $GITHUB_OUTPUT run_matrix: name: Run Matrix diff --git a/matrix.py b/matrix.py index ac83306..b0c201f 100644 --- a/matrix.py +++ b/matrix.py @@ -20,12 +20,18 @@ def main(): + # TODO: + # add arguments + # --platforms=n64,ps1,gc_wii ; limit to selected platforms + # --changed-files=files.txt ; limit to selected Dockerfiles + dockerfiles = glob.glob("platforms/*/*/Dockerfile") dockerfiles += glob.glob("platforms/*/*/*/Dockerfile") if len(sys.argv) > 1: - # if we are passed an argument, use it to filter dockerfiles - filtered_dockerfiles = sys.argv[2].split(",") + # if we are passed an argument, treat it as a file listing all changes + with open(sys.argv[1], "r") as f: + filtered_dockerfiles = f.readlines() dockerfiles = filter(lambda x: x in filtered_dockerfiles, dockerfiles) includes = []