From 032f182bdc7ab7393fb295864e10d63baed1b367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Wed, 2 Sep 2020 08:24:03 +0200 Subject: [PATCH] Use nextcloudci/server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- .github/workflows/cypress.yml | 52 ++++++++++++++--------------------- cypress/docker-compose.yml | 16 +++++++++++ cypress/initserver.sh | 10 +++++++ cypress/support/commands.js | 8 +++--- 4 files changed, 51 insertions(+), 35 deletions(-) create mode 100644 cypress/docker-compose.yml create mode 100755 cypress/initserver.sh diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 2564ee90f..d783e6971 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -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:8081/index.php jobs: cypress: @@ -24,24 +25,25 @@ 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: Pulling 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 + cd cypress + docker-compose pull - - name: Checkout app - uses: actions/checkout@v2 - with: - path: apps/${{ env.APP_NAME }} + - name: Caching server + uses: satackey/action-docker-layer-caching@v0.0.8 + # Ignore the failure of a step and avoid terminating the job. + continue-on-error: true + + - name: Setup server + run: | + cd cypress + docker-compose up -d - name: Set up node ${{ matrix.node-version }} uses: actions/setup-node@v1 @@ -49,30 +51,19 @@ jobs: 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 -T nextcloud --env APP_NAME=${{ env.APP_NAME }} bash /initserver.sh - name: Cypress run uses: cypress-io/github-action@v1 @@ -80,7 +71,6 @@ jobs: 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: diff --git a/cypress/docker-compose.yml b/cypress/docker-compose.yml new file mode 100644 index 000000000..b2049e1e0 --- /dev/null +++ b/cypress/docker-compose.yml @@ -0,0 +1,16 @@ +version: '3' + +services: + nextcloud: + image: nextcloudci/server + + ports: + - 8081:80 + + environment: + CYPRESS_baseUrl: "http://127.0.0.1:8081/index.php" + BRANCH: master + + volumes: + - ../:/var/www/html/apps/viewer + - ./initserver.sh:/initserver.sh diff --git a/cypress/initserver.sh b/cypress/initserver.sh new file mode 100755 index 000000000..4d997b588 --- /dev/null +++ b/cypress/initserver.sh @@ -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 +" diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 5b12ce34d..a5a1cab9d 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -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) }) @@ -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)