Skip to content

Commit

Permalink
Add automatic phpunit scheduling after assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
tsdicloud committed Jul 11, 2023
1 parent 475bb5a commit 914ff80
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/nmc-custom-app-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Assembly fails if a PR does not merge automatically.
#

name: MCLOUD custom app build
name: MCLOUD build (app)

on:
workflow_call:
Expand Down
113 changes: 113 additions & 0 deletions .github/workflows/nmc-custom-app-phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: MCLOUD phpunit (app)

on:
workflow_call:
inputs:
assembly:
description: name of the customisation assembly branch, not needed for non-fork apps
required: true
type: string
appname:
description: name of the app to test
required: true
type: string
server-repo:
description: uncustomized nextcloud stable version branch
required: false
type: string
default: 'nextcloud/server'
server-branch:
description: nextcloud stable version branch
required: true
type: string
phpversion:
description: php version to use
required: false
type: string
default: '8.0'
database:
description: database to use
required: false
type: string
default: 'mysql'

jobs:
unitrun:
runs-on: ubuntu-latest

strategy:
fail-fast: false
#matrix:
# php-versions: ['8.0', '8.1']
# databases: ['mysql']

name: ${{ inputs.assembly }}-php${{ inputs.phpversion }}-${{ inputs.database }}

services:
#postgres:
# image: postgres:14
# ports:
# - 4445:5432/tcp
# env:
# POSTGRES_USER: root
# POSTGRES_PASSWORD: rootpassword
# POSTGRES_DB: nextcloud
# options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5
mysql:
image: mariadb:10.5
ports:
- 4444:3306/tcp
env:
MYSQL_ROOT_PASSWORD: rootpassword
options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5

steps:
# we test apps with plain Nextcloud server to keep things independent
# full integration test is separately done
- name: Checkout server
uses: actions/checkout@v2
with:
repository: nextcloud/server
ref: ${{ inputs.serverbranch }}

- name: Checkout submodules
shell: bash
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:
repository: nextmcloud/${{ inputs.appname }}
ref: ${{ inputs.assembly }}
path: apps/${{ inputs.appname }}

- name: Set up php ${{ inputs.phpversion }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.phpversion }}
tools: phpunit
extensions: zip, gd, mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, mysql, pdo_mysql, pgsql, pdo_pgsql
coverage: none

- name: Set up PHPUnit
working-directory: apps/${{ inputs.appname }}
run: composer i

- name: Set up Nextcloud DB
run: |
if [ "${{ inputs.database }}" = "mysql" ]; then
export DB_PORT=4444
#elif [ "${{ inputs.database }}" = "pgsql" ]; then
# export DB_PORT=4445
fi
mkdir data
./occ maintenance:install --verbose --database=${{ inputs.database }} --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
./occ app:enable --force ${{ inputs.appname }}
php -S localhost:8080 &
- name: PHPUnit
working-directory: apps/${{ inputs.appname }}
run: composer run test:unit

0 comments on commit 914ff80

Please sign in to comment.