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

DEVX improvement: initial GitHub codespaces setup #103

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ node_modules/
tests/node_modules/
tests/cucumber/screenshots/
.idea/
.screenshots
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,22 @@ docker-compose up -d materials-designer
sleep 30 # let the app actually start
docker-compose run materials-designer-test
```

## GitHub Codespace

When using a GitHub codespace "from scratch", see [codespace-setup.sh](codespace-setup.sh) for how the application and tests can be started.

When coming back to the previously used codespace - to run application:

```bash
nvm use 12.21.0
npm start
```

then, to run tests in headless mode in another terminal session, use the following example:

```bash
nvm use 8
export PATH=/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin:$PATH
./run-tests.sh -s=true -hm=true -f=menu/edit/reset-clone-undo-redo.feature
```
25 changes: 25 additions & 0 deletions codespace-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Setup for a default GitHub codespace container (Linux/Ubuntu) circa 2022-12
# TODO: migrate to using `.devcontainer` setup per
# https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/introduction-to-dev-containers

# Application
nvm install 12.21.0
chmod +x run-application.sh
npm start

# Run Tests
sudo apt-get upgrade
sudo apt-get update
sudo apt-get install openjdk-8-jdk
sudo apt-get install git bzip2
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt-get --fix-broken install
nvm use 8
cd tests
npm install
cd ..
export PATH=/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin:$PATH
java -version
./run-tests.sh -s=true -hm=true -f=menu/edit/reset-clone-undo-redo.feature

86 changes: 42 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file modified run-application.sh
100644 → 100755
Empty file.
30 changes: 25 additions & 5 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,24 @@ check_args () {
FEATURES="/"
OPTIONS=""
BROWSER="chrome"
HEADLESS_MODE="false"
for i in "$@"
do
case $i in
-h=*|--host=*)
HOST="${i#*=}"
shift
;;
-p=*|--port=*)
PORT="${i#*=}"
shift
;;
-s=*|--skip-install=*)
SKIP_INSTALL="${i#*=}"
shift
;;
-p=*|--port=*)
PORT="${i#*=}"
-hm=*|--headless-mode=*)
HEADLESS_MODE="${i#*=}"
shift
;;
-f=*|--features-dir=*)
Expand Down Expand Up @@ -79,6 +84,9 @@ SCREENSHOTS_DIR="${CUCUMBER_DIR}/screenshots"

export ROOT_URL="${HOST}:${PORT}"

# For using Java inside a GitHub Codespace VM; TODO: find a better way
export PATH=/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin:$PATH

cd ${TESTS_DIR}
DEFAULT_NVM_DIR="${HOME}/.nvm"
source ${NVM_DIR:-$DEFAULT_NVM_DIR}/nvm.sh
Expand All @@ -94,14 +102,26 @@ rm -rf ${SCREENSHOTS_DIR}
# https://www.jetbrains.com/help/webstorm/running-and-debugging-node-js.html#node_debugging_overview
# sed -ie 's/--debug/--inspect/g' ${TESTS_DIR}/node_modules/chimp/dist/lib/cucumberjs/cucumber.js

${TESTS_DIR}/node_modules/.bin/chimp \
DEFAULT_OPTIONS="\
--serverHost="${HOST}" \
--serverPort="${PORT}" \
--path=${CUCUMBER_DIR}/features/$FEATURES -r=${SUPPORT_DIR} \
--path=${CUCUMBER_DIR}/features/${FEATURES} \
-r=${SUPPORT_DIR} \
--singleSnippetPerFile=1 \
--screenshotsOnError=true --captureAllStepScreenshots=false \
--screenshotsPath=${SCREENSHOTS_DIR} \
--browser=${BROWSER} \
--webdriverio.deprecationWarnings=false \
--webdriverio.logLevel="silent" \
${OPTIONS}
"

if [[ ${HEADLESS_MODE} == "true" ]]; then
DEFAULT_OPTIONS="${DEFAULT_OPTIONS} \
--webdriverio.desiredCapabilities.chromeOptions.args="headless" \
--webdriverio.desiredCapabilities.chromeOptions.args="disable-gpu" \
--webdriverio.desiredCapabilities.chromeOptions.args="no-sandbox" \
--webdriverio.desiredCapabilities.chromeOptions.args="window-size=1920,1080" \
"
fi

${TESTS_DIR}/node_modules/.bin/chimp ${DEFAULT_OPTIONS} ${OPTIONS}