Skip to content

Commit

Permalink
Add generate_manifests.bash script for generation of yamf manifests…
Browse files Browse the repository at this point in the history
… at a large scale (#5)

* Add generate_manifests.bash script for generation of `yamf` manifests at a large scale

* Added required variables for module loading

* Remove creation of manifests for empty leaf

* cd into directory before running `yamf`

* Corrected variable name

* Update .github/scripts/generate_manifests.bash

Co-authored-by: Davide Marchegiani <[email protected]>

* Exclude `.git` subdirectories, fix loop

* cd back to previous directory

* De-functioned the script, removed the exclusion on `.git` subdirs because we don't have them anymore

* Updated messaging, comments, removed `module unload`

---------

Co-authored-by: Davide Marchegiani <[email protected]>
  • Loading branch information
CodeGat and atteggiani authored Oct 23, 2024
1 parent ac8eac1 commit 63d38c4
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/scripts/generate_manifests.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
# Script for the initial generation of manifest.yaml files in inputs directories

if [[ $# -ne 3 ]]; then
echo "Error, arguments required are not given. Usage: $(basename "$0") YAMF_MODULE_PATH YAMF_MODULE_NAME START_DIR"
echo "Where: YAMF_MODULE_PATH is the path to a module folder, YAMF_MODULE_NAME is the name of a module that contains yamf, and START_DIR is a directory to begin searching for leaf nodes."
exit 1
fi

yamf_module_path="${1}"
yamf_module_name="${2}"
# Defaults to '.' unless the third argument is given
start_dir="${3:-.}"

module use "$yamf_module_path"
module load "$yamf_module_name"

# This command finds all the leaf directories: see https://unix.stackexchange.com/questions/68577/find-directories-that-do-not-contain-subdirectories/203991#203991
dir_without_subdir=$(find "$start_dir" -type d -links 2 ! -empty)

for dir in $dir_without_subdir; do
echo "Working on $dir:"
# Find all the files that we want to turn into manifests
files=$(find "$dir" -maxdepth 1 -type f -printf '%f ')
if [ -n "$files" ]; then
# If there are some files, add them using yamf
cd "$dir" || exit 2
# shellcheck disable=SC2086
yamf add -n manifest.yaml $files
cd - || exit 2
fi
done

0 comments on commit 63d38c4

Please sign in to comment.