Skip to content

Commit

Permalink
Simplify separator handling of changed files array (#40)
Browse files Browse the repository at this point in the history
* try to fix separator

* remove local

* fix

* simplify array

* update changelog
  • Loading branch information
rcannood authored Jul 17, 2024
1 parent a47da7a commit 04393de
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: monthly
interval: weekly
labels:
- "dependencies"
commit-message:
Expand All @@ -18,6 +18,6 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: monthly
interval: weekly
labels:
- "dependencies"
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

## New functionality

`.github/workflows/build.yaml`: Added a callable workflow for building Viash components (PR #38).
* `.github/workflows/build.yaml`: Added a callable workflow for building Viash components (PR #38).

`.github/workflows/test.yaml`: Added a callable workflow for testing Viash components (PR #38).
* `.github/workflows/test.yaml`: Added a callable workflow for testing Viash components (PR #38).

## Minor changes

* `project/detect-changed-components`: Simplify separator handling of changed files array (PR #40).

## Bug fixes

Expand Down
18 changes: 5 additions & 13 deletions project/detect-changed-components/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ runs:
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v42.0.5
uses: tj-actions/changed-files@v44
with:
separator: ";"
separator: ","
diff_relative: true

# Note: a component's resources is detected using a jq statement.
Expand Down Expand Up @@ -90,17 +90,9 @@ runs:
# create output array
declare -a output_array=()
# The output from changed-files is delimited by \;
# So we use delimiter ';' to read the file and trim the backslash from the end.
declare -a changed_files=()
trim_slash() {
local line=$2
local trimmed_line=${line/%\\/}
echo "Found changed file: '$trimmed_line'"
changed_files[$1]="${trimmed_line}"
}
# read changed files as array
readarray -d ';' -C trim_slash -c 1 -t <<< "${{ steps.changed-files.outputs.all_changed_files }}"
# The output from changed-files is delimited by ,
# also remove newline if any
IFS=$',' read -a changed_files <<< "${{ steps.changed-files.outputs.all_changed_files }}"
# read components as array
readarray -t components < <(jq -c '.[]' "${{ inputs.input_file }}")
Expand Down

0 comments on commit 04393de

Please sign in to comment.