From 7426c001383534bb1ab044ac54326ce42bef3943 Mon Sep 17 00:00:00 2001 From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Tue, 5 Mar 2024 21:13:01 +0100 Subject: [PATCH 01/17] Bump tj-actions/changed-files to 42.0.5 --- CHANGELOG.md | 8 +++++++- project/detect-changed-components/action.yml | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab6d860..014be04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# viash-actions v5.2.2 + +## Minor changes + +* `project/detect-changed-components`: bump `tj-actions/changed-files` to `42.0.5` (PR #) + # viash-actions v5.2.1 ## Bug Fixes @@ -145,4 +151,4 @@ Initial release. Contains the following actions: * `setup`: Install Viash -* `ns-list`: List components in repo \ No newline at end of file +* `ns-list`: List components in repo diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 6220206..f824e6f 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -19,7 +19,7 @@ runs: steps: - name: Get changed files id: changed-files - uses: tj-actions/changed-files@v42.0.2 + uses: tj-actions/changed-files@v42.0.5 with: separator: ";" diff_relative: true @@ -116,4 +116,4 @@ runs: # reformat as json and write to file jq -cs '.' <<< "${output_array[*]}" > "$output_file" - echo "output_file=$output_file" >> $GITHUB_OUTPUT \ No newline at end of file + echo "output_file=$output_file" >> $GITHUB_OUTPUT From b9cb3b4c21946d19747a3b9096c0e06a438066b2 Mon Sep 17 00:00:00 2001 From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Tue, 5 Mar 2024 21:40:46 +0100 Subject: [PATCH 02/17] Add debugging output --- project/detect-changed-components/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index f824e6f..84ccf3c 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -76,6 +76,7 @@ runs: declare -a changed_files=() trim_slash() { line=$2 + echo "Found changed file: $line" changed_files[$1]="${line/%\\/}" } # read changed files as array From 125db5d1d9e5b17ae1f2f62a278a4d28869c8351 Mon Sep 17 00:00:00 2001 From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Tue, 5 Mar 2024 21:50:40 +0100 Subject: [PATCH 03/17] More debugging output --- project/detect-changed-components/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 84ccf3c..a3f54cc 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -103,7 +103,7 @@ runs: )[] ' <<< "$component" ) - + echo "Found resources: "${resources[@]}"" # check if resource is in the list of changed resources for resource_rel_path in "${resources[@]}"; do resource_project_path=$(realpath --relative-to="$GITHUB_WORKSPACE" "$resource_rel_path") From 45c74c51d67358b12cf874a9d8942f6b3cb464ca Mon Sep 17 00:00:00 2001 From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Wed, 6 Mar 2024 08:48:31 +0100 Subject: [PATCH 04/17] Print absolute path --- project/detect-changed-components/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index a3f54cc..90ba6be 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -107,6 +107,7 @@ runs: # check if resource is in the list of changed resources for resource_rel_path in "${resources[@]}"; do resource_project_path=$(realpath --relative-to="$GITHUB_WORKSPACE" "$resource_rel_path") + echo "Absolute path: $resource_project_path" if [[ " ${changed_files[*]} " =~ " ${resource_project_path} " ]]; then echo " Detected changed resources!" output_array+="$component" From a6c362fe5ad570c7587022d9039e776e4d9fc9fe Mon Sep 17 00:00:00 2001 From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Wed, 6 Mar 2024 09:50:18 +0100 Subject: [PATCH 05/17] Add support or resources that are directories --- project/detect-changed-components/action.yml | 39 ++++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 90ba6be..980794a 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -105,14 +105,39 @@ runs: ) echo "Found resources: "${resources[@]}"" # check if resource is in the list of changed resources - for resource_rel_path in "${resources[@]}"; do - resource_project_path=$(realpath --relative-to="$GITHUB_WORKSPACE" "$resource_rel_path") - echo "Absolute path: $resource_project_path" - if [[ " ${changed_files[*]} " =~ " ${resource_project_path} " ]]; then - echo " Detected changed resources!" - output_array+="$component" - break + for resource in "${resources[@]}"; do + echo "Checking resource: $resource" + + resource_real_path=$(realpath "$resource_rel_path") + status=$? + if [ $status -ne 0 ]; then + echo "Could not resolve path $resource_rel_path to a real path. Please make sure it exists" + exit $status + fi + declare -a resources_arr + resources_arr+=($resource_real_path) + # Resolve resources that are a directory into files + if [ -d "$resource_real_path" ]; then + echo "Resource is a directory" + readarray -d '' files_from_directories < <(find $resource -type f -print0) + resource_arr+=(${files_from_directories[@]}) fi + + for changed_file in ${changed_files[@]}; do + should_add_component=0 + changed_file_real_path=$(realpath "$resource_rel_path") + for resource_to_check in ${resource_arr[@]}; do + if [ "$changed_file_real_path" = "$resource_to_check" ]; then + echo "Detected changed component!" + should_add_component=1 + break + fi + done + if [[ "$should_add_component" -eq 1 ]]; then + output_array+="$component" + break + fi + done done done From ff4d689ed64e12ab1e3fed83d0a60a12f674e9b7 Mon Sep 17 00:00:00 2001 From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Wed, 6 Mar 2024 09:53:58 +0100 Subject: [PATCH 06/17] Fix undefined variable --- project/detect-changed-components/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 980794a..cd97d16 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -108,7 +108,7 @@ runs: for resource in "${resources[@]}"; do echo "Checking resource: $resource" - resource_real_path=$(realpath "$resource_rel_path") + resource_real_path=$(realpath "$resource") status=$? if [ $status -ne 0 ]; then echo "Could not resolve path $resource_rel_path to a real path. Please make sure it exists" From 0a0c5f8b448576d613aa8832ce82302eb386055a Mon Sep 17 00:00:00 2001 From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Wed, 6 Mar 2024 09:59:42 +0100 Subject: [PATCH 07/17] Do resource exist check before realpath --- project/detect-changed-components/action.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index cd97d16..1375da5 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -107,13 +107,11 @@ runs: # check if resource is in the list of changed resources for resource in "${resources[@]}"; do echo "Checking resource: $resource" - - resource_real_path=$(realpath "$resource") - status=$? - if [ $status -ne 0 ]; then - echo "Could not resolve path $resource_rel_path to a real path. Please make sure it exists" - exit $status + if [ ! -e "$resource" ]; then + echo "Resource $resource does not exist." + exit 1 fi + resource_real_path=$(realpath "$resource") declare -a resources_arr resources_arr+=($resource_real_path) # Resolve resources that are a directory into files From b691ca47363a07f0d2fef4a3030239de733979f4 Mon Sep 17 00:00:00 2001 From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Wed, 6 Mar 2024 10:17:46 +0100 Subject: [PATCH 08/17] Fix undefined variable --- project/detect-changed-components/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 1375da5..9382bdd 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -120,10 +120,10 @@ runs: readarray -d '' files_from_directories < <(find $resource -type f -print0) resource_arr+=(${files_from_directories[@]}) fi - + echo "Checking if resource is in the changes files." for changed_file in ${changed_files[@]}; do should_add_component=0 - changed_file_real_path=$(realpath "$resource_rel_path") + changed_file_real_path=$(realpath "$changed_file") for resource_to_check in ${resource_arr[@]}; do if [ "$changed_file_real_path" = "$resource_to_check" ]; then echo "Detected changed component!" From 64160bd242f4e45ed807d010eaad79a3ec513211 Mon Sep 17 00:00:00 2001 From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Wed, 6 Mar 2024 10:28:55 +0100 Subject: [PATCH 09/17] Add more debugging output --- project/detect-changed-components/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 9382bdd..a22d5db 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -124,6 +124,7 @@ runs: for changed_file in ${changed_files[@]}; do should_add_component=0 changed_file_real_path=$(realpath "$changed_file") + echo "Against $changed_file_real_path" for resource_to_check in ${resource_arr[@]}; do if [ "$changed_file_real_path" = "$resource_to_check" ]; then echo "Detected changed component!" From 7530075d59ca302f4e5ef43ecaa39fb51ed58255 Mon Sep 17 00:00:00 2001 From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Wed, 6 Mar 2024 10:47:50 +0100 Subject: [PATCH 10/17] Better debugging output --- project/detect-changed-components/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index a22d5db..46e3d1e 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -120,12 +120,12 @@ runs: readarray -d '' files_from_directories < <(find $resource -type f -print0) resource_arr+=(${files_from_directories[@]}) fi - echo "Checking if resource is in the changes files." + echo "All resources including files from directory: ${resource_arr[@]}" for changed_file in ${changed_files[@]}; do should_add_component=0 changed_file_real_path=$(realpath "$changed_file") - echo "Against $changed_file_real_path" for resource_to_check in ${resource_arr[@]}; do + echo "Checking $changed_file_real_path against $resource_to_check" if [ "$changed_file_real_path" = "$resource_to_check" ]; then echo "Detected changed component!" should_add_component=1 From f09553e64677c1ff2fa0553d0be7bbe8ee3f4fa2 Mon Sep 17 00:00:00 2001 From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Wed, 6 Mar 2024 11:02:52 +0100 Subject: [PATCH 11/17] Descrease verbosity --- project/detect-changed-components/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 46e3d1e..3cc2f9a 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -120,12 +120,12 @@ runs: readarray -d '' files_from_directories < <(find $resource -type f -print0) resource_arr+=(${files_from_directories[@]}) fi - echo "All resources including files from directory: ${resource_arr[@]}" + echo "All resources including files from directories: ${resource_arr[@]}" for changed_file in ${changed_files[@]}; do should_add_component=0 changed_file_real_path=$(realpath "$changed_file") + echo "Using changed file: $changed_file_real_path" for resource_to_check in ${resource_arr[@]}; do - echo "Checking $changed_file_real_path against $resource_to_check" if [ "$changed_file_real_path" = "$resource_to_check" ]; then echo "Detected changed component!" should_add_component=1 From 74cd6c9a791c02ae9ccf617beb9a706185755fb3 Mon Sep 17 00:00:00 2001 From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Wed, 6 Mar 2024 11:15:31 +0100 Subject: [PATCH 12/17] Fix array init --- project/detect-changed-components/action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 3cc2f9a..86ee4f3 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -112,8 +112,7 @@ runs: exit 1 fi resource_real_path=$(realpath "$resource") - declare -a resources_arr - resources_arr+=($resource_real_path) + resources_arr=($resource_real_path) # Resolve resources that are a directory into files if [ -d "$resource_real_path" ]; then echo "Resource is a directory" From 43aeddf7de4f53e6064ab17874c1e215f355f307 Mon Sep 17 00:00:00 2001 From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Wed, 6 Mar 2024 11:27:01 +0100 Subject: [PATCH 13/17] Overwrite files_from_directories --- project/detect-changed-components/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 86ee4f3..578f257 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -116,6 +116,7 @@ runs: # Resolve resources that are a directory into files if [ -d "$resource_real_path" ]; then echo "Resource is a directory" + files_from_directories=() readarray -d '' files_from_directories < <(find $resource -type f -print0) resource_arr+=(${files_from_directories[@]}) fi From 342c2429dcc1e28975b84c28c4e5d31c6562908e Mon Sep 17 00:00:00 2001 From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Wed, 6 Mar 2024 11:34:31 +0100 Subject: [PATCH 14/17] Fix assignment --- project/detect-changed-components/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 578f257..87259a2 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -112,7 +112,8 @@ runs: exit 1 fi resource_real_path=$(realpath "$resource") - resources_arr=($resource_real_path) + resources_arr=() + resources_arr+=("$resource_real_path") # Resolve resources that are a directory into files if [ -d "$resource_real_path" ]; then echo "Resource is a directory" From 20bd58be9fcba1074b78fefedba517779bb1e220 Mon Sep 17 00:00:00 2001 From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Wed, 6 Mar 2024 11:42:54 +0100 Subject: [PATCH 15/17] Fix --- project/detect-changed-components/action.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 87259a2..3fd197c 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -112,13 +112,12 @@ runs: exit 1 fi resource_real_path=$(realpath "$resource") - resources_arr=() - resources_arr+=("$resource_real_path") + resources_arr=("$resource_real_path") # Resolve resources that are a directory into files if [ -d "$resource_real_path" ]; then echo "Resource is a directory" files_from_directories=() - readarray -d '' files_from_directories < <(find $resource -type f -print0) + readarray -d '' files_from_directories < <(find $resource_real_path -type f -print0) resource_arr+=(${files_from_directories[@]}) fi echo "All resources including files from directories: ${resource_arr[@]}" From 1235b5748a43767dae23528500a65a0e4a9c85bf Mon Sep 17 00:00:00 2001 From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Wed, 6 Mar 2024 11:58:53 +0100 Subject: [PATCH 16/17] typo --- project/detect-changed-components/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 3fd197c..48c01a9 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -112,7 +112,7 @@ runs: exit 1 fi resource_real_path=$(realpath "$resource") - resources_arr=("$resource_real_path") + resource_arr=("$resource_real_path") # Resolve resources that are a directory into files if [ -d "$resource_real_path" ]; then echo "Resource is a directory" From 27b2cc80a2f03fa367bb699a73ffa9f9d9bd50cd Mon Sep 17 00:00:00 2001 From: DriesSchaumont <5946712+DriesSchaumont@users.noreply.github.com> Date: Wed, 6 Mar 2024 12:25:00 +0100 Subject: [PATCH 17/17] Update CHANGELOG --- CHANGELOG.md | 6 +++--- project/detect-changed-components/action.yml | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 014be04..8db26da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ -# viash-actions v5.2.2 +# viash-actions v5.3.0 -## Minor changes +## New functionality -* `project/detect-changed-components`: bump `tj-actions/changed-files` to `42.0.5` (PR #) +* `project/detect-changed-components`: Detect changed components when a resource is a directory (PR #28). # viash-actions v5.2.1 diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 48c01a9..3ebe041 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -103,7 +103,6 @@ runs: )[] ' <<< "$component" ) - echo "Found resources: "${resources[@]}"" # check if resource is in the list of changed resources for resource in "${resources[@]}"; do echo "Checking resource: $resource" @@ -142,4 +141,4 @@ runs: # reformat as json and write to file jq -cs '.' <<< "${output_array[*]}" > "$output_file" - echo "output_file=$output_file" >> $GITHUB_OUTPUT + echo "output_file=$output_file" >> $GITHUB_OUTPUT \ No newline at end of file