From d97e4aaefff08808ae5838eee8597b0529f7b679 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 24 Sep 2020 13:27:50 +0200 Subject: [PATCH] Add CI and dependatbot configs Signed-off-by: Roeland Jago Douma --- .eslintrc.js | 5 + .github/dependabot.yml | 24 ++ .github/workflows/app-code-check.yml | 55 +++++ .../workflows/dependabot-approve-merge.yml | 19 ++ .github/workflows/lint.yml | 97 ++++++++ .github/workflows/node.yml | 34 +++ .github/workflows/phpunit.yml | 215 ++++++++++++++++++ .php_cs.dist | 17 ++ composer.json | 22 ++ 9 files changed, 488 insertions(+) create mode 100644 .eslintrc.js create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/app-code-check.yml create mode 100644 .github/workflows/dependabot-approve-merge.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/node.yml create mode 100644 .github/workflows/phpunit.yml create mode 100644 .php_cs.dist create mode 100644 composer.json diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..35cc688 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,5 @@ +module.exports = { + extends: [ + '@nextcloud', + ] +} diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..1650424 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,24 @@ +version: 2 +updates: +- package-ecosystem: composer + directory: "/" + schedule: + interval: weekly + day: saturday + time: "03:00" + timezone: Europe/Paris + open-pull-requests-limit: 10 + labels: + - 3. to review + - dependencies +- package-ecosystem: npm + directory: "/" + schedule: + interval: weekly + day: saturday + time: "03:00" + timezone: Europe/Paris + open-pull-requests-limit: 10 + labels: + - 3. to review + - dependencies diff --git a/.github/workflows/app-code-check.yml b/.github/workflows/app-code-check.yml new file mode 100644 index 0000000..c55777c --- /dev/null +++ b/.github/workflows/app-code-check.yml @@ -0,0 +1,55 @@ +name: PHP AppCode Check + +on: + pull_request: + push: + branches: + - master + - stable* + +env: + APP_NAME: notestutorial + +jobs: + unit-tests: + runs-on: ubuntu-latest + + strategy: + matrix: + php-versions: ['7.4'] + server-versions: ['master'] + + name: AppCode check php${{ matrix.php-versions }}-${{ matrix.server-versions }} + steps: + - name: Checkout server + uses: actions/checkout@v2 + with: + repository: nextcloud/server + ref: ${{ matrix.server-versions }} + + - name: Checkout submodules + shell: bash + run: | + auth_header="$(git config --local --get http.https://github.com/.extraheader)" + git submodule sync --recursive + git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 + + - name: Checkout app + uses: actions/checkout@v2 + with: + path: apps/${{ env.APP_NAME }} + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@v1 + with: + php-version: ${{ matrix.php-versions }} + tools: phpunit + extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite + + - name: Checkout app + uses: actions/checkout@v2 + with: + path: apps/${{ env.APP_NAME }} + + - name: App code check + run: php occ app:check-code ${{ env.APP_NAME }} diff --git a/.github/workflows/dependabot-approve-merge.yml b/.github/workflows/dependabot-approve-merge.yml new file mode 100644 index 0000000..8830103 --- /dev/null +++ b/.github/workflows/dependabot-approve-merge.yml @@ -0,0 +1,19 @@ +name: Dependabot +on: pull_request + +jobs: + auto-merge: + runs-on: ubuntu-latest + steps: + # Default github action approve + - uses: hmarr/auto-approve-action@v2.0.0 + if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]' + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + # Nextcloud bot approve and merge request + - uses: ahmadnassri/action-dependabot-auto-merge@v1 + if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]' + with: + target: minor + github-token: ${{ secrets.DEPENDABOT_AUTOMERGE_TOKEN }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..0290f72 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,97 @@ +name: Lint + +on: + pull_request: + push: + branches: + - master + - stable* + +jobs: + php: + runs-on: ubuntu-latest + + strategy: + matrix: + php-versions: ['7.2', '7.3', '7.4'] + + name: php${{ matrix.php-versions }} + steps: + - uses: actions/checkout@v2 + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@v1 + with: + php-version: ${{ matrix.php-versions }} + coverage: none + + - name: Lint + run: composer run lint + + php-cs-fixer: + runs-on: ubuntu-latest + + strategy: + matrix: + php-versions: ['7.4'] + + name: cs php${{ matrix.php-versions }} + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up php + uses: shivammathur/setup-php@master + with: + php-version: ${{ matrix.php-versions }} + coverage: none + + - name: Install dependencies + run: composer i + + - name: Run coding standards check + run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 ) + + node: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x] + + name: eslint node${{ matrix.node-version }} + steps: + - uses: actions/checkout@v2 + + - name: Set up node ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + run: npm ci + + - name: Lint + run: npm run lint + + stylelint: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x] + + name: stylelint node${{ matrix.node-version }} + steps: + - uses: actions/checkout@v2 + + - name: Set up node ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + run: npm ci + + - name: Lint + run: npm run stylelint diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml new file mode 100644 index 0000000..a971a7e --- /dev/null +++ b/.github/workflows/node.yml @@ -0,0 +1,34 @@ +name: Node + +on: + pull_request: + push: + branches: + - master + - stable* + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x] + + name: node${{ matrix.node-version }} + steps: + - uses: actions/checkout@v2 + + - name: Set up node ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies & build + run: | + npm ci + npm run build --if-present + + - name: Check webpack build changes + run: | + bash -c "[[ ! \"`git status --porcelain `\" ]] || ( echo 'Uncommited changes in webpack build' && git status && exit 1 )" diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml new file mode 100644 index 0000000..3a49118 --- /dev/null +++ b/.github/workflows/phpunit.yml @@ -0,0 +1,215 @@ +name: PHPUnit + +on: + pull_request: + push: + branches: + - master + - stable* + +env: + APP_NAME: flow_webhooks + +jobs: + php: + runs-on: ubuntu-latest + + strategy: + # do not stop on another job's failure + fail-fast: false + matrix: + php-versions: ['7.4'] + databases: ['sqlite'] + server-versions: ['master'] + + name: php${{ matrix.php-versions }}-${{ matrix.databases }}-${{ matrix.server-versions }} + + steps: + - name: Checkout server + uses: actions/checkout@v2 + with: + repository: nextcloud/server + ref: ${{ matrix.server-versions }} + + - name: Checkout submodules + shell: bash + run: | + auth_header="$(git config --local --get http.https://github.com/.extraheader)" + git submodule sync --recursive + git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 + + - name: Checkout app + uses: actions/checkout@v2 + with: + path: apps/${{ env.APP_NAME }} + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@v1 + with: + php-version: ${{ matrix.php-versions }} + tools: phpunit + extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite + coverage: none + + - name: Set up PHPUnit + working-directory: apps/${{ env.APP_NAME }} + run: composer i + + - name: Set up Nextcloud + env: + DB_PORT: 4444 + run: | + mkdir data + ./occ maintenance:install --verbose --database=${{ matrix.databases }} --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 + ./occ app:enable --force ${{ env.APP_NAME }} + php -S localhost:8080 & + + - name: PHPUnit + working-directory: apps/${{ env.APP_NAME }} + run: ./vendor/phpunit/phpunit/phpunit -c phpunit.xml + + - name: PHPUnit integration + working-directory: apps/${{ env.APP_NAME }} + run: ./vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml + + mysql: + runs-on: ubuntu-latest + + strategy: + # do not stop on another job's failure + fail-fast: false + matrix: + php-versions: ['7.2', '7.3', '7.4'] + databases: ['mysql'] + server-versions: ['master'] + + name: php${{ matrix.php-versions }}-${{ matrix.databases }}-${{ matrix.server-versions }} + + services: + mysql: + image: mariadb + ports: + - 4444:3306/tcp + env: + MYSQL_ROOT_PASSWORD: rootpassword + options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5 + + steps: + - name: Checkout server + uses: actions/checkout@v2 + with: + repository: nextcloud/server + ref: ${{ matrix.server-versions }} + + - name: Checkout submodules + shell: bash + run: | + auth_header="$(git config --local --get http.https://github.com/.extraheader)" + git submodule sync --recursive + git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 + + - name: Checkout app + uses: actions/checkout@v2 + with: + path: apps/${{ env.APP_NAME }} + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@v1 + with: + php-version: ${{ matrix.php-versions }} + tools: phpunit + extensions: mbstring, iconv, fileinfo, intl, mysql, pdo_mysql + coverage: none + + - name: Set up PHPUnit + working-directory: apps/${{ env.APP_NAME }} + run: composer i + + - name: Set up Nextcloud + env: + DB_PORT: 4444 + run: | + mkdir data + ./occ maintenance:install --verbose --database=${{ matrix.databases }} --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 + ./occ app:enable --force ${{ env.APP_NAME }} + php -S localhost:8080 & + + - name: PHPUnit + working-directory: apps/${{ env.APP_NAME }} + run: ./vendor/phpunit/phpunit/phpunit -c phpunit.xml + + - name: PHPUnit integration + working-directory: apps/${{ env.APP_NAME }} + run: ./vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml + + pgsql: + runs-on: ubuntu-latest + + strategy: + # do not stop on another job's failure + fail-fast: false + matrix: + php-versions: ['7.4'] + databases: ['pgsql'] + server-versions: ['master'] + + name: php${{ matrix.php-versions }}-${{ matrix.databases }}-${{ matrix.server-versions }} + + services: + postgres: + image: postgres + ports: + - 4444:5432/tcp + env: + POSTGRES_USER: root + POSTGRES_PASSWORD: rootpassword + POSTGRES_DB: nextcloud + options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5 + + steps: + - name: Checkout server + uses: actions/checkout@v2 + with: + repository: nextcloud/server + ref: ${{ matrix.server-versions }} + + - name: Checkout submodules + shell: bash + run: | + auth_header="$(git config --local --get http.https://github.com/.extraheader)" + git submodule sync --recursive + git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 + + - name: Checkout app + uses: actions/checkout@v2 + with: + path: apps/${{ env.APP_NAME }} + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@v1 + with: + php-version: ${{ matrix.php-versions }} + tools: phpunit + extensions: mbstring, iconv, fileinfo, intl, pgsql, pdo_pgsql + coverage: none + + - name: Set up PHPUnit + working-directory: apps/${{ env.APP_NAME }} + run: composer i + + - name: Set up Nextcloud + env: + DB_PORT: 4444 + run: | + mkdir data + ./occ maintenance:install --verbose --database=${{ matrix.databases }} --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 + ./occ app:enable --force ${{ env.APP_NAME }} + php -S localhost:8080 & + + - name: PHPUnit + working-directory: apps/${{ env.APP_NAME }} + run: ./vendor/phpunit/phpunit/phpunit -c phpunit.xml + + - name: PHPUnit integration + working-directory: apps/${{ env.APP_NAME }} + run: ./vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 0000000..8a0cb43 --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,17 @@ +getFinder() + ->notPath('build') + ->notPath('l10n') + ->notPath('src') + ->notPath('vendor') + ->in(__DIR__); +return $config; diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..f2dd1e0 --- /dev/null +++ b/composer.json @@ -0,0 +1,22 @@ +{ + "name": "nextcloud/flow_webhooks", + "type": "project", + "license": "AGPL", + "require": {}, + "require-dev": { + "phpunit/phpunit": "^7.5", + "nextcloud/coding-standard": "^0.3.0" + }, + "config": { + "optimize-autoloader": true, + "classmap-authoritative": true, + "platform": { + "php": "7.3" + } + }, + "scripts": { + "lint": "find . -name \\*.php -not -path './vendor/*' -not -path './build/*' -print0 | xargs -0 -n1 php -l", + "cs:check": "php-cs-fixer fix --dry-run --diff", + "cs:fix": "php-cs-fixer fix" + } +}