Skip to content
Merged
Show file tree
Hide file tree
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
55 changes: 55 additions & 0 deletions scripts/e2e-testing/README.md
Original file line number Diff line number Diff line change
@@ -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.

38 changes: 27 additions & 11 deletions scripts/e2e-testing/ubuntu-test-install.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand All @@ -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
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
Loading