-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Introduction | ||
|
||
| name | .env | desc | | ||
| -- | -- | -- | | ||
| full | full.env | enable all features | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
The tools in the directory contains following generalfeatures | ||
- collecting envs and run each | ||
- collect results and generate summary |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/sh | ||
cat << "EOF" > /dev/null | ||
Given a directory with *.env files. Run each one. | ||
usage for example: | ||
1) directly run command without extra shared envs | ||
./run_envs.sh -d <dir_to_*.envfiles> -j <number of parallel process> -- <command> | ||
2) load shared envs `.env` before running command with different envs. | ||
dotenv run -- ./run_envs.sh -d <dir_to_*.envfiles> -j <number of parallel process> -- <command> | ||
EOF | ||
|
||
# Function to display usage | ||
usage() { | ||
echo "Usage: $0 -d <dir_to_*.envfiles> -j <number of parallel process> -- <command>" | ||
exit 1 | ||
} | ||
|
||
# Parse command line arguments | ||
while getopts "d:j:" opt; do | ||
case $opt in | ||
d) DIR=$OPTARG ;; | ||
j) JOBS=$OPTARG ;; | ||
*) usage ;; | ||
esac | ||
done | ||
|
||
# Shift to get the command | ||
shift $((OPTIND -1)) | ||
|
||
# Check if directory and jobs are set | ||
if [ -z "$DIR" ] || [ -z "$OBS" ] || [ $# -eq 0 ]; then | ||
usage | ||
fi | ||
|
||
COMMAND="$@" | ||
|
||
# Export and run each .env file in parallel | ||
find "$DIR" -name "*.env" | xargs -n 1 -P "$JOBS" -I {} sh -c " | ||
set -a | ||
. {} | ||
set +a | ||
$COMMAND | ||
" |