How to use docker-ci project for developers Nextcloud's app?

Hi everyone :blush:

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 :slight_smile:

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 :wink:

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 :slight_smile:

Hi @nickvergessen :slight_smile:

I’m sorry for the delay and thanks for your help :slight_smile:

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.

    runs-on: ubuntu-latest

      # do not stop on another job's failure
      fail-fast: false
        php-versions: ['7.4', '8.0']
        server-versions: ['master']

        image: mariadb:10.5
          - 4444:3306/tcp
          MYSQL_ROOT_PASSWORD: rootpassword
        options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5

      - name: Enable ONLY_FULL_GROUP_BY MySQL option
        run: |
          echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h -P 4444 -u root -prootpassword
          echo "SELECT @@sql_mode;" | mysql -h -P 4444 -u root -prootpassword
      - name: Checkout server
        uses: actions/checkout@v3
          submodules: true
          repository: nextcloud/server
          ref: ${{ matrix.server-versions }}

      - name: Checkout app
        uses: actions/checkout@v3
          path: apps/${{ env.APP_NAME }}

      - name: Set up php ${{ matrix.php-versions }}
        uses: shivammathur/setup-php@v2
          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
          DB_PORT: 4444
        run: |
          mkdir data
          ./occ maintenance:install --verbose --database=mysql --database-name=nextcloud --database-host= --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 :slight_smile:
I will try it later :wink:

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.