From 92b85ba6ff10127faeae8d2a9e3df5f01eda6926 Mon Sep 17 00:00:00 2001 From: sualko Date: Sat, 13 Feb 2021 16:47:20 +0100 Subject: [PATCH] ci: move to github actions --- .github/workflows/lint.yml | 33 +++++++++++++ .github/workflows/php-test.yml | 57 ++++++++++++++++++++++ .github/workflows/static.yml | 24 ++++++++++ .travis.yml | 87 ---------------------------------- composer.json | 1 + 5 files changed, 115 insertions(+), 87 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/php-test.yml create mode 100644 .github/workflows/static.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..ce3478e --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,33 @@ +name: Lint +on: pull_request + +jobs: + xml-linters: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@master + - name: Download schema + run: wget https://apps.nextcloud.com/schema/apps/info.xsd + - name: Lint info.xml + uses: ChristophWurst/xmllint-action@v1 + with: + xml-file: ./appinfo/info.xml + xml-schema-file: ./info.xsd + + php-linters: + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: [7.2, 7.3, 7.4, 8.0] + name: php${{ matrix.php-versions }} lint + steps: + - name: Checkout + uses: actions/checkout@master + - name: Set up php${{ matrix.php-versions }} + uses: shivammathur/setup-php@master + with: + php-version: ${{ matrix.php-versions }} + coverage: none + - name: Lint + run: composer run lint \ No newline at end of file diff --git a/.github/workflows/php-test.yml b/.github/workflows/php-test.yml new file mode 100644 index 0000000..b323c99 --- /dev/null +++ b/.github/workflows/php-test.yml @@ -0,0 +1,57 @@ +name: PHP Tests + +on: + pull_request: + push: + branches: + - master + +jobs: + unit-tests: + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: ['7.3', '7.4'] + nextcloud-versions: ['stable19', 'stable20', 'stable21', 'master'] + include: + - php-versions: '7.2' + nextcloud-versions: 'stable19' + - php-versions: '7.2' + nextcloud-versions: 'stable20' + - php-versions: '8.0' + nextcloud-versions: 'stable21' + - php-versions: '8.0' + nextcloud-versions: 'master' + name: php${{ matrix.php-versions }} on ${{ matrix.nextcloud-versions }} unit tests + env: + CI: true + XDEBUG_MODE: coverage + steps: + - name: Set up php${{ matrix.php-versions }} + uses: shivammathur/setup-php@master + with: + php-version: ${{ matrix.php-versions }} + extensions: ctype, curl, dom, gd, gmp, iconv, intl, json, mbstring, openssl, pdo_sqlite, 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-name oc_autotest --database-user oc_autotest --admin-user admin --admin-pass admin --database sqlite --database-pass='' + - name: Checkout the app + uses: actions/checkout@master + with: + path: nextcloud/apps/bbb + - name: Fix php-parser on stable20 incompatibility with phpunit 9.3+ + if: ${{ matrix.nextcloud-versions == 'stable20' }} + working-directory: nextcloud/3rdparty + run: composer require nikic/php-parser:4.10 + - name: Downgrade phpunit for php7.2 + if: ${{ matrix.php-versions == '7.2' }} + working-directory: nextcloud/apps/bbb + run: composer update christophwurst/nextcloud_testing -W + - name: Install dependencies + working-directory: nextcloud/apps/bbb + run: composer install + - name: Run tests + working-directory: nextcloud/apps/bbb + run: composer run test \ No newline at end of file diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml new file mode 100644 index 0000000..d73511c --- /dev/null +++ b/.github/workflows/static.yml @@ -0,0 +1,24 @@ +name: Static analysis +on: [push] + +jobs: + static-psalm-analysis: + runs-on: ubuntu-latest + strategy: + matrix: + ocp-version: [ 'dev-master', 'v20.0.0' ] + name: Nextcloud ${{ matrix.ocp-version }} + steps: + - name: Checkout + uses: actions/checkout@master + - name: Set up php + uses: shivammathur/setup-php@master + with: + php-version: 7.4 + coverage: none + - name: Install dependencies + run: composer i + - name: Install dependencies + run: composer require --dev christophwurst/nextcloud:${{ matrix.ocp-version }} + - name: Run coding standards check + run: composer run psalm \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bb48007..0000000 --- a/.travis.yml +++ /dev/null @@ -1,87 +0,0 @@ -dist: bionic -language: php -php: - - 7.2 - - 7.3 - - 7.4 - -services: - - mysql - - postgresql - -env: - global: - - CORE_BRANCH=stable20 - - DB=mysql - - LINT=false - - BUILD=false - -matrix: - include: - - php: 7.3 - env: DB=sqlite - - php: 7.4 - env: DB=sqlite - - php: 7.3 - env: DB=pgsql - - php: 7.4 - env: DB=pgsql - - php: 7.3 - env: LINT=true - env: BUILD=true - - php: 7.2 - env: DB=sqlite CORE_BRANCH=stable19 - - php: 7.3 - env: CORE_BRANCH=stable18 - - php: 7.4 - env: CORE_BRANCH=master - - php: nightly - env: DB=sqlite - fast_finish: true - allow_failures: - - php: nightly - - php: 7.4 - env: "CORE_BRANCH=master" - -cache: - yarn: true - directories: - - "$HOME/core/apps/bbb/node_modules" - - "$HOME/.composer/cache/files" - - "$HOME/.npm" - -#before_script: phpenv global 7.3 - -before_install: - - php --info - - # Set up DB - - if [[ "$DB" == 'pgsql' ]]; then createuser -U travis -s oc_autotest; fi - - if [[ "$DB" == 'mysql' ]]; then mysql -u root -e 'create database oc_autotest;'; fi - - if [[ "$DB" == 'mysql' ]]; then mysql -u root -e "CREATE USER 'oc_autotest'@'localhost' IDENTIFIED BY '';"; fi - - if [[ "$DB" == 'mysql' ]]; then mysql -u root -e "GRANT ALL ON oc_autotest.* TO 'oc_autotest'@'localhost';"; fi - - - composer self-update - - yarn install - - yarn composer:install:dev - - cd .. - - git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b $CORE_BRANCH core - - mv cloud_bbb core/apps/bbb - -before_script: - # Set up core - - php -f core/occ maintenance:install --database-name oc_autotest --database-user oc_autotest --admin-user admin --admin-pass admin --database $DB --database-pass='' - - # Set up app - - php -f core/occ app:enable bbb - # Enable app twice to check occ errors of registered commands - - php -f core/occ app:enable bbb - - - cd core/apps/bbb - -script: - - php -v - - yarn test - - if [[ "$LINT" = 'true' ]]; then yarn lint; fi - - if [[ "$LINT" = 'true' ]]; then yarn commitlint-travis; fi - - if [[ "$BUILD" = 'true' ]]; then yarn build; fi diff --git a/composer.json b/composer.json index 75c5174..b23c5c0 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,7 @@ "classmap-authoritative": true }, "scripts": { + "test": "phpunit --configuration phpunit.xml --fail-on-warning", "cs:check": "php-cs-fixer fix --dry-run --diff", "cs:fix": "php-cs-fixer fix", "lint": "find . -name \\*.php -not -path './vendor/*' -exec php -l \"{}\" \\;",