Skip to content

[stable2.2] fix(autoconfig): Refactor DNS query for testing #16238

[stable2.2] fix(autoconfig): Refactor DNS query for testing

[stable2.2] fix(autoconfig): Refactor DNS query for testing #16238

Workflow file for this run

name: Test
on: pull_request
permissions:
contents: read
jobs:
unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.0', '8.1', '8.2']
nextcloud-versions: ['stable26']
include:
- php-versions: 7.4
nextcloud-versions: stable25
- php-versions: 8.0
nextcloud-versions: stable25
name: Nextcloud ${{ matrix.nextcloud-versions }} php${{ matrix.php-versions }} unit tests
steps:
- name: Set up php${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ctype,curl,dom,gd,iconv,intl,json,mbstring,openssl,posix,sqlite,xml,zip,gmp
coverage: xdebug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Nextcloud
run: git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b ${{ matrix.nextcloud-versions }} nextcloud
- name: Patch version check for nightly PHP
if: ${{ matrix.php-versions == '8.2' }}
run: echo "<?php" > nextcloud/lib/versioncheck.php
- name: Install Nextcloud
run: php -f nextcloud/occ maintenance:install --database-name oc_autotest --database-user oc_autotest --admin-user admin --admin-pass admin --database sqlite --database-pass=''
- name: Checkout Mail
uses: actions/checkout@v3
with:
path: nextcloud/apps/mail
- name: Install dependencies
working-directory: nextcloud/apps/mail
run: composer install
- name: Run tests
working-directory: nextcloud/apps/mail
run: composer run test:unit
if: ${{ matrix.php-versions == '8.0' }}
env:
XDEBUG_MODE: coverage
- name: Run tests
working-directory: nextcloud/apps/mail
run: composer run test:unit
if: ${{ matrix.php-versions != '8.0' }}
env:
XDEBUG_MODE: off
- name: Report coverage
uses: codecov/codecov-action@v3.1.1
if: ${{ always() && matrix.php-versions == '8.0' }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./nextcloud/apps/mail/tests/clover.unit.xml
flags: unittests
fail_ci_if_error: true
integration-tests:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.0']
nextcloud-versions: ['stable26']
db: ['sqlite', 'mysql', 'pgsql']
include:
- php-versions: 7.4
nextcloud-versions: stable25
db: 'mysql'
- php-versions: 8.1
nextcloud-versions: stable26
db: 'pgsql'
- php-versions: 8.2
nextcloud-versions: stable26
db: 'sqlite'
name: php${{ matrix.php-versions }}-${{ matrix.db }} integration tests
services:
mail-service:
image: ghcr.io/christophwurst/docker-imap-devel:latest
env:
MAILNAME: mail.domain.tld
MAIL_ADDRESS: user@domain.tld
MAIL_PASS: mypassword
ports:
- 25:25
- 143:143
- 993:993
- 4190:4190
mysql-service:
image: mariadb:10.5
env:
MYSQL_ROOT_PASSWORD: my-secret-pw
MYSQL_DATABASE: nextcloud
MYSQL_USER: nextcloud
MYSQL_PASSWORD: nextcloud
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
postgres-service:
image: postgres:14
env:
POSTGRES_USER: nextcloud
POSTGRES_DB: nextcloud
POSTGRES_PASSWORD: nextcloud
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Set up php${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ctype,curl,dom,gd,iconv,intl,json,mbstring,openssl,posix,sqlite,xml,zip,gmp
coverage: xdebug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Nextcloud
run: git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b ${{ matrix.nextcloud-versions }} nextcloud
- name: Patch version check for nightly PHP
if: ${{ matrix.php-versions == '8.2' }}
run: echo "<?php" > nextcloud/lib/versioncheck.php
- name: Install Nextcloud
run: php -f nextcloud/occ maintenance:install --database-host 127.0.0.1 --database-name nextcloud --database-user nextcloud --database-pass nextcloud --admin-user admin --admin-pass admin --database ${{ matrix.db }}
- name: Checkout Mail
uses: actions/checkout@v3
with:
path: nextcloud/apps/mail
- name: Install dependencies
working-directory: nextcloud/apps/mail
run: composer install
- name: Patch version check for nightly PHP
if: ${{ matrix.php-versions == '8.2' }}
run: sed -i 's/max-version="8.1"/max-version="8.2"/' nextcloud/apps/mail/appinfo/info.xml
- name: Install Mail
run: php -f nextcloud/occ app:enable mail
- name: Configure Nextcloud for testing
run: |
php -f nextcloud/occ config:system:set debug --type bool --value true
php -f nextcloud/occ config:system:set app.mail.verify-tls-peer --type bool --value false
- name: Enable slow mysql query logs
if: ${{ matrix.db == 'mysql' }}
run: |
echo "SET GLOBAL log_queries_not_using_indexes = 1;" | mysql -h 127.0.0.1 -u root -pmy-secret-pw
echo "SET GLOBAL slow_query_log=1;" | mysql -h 127.0.0.1 -u root -pmy-secret-pw
echo "SET GLOBAL log_output = 'table';" | mysql -h 127.0.0.1 -u root -pmy-secret-pw
- name: Run tests
working-directory: nextcloud/apps/mail
if: ${{ matrix.db == 'mysql' }}
run: composer run test:integration
env:
XDEBUG_MODE: coverage
- name: Run tests
working-directory: nextcloud/apps/mail
if: ${{ matrix.db != 'mysql' }}
run: composer run test:integration
env:
XDEBUG_MODE: off
- name: Read slow queries
if: ${{ always() }}
run: echo "SELECT * FROM mysql.slow_log WHERE sql_text LIKE '%oc_mail%' AND sql_text NOT LIKE '%information_schema%'" | mysql -h 127.0.0.1 -u root -pmy-secret-pw
- name: Print debug logs
if: ${{ always() }}
run: cat nextcloud/data/horde_*.log
- name: Report coverage
uses: codecov/codecov-action@v3.1.1
if: ${{ always() && matrix.db == 'mysql' }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./nextcloud/apps/mail/tests/clover.integration.xml
flags: integrationtests
fail_ci_if_error: true
frontend-unit-test:
runs-on: ubuntu-latest
name: Front-end unit tests
steps:
- uses: actions/checkout@v3
- name: Read package.json node and npm engines version
uses: skjnldsv/read-package-engines-version-actions@v1.2
id: versions
with:
fallbackNode: '^14'
fallbackNpm: '^7'
- 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: npm install
run: npm install
- name: run tests
run: npm run test:unit
env:
CI: true
summary:
runs-on: ubuntu-latest
needs:
- unit-tests
- integration-tests
- frontend-unit-test
if: always()
name: test-summary
steps:
- name: Unit test status
run: if ${{ needs.unit-tests.result != 'success' && needs.unit-tests.result != 'skipped' }}; then exit 1; fi
- name: Integration test status
run: if ${{ needs.integration-tests.result != 'success' && needs.integration-tests.result != 'skipped' }}; then exit 1; fi
- name: Frontend unit test status
run: if ${{ needs.frontend-unit-test.result != 'success' && needs.frontend-unit-test.result != 'skipped' }}; then exit 1; fi