files-external-s3.yml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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
  12. outputs:
  13. src: ${{ steps.changes.outputs.src}}
  14. steps:
  15. - uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd # v3.0.0
  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. - '.php-cs-fixer.dist.php'
  27. - 'composer.json'
  28. - 'composer.lock'
  29. - '**.php'
  30. files-external-s3-minio:
  31. runs-on: ubuntu-latest
  32. needs: changes
  33. if: ${{ github.repository_owner != 'nextcloud-gmbh' && needs.changes.outputs.src != 'false' }}
  34. strategy:
  35. matrix:
  36. php-versions: ['8.0', '8.1', '8.2', '8.3']
  37. include:
  38. - php-versions: '8.3'
  39. coverage: true
  40. name: php${{ matrix.php-versions }}-s3
  41. services:
  42. minio:
  43. image: bitnami/minio
  44. env:
  45. MINIO_ROOT_USER: nextcloud
  46. MINIO_ROOT_PASSWORD: bWluaW8tc2VjcmV0LWtleS1uZXh0Y2xvdWQ=
  47. MINIO_DEFAULT_BUCKETS: nextcloud
  48. ports:
  49. - "9000:9000"
  50. steps:
  51. - name: Checkout server
  52. uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
  53. with:
  54. submodules: true
  55. - name: Set up php ${{ matrix.php-versions }}
  56. uses: shivammathur/setup-php@4bd44f22a98a19e0950cbad5f31095157cc9621b # v2
  57. with:
  58. php-version: ${{ matrix.php-versions }}
  59. # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
  60. 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
  61. coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
  62. ini-file: development
  63. env:
  64. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  65. - name: Set up Nextcloud
  66. env:
  67. OBJECT_STORE_KEY: nextcloud
  68. OBJECT_STORE_SECRET: bWluaW8tc2VjcmV0LWtleS1uZXh0Y2xvdWQ=
  69. run: |
  70. composer install
  71. ./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
  72. ./occ app:enable --force files_external
  73. 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
  74. - name: Wait for S3
  75. run: |
  76. sleep 10
  77. curl -f -m 1 --retry-connrefused --retry 10 --retry-delay 10 http://localhost:9000/minio/health/ready
  78. - name: PHPUnit
  79. run: composer run test:files_external -- \
  80. apps/files_external/tests/Storage/Amazons3Test.php \
  81. apps/files_external/tests/Storage/VersionedAmazonS3Test.php \
  82. ${{ matrix.coverage && ' --coverage-clover ./clover.xml' || '' }}
  83. - name: Upload code coverage
  84. if: ${{ !cancelled() && matrix.coverage }}
  85. uses: codecov/codecov-action@v3
  86. with:
  87. files: ./clover.xml
  88. flags: phpunit-files-external-s3
  89. - name: S3 logs
  90. if: always()
  91. run: |
  92. docker ps -a
  93. docker ps -aq | while read container ; do IMAGE=$(docker inspect --format='{{.Config.Image}}' $container); echo $IMAGE; docker logs $container; echo "\n\n" ; done
  94. files-external-s3-localstack:
  95. runs-on: ubuntu-latest
  96. needs: changes
  97. if: ${{ github.repository_owner != 'nextcloud-gmbh' && needs.changes.outputs.src != 'false' }}
  98. strategy:
  99. matrix:
  100. php-versions: ['8.0', '8.1', '8.2', '8.3']
  101. include:
  102. - php-versions: '8.3'
  103. coverage: true
  104. name: php${{ matrix.php-versions }}-s3
  105. services:
  106. localstack:
  107. env:
  108. SERVICES: s3
  109. DEBUG: 1
  110. image: localstack/localstack
  111. ports:
  112. - "4566:4566"
  113. steps:
  114. - name: Checkout server
  115. uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
  116. with:
  117. submodules: true
  118. - name: Set up php ${{ matrix.php-versions }}
  119. uses: shivammathur/setup-php@4bd44f22a98a19e0950cbad5f31095157cc9621b # v2
  120. with:
  121. php-version: ${{ matrix.php-versions }}
  122. # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
  123. 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
  124. coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
  125. ini-file: development
  126. env:
  127. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  128. - name: Set up Nextcloud
  129. run: |
  130. composer install
  131. ./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
  132. ./occ app:enable --force files_external
  133. 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
  134. - name: PHPUnit
  135. run: composer run test:files_external -- \
  136. apps/files_external/tests/Storage/Amazons3Test.php \
  137. apps/files_external/tests/Storage/VersionedAmazonS3Test.php \
  138. ${{ matrix.coverage && ' --coverage-clover ./clover.xml' || '' }}
  139. - name: Upload code coverage
  140. if: ${{ !cancelled() && matrix.coverage }}
  141. uses: codecov/codecov-action@v3
  142. with:
  143. files: ./clover.xml
  144. flags: phpunit-files-external-s3
  145. - name: S3 logs
  146. if: always()
  147. run: |
  148. docker ps -a
  149. docker ps -aq | while read container ; do IMAGE=$(docker inspect --format='{{.Config.Image}}' $container); echo $IMAGE; docker logs $container; echo "\n\n" ; done
  150. s3-external-summary:
  151. runs-on: ubuntu-latest
  152. needs: [changes, files-external-s3-minio, files-external-s3-localstack]
  153. if: always()
  154. steps:
  155. - name: Summary status
  156. 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