Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update git-opensource-tests.sh #359

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions tests/git-opensource-tests.sh
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
#!/bin/sh
#
# This script can clone/checkout a single folder from git repository
# - Might be used for checking out micro-services from monolithic git repository
# This script is designed copy the necessary e2e framework and test scripts from the Open MCT
# repository.
#
# - You can even do checkout into home directory, for example
# git-sparse-clone.sh [email protected]:readdle/fluix-web.git /home/login login
# Usage:
# ./tests/git-opensource-tests.sh [branch-name]
#
# If no branch name is provided, the script defaults to the 'master' branch.

SCRIPT_PATH=${0%/*} # Get the relative path to the script dir from the cwd
if [ "$0" != "$SCRIPT_PATH" ] && [ "$SCRIPT_PATH" != "" ]; then
cd "$SCRIPT_PATH"
fi
set -e # Exit immediately if a command exits with a nonzero exit value

rm -rf e2e/opensource
SCRIPT_DIR="$(dirname "$0")" # Get the directory of the script
REPO_DIR="$SCRIPT_DIR/.." # Get the root directory of the repository

# This will cause the shell to exit immediately if a simple command exits with a nonzero exit value.
set -e
rm -rf "$REPO_DIR/e2e/opensource"

REPO_URL=https://github.com/nasa/openmct.git
REPO_BRANCH=${1:-master} # Use the first argument as the branch, or default to 'master'
REPO_PATH=e2e
LOCAL_REPO_ROOT="e2e/opensource"
LOCAL_REPO_ROOT="$REPO_DIR/e2e/opensource"
TARGET_DIR="$REPO_DIR/opensource"

git clone --no-checkout --depth 1 $REPO_URL "$LOCAL_REPO_ROOT"
# Create target directory if it doesn't exist
mkdir -p "$TARGET_DIR"

git clone --no-checkout --depth 1 --branch $REPO_BRANCH $REPO_URL "$LOCAL_REPO_ROOT"
cd "$LOCAL_REPO_ROOT"
git config core.sparsecheckout true
echo "/$REPO_PATH/**" > .git/info/sparse-checkout
git read-tree -m -u HEAD

# moving back to /tests/ dir
cd ..
# Debugging information
echo "Listing contents of $LOCAL_REPO_ROOT:"
ls -l

# Move all required files and folders
mv "$LOCAL_REPO_ROOT/e2e"/*Fixtures.js "$LOCAL_REPO_ROOT/e2e/appActions.js" "$LOCAL_REPO_ROOT/e2e"/* "$LOCAL_REPO_ROOT/e2e/.eslintrc.js" "$TARGET_DIR"

# Move fixtures and appActions
mv opensource/e2e/*Fixtures.js ./opensource
mv opensource/e2e/appActions.js ./opensource
# Move subfolders
mv opensource/e2e/*/ ./opensource
# Move eslint config
mv opensource/e2e/.eslintrc.js ./opensource
# Cleanup
rm -rf opensource/e2e
rm -rf "$LOCAL_REPO_ROOT/e2e"