files-external-sftp.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. # SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  2. # SPDX-License-Identifier: MIT
  3. name: PHPUnit files_external sFTP
  4. on:
  5. pull_request:
  6. schedule:
  7. - cron: "5 2 * * *"
  8. concurrency:
  9. group: files-external-sftp-${{ 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-sftp:
  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. sftpd: ['openssh']
  41. include:
  42. - php-versions: '8.1'
  43. coverage: ${{ github.event_name != 'pull_request' }}
  44. name: php${{ matrix.php-versions }}-${{ matrix.sftpd }}
  45. steps:
  46. - name: Checkout server
  47. uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
  48. with:
  49. submodules: true
  50. - name: Set up sftpd
  51. run: |
  52. sudo mkdir /tmp/sftp
  53. sudo chown -R 0777 /tmp/sftp
  54. if [[ '${{ matrix.sftpd }}' == 'openssh' ]]; then docker run -p 2222:22 --name sftp -d -v /tmp/sftp:/home/test atmoz/sftp 'test:test:::data'; fi
  55. - name: Set up php ${{ matrix.php-versions }}
  56. uses: shivammathur/setup-php@c5fc0d8281aba02c7fda07d3a70cc5371548067d #v2.25.2
  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: 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. env:
  63. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  64. - name: Set up Nextcloud
  65. run: |
  66. composer install
  67. mkdir data
  68. ./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
  69. ./occ app:enable --force files_external
  70. echo "<?php return ['run' => true, 'host' => 'localhost:2222','user' => 'test','password' => 'test', 'root' => 'data'];" > apps/files_external/tests/config.sftp.php
  71. - name: PHPUnit
  72. run: composer run test:files_external -- \
  73. apps/files_external/tests/Storage/SftpTest.php \
  74. apps/files_external/tests/Storage/SFTP_KeyTest.php \
  75. ${{ matrix.coverage && ' --coverage-clover ./clover.xml' || '' }}
  76. - name: Upload code coverage
  77. if: ${{ !cancelled() && matrix.coverage }}
  78. uses: codecov/codecov-action@v4.1.1
  79. with:
  80. files: ./clover.xml
  81. flags: phpunit-files-external-sftp
  82. - name: sftpd logs
  83. if: always()
  84. run: |
  85. ls -l /tmp/sftp
  86. docker logs sftp
  87. sftp-summary:
  88. runs-on: ubuntu-latest-low
  89. needs: [changes, files-external-sftp]
  90. if: always()
  91. steps:
  92. - name: Summary status
  93. run: if ${{ needs.changes.outputs.src != 'false' && needs.files-external-sftp.result != 'success' }}; then exit 1; fi