diff options
author | sualko <klaus@jsxc.org> | 2021-05-16 19:35:01 +0300 |
---|---|---|
committer | sualko <klaus@jsxc.org> | 2021-05-16 19:35:01 +0300 |
commit | b2516102bff22291b1426dcc3b0e9721c1fda67c (patch) | |
tree | 03a3952287dcb1a7657bbe8b91a9d09c72ea9430 | |
parent | 2750aefefe3ff3fd7b5720534ab0187340de976c (diff) |
ci: move to github actions
-rw-r--r-- | .github/workflows/lint.yml | 37 | ||||
-rw-r--r-- | .github/workflows/php-test.yml | 62 | ||||
-rw-r--r-- | .travis.yml | 52 | ||||
-rw-r--r-- | composer.json | 6 |
4 files changed, 105 insertions, 52 deletions
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..dc22b8f --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,37 @@ +name: Lint +on: + pull_request: + push: + branches: + - main + +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 diff --git a/.github/workflows/php-test.yml b/.github/workflows/php-test.yml new file mode 100644 index 0000000..0cb6065 --- /dev/null +++ b/.github/workflows/php-test.yml @@ -0,0 +1,62 @@ + +name: PHP Tests + +on: + pull_request: + push: + branches: + - main + +jobs: + unit-tests: + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: ['7.3', '7.4'] + nextcloud-versions: ['stable20', 'stable21'] + include: + - php-versions: '7.2' + nextcloud-versions: 'stable20' + - php-versions: '8.0' + nextcloud-versions: 'stable20' + 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/ojsxc + - name: Remove OCP + working-directory: nextcloud/apps/ojsxc + run: composer remove --no-update --dev christophwurst/nextcloud + - 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/ojsxc + run: composer update phpunit/phpunit -W + - name: Install dependencies + working-directory: nextcloud/apps/ojsxc + run: composer install + - name: Enable app + run: php -f nextcloud/occ app:enable ojsxc + - name: Run unit tests + working-directory: nextcloud/apps/ojsxc + run: composer run test + - name: Run integration tests + working-directory: nextcloud/apps/ojsxc + run: composer run test:integration diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 79dac77..0000000 --- a/.travis.yml +++ /dev/null @@ -1,52 +0,0 @@ -dist: bionic -sudo: false - -language: php -php: - - 7.2 - - 7.3 - - 7.4 - -services: - - mysql - - postgresql - -env: - global: - - BRANCH=stable19 - - DB=mysql - - LINT=false - -matrix: - include: - - php: 7.2 - env: DB=sqlite - - php: 7.3 - env: DB=sqlite - - php: 7.4 - env: DB=sqlite LINT=true - - env: DB=pgsql - - env: BRANCH=stable17 - - env: BRANCH=stable18 - - php: 7.4 - env: BRANCH=master - allow_failures: - - php: 7.4 - env: BRANCH=master - - -install: - - which mysql && until mysql -u root -e "show status" &>/dev/null; do sleep 1; done - - ./tests/travis/install-nc.sh - -# Note the install script should make sure we are in the apps/ojsxc directory -script: - - composer install - - ./vendor/bin/phpunit -c phpunit.xml --coverage-clover=unit-coverage.xml - - ./vendor/bin/phpunit -c phpunit.integration.xml --coverage-clover=integration-coverage.xml - - cat ../../data/nextcloud.log - - if [[ "$LINT" = 'true' ]]; then vendor/bin/php-cs-fixer fix --dry-run; fi - - rm -rf vendor/ && ../../occ app:check-code ojsxc || true - -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/composer.json b/composer.json index 76601dc..166316c 100644 --- a/composer.json +++ b/composer.json @@ -6,5 +6,11 @@ "require-dev": { "phpunit/phpunit": "^8", "friendsofphp/php-cs-fixer": "^2.14" + }, + "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 \"{}\" \\;" } } |