1
0

files-external-ftp.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. # SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  2. # SPDX-License-Identifier: MIT
  3. name: PHPUnit files_external FTP
  4. on:
  5. pull_request:
  6. schedule:
  7. - cron: "5 2 * * *"
  8. concurrency:
  9. group: files-external-ftp-${{ github.head_ref || github.run_id }}
  10. cancel-in-progress: true
  11. jobs:
  12. changes:
  13. runs-on: ubuntu-latest-low
  14. outputs:
  15. src: ${{ steps.changes.outputs.src}}
  16. steps:
  17. - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
  18. id: changes
  19. continue-on-error: true
  20. with:
  21. filters: |
  22. src:
  23. - '.github/workflows/**'
  24. - '3rdparty/**'
  25. - 'apps/files_external/**'
  26. - 'vendor/**'
  27. - 'vendor-bin/**'
  28. - 'composer.json'
  29. - 'composer.lock'
  30. - '**.php'
  31. files-external-ftp:
  32. runs-on: ubuntu-latest
  33. needs: changes
  34. if: ${{ github.repository_owner != 'nextcloud-gmbh' && needs.changes.outputs.src != 'false' }}
  35. strategy:
  36. # do not stop on another job's failure
  37. fail-fast: false
  38. matrix:
  39. php-versions: ['8.1', '8.3']
  40. ftpd: ['proftpd', 'vsftpd', 'pure-ftpd']
  41. include:
  42. - php-versions: '8.1'
  43. coverage: ${{ github.event_name != 'pull_request' }}
  44. name: php${{ matrix.php-versions }}-${{ matrix.ftpd }}
  45. steps:
  46. - name: Checkout server
  47. uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
  48. with:
  49. submodules: true
  50. - name: Set up ftpd
  51. run: |
  52. sudo mkdir /tmp/ftp
  53. sudo chmod -R 0777 /tmp/ftp
  54. if [[ "${{ matrix.ftpd }}" == 'proftpd' ]]; then echo '$6$Q7V2n3q2GRVv5YeQ$/AhLu07H76Asojy7bxGXMY1caKLAbp5Vt82LOZYMkD/8uDzyMAEXwk0c1Bdz1DkBsk2Vh/9SF130mOPavRGMo.' > /tmp/secret.txt; fi
  55. if [[ "${{ matrix.ftpd }}" == 'proftpd' ]]; then echo 'FTP_ROOT=/home/test' > $GITHUB_ENV; fi
  56. 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
  57. 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
  58. 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
  59. - name: Set up php ${{ matrix.php-versions }}
  60. uses: shivammathur/setup-php@2e947f1f6932d141d076ca441d0e1e881775e95b #v2.31.0
  61. with:
  62. php-version: ${{ matrix.php-versions }}
  63. # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
  64. extensions: ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, redis, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
  65. coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
  66. env:
  67. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  68. - name: Set up Nextcloud
  69. run: |
  70. composer install
  71. mkdir data
  72. ./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
  73. ./occ app:enable --force files_external
  74. echo "<?php return ['run' => true,'host' => 'localhost','user' => 'test','password' => 'test', 'root' => '${{ env.FTP_ROOT }}'];" > apps/files_external/tests/config.ftp.php
  75. - name: smoketest ftp
  76. run: |
  77. php -r 'var_dump(file_put_contents("ftp://test:test@localhost${{ env.FTP_ROOT }}/ftp.txt", "asd"));'
  78. php -r 'var_dump(file_get_contents("ftp://test:test@localhost${{ env.FTP_ROOT }}/ftp.txt"));'
  79. php -r 'var_dump(mkdir("ftp://test:test@localhost${{ env.FTP_ROOT }}/asdads"));'
  80. ls -l /tmp/ftp
  81. [ -f /tmp/ftp/ftp.txt ]
  82. - name: PHPUnit
  83. run: composer run test:files_external -- \
  84. apps/files_external/tests/Storage/FtpTest.php \
  85. ${{ matrix.coverage && ' --coverage-clover ./clover.xml' || '' }}
  86. - name: Upload code coverage
  87. if: ${{ !cancelled() && matrix.coverage }}
  88. uses: codecov/codecov-action@v4.1.1
  89. with:
  90. files: ./clover.xml
  91. flags: phpunit-files-external-ftp
  92. - name: ftpd logs
  93. if: always()
  94. run: |
  95. docker logs ftp
  96. ftp-summary:
  97. runs-on: ubuntu-latest-low
  98. needs: [changes, files-external-ftp]
  99. if: always()
  100. steps:
  101. - name: Summary status
  102. run: if ${{ needs.changes.outputs.src != 'false' && needs.files-external-ftp.result != 'success' }}; then exit 1; fi