diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..7842e081 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,22 @@ +name: Build +on: pull_request + +jobs: + build-js: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [ 13, 14, 15 ] + name: Build front-end with Node ${{ matrix.node-version }} + steps: + - uses: actions/checkout@master + - name: Set up Node + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: npm install + run: npm install + - name: run tests + run: npm run build + env: + CI: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4bf052a1..754db795 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,8 +13,8 @@ jobs: strategy: matrix: - php-versions: ['7.3', '7.4'] - + php-versions: [ '7.3', '7.4', '8.0' ] + name: php${{ matrix.php-versions }} steps: - uses: actions/checkout@v2 @@ -33,7 +33,7 @@ jobs: strategy: matrix: - node-versions: [12.x] + node-versions: [ 14.x ] name: node${{ matrix.node-versions }} steps: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..e27782e7 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,65 @@ +name: Test +on: pull_request + +jobs: + smoke-test: + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: [7.3, 7.4, 8.0] + nextcloud-versions: ['master'] + db: ['sqlite', 'mysql', 'pgsql'] + name: Nextcloud ${{ matrix.nextcloud-versions }} and php${{ matrix.php-versions }} smoke test + services: + mysql-service: + image: mariadb:10 + env: + MYSQL_ROOT_PASSWORD: my-secret-pw + MYSQL_DATABASE: nextcloud + MYSQL_USER: nextcloud + MYSQL_PASSWORD: nextcloud + ports: + - 3306:3306 + options: >- + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=5s + --health-retries=3 + postgres-service: + image: postgres + env: + POSTGRES_USER: nextcloud + POSTGRES_DB: nextcloud + POSTGRES_PASSWORD: nextcloud + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: + - name: Set up php${{ matrix.php-versions }} + uses: shivammathur/setup-php@master + with: + php-version: ${{ matrix.php-versions }} + tools: composer:v1 + extensions: ctype,curl,dom,gd,iconv,intl,json,mbstring,openssl,posix,sqlite,xml,zip + coverage: xdebug + - name: Checkout Nextcloud + run: git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b ${{ matrix.nextcloud-versions }} nextcloud + - name: Install Nextcloud + run: php -f nextcloud/occ maintenance:install --database-host 127.0.0.1 --database-name nextcloud --database-user nextcloud --database-pass nextcloud --admin-user admin --admin-pass admin --database ${{ matrix.db }} + - name: Checkout app + uses: actions/checkout@master + with: + path: nextcloud/apps/recommendations + - name: Install dependencies + working-directory: nextcloud/apps/recommendations + run: composer install + - name: Install app + run: php -f nextcloud/occ app:enable recommendations + - name: Install app + run: php -f nextcloud/occ app:enable recommendations + - name: Run a smoke test + run: php -f nextcloud/occ files:recommendations:recommend admin diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0c8c38eb..00000000 --- a/.travis.yml +++ /dev/null @@ -1,65 +0,0 @@ -sudo: required -dist: trusty -language: php -php: - - 7.3 - - 7.4snapshot - -addons: - apt: - packages: - - mysql-server-5.6 - - mysql-client-core-5.6 - - mysql-client-5.6 - -services: - - postgresql - -env: - global: - - TEST_JS=FALSE - - CORE_BRANCH=master - matrix: - - DB=sqlite - -matrix: - include: - - php: 7.3 - env: "DB=sqlite TEST_JS=TRUE" - fast_finish: true - -branches: - only: - - master - - "/^stable\\d+(\\.\\d+)?+(\\.\\d+)?$/" - - /^v\d++(\.\d+)?+(\.\d+)?+(\.\d+)?$/ - -cache: - directories: - - "$HOME/.composer/cache/files" - - "$HOME/.npm" - -before_install: - - sh -c "if [ '$TEST_JS' = 'TRUE' ]; then npm install; fi" - - - cd .. - - git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b $CORE_BRANCH core - - mv recommendations core/apps/ - -before_script: - # Set up core - - php -f core/occ maintenance:install --database-name nc_autotest --database-user nc_autotest --admin-user admin --admin-pass admin --database $DB --database-pass='' - - # Set up app - - php -f core/occ app:enable recommendations - - cd core/apps/recommendations - -script: - # Check PHP syntax errors - - composer run lint - - # Run server's app code checker - - php ../../occ app:check-code --skip-validate-info recommendations - - # Build JS - - sh -c "if [ '$TEST_JS' = 'TRUE' ]; then npm run build; fi" diff --git a/lib/Command/GetRecommendations.php b/lib/Command/GetRecommendations.php index 7e7f583f..0c5c0020 100644 --- a/lib/Command/GetRecommendations.php +++ b/lib/Command/GetRecommendations.php @@ -72,7 +72,7 @@ public function execute(InputInterface $input, OutputInterface $output) { return 1; } - if ($input->hasArgument('max')) { + if ($input->getArgument('max')) { $recommendations = $this->recommendationService->getRecommendations($user, (int) $input->getArgument('max')); } else { $recommendations = $this->recommendationService->getRecommendations($user);