1
0

phpunit-pgsql.yml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. # This workflow is provided via the organization template repository
  2. #
  3. # https://github.com/nextcloud/.github
  4. # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
  5. #
  6. # SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
  7. # SPDX-License-Identifier: MIT
  8. name: PHPUnit PostgreSQL
  9. on:
  10. pull_request:
  11. schedule:
  12. - cron: "5 2 * * *"
  13. permissions:
  14. contents: read
  15. concurrency:
  16. group: phpunit-pgsql-${{ github.head_ref || github.run_id }}
  17. cancel-in-progress: true
  18. jobs:
  19. changes:
  20. runs-on: ubuntu-latest-low
  21. outputs:
  22. src: ${{ steps.changes.outputs.src }}
  23. steps:
  24. - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
  25. id: changes
  26. continue-on-error: true
  27. with:
  28. filters: |
  29. src:
  30. - '.github/workflows/**'
  31. - '3rdparty/**'
  32. - '**/appinfo/**'
  33. - '**/lib/**'
  34. - '**/templates/**'
  35. - '**/tests/**'
  36. - 'vendor/**'
  37. - 'vendor-bin/**'
  38. - '.php-cs-fixer.dist.php'
  39. - 'composer.json'
  40. - 'composer.lock'
  41. - '**.php'
  42. phpunit-pgsql:
  43. runs-on: ubuntu-latest
  44. needs: changes
  45. if: needs.changes.outputs.src != 'false'
  46. strategy:
  47. matrix:
  48. php-versions: ['8.1']
  49. # To keep the matrix smaller we ignore PostgreSQL versions in between as we already test the minimum and the maximum
  50. postgres-versions: ['13', '17']
  51. include:
  52. - php-versions: '8.3'
  53. postgres-versions: '17'
  54. coverage: ${{ github.event_name != 'pull_request' }}
  55. - php-versions: '8.4'
  56. postgres-versions: '17'
  57. name: PostgreSQL ${{ matrix.postgres-versions }} (PHP ${{ matrix.php-versions }}) - database tests
  58. services:
  59. cache:
  60. image: ghcr.io/nextcloud/continuous-integration-redis:latest
  61. ports:
  62. - 6379:6379/tcp
  63. options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
  64. postgres:
  65. image: ghcr.io/nextcloud/continuous-integration-postgres-${{ matrix.postgres-versions }}:latest
  66. ports:
  67. - 4444:5432/tcp
  68. env:
  69. POSTGRES_USER: root
  70. POSTGRES_PASSWORD: rootpassword
  71. POSTGRES_DB: nextcloud
  72. options: --mount type=tmpfs,destination=/var/lib/postgresql/data --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5
  73. steps:
  74. - name: Checkout server
  75. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  76. with:
  77. submodules: true
  78. - name: Set up php ${{ matrix.php-versions }}
  79. uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 #v2.31.1
  80. with:
  81. php-version: ${{ matrix.php-versions }}
  82. # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
  83. extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, redis, session, simplexml, xmlreader, xmlwriter, zip, zlib, pgsql, pdo_pgsql
  84. coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
  85. ini-file: development
  86. env:
  87. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  88. - name: Set up dependencies
  89. run: composer i
  90. - name: Set up Nextcloud
  91. env:
  92. DB_PORT: 4444
  93. run: |
  94. mkdir data
  95. cp tests/redis.config.php config/
  96. cp tests/preseed-config.php config/config.php
  97. ./occ maintenance:install --verbose --database=pgsql --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
  98. php -f tests/enable_all.php | grep -i -C9999 error && echo "Error during app setup" && exit 1 || exit 0
  99. - name: PHPUnit database tests
  100. run: composer run test:db ${{ matrix.coverage && ' -- --coverage-clover ./clover.db.xml' || '' }}
  101. - name: Upload db code coverage
  102. if: ${{ !cancelled() && matrix.coverage }}
  103. uses: codecov/codecov-action@v5.0.7
  104. with:
  105. files: ./clover.db.xml
  106. flags: phpunit-postgres
  107. - name: Run repair steps
  108. run: |
  109. ./occ maintenance:repair --include-expensive
  110. - name: Print logs
  111. if: always()
  112. run: |
  113. cat data/nextcloud.log
  114. summary:
  115. permissions:
  116. contents: none
  117. runs-on: ubuntu-latest-low
  118. needs: [changes, phpunit-pgsql]
  119. if: always()
  120. name: phpunit-pgsql-summary
  121. steps:
  122. - name: Summary status
  123. run: if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-pgsql.result != 'success' }}; then exit 1; fi