Skip to content

Commit

Permalink
Add Cypress workflow (#1895)
Browse files Browse the repository at this point in the history
* Initial configuration for cypress e2e tests.

* Use tmp-dir instead of fixed location.
  • Loading branch information
peterp committed Mar 4, 2021
1 parent 9f62208 commit 9f87e1e
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 13 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Cypress E2E tests

on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened]

jobs:
cypress-run:
if: github.repository == 'redwoodjs/redwood'
runs-on: ubuntu-16.04

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Install framework modules
run: yarn install --frozen-lockfile

- name: Create a temporary directory
id: createpath
run: |
project_path=$(mktemp -d -t redwood.XXXXXX)
echo "::set-output name=project_path::$project_path"
- name: Create a RedwoodJS app
run: ./tasks/test-tutorial ${{ steps.createpath.outputs.project_path }}
env:
CREATE_RWJS_PROJECT: 1
CI: 1

- name: Start server in background
run: yarn rw dev &
working-directory: ${{ steps.createpath.outputs.project_path }}


- name: Cypress run
uses: cypress-io/github-action@v2
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_RW_PATH: "${{ steps.createpath.outputs.project_path }}"
CYPRESS_pageLoadTimeout: 300000
CYPRESS_defaultCommandTimeout: 300000
CYPRESS_requestTimeout: 300000
with:
browser: chrome
env: true
wait-on: 'http://localhost:8910'
record: true
working-directory: ./tasks/e2e
3 changes: 2 additions & 1 deletion tasks/e2e/cypress.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"ignoreTestFiles": ["**/codemods/*.js"]
"ignoreTestFiles": ["**/codemods/*.js"],
"projectId": "ao5sqb"
}
3 changes: 1 addition & 2 deletions tasks/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@

"devDependencies": {
"cypress": "^5.1.0"
},
"dependencies": {}
}
}
31 changes: 21 additions & 10 deletions tasks/test-tutorial
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,45 @@ yarn install

if [ -z "$1" ]
then
echo "You have not supplied a path to a Redwood project."
echo "You have not supplied a path to a RedwoodJS project."
echo "We will create one for you."
echo "We will copy './packages/create-redwood-app/template' and the packages/*"

TMP_DIR=$(mktemp -d -t redwood)

cd ../../packages/create-redwood-app
yarn babel-node src/create-redwood-app.js $TMP_DIR --no-yarn-install
else
echo "You have supplied a path $1, we will not create a new "
echo "Redwood project, we will use the app you have specified."
TMP_DIR=$1
fi

if [ -z "$1" ]
if [[ -z "$1" || "$CREATE_RWJS_PROJECT" == "1" ]]
then
echo "Creating new RedwoodJS Project..."
cd ../../packages/create-redwood-app
yarn babel-node src/create-redwood-app.js $TMP_DIR --no-yarn-install
fi

if [[ -z "$1" || "$CREATE_RWJS_PROJECT" == "1" ]]
then
cd "$SCRIPTPATH/../"
# build all the packages
# build all the packages, but not the TypeScript
# since it is slow and we do not need it.
yarn build:clean && yarn lerna run build:js
fi

cd $TMP_DIR

if [ -z "$1" ]
if [[ -z "$1" || "$CREATE_RWJS_PROJECT" == "1" ]];
then
# make the e2e tests use the packages from this repo.
echo "Linking packages from $SCRIPTPATH"
# make the e2e tests use the packages from this Redwood Framework Repo.
ln -s "$SCRIPTPATH/../packages"
fi

yarn install
yarn rw dev --fwd="--open=false" & cd "$SCRIPTPATH/e2e"; yarn cypress open --env RW_PATH=$TMP_DIR

if [ -z "$CI" ]
then
yarn rw dev --fwd="--open=false" & cd "$SCRIPTPATH/e2e"; yarn cypress open --env RW_PATH=$TMP_DIR
else
echo "CI env-var set skipping Cypress run."
fi

0 comments on commit 9f87e1e

Please sign in to comment.