From ded46161f654dd617365eda3b97a81d7e22a156a Mon Sep 17 00:00:00 2001 From: Ben Grande Date: Mon, 1 Jul 2024 12:09:07 +0200 Subject: [PATCH] ci: close PRs that have commits made on GitHub Web --- .../pull_request_template.md | 25 +++++++++ .github/workflows/reject-pr.yaml | 56 +++++++++++++++++++ .reuse/dep5 | 2 +- docs/CONTRIBUTE.md | 6 +- 4 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE/pull_request_template.md create mode 100644 .github/workflows/reject-pr.yaml diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md new file mode 100644 index 0000000..6dcb2d6 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -0,0 +1,25 @@ +## Contribution checklist + +Before contributing, I, the opener of this request: + +- [ ] Agree to use the same license of each modified file; +- [ ] Have followed the [contribution guidelines](docs/CONTRIBUTE.md); +- [ ] I have tested it locally; +- [ ] I have committed locally and not through a git hosting service such as + GitHub Web; and +- [ ] I have reviewed and updated any documentation if relevant. + +Lacking to check any of the above can result in the rejection of the +contribution without no further comment. + +## What does this PR aims to accomplish? + + + +## What does this PR change? + + + +. diff --git a/.github/workflows/reject-pr.yaml b/.github/workflows/reject-pr.yaml new file mode 100644 index 0000000..481de11 --- /dev/null +++ b/.github/workflows/reject-pr.yaml @@ -0,0 +1,56 @@ +# yamllint disable-line rule:line-length +# SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. +# +# SPDX-License-Identifier: GPL-3.0-or-later + +--- +name: Reject pull requests of user's that don't read the contribution guidelines + +# yamllint disable-line rule:truthy +on: + pull_request: + types: + - opened + - reopened + - synchronize + +concurrency: + group: ci-${{ github.ref }}-1 + cancel-in-progress: true + +jobs: + lint: + strategy: + fail-fast: false + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-python@v5 + - name: Block commits made using the GitHub WebUI + if: failure() + uses: peter-evans/close-pull@v3 + with: + # yamllint disable-line rule:line-length + comment: 'Automatically closing this PR due to submitter not reading the contribution guidelines and using GitHub WebUI to commit. Please fix the issues and open a new PR after you have read the contribution guidelines.' + delete-branch: false + run: | + if test "${{ github.event_name}}" = "pull_request" + then + base="${{ github.event.pull_request.base.sha }}" + head="${{ github.event.pull_request.head.sha }}" + else + base="${{ github.event.before }}" + head="${{ github.event.after }}" + fi + if test "${base}" = "${head}" || test -z "${base}" + then + committer="$(git show -s --format=%cn ${head})" + else + committer="$(git show -s --format=%cn ${base}..${head})" + fi + if echo "${committer}" | grep -q "^GitHub$"; then + echo "Commit was made using the GitHub WebUI" >&2 + exit 1 + fi diff --git a/.reuse/dep5 b/.reuse/dep5 index c49d725..3209d79 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -3,7 +3,7 @@ Upstream-Name: qusal Upstream-Contact: Benjamin Grande M. S. Source: https://github.com/ben-grande/qusal -Files: README.md */README.md docs/* .github/ISSUE_TEMPLATE/* +Files: README.md */README.md docs/* .github/*_TEMPLATE/* Copyright: 2023 - 2024 Benjamin Grande M. S. License: CC-BY-SA-4.0 diff --git a/docs/CONTRIBUTE.md b/docs/CONTRIBUTE.md index f34e3ac..9eadfb0 100644 --- a/docs/CONTRIBUTE.md +++ b/docs/CONTRIBUTE.md @@ -6,7 +6,7 @@ Qusal contribution guidelines. * [Respect](#respect) * [Starters](#starters) -* [Requirements](#requirements) +* [Environment](#environment) * [Issues](#issues) * [Lint](#lint) @@ -40,8 +40,10 @@ made and what can be improved, see the [design guide](DESIGN.md). Experiment with some formulas, read them, understand what is being done. +## Environment -## Requirements +Setting up your environment is mandatory. Commits made using the Github Web +interface will be rejected. For an automatic setup, use the [dev formula](../salt/dev), else, install the packages below depending on the task: