From 08ef97469f9cf58585e6a4a537a46146f174308b Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Sat, 7 Sep 2024 11:55:22 +0200 Subject: [PATCH] Remove Python setup and fix multiline prerequisites output (#3) --- .github/workflows/ci.yml | 2 +- action.yml | 8 ++------ list-make-prerequisites.py | 6 +++--- test/Makefile | 3 ++- test/preprereq | 1 - test/preprereq1 | 1 + test/preprereq2 | 1 + 7 files changed, 10 insertions(+), 12 deletions(-) delete mode 100644 test/preprereq create mode 100644 test/preprereq1 create mode 100644 test/preprereq2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6608a94..31fa175 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,5 +31,5 @@ jobs: flags: --recursive - name: Check recursive prerequisites run: | - test "${{ steps.recursive-prerequisites.outputs.prerequisites }}" = "preprereq" + test "${{ steps.recursive-prerequisites.outputs.prerequisites }}" = "preprereq1 preprereq2" echo ${{ steps.recursive-prerequisites.outputs.hash }} diff --git a/action.yml b/action.yml index e62d560..6c1d890 100644 --- a/action.yml +++ b/action.yml @@ -26,19 +26,15 @@ outputs: runs: using: "composite" steps: - - name: Install Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - name: Install Dependencies shell: bash - run: pip install -r requirements.txt + run: python -m pip install -r ${GITHUB_ACTION_PATH}/requirements.txt - name: List Make Prerequisites id: list-make-prerequisites shell: bash working-directory: ${{ inputs.working-directory }} run: | hash=$(${GITHUB_ACTION_PATH}/list-make-prerequisites.py ${{ inputs.target }} ${{ inputs.flags }} --hash 2>/dev/null) - prerequisites=$(${GITHUB_ACTION_PATH}/list-make-prerequisites.py ${{ inputs.target }} ${{ inputs.flags }} 2>/dev/null) + prerequisites=$(${GITHUB_ACTION_PATH}/list-make-prerequisites.py ${{ inputs.target }} ${{ inputs.flags }} 2>/dev/null | xargs) echo "hash=$hash" >> $GITHUB_OUTPUT echo "prerequisites=$prerequisites" >> $GITHUB_OUTPUT diff --git a/list-make-prerequisites.py b/list-make-prerequisites.py index ebbbbd7..7836625 100755 --- a/list-make-prerequisites.py +++ b/list-make-prerequisites.py @@ -122,8 +122,8 @@ def list_prerequisites(target, recursive=False, debug=False): # Find all leaf prerequisites leaf_prerequisites = [node.name for node in root.descendants if node.is_leaf] - # Remove repetitions - leaf_prerequisites = list(set(leaf_prerequisites)) + # Remove repetitions and sort for consistency + leaf_prerequisites = sorted(list(set(leaf_prerequisites))) # Return prerequisites return leaf_prerequisites @@ -158,7 +158,7 @@ def hash_files(file_list): if args.hash: # Print a hash of the prerequisites' contents - hash_value = hash_files(sorted(prerequisites)) + hash_value = hash_files(prerequisites) print(hash_value) else: # Print the list of prerequisites diff --git a/test/Makefile b/test/Makefile index 7af0dc8..750deca 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,5 +1,6 @@ test: prereq cp $< $@ -prereq: preprereq +prereq: preprereq1 preprereq2 cp $< $@ + cat preprereq2 >> $@ diff --git a/test/preprereq b/test/preprereq deleted file mode 100644 index 08e00ed..0000000 --- a/test/preprereq +++ /dev/null @@ -1 +0,0 @@ -Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. \ No newline at end of file diff --git a/test/preprereq1 b/test/preprereq1 new file mode 100644 index 0000000..0e26918 --- /dev/null +++ b/test/preprereq1 @@ -0,0 +1 @@ +preprereq1 \ No newline at end of file diff --git a/test/preprereq2 b/test/preprereq2 new file mode 100644 index 0000000..4995b5b --- /dev/null +++ b/test/preprereq2 @@ -0,0 +1 @@ +preprereq2 \ No newline at end of file