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

Use nextcloudci/server, cleanup github actions cypress process #588

Merged
merged 1 commit into from
Sep 2, 2020
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
44 changes: 12 additions & 32 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ on:

env:
APP_NAME: viewer
CYPRESS_baseUrl: http://127.0.0.1:8080/index.php
BRANCH: ${{ github.base_ref }}
CYPRESS_baseUrl: http://127.0.0.1:8082/index.php

jobs:
cypress:
Expand All @@ -24,63 +25,42 @@ jobs:
php-versions: ['7.4']

name: Runner ${{ matrix.containers }}

steps:
- name: Checkout server
- name: Checkout app
uses: actions/checkout@v2
with:
repository: nextcloud/server
ref: ${{ github.base_ref }}

- name: Checkout submodules
shell: bash
- name: Setup server
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1

- name: Checkout app
uses: actions/checkout@v2
with:
path: apps/${{ env.APP_NAME }}
cd cypress
docker-compose up -d

- name: Set up node ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies & build app
working-directory: apps/${{ env.APP_NAME }}
run: |
npm ci
TESTING=true npm run build --if-present

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v1
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit
extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite
coverage: none

- name: Set up Nextcloud
run: |
mkdir data
./occ maintenance:install --verbose --database sqlite --admin-user admin --admin-pass admin
./occ app:enable $APP_NAME
php -S 0.0.0.0:8080 &

- name: Wait for server
run: |
npm install -g wait-on
wait-on -i 500 -t 240000 $CYPRESS_baseUrl

- name: Enable app & configure server
run: |
cd cypress
docker-compose exec --env APP_NAME=${{ env.APP_NAME }} -T nextcloud bash /initserver.sh

- name: Cypress run
uses: cypress-io/github-action@v1
with:
record: true
parallel: true
# cypress env
working-directory: apps/${{ env.APP_NAME }}
ci-build-id: ${{ github.sha }}-${{ github.run_number }}
tag: ${{ github.event_name }}
env:
Expand Down
2 changes: 1 addition & 1 deletion cypress.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"baseUrl": "http://localhost:8000/index.php/",
"baseUrl": "http://localhost:8082/index.php/",
"projectId": "xysa6x",
"viewportWidth": 1280,
"viewportHeight": 720,
Expand Down
16 changes: 16 additions & 0 deletions cypress/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3'

services:
nextcloud:
image: nextcloudci/server

ports:
- 8082:80

environment:
CYPRESS_baseUrl: "http://127.0.0.1:8082/index.php"
BRANCH: master

volumes:
- ../:/var/www/html/apps/viewer
- ./initserver.sh:/initserver.sh
10 changes: 10 additions & 0 deletions cypress/initserver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

echo "APP_NAME: $APP_NAME"
chown -R www-data:www-data /var/www/html/data

su www-data -c "
php occ config:system:set force_language --value en
php occ app:enable $APP_NAME
php occ app:list
"
18 changes: 7 additions & 11 deletions cypress/start.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
#! /bin/sh
#!/usr/bin/env bash
# RUN THIS SCRIPT FROM THE ROOT FOLDER OF YOUR APP
appname=${PWD##*/}
APP_NAME=${PWD##*/}

if [[ $appname == "cypress" ]]
if [[ $APP_NAME == "cypress" ]]
then
echo "Please run this app from your app root folder."
else
echo "Launching docker server for the $appname app"
dockername="cypress_testing_$appname"

docker run -p 8000:80 --rm --name $dockername --volume $(pwd):/var/www/html/apps/$appname --env BRANCH=master --detach nextcloudci/server:latest
npm i --no-save wait-on
npm run wait-on -- http://localhost:8000
docker exec --user www-data $dockername php occ app:enable $appname
docker exec --user www-data $dockername php occ config:system:set force_language --value en
echo "Launching docker server for the $APP_NAME app"
cd cypress
docker-compose up -d
docker-compose exec --env APP_NAME=$APP_NAME -T nextcloud bash /initserver.sh
fi
6 changes: 3 additions & 3 deletions cypress/stop.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/sh
#!/usr/bin/env bash
# RUN THIS SCRIPT FROM THE ROOT FOLDER OF YOUR APP
appname=${PWD##*/}

Expand All @@ -7,6 +7,6 @@ then
echo "Please run this app from your app root folder."
else
echo "Killing server for the $appname app"
dockername="cypress_testing_$appname"
docker kill $dockername
cd cypress
docker-compose stop
fi
8 changes: 4 additions & 4 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ Cypress.Commands.add('nextcloudCreateUser', (user, password) => {
form: true,
body: {
userid: user,
password: password
password,
},
auth: { user: 'admin', pass: 'admin' },
headers: {
'OCS-ApiRequest': 'true',
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: 'Basic YWRtaW46YWRtaW4='
}
Authorization: `Basic ${btoa('admin:admin')}`,
},
}).then(response => {
cy.log(`Created user ${user}`, response.status)
})
Expand All @@ -80,7 +80,7 @@ Cypress.Commands.add('uploadFile', (fileName, mimeType, path = '') => {
await axios.put(`${Cypress.env('baseUrl')}/remote.php/webdav${path}/${fileName}`, file, {
headers: {
requesttoken: window.OC.requestToken,
'Content-Type': mimeType
'Content-Type': mimeType,
}
}).then(response => {
cy.log(`Uploaded ${fileName}`, response)
Expand Down