Skip to content

Commit

Permalink
Add extra outputs to matrices (#33)
Browse files Browse the repository at this point in the history
* Add extra outputs to matrices

* update changelog
  • Loading branch information
rcannood authored Jul 2, 2024
1 parent 04cea15 commit 5aa2180
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 11 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

## Minor changes

* `detect-changed-components`: Make action less verbose by not printing out every changed file for every component (PR #32).
* `project/detect-changed-components`: Make action less verbose by not printing out every changed file for every component (PR #32).

* `ns-list`: Output the `main_script_type` of each component (PR #33).

* `project/detect-changed-components`: Output the `full_name` and `main_script_type` of each component (PR #33).


# viash-actions v6.0.0

Expand Down
14 changes: 11 additions & 3 deletions ns-list/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,24 @@ We recommend using a Linux or MacOS runner if possible.
- `output`: The output of the ‘viash ns list’ command, which is a list
of all of the components found. By default this will be a yaml, unless
the format argument was set to ‘json’.

- `output_file`: Path of a file to which the output was written (same as
\`inputs.output_file\`\`). We recommend using this property for
capturing the action’s output because there is a limit in the object
size that github actions can manage. Additionally, if you use this
property instead of a static file path, changing the location of the
output file will not require you to adjust settings for downstream
actions as well.
- `output_matrix`: A simplified version of the output, which is a list
of components with fields ‘name’, ‘namespace’, ‘full_name’, ‘config’,
and ‘dir’.

- `output_matrix`: Matrix of components. The matrix is a json array with
the following fields:

- name: The name of the component
- namespace: The namespace of the component
- full_name: The full name of the component
- config: The path to the config file of the component
- dir: The directory of the config file of the component
- main_script_type: The type of the main script of the component

## Usage

Expand Down
11 changes: 9 additions & 2 deletions ns-list/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,15 @@ outputs:
of the output file will not require you to adjust settings for downstream actions
as well.
output_matrix:
description: A simplified version of the output, which is a list of components
with fields 'name', 'namespace', 'full_name', 'config', and 'dir'.
description: |
Matrix of components. The matrix is a json array with the following fields:
- name: The name of the component
- namespace: The namespace of the component
- full_name: The full name of the component
- config: The path to the config file of the component
- dir: The directory of the config file of the component
- main_script_type: The type of the main script of the component
runs:
using: node20
main: index.js
Expand Down
5 changes: 4 additions & 1 deletion ns-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,16 @@ async function run() {
const comp_fullname = comp_namespace ? comp_namespace + "/" + comp_name : comp_name
const comp_config = component?.build_info?.config ?? component?.info?.config
const comp_dir = comp_config ? path.dirname(comp_config) : undefined
const resources = component?.resources ?? component?.functionality?.resources
const comp_main_script_type = resources ? resources[0]?.type : undefined
// todo: if component has a test_resource with a nextflow_script, get the entrypoint?
return {
name: comp_name,
namespace: comp_namespace,
full_name: comp_fullname,
config: comp_config,
dir: comp_dir
dir: comp_dir,
main_script_type: comp_main_script_type
}
})
// return matrix as json
Expand Down
15 changes: 14 additions & 1 deletion project/detect-changed-components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,20 @@ has been changed with respect to the default branch.
on whether one of the resources of the component has been changed or
not.

- `output_matrix`: Matrix of components that have changed resources.
- `output_matrix`: Matrix of components that have changed resources. The
matrix is a json array with the following fields:

- name: The name of the component

- namespace: The namespace of the component

- full_name: The full name of the component

- config: The path to the config file of the component

- dir: The directory of the config file of the component

- main_script_type: The type of the main script of the component

## Examples

Expand Down
16 changes: 13 additions & 3 deletions project/detect-changed-components/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ outputs:
value: ${{ steps.filter.outputs.output_file }}
output_matrix:
description: |
Matrix of components that have changed resources.
Matrix of components that have changed resources. The matrix is a json array with the following fields:
- name: The name of the component
- namespace: The namespace of the component
- full_name: The full name of the component
- config: The path to the config file of the component
- dir: The directory of the config file of the component
- main_script_type: The type of the main script of the component
value: ${{ steps.set_matrix.outputs.matrix }}
runs:
using: 'composite'
Expand Down Expand Up @@ -174,8 +182,10 @@ runs:
"name": (.name // .functionality.name),
"namespace": (.namespace // .functionality.namespace // ""),
"config": (.build_info.config // .info.config),
"dir": (.build_info.config // .info.config) | capture("^(?<dir>.*\/)").dir
}
"dir": (.build_info.config // .info.config) | capture("^(?<dir>.*\/)").dir,
"main_script_type": (.resources // .functionality.resources)[0].type
} |
.full_name = if .namespace == "" then .name else .namespace + "/" + .name end
]' $comp_file
)
echo "matrix=$matrix" >> $GITHUB_OUTPUT

0 comments on commit 5aa2180

Please sign in to comment.