diff --git a/scripts/e2e-testing/README.md b/scripts/e2e-testing/README.md new file mode 100644 index 0000000..fe1874b --- /dev/null +++ b/scripts/e2e-testing/README.md @@ -0,0 +1,55 @@ +# How to Run the End-to-End Test Script + +### A mock data script that contains all the information needed to create an OSEDA project is required for the test script to work. + + +## Making the Mock Data Script +- You need to export a few specific variables in the mock data script that the test install script will use: + - `PRIVATE_KEY`: the private ssh key generated for the GitHub account you are using to link to your OSEDA project + - `PUBLIC_KEY`: the public ssh key generated for the github account you are using to link to you OSEDA project + - `ADMIN_PASSWD`: password to the linux terminal you are running the script on + - `USERNAME`: your Git username (assuming your Git and GitHub usernames are the same) + - `EMAIL`: your Git email (assuming your Git and GitHub emails are the same) +- Create the `mock_data.sh` file: +``` +touch mock_data.sh +{ + echo "read -r -d '' PRIVATE_KEY <<'KEY'" + cat ~/.ssh/[PATH_TO_PRIVATE_KEY] + echo "KEY" + echo "export PRIVATE_KEY" +} > mock_data.sh +echo "export PUBLIC_KEY=\"$(cat ~/.ssh/[PATH_TO_PRIVATE_KEY])\"" >> mock_data.sh +echo "export ADMIN_PASSWD=\"[YOUR_PASSWORD]\"" >> mock_data.sh +echo "export USERNAME=\"[YOUR_GIT_USERNAME]\"" >> mock_data.sh +echo "export EMAIL=\"[YOUR_GIT_EMAIL]\"" >> mock_data.sh +``` + + +- The file should look like this: +``` +read -r -d '' PRIVATE_KEY <<'KEY' +-----BEGIN OPENSSH PRIVATE KEY----- +********************************************************************** +********************************************************************** +********************************************************************** +********************************************************************** +********************************************************************** +-----END OPENSSH PRIVATE KEY----- +KEY +export PRIVATE_KEY +export PUBLIC_KEY="ssh-ed25519 [YOUR_SSH_PUBLICKEY]"export ADMIN_PASSWD="12345" +export USERNAME="[YOUR_GIT_USERNAME]" +export EMAIL="[YOUR_GIT_EMAIL]" +``` + + +## Running the Test Scipt +- Create the mock data script (using the commands above) and make sure it is in the same directory as the test script +- Give the test script executable permissions and run it using `source` +``` +chmod +x ubuntu-test-intall.sh +source ubuntu-test-install.sh +``` +- At the end of the output, it should print "Script succeeded" if all the dependencies were downloaded, a new OSEDA project was created, and `oseda check` passed. + diff --git a/scripts/e2e-testing/ubuntu-test-install.sh b/scripts/e2e-testing/ubuntu-test-install.sh index 86d08c3..7b27cf0 100755 --- a/scripts/e2e-testing/ubuntu-test-install.sh +++ b/scripts/e2e-testing/ubuntu-test-install.sh @@ -1,14 +1,18 @@ #!/bin/bash -# This is not meant directly executed +# Run this script using this command: `source ubuntu-test-install.sh` + +# This mock data script is not meant directly executed # just the set of commands to install in a fresh ubuntu vm for testing +# must be included for this script to work source mock_data.sh -#TODO test to make sure this works -echo $ADMIN_PASSWD |sudo -S apt install curl -yes | sudo apt install git +echo $ADMIN_PASSWD | sudo -S apt update +sudo apt install curl # Pipe yes into these installation commands +yes | sudo apt install git + yes | sudo apt install npm yes | sudo apt install pkg-config @@ -19,9 +23,8 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y # Puts cargo on the PATH without having to restart the current shell . "$HOME/.cargo/env" -curl -sL https://raw.githubusercontent.com/oseda-dev/oseda-cli/refs/heads/main/scripts/curl-install.sh | $SHELL - -#TODO: test this in VM before merging branch +#curl -sL https://raw.githubusercontent.com/oseda-dev/oseda-cli/refs/heads/main/scripts/curl-install.sh | $SHELL +cargo install oseda-cli # make sure .ssh directory exists mkdir -p "${HOME}/.ssh" @@ -34,7 +37,20 @@ chmod 600 "${HOME}/.ssh/id_ed25519_oseda_testing" # assuming git username is same as github username git config --global user.name $USERNAME - -oseda init - -oseda run \ No newline at end of file +git config --global user.email $EMAIL + +# create a new oseda project using flags so it doesn't have to stop +oseda init --title ExampleProject --tags economics ComputerScience --color red --template Markdown +# make sure to cd to the same name as the title of the project +cd ExampleProject + +#oseda run +oseda check + +# if oseda check fails, then it prints the exit code +# otherwise ends the script with a message saying it succeeded +if [ $? -ne 0 ]; then + echo "Command failed. Exit code was $?" +else + echo "Script succeeded" +fi \ No newline at end of file