diff --git a/.github/workflows/command-compile.yml b/.github/workflows/command-compile.yml new file mode 100644 index 000000000..090324e98 --- /dev/null +++ b/.github/workflows/command-compile.yml @@ -0,0 +1,117 @@ +name: Compile Command +on: + issue_comment: + types: [created] + +jobs: + init: + runs-on: ubuntu-latest + + # On pull requests and if the comment starts with `/compile` + if: github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/compile') + + outputs: + git_path: ${{ steps.git-path.outputs.path }} + arg1: ${{ steps.command.outputs.arg1 }} + arg2: ${{ steps.command.outputs.arg2 }} + head_ref: ${{ steps.comment-branch.outputs.head_ref }} + + steps: + - name: Check actor permission + uses: skjnldsv/check-actor-permission@v2 + with: + require: write + + - name: Add reaction on start + uses: peter-evans/create-or-update-comment@v1 + with: + token: ${{ secrets.COMMAND_BOT_PAT }} + repository: ${{ github.event.repository.full_name }} + comment-id: ${{ github.event.comment.id }} + reaction-type: "+1" + + - name: Parse command + uses: skjnldsv/parse-command-comment@master + id: command + + # Init path depending on which command is run + - name: Init path + id: git-path + run: | + if ${{ startsWith(steps.command.outputs.arg1, '/') }}; then + echo "::set-output name=path::${{ github.workspace }}${{steps.command.outputs.arg1}}" + else + echo "::set-output name=path::${{ github.workspace }}${{steps.command.outputs.arg2}}" + fi + + - name: Init branch + uses: xt0rted/pull-request-comment-branch@v1 + id: comment-branch + + process: + runs-on: ubuntu-latest + needs: init + + steps: + - name: Checkout ${{ needs.init.outputs.head_ref }} + uses: actions/checkout@v2 + with: + token: ${{ secrets.COMMAND_BOT_PAT }} + fetch-depth: 0 + ref: ${{ needs.init.outputs.head_ref }} + + - name: Setup git + run: | + git config --local user.email "nextcloud-command@users.noreply.github.com" + git config --local user.name "nextcloud-command" + + - name: Read package.json node and npm engines version + uses: skjnldsv/read-package-engines-version-actions@v1 + id: package-engines-versions + with: + fallbackNode: '^12' + fallbackNpm: '^6' + + - name: Set up node ${{ steps.package-engines-versions.outputs.nodeVersion }} + uses: actions/setup-node@v2 + with: + node-version: ${{ steps.package-engines-versions.outputs.nodeVersion }} + cache: npm + + - name: Set up npm ${{ steps.package-engines-versions.outputs.npmVersion }} + run: npm i -g npm@"${{ steps.package-engines-versions.outputs.npmVersion }}" + + - name: Install dependencies & build + run: | + npm ci + npm run build --if-present + + - name: Commit and push default + if: ${{ needs.init.outputs.arg1 != 'fixup' && needs.init.outputs.arg1 != 'amend' }} + run: | + git add ${{ needs.init.outputs.git_path }} + git commit --signoff -m 'Compile assets' + git push origin ${{ needs.init.outputs.head_ref }} + + - name: Commit and push fixup + if: ${{ needs.init.outputs.arg1 == 'fixup' }} + run: | + git add ${{ needs.init.outputs.git_path }} + git commit --fixup=HEAD --signoff + git push origin ${{ needs.init.outputs.head_ref }} + + - name: Commit and push amend + if: ${{ needs.init.outputs.arg1 == 'amend' }} + run: | + git add ${{ needs.init.outputs.git_path }} + git commit --amend --no-edit --signoff + git push --force origin ${{ needs.init.outputs.head_ref }} + + - name: Add reaction on failure + uses: peter-evans/create-or-update-comment@v1 + if: failure() + with: + token: ${{ secrets.COMMAND_BOT_PAT }} + repository: ${{ github.event.repository.full_name }} + comment-id: ${{ github.event.comment.id }} + reaction-type: "-1" diff --git a/.github/workflows/command-rebase.yml b/.github/workflows/command-rebase.yml new file mode 100644 index 000000000..c497cb38e --- /dev/null +++ b/.github/workflows/command-rebase.yml @@ -0,0 +1,46 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization + +name: Rebase command + +on: + issue_comment: + types: created + +jobs: + rebase: + runs-on: ubuntu-latest + + # On pull requests and if the comment starts with `/rebase` + if: github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/rebase') + + steps: + - name: Add reaction on start + uses: peter-evans/create-or-update-comment@v1 + with: + token: ${{ secrets.COMMAND_BOT_PAT }} + repository: ${{ github.event.repository.full_name }} + comment-id: ${{ github.event.comment.id }} + reaction-type: "+1" + + - name: Checkout the latest code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + token: ${{ secrets.COMMAND_BOT_PAT }} + + - name: Automatic Rebase + uses: cirrus-actions/rebase@1.5 + env: + GITHUB_TOKEN: ${{ secrets.COMMAND_BOT_PAT }} + + - name: Add reaction on failure + uses: peter-evans/create-or-update-comment@v1 + if: failure() + with: + token: ${{ secrets.COMMAND_BOT_PAT }} + repository: ${{ github.event.repository.full_name }} + comment-id: ${{ github.event.comment.id }} + reaction-type: "-1" diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 5b2bb0ae8..d1e9e8c78 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -22,8 +22,6 @@ jobs: matrix: # run multiple copies of the current job in parallel containers: [1, 2, 3, 4, 5, 6, 7, 8] - node-version: ['12.x'] - php-versions: ['7.4'] name: runner ${{ matrix.containers }} @@ -36,10 +34,13 @@ jobs: cd cypress docker-compose up -d - - name: Set up node ${{ matrix.node-version }} - uses: actions/setup-node@v1 + - name: Set up node + uses: actions/setup-node@v2 with: - node-version: ${{ matrix.node-version }} + node-version: 14 + + - name: Set up npm7 + run: npm i -g npm@7 - name: Install dependencies & build app run: | @@ -48,7 +49,7 @@ jobs: - name: Wait for server run: npm run wait-on $CYPRESS_baseUrl - + - name: Enable app & configure server run: | cd cypress @@ -66,3 +67,13 @@ jobs: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} # https://github.com/cypress-io/github-action/issues/124 COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} + + summary: + runs-on: ubuntu-latest + needs: cypress + + if: always() + + steps: + - name: Summary status + run: if ${{ needs.cypress.result != 'success' && needs.cypress.result != 'skipped' }}; then exit 1; fi diff --git a/.github/workflows/dependabot-approve-merge.yml b/.github/workflows/dependabot-approve-merge.yml index 19a1311b4..6c5d73739 100644 --- a/.github/workflows/dependabot-approve-merge.yml +++ b/.github/workflows/dependabot-approve-merge.yml @@ -7,23 +7,23 @@ name: Dependabot on: pull_request_target: - branches: + branches: - master - stable* jobs: - auto-approve-merge: - if: github.actor == 'dependabot[bot]' + auto-merge: runs-on: ubuntu-latest - steps: - # Github actions bot approve + # Default github action approve - uses: hmarr/auto-approve-action@v2 + 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@v2 + 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-eslint.yml b/.github/workflows/lint-eslint.yml new file mode 100644 index 000000000..11590ffb0 --- /dev/null +++ b/.github/workflows/lint-eslint.yml @@ -0,0 +1,44 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization + +name: Lint + +on: + pull_request: + push: + branches: + - master + - stable* + +jobs: + lint: + runs-on: ubuntu-latest + + name: eslint + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Read package.json node and npm engines version + uses: skjnldsv/read-package-engines-version-actions@v1.1 + id: versions + with: + fallbackNode: '^12' + fallbackNpm: '^6' + + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} + uses: actions/setup-node@v2 + with: + node-version: ${{ steps.versions.outputs.nodeVersion }} + + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} + run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" + + - name: Install dependencies + run: npm ci + + - name: Lint + run: npm run lint diff --git a/.github/workflows/lint-php-cs.yml b/.github/workflows/lint-php-cs.yml new file mode 100644 index 000000000..9aad51409 --- /dev/null +++ b/.github/workflows/lint-php-cs.yml @@ -0,0 +1,35 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization + +name: Lint + +on: + pull_request: + push: + branches: + - master + - stable* + +jobs: + lint: + runs-on: ubuntu-latest + + name: php-cs + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@v2 + with: + php-version: "7.4" + coverage: none + + - name: Install dependencies + run: composer i + + - name: Lint + run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 ) diff --git a/.github/workflows/lint-php.yml b/.github/workflows/lint-php.yml new file mode 100644 index 000000000..3e8bac9b9 --- /dev/null +++ b/.github/workflows/lint-php.yml @@ -0,0 +1,35 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization + +name: Lint + +on: + pull_request: + push: + branches: + - master + - stable* + +jobs: + lint: + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: ["7.3", "7.4", "8.0"] + + name: php + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + coverage: none + + - name: Lint + run: composer run lint diff --git a/.github/workflows/lint-stylelint.yml b/.github/workflows/lint-stylelint.yml new file mode 100644 index 000000000..64edcfba5 --- /dev/null +++ b/.github/workflows/lint-stylelint.yml @@ -0,0 +1,44 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization + +name: Lint + +on: + pull_request: + push: + branches: + - master + - stable* + +jobs: + lint: + runs-on: ubuntu-latest + + name: stylelint + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Read package.json node and npm engines version + uses: skjnldsv/read-package-engines-version-actions@v1.1 + id: versions + with: + fallbackNode: '^12' + fallbackNpm: '^6' + + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} + uses: actions/setup-node@v2 + with: + node-version: ${{ steps.versions.outputs.nodeVersion }} + + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} + run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" + + - name: Install dependencies + run: npm ci + + - name: Lint + run: npm run stylelint diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index a861a461e..000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,97 +0,0 @@ -name: Lint - -on: - pull_request: - push: - branches: - - master - - stable* - -jobs: - php: - runs-on: ubuntu-latest - - strategy: - matrix: - php-versions: ['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 index daabff6c8..4b20eb5ed 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -1,3 +1,8 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization + name: Node on: @@ -11,18 +16,25 @@ jobs: build: runs-on: ubuntu-latest - strategy: - matrix: - node-version: ['12.x'] - - name: node${{ matrix.node-version }} + name: node steps: - - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v2 + + - name: Read package.json node and npm engines version + uses: skjnldsv/read-package-engines-version-actions@v1.1 + id: versions + with: + fallbackNode: '^12' + fallbackNpm: '^6' - - name: Set up node ${{ matrix.node-version }} - uses: actions/setup-node@v1 + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} + uses: actions/setup-node@v2 with: - node-version: ${{ matrix.node-version }} + node-version: ${{ steps.versions.outputs.nodeVersion }} + + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} + run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" - name: Install dependencies & build run: | @@ -31,4 +43,10 @@ jobs: - name: Check webpack build changes run: | - bash -c "[[ ! \"`git status --porcelain `\" ]] || ( echo 'Uncommited changes in webpack build' && git status && exit 1 )" + bash -c "[[ ! \"`git status --porcelain `\" ]] || exit 1" + + - name: Show changes on failure + if: failure() + run: | + git status + git --no-pager diff