Skip to content

Commit

Permalink
chore: change cypress workflow (#4654)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin authored Dec 5, 2020
1 parent ca65bf8 commit 1c42169
Showing 1 changed file with 101 additions and 97 deletions.
198 changes: 101 additions & 97 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name: Chrome headless
name: Cypress tests

on:
push:
branches-ignore:
- 'l10n_master*'
pull_request:
types: [labeled, opened, synchronize, reopened]

jobs:
cypress-run:
cypress:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'cypress')
name: Cypress tests with ${{ matrix.browser }} (PHP ${{ matrix.php-version }})

services:
mysql:
image: mysql:5.7
Expand All @@ -17,104 +19,106 @@ jobs:
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

strategy:
fail-fast: false
matrix:
php-version: [7.3]
browser: [chrome]
containers: [1, 2, 3, 4, 5, 6, 7, 8]
max-parallel: 10
name: Cypress Test with PHP ${{ matrix.php-version }} browser ${{ matrix.browser }}

steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: imagick
coverage: none
- name: Check PHP Version
run: php -v
- name: Check Composer Version
run: composer -V
- name: Check PHP Extensions
run: php -m

# step-prepare-environment
- name: Prepare environment
run: |
mkdir -p results/coverage
cp scripts/ci/.env.mysql .env
touch .sentry-release
echo "REQUIRES_SUBSCRIPTION=true" >> .env
- name: Validate composer.json and composer.lock
run: composer validate

- name: Get Composer Cache Directory
id: composer-cache-dir-path
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer files
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-interaction --no-suggest --ignore-platform-reqs

# step-prepare-db
- name: Prepare db
run: mysql -h 127.0.0.1 -u root -P 3306 monica < scripts/database.test.sql
- name: Run migration scripts
run: php artisan migrate --no-interaction -vvv

# step-seed-test-db
- name: Seed database
run: |
php artisan db:seed --no-interaction -vvv
php artisan passport:keys --no-interaction -vvv
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: yarn install
run: yarn inst
- name: Cypress verify
run: npm run cy:verify

- name: which google-chrome
run: |
which google-chrome || true
- uses: cypress-io/github-action@v1
with:
start: php artisan serve
browser: ${{ matrix.browser }}
headless: true
record: true
parallel: true
group: Azure DevOps CI ${{ matrix.browser }}
config: baseUrl=http://localhost:8000
wait-on: http://localhost:8000
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - name: Store results
# uses: actions/upload-artifact@v1
# with:
# name: results
# path: results/junit/cypress/results*.xml
- name: Checkout sources
uses: actions/checkout@v2

- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: imagick
coverage: none
- name: Check PHP Version
run: php -v
- name: Check Composer Version
run: composer -V
- name: Check PHP Extensions
run: php -m

# step-prepare-environment
- name: Prepare environment
run: |
mkdir -p results/coverage
cp scripts/ci/.env.mysql .env
touch .sentry-release
echo "REQUIRES_SUBSCRIPTION=true" >> .env
- name: Validate composer.json and composer.lock
run: composer validate

- name: Get Composer Cache Directory
id: composer-cache-dir-path
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer files
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-interaction --no-suggest --ignore-platform-reqs

# step-prepare-db
- name: Prepare db
run: mysql -h 127.0.0.1 -u root -P 3306 monica < scripts/database.test.sql
- name: Run migration scripts
run: php artisan migrate --no-interaction -vvv

# step-seed-test-db
- name: Seed database
run: |
php artisan db:seed --no-interaction -vvv
php artisan passport:keys --no-interaction -vvv
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: yarn install
run: yarn inst
- name: Cypress verify
run: npm run cy:verify

- name: which google-chrome
run: |
which google-chrome || true
- uses: cypress-io/github-action@v1
with:
start: php artisan serve
browser: ${{ matrix.browser }}
headless: true
record: true
parallel: true
install: false
group: Azure DevOps CI ${{ matrix.browser }}
tag: ${{ github.event_name }}
config: baseUrl=http://localhost:8000
wait-on: http://localhost:8000
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}

- name: Cypress infos
run: |
echo Cypress finished with: ${{ steps.cypress.outcome }}
echo See results at ${{ steps.cypress.outputs.dashboardUrl }}

0 comments on commit 1c42169

Please sign in to comment.