files-external-ftp.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. name: PHPUnit files_external FTP
  2. on:
  3. pull_request:
  4. schedule:
  5. - cron: "5 2 * * *"
  6. concurrency:
  7. group: files-external-ftp-${{ 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@ebc4d7e9ebcb0b1eb21480bb8f43113e996ac77a # v3.0.1
  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-ftp:
  30. runs-on: ubuntu-latest
  31. needs: changes
  32. if: ${{ github.repository_owner != 'nextcloud-gmbh' && needs.changes.outputs.src != 'false' }}
  33. strategy:
  34. # do not stop on another job's failure
  35. fail-fast: false
  36. matrix:
  37. php-versions: ['8.0', '8.3']
  38. ftpd: ['proftpd', 'vsftpd', 'pure-ftpd']
  39. include:
  40. - php-versions: '8.0'
  41. coverage: ${{ github.event_name != 'pull_request' }}
  42. name: php${{ matrix.php-versions }}-${{ matrix.ftpd }}
  43. steps:
  44. - name: Checkout server
  45. uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
  46. with:
  47. submodules: true
  48. - name: Set up ftpd
  49. run: |
  50. sudo mkdir /tmp/ftp
  51. sudo chmod -R 0777 /tmp/ftp
  52. if [[ "${{ matrix.ftpd }}" == 'proftpd' ]]; then echo '$6$Q7V2n3q2GRVv5YeQ$/AhLu07H76Asojy7bxGXMY1caKLAbp5Vt82LOZYMkD/8uDzyMAEXwk0c1Bdz1DkBsk2Vh/9SF130mOPavRGMo.' > /tmp/secret.txt; fi
  53. if [[ "${{ matrix.ftpd }}" == 'proftpd' ]]; then echo 'FTP_ROOT=/home/test' > $GITHUB_ENV; fi
  54. if [[ "${{ matrix.ftpd }}" == 'proftpd' ]]; then docker run --name ftp -d --net host -e PASV_ADDRESS=127.0.0.1 -e FTPUSER_NAME=test -v /tmp/secret.txt:/run/secrets/ftp-user-password-secret -v /tmp/ftp:/home/test instantlinux/proftpd; fi
  55. if [[ "${{ matrix.ftpd }}" == 'vsftpd' ]]; then docker run --name ftp -d --net host -e FTP_USER=test -e FTP_PASS=test -e PASV_ADDRESS=127.0.0.1 -v /tmp/ftp:/home/vsftpd/test fauria/vsftpd; fi
  56. if [[ "${{ matrix.ftpd }}" == 'pure-ftpd' ]]; then docker run --name ftp -d --net host -e "PUBLICHOST=localhost" -e FTP_USER_NAME=test -e FTP_USER_PASS=test -e FTP_USER_HOME=/home/test -v /tmp/ftp:/home/test -v /tmp/ftp:/etc/pure-ftpd/passwd stilliard/pure-ftpd; fi
  57. - name: Set up php ${{ matrix.php-versions }}
  58. uses: shivammathur/setup-php@c5fc0d8281aba02c7fda07d3a70cc5371548067d #v2.25.2
  59. with:
  60. php-version: ${{ matrix.php-versions }}
  61. # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
  62. extensions: ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, redis, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
  63. coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
  64. env:
  65. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  66. - name: Set up Nextcloud
  67. run: |
  68. composer install
  69. mkdir data
  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,'host' => 'localhost','user' => 'test','password' => 'test', 'root' => '${{ env.FTP_ROOT }}'];" > apps/files_external/tests/config.ftp.php
  73. - name: smoketest ftp
  74. run: |
  75. php -r 'var_dump(file_put_contents("ftp://test:test@localhost${{ env.FTP_ROOT }}/ftp.txt", "asd"));'
  76. php -r 'var_dump(file_get_contents("ftp://test:test@localhost${{ env.FTP_ROOT }}/ftp.txt"));'
  77. php -r 'var_dump(mkdir("ftp://test:test@localhost${{ env.FTP_ROOT }}/asdads"));'
  78. ls -l /tmp/ftp
  79. [ -f /tmp/ftp/ftp.txt ]
  80. - name: PHPUnit
  81. run: composer run test:files_external -- \
  82. apps/files_external/tests/Storage/FtpTest.php \
  83. ${{ matrix.coverage && ' --coverage-clover ./clover.xml' || '' }}
  84. - name: Upload code coverage
  85. if: ${{ !cancelled() && matrix.coverage }}
  86. uses: codecov/codecov-action@v4
  87. with:
  88. files: ./clover.xml
  89. flags: phpunit-files-external-ftp
  90. - name: ftpd logs
  91. if: always()
  92. run: |
  93. docker logs ftp
  94. ftp-summary:
  95. runs-on: ubuntu-latest-low
  96. needs: [changes, files-external-ftp]
  97. if: always()
  98. steps:
  99. - name: Summary status
  100. run: if ${{ needs.changes.outputs.src != 'false' && needs.files-external-ftp.result != 'success' }}; then exit 1; fi