z4k
May 13, 2022, 7:36am
1
Hi everyone
I searched how to use Docker in the CI and I found this project : GitHub - nextcloud/docker-ci: Containers used for Continous Integration jobs (automated testing) .
I think it’s very interesting to use it as developers Nextcloud’s app
Is that what it’s for ?
If yes, I have never done of CI with Docker. Can I add my app ? Can I add a fork of a Nextcloud’s app ?
Thanks in advance
For CI you can follow out app-tutorial app:
That has good templates how to run unit and integration tests
Hi @z4k !
Does it answer your question?
I think I have the same kind of question, I want to develop an app, and I want to do integration test of this app, so then I need a fulll Nc install to do so in my CI pipeline for the app, before publishing it.
I’m currently looking into it, but if people have recommendations, it would be appreciated
z4k
May 19, 2022, 12:48pm
4
Hi @nickvergessen
I’m sorry for the delay and thanks for your help
But, in my unit tests I need to run a Nextcloud server to request APIs. In your link, I don’t see how to run a Nextcloud server with Docker.
I think it’s possible to run a nextcloud server via Docker, but, I don’t know how to do this…
Oooh wait !
I see in this file you don’t use Docker to run a Nextcloud server ?
Link : app-tutorial/phpunit-mysql.yml at master · nextcloud/app-tutorial · GitHub
When I see this code, I think it’s possible to trigger unit and integration tests.
jobs:
phpunit-mysql:
runs-on: ubuntu-latest
strategy:
# do not stop on another job's failure
fail-fast: false
matrix:
php-versions: ['7.4', '8.0']
server-versions: ['master']
services:
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:
- name: Enable ONLY_FULL_GROUP_BY MySQL option
run: |
echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
- name: Checkout server
uses: actions/checkout@v3
with:
submodules: true
repository: nextcloud/server
ref: ${{ matrix.server-versions }}
- name: Checkout app
uses: actions/checkout@v3
with:
path: apps/${{ env.APP_NAME }}
- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit
extensions: mbstring, iconv, fileinfo, intl, mysql, pdo_mysql
coverage: none
- name: Set up PHPUnit
working-directory: apps/${{ env.APP_NAME }}
run: composer i
- name: Set up Nextcloud
env:
DB_PORT: 4444
run: |
mkdir data
./occ maintenance:install --verbose --database=mysql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
./occ app:enable --force ${{ env.APP_NAME }}
php -S localhost:8080 &
- name: PHPUnit
# Only run if phpunit config file exists
if: env.PHPUNIT_CONFIG != ''
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }}
- name: PHPUnit integration
# Only run if phpunit integration config file exists
if: env.PHPUNIT_INTEGRATION_CONFIG != ''
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }}
Thanks @nickvergessen
I will try it later
You can try this template example ?
Before I use it, I will try to run unit tests with a container Docker to run a Nextcloud server from the local.