files-external-s3.yml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. name: PHPUnit files_external S3
  2. on:
  3. pull_request:
  4. schedule:
  5. - cron: "5 2 * * *"
  6. concurrency:
  7. group: files-external-s3-${{ github.head_ref || github.run_id }}
  8. cancel-in-progress: true
  9. jobs:
  10. changes:
  11. runs-on: ubuntu-latest-low
  12. outputs:
  13. src: ${{ steps.changes.outputs.src}}
  14. steps:
  15. - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
  16. id: changes
  17. continue-on-error: true
  18. with:
  19. filters: |
  20. src:
  21. - '.github/workflows/**'
  22. - '3rdparty/**'
  23. - 'apps/files_external/**'
  24. - 'vendor/**'
  25. - 'vendor-bin/**'
  26. - 'composer.json'
  27. - 'composer.lock'
  28. - '**.php'
  29. files-external-s3-minio:
  30. runs-on: ubuntu-latest
  31. needs: changes
  32. if: ${{ github.repository_owner != 'nextcloud-gmbh' && needs.changes.outputs.src != 'false' }}
  33. strategy:
  34. matrix:
  35. php-versions: ['8.0', '8.1', '8.2', '8.3']
  36. include:
  37. - php-versions: '8.2'
  38. coverage: ${{ github.event_name != 'pull_request' }}
  39. name: php${{ matrix.php-versions }}-s3
  40. services:
  41. minio:
  42. image: bitnami/minio
  43. env:
  44. MINIO_ROOT_USER: nextcloud
  45. MINIO_ROOT_PASSWORD: bWluaW8tc2VjcmV0LWtleS1uZXh0Y2xvdWQ=
  46. MINIO_DEFAULT_BUCKETS: nextcloud
  47. ports:
  48. - "9000:9000"
  49. steps:
  50. - name: Checkout server
  51. uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  52. with:
  53. submodules: true
  54. - name: Set up php ${{ matrix.php-versions }}
  55. uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
  56. with:
  57. php-version: ${{ matrix.php-versions }}
  58. # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
  59. extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, redis, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
  60. coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
  61. ini-file: development
  62. env:
  63. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  64. - name: Set up Nextcloud
  65. env:
  66. OBJECT_STORE_KEY: nextcloud
  67. OBJECT_STORE_SECRET: bWluaW8tc2VjcmV0LWtleS1uZXh0Y2xvdWQ=
  68. run: |
  69. composer install
  70. ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
  71. ./occ app:enable --force files_external
  72. echo "<?php return ['run' => true, 'secret' => 'actually-not-secret', 'passwordsalt' => 'actually-not-secret', 'hostname' => 'localhost','key' => '$OBJECT_STORE_KEY','secret' => '$OBJECT_STORE_SECRET', 'bucket' => 'bucket', 'port' => 9000, 'use_ssl' => false, 'autocreate' => true, 'use_path_style' => true];" > apps/files_external/tests/config.amazons3.php
  73. - name: Wait for S3
  74. run: |
  75. sleep 10
  76. curl -f -m 1 --retry-connrefused --retry 10 --retry-delay 10 http://localhost:9000/minio/health/ready
  77. - name: PHPUnit
  78. run: composer run test:files_external -- \
  79. apps/files_external/tests/Storage/Amazons3Test.php \
  80. apps/files_external/tests/Storage/VersionedAmazonS3Test.php \
  81. ${{ matrix.coverage && ' --coverage-clover ./clover.xml' || '' }}
  82. - name: Upload code coverage
  83. if: ${{ !cancelled() && matrix.coverage }}
  84. uses: codecov/codecov-action@v4
  85. with:
  86. files: ./clover.xml
  87. flags: phpunit-files-external-s3
  88. - name: S3 logs
  89. if: always()
  90. run: |
  91. docker ps -a
  92. docker ps -aq | while read container ; do IMAGE=$(docker inspect --format='{{.Config.Image}}' $container); echo $IMAGE; docker logs $container; echo "\n\n" ; done
  93. files-external-s3-localstack:
  94. runs-on: ubuntu-latest
  95. needs: changes
  96. if: ${{ github.repository_owner != 'nextcloud-gmbh' && needs.changes.outputs.src != 'false' }}
  97. strategy:
  98. matrix:
  99. php-versions: ['8.0', '8.1', '8.2', '8.3']
  100. include:
  101. - php-versions: '8.3'
  102. coverage: true
  103. name: php${{ matrix.php-versions }}-s3
  104. services:
  105. localstack:
  106. env:
  107. SERVICES: s3
  108. DEBUG: 1
  109. image: localstack/localstack
  110. ports:
  111. - "4566:4566"
  112. steps:
  113. - name: Checkout server
  114. uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  115. with:
  116. submodules: true
  117. - name: Set up php ${{ matrix.php-versions }}
  118. uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
  119. with:
  120. php-version: ${{ matrix.php-versions }}
  121. # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
  122. extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, redis, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
  123. coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
  124. ini-file: development
  125. env:
  126. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  127. - name: Set up Nextcloud
  128. run: |
  129. composer install
  130. ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
  131. ./occ app:enable --force files_external
  132. echo "<?php return ['run' => true,'hostname' => 'localhost','key' => 'ignored','secret' => 'ignored', 'bucket' => 'bucket', 'port' => 4566, 'use_ssl' => false, 'autocreate' => true, 'use_path_style' => true];" > apps/files_external/tests/config.amazons3.php
  133. - name: PHPUnit
  134. run: composer run test:files_external -- \
  135. apps/files_external/tests/Storage/Amazons3Test.php \
  136. apps/files_external/tests/Storage/VersionedAmazonS3Test.php \
  137. ${{ matrix.coverage && ' --coverage-clover ./clover.xml' || '' }}
  138. - name: Upload code coverage
  139. if: ${{ !cancelled() && matrix.coverage }}
  140. uses: codecov/codecov-action@v4
  141. with:
  142. files: ./clover.xml
  143. flags: phpunit-files-external-s3
  144. - name: S3 logs
  145. if: always()
  146. run: |
  147. docker ps -a
  148. docker ps -aq | while read container ; do IMAGE=$(docker inspect --format='{{.Config.Image}}' $container); echo $IMAGE; docker logs $container; echo "\n\n" ; done
  149. s3-external-summary:
  150. runs-on: ubuntu-latest-low
  151. needs: [changes, files-external-s3-minio, files-external-s3-localstack]
  152. if: always()
  153. steps:
  154. - name: Summary status
  155. run: if ${{ needs.changes.outputs.src != 'false' && (needs.files-external-s3-minio.result != 'success' || needs.files-external-s3-localstack.result != 'success') }}; then exit 1; fi