|
| 1 | + |
| 2 | +# SPDX-FileCopyrightText: Nextcloud contributors |
| 3 | +# SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | +name: Integration Test |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + - stable* |
| 12 | + tags: |
| 13 | + - "v*" |
| 14 | + - "test*" |
| 15 | + |
| 16 | +env: |
| 17 | + APP_NAME: secrets |
| 18 | + |
| 19 | +jobs: |
| 20 | + integration-test-cli: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + php-versions: ['8.3'] |
| 26 | + server-versions: ['v30.0.4', 'v31.0.0beta2'] |
| 27 | + |
| 28 | + services: |
| 29 | + mysql: |
| 30 | + image: mariadb:10.5 |
| 31 | + ports: |
| 32 | + - 4444:3306/tcp |
| 33 | + env: |
| 34 | + MYSQL_ROOT_PASSWORD: rootpassword |
| 35 | + options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5 |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Set app env |
| 39 | + run: | |
| 40 | + # Split and keep last |
| 41 | + echo "APP_NAME=secrets" >> $GITHUB_ENV |
| 42 | +
|
| 43 | + - name: Enable ONLY_FULL_GROUP_BY MySQL option |
| 44 | + run: | |
| 45 | + echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword |
| 46 | + echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword |
| 47 | +
|
| 48 | + - name: Checkout server |
| 49 | + uses: actions/checkout@v3 |
| 50 | + with: |
| 51 | + submodules: true |
| 52 | + repository: nextcloud/server |
| 53 | + ref: ${{ matrix.server-versions }} |
| 54 | + |
| 55 | + - name: Checkout app |
| 56 | + uses: actions/checkout@v3 |
| 57 | + with: |
| 58 | + path: apps/${{ env.APP_NAME }} |
| 59 | + |
| 60 | + - name: Set up php ${{ matrix.php-versions }} |
| 61 | + uses: shivammathur/setup-php@v2 |
| 62 | + with: |
| 63 | + php-version: ${{ matrix.php-versions }} |
| 64 | + tools: phpunit |
| 65 | + extensions: mbstring, iconv, fileinfo, intl, mysql, pdo_mysql |
| 66 | + coverage: none |
| 67 | + |
| 68 | + - name: Read package.json node and npm engines version |
| 69 | + uses: skjnldsv/read-package-engines-version-actions@v1.2 |
| 70 | + id: versions |
| 71 | + with: |
| 72 | + fallbackNode: '^12' |
| 73 | + fallbackNpm: '^6' |
| 74 | + |
| 75 | + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} |
| 76 | + uses: actions/setup-node@v3 |
| 77 | + with: |
| 78 | + node-version: ${{ steps.versions.outputs.nodeVersion }} |
| 79 | + |
| 80 | + - name: Set up bun |
| 81 | + uses: oven-sh/setup-bun@v1 |
| 82 | + |
| 83 | + - name: Build cli |
| 84 | + working-directory: apps/${{ env.APP_NAME }}/cli |
| 85 | + run: | |
| 86 | + cp ../src/crypto.js ./crypto.import.js |
| 87 | + bun install --dev |
| 88 | + bun build --compile ./cli.ts --outfile nc-secrets |
| 89 | +
|
| 90 | + - name: Set up Nextcloud |
| 91 | + env: |
| 92 | + DB_PORT: 4444 |
| 93 | + run: | |
| 94 | + mkdir data |
| 95 | + ./occ maintenance:install --verbose --database=mysql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password |
| 96 | + ./occ --version |
| 97 | + ./occ app:enable ${{ env.APP_NAME }} |
| 98 | +
|
| 99 | + - name: Run Nextcloud |
| 100 | + run: php -S localhost:8080 > ./php.log 2>&1 & |
| 101 | + |
| 102 | + - name: '[TEST] create and retrieve secret' |
| 103 | + working-directory: apps/${{ env.APP_NAME }}/cli |
| 104 | + id: integration_test |
| 105 | + shell: /usr/bin/bash -ie {0} |
| 106 | + run: | |
| 107 | + set -ex |
| 108 | + echo 'INTEGRATION_TEST' > ./secret_data |
| 109 | + result="$(./nc-secrets -k create -t 'integration-test' http://localhost:8080 admin ./secret_data <<<"password")" |
| 110 | + echo "${result}" |
| 111 | +
|
| 112 | + - name: Report |
| 113 | + if: always() |
| 114 | + run: | |
| 115 | + tail ./php.log |
| 116 | + |
| 117 | + if ${{ steps.integration_test.result != 'success' }}; then exit 1; fi |
| 118 | +
|
| 119 | + summary: |
| 120 | + runs-on: ubuntu-latest |
| 121 | + needs: integration-test-cli |
| 122 | + if: always() |
| 123 | + name: integration-test-summary |
| 124 | + |
| 125 | + steps: |
| 126 | + - name: 'Report' |
| 127 | + run: if ${{ needs.integration-test-cli.result != 'success' }}; then exit 1; fi |
0 commit comments