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

Bump cypress from 9.6.1 to 10.6.0 #874

Closed
wants to merge 2 commits into from
Closed
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
124 changes: 82 additions & 42 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,65 +9,105 @@ on:

env:
APP_NAME: activity
CYPRESS_baseUrl: http://localhost:8081/index.php
BRANCH: ${{ github.base_ref }}
PHP_VERSION: 7.4
CYPRESS_baseUrl: http://127.0.0.1:8082/index.php
TESTING: true

jobs:
init:
runs-on: ubuntu-latest

steps:
- name: Checkout app
uses: actions/checkout@v3

- name: Read package.json node and npm engines version
uses: skjnldsv/read-package-engines-version-actions@v1.1
id: versions
with:
fallbackNode: '^12'
fallbackNpm: '^6'

- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@v3
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}

- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"

- name: Install dependencies & build app
run: |
npm ci
TESTING=true npm run build --if-present

- name: Save context
uses: actions/cache@v3
with:
key: cypress-context-${{ github.run_id }}
path: /home/runner/work/activity

cypress:
name: cypress
runs-on: ubuntu-latest
needs: init

strategy:
fail-fast: false
matrix:
# run multiple copies of the current job in parallel
containers: [1, 2, 3, 4, 5, 6, 7, 8]

name: runner ${{ matrix.containers }}

steps:
- name: Checkout server
uses: actions/checkout@v2
- name: Restore context
uses: actions/cache@v3
with:
repository: nextcloud/server
submodules: true
ref: ${{ env.BRANCH }}
key: cypress-context-${{ github.run_id }}
path: /home/runner/work/activity

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

- name: Set up php ${{ env.PHP_VERSION }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, zip, gd, apcu
coverage: none
ini-values:
apc.enable_cli=on
- name: Wait for server
run: npm run wait-on $CYPRESS_baseUrl

- name: Set up Nextcloud
env:
DB_PORT: 4444
PHP_CLI_SERVER_WORKERS: 10
- name: Enable app & configure server
run: |
mkdir data
php occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin
php occ config:system:set memcache.local --value="\\OC\\Memcache\\APCu"
php -f index.php
php -S 0.0.0.0:8081 &
export OC_PASS=1234561
php occ user:add --password-from-env user1
php occ user:add --password-from-env user2
php occ config:system:set force_language --value en
php occ app:enable activity
php occ app:list
curl -v http://localhost:8081/index.php/login
cat data/nextcloud.log
cd cypress
docker-compose exec --env APP_NAME=${{ env.APP_NAME }} --env BRANCH=${{ env.BRANCH }} -T nextcloud bash /initserver.sh

- name: Cypress run
uses: cypress-io/github-action@v2
uses: cypress-io/github-action@v4
with:
record: false # disabled for now as we have no way to savely use the token in our org
parallel: false
wait-on: '${{ env.CYPRESS_baseUrl }}'
working-directory: 'apps/${{ env.APP_NAME }}'
record: true
parallel: true
# cypress env
ci-build-id: ${{ github.sha }}-${{ github.run_number }}
tag: ${{ github.event_name }}
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# https://github.com/cypress-io/github-action/issues/124
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
TESTING: true

- name: Upload snapshots
uses: actions/upload-artifact@v3
if: always()
with:
name: snapshots
path: cypress/snapshots

summary:
runs-on: ubuntu-latest
needs: [init, cypress]

if: always()

name: cypress-summary

steps:
- name: Summary status
run: if ${{ needs.init.result != 'success' || ( needs.cypress.result != 'success' && needs.cypress.result != 'skipped' ) }}; then exit 1; fi
28 changes: 28 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { defineConfig } = require("cypress");
const browserify = require('@cypress/browserify-preprocessor')

module.exports = defineConfig({
projectId: '5bsgwk',

viewportWidth: 1280,
viewportHeight: 720,
defaultCommandTimeout: 6000,
retries: 1,

env: {
failSilently: false,
type: 'actual',
},

screenshotsFolder: 'cypress/snapshots/actual',
trashAssetsBeforeRuns: true,

e2e: {
baseUrl: 'http://localhost:8082/index.php',

setupNodeEvents(on, config) {
// Fix browserslist extend https://github.com/cypress-io/cypress/issues/2983#issuecomment-570616682
on('file:preprocessor', browserify())
},
},
});
6 changes: 0 additions & 6 deletions cypress.json

This file was deleted.

20 changes: 12 additions & 8 deletions cypress/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
version: '3'
version: '3.7'

services:
nextcloud:
build:
context: .
restart: always
image: ghcr.io/nextcloud/continuous-integration-shallow-server

ports:
- 8081:80
- 8082:80

environment:
CYPRESS_baseUrl:
APP_SOURCE:
CYPRESS_baseUrl: "http://127.0.0.1:8082/index.php"
BRANCH: "${BRANCH:-master}"

volumes:
- ${APP_SOURCE}:/var/www/html/apps/activity
# Using fallback to make sure this script doesn't mess
# with the mounting if APP_NAME is not provided.
- ../:/var/www/html/apps/${APP_NAME:-activity}
- ./initserver.sh:/initserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
*
*/

import { randHash } from '../utils'
import { randHash } from '../../utils'

const randUser = randHash()

describe('Open test.md in viewer', function() {
before(function() {
describe('Open test.md in viewer', function () {
before(function () {
cy.nextcloudCreateUser(randUser, 'password')
cy.login(randUser, 'password')

Expand All @@ -33,16 +34,16 @@ describe('Open test.md in viewer', function() {
cy.wait(1000)
})

after(function() {
after(function () {
cy.logout()
})

it('Has creation activity', function() {
it('Has creation activity', function () {
cy.showActivityTab('welcome.txt')
cy.get('.activity-entry').eq(0).should('contains.text', 'You created')
})

it('Has favorite activity', function() {
it('Has favorite activity', function () {
cy.addToFavorites('welcome.txt')
cy.showActivityTab('welcome.txt')
cy.get('.activity-entry').eq(0).should('contains.text', 'Added to favorites')
Expand All @@ -52,21 +53,21 @@ describe('Open test.md in viewer', function() {
cy.get('.activity-entry').eq(0).should('contains.text', 'Removed from favorites')
})

it('Has share activity', function() {
it('Has share activity', function () {
cy.createPublicShare('welcome.txt')
cy.showActivityTab('welcome.txt')
cy.get('.activity-entry').eq(0).should('contains.text', 'Shared as public link')
})

it('Has rename activity', function() {
it('Has rename activity', function () {
cy.renameFile('welcome.txt', 'new name')
cy.renameFile('new name.txt', 'welcome')

cy.showActivityTab('welcome.txt')
cy.get('.activity-entry').eq(0).should('contains.text', 'You renamed')
})

it('Has move activity', function() {
it('Has move activity', function () {
cy.createFolder('Test folder')
cy.moveFile('welcome.txt', 'Test folder')
cy.goToDir('Test folder')
Expand All @@ -75,14 +76,14 @@ describe('Open test.md in viewer', function() {
cy.get('.activity-entry').eq(0).should('contains.text', 'You moved')
})

it('Has tag activity', function() {
it('Has tag activity', function () {
cy.addTag('welcome.txt', 'my_tag')

cy.showActivityTab('welcome.txt')
cy.get('.activity-entry').eq(0).should('contains.text', 'Added system tag')
})

it('Has comment activity', function() {
it('Has comment activity', function () {
cy.addComment('welcome.txt', 'A comment')

cy.showActivityTab('welcome.txt')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

/// <reference types="Cypress" />

import { randHash } from '../utils'
import { randHash } from '../../utils'
const randUser = randHash()

describe('Check that user\'s settings survive a reload', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

/// <reference types="Cypress" />

import { randHash } from '../utils'
import { randHash } from '../../utils'
const randUser = randHash()

describe('Check activity listing in the sidebar', function() {
before(function() {
describe('Check activity listing in the sidebar', function () {
before(function () {
cy.nextcloudCreateUser(randUser, 'password')
cy.login(randUser, 'password')

Expand All @@ -35,16 +35,16 @@ describe('Check activity listing in the sidebar', function() {
cy.wait(1000)
})

after(function() {
after(function () {
cy.logout()
})

it('Has creation activity', function() {
it('Has creation activity', function () {
cy.showActivityTab('welcome.txt')
cy.get('.activity-entry').eq(0).should('contains.text', 'You created')
})

it('Has favorite activity', function() {
it('Has favorite activity', function () {
cy.addToFavorites('welcome.txt')
cy.showActivityTab('welcome.txt')
cy.get('.activity-entry').eq(0).should('contains.text', 'Added to favorites')
Expand All @@ -54,21 +54,21 @@ describe('Check activity listing in the sidebar', function() {
cy.get('.activity-entry').eq(0).should('contains.text', 'Removed from favorites')
})

it('Has share activity', function() {
it('Has share activity', function () {
cy.createPublicShare('welcome.txt')
cy.showActivityTab('welcome.txt')
cy.get('.activity-entry').eq(0).should('contains.text', 'Shared as public link')
})

it('Has rename activity', function() {
it('Has rename activity', function () {
cy.renameFile('welcome.txt', 'new name')
cy.renameFile('new name.txt', 'welcome')

cy.showActivityTab('welcome.txt')
cy.get('.activity-entry').eq(0).should('contains.text', 'You renamed')
})

it('Has move activity', function() {
it('Has move activity', function () {
cy.createFolder('Test folder')
cy.moveFile('welcome.txt', 'Test folder')
cy.goToDir('Test folder')
Expand All @@ -77,14 +77,14 @@ describe('Check activity listing in the sidebar', function() {
cy.get('.activity-entry').eq(0).should('contains.text', 'You moved')
})

it('Has tag activity', function() {
it('Has tag activity', function () {
cy.addTag('welcome.txt', 'my_tag')

cy.showActivityTab('welcome.txt')
cy.get('.activity-entry').eq(0).should('contains.text', 'Added system tag')
})

it('Has comment activity', function() {
it('Has comment activity', function () {
cy.addComment('welcome.txt', 'A comment')

cy.showActivityTab('welcome.txt')
Expand Down
13 changes: 13 additions & 0 deletions cypress/initserver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

echo "APP_NAME: $APP_NAME"
echo "BRANCH: $BRANCH"

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 config:system:set enforce_theme --value light
php occ app:enable $APP_NAME
php occ app:list
"
Loading