diff --git a/.github/workflows/pull-request-lint.yaml b/.github/workflows/pull-request-lint.yaml new file mode 100644 index 00000000..b399514b --- /dev/null +++ b/.github/workflows/pull-request-lint.yaml @@ -0,0 +1,30 @@ +name: Pull Request Lint +on: + pull_request_target: + types: + - opened + - synchronize + - reopened + - edited + branches-ignore: + - mergify/merge-queue/* +jobs: + validate: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + types: |- + feat + fix + docs + chore + rfc + revert + subjectPattern: ^[^A-Z][^:]+[^.]$ + subjectPatternError: Subject must start with a lowercase, should not include ':' + and should not end with a period + requireScope: false diff --git a/.github/workflows/redis-pull.yaml b/.github/workflows/redis-pull.yaml index e0bf3e99..abd3b362 100644 --- a/.github/workflows/redis-pull.yaml +++ b/.github/workflows/redis-pull.yaml @@ -24,3 +24,6 @@ jobs: - name: Test run: wing test working-directory: redis + - name: Pack + run: wing pack + working-directory: redis diff --git a/.mergify.yml b/.mergify.yml new file mode 100644 index 00000000..fa349e9d --- /dev/null +++ b/.mergify.yml @@ -0,0 +1,55 @@ +queue_rules: + - name: default + speculative_checks: 2 + conditions: + - -files=.mergify.yml +pull_request_rules: + - name: automatic merge + actions: + comment: + message: > + Thanks for contributing, @{{author}}! This PR will now be added to the + [merge queue](https://mergify.com/merge-queue), or immediately merged + if `{{head}}` is up-to-date with `{{base}}` and the queue is empty. + queue: + name: default + method: squash + commit_message_template: |- + {{ title }} (#{{ number }}) + {{ body }} + conditions: + - -files=.mergify.yml + - -title~=(?i)wip + - -label~=(🚧 pr/do-not-merge|⚠️ pr/review-mutation) + - -merged + - -closed + - branch-protection-review-decision=APPROVED + - "#approved-reviews-by>=1" + - "#changes-requested-reviews-by=0" + - "#review-threads-unresolved=0" + - -approved-reviews-by~=author + - check-success=Validate PR title + - base=main + - name: requires manual merge + conditions: + - files=.mergify.yml + - -title~=(?i)wip + - -label~=(🚧 pr/do-not-merge|⚠️ pr/review-mutation|⚠️ + mergify/review-config) + - -merged + - -closed + - "#approved-reviews-by>=1" + - "#changes-requested-reviews-by=0" + - "#review-threads-unresolved=0" + - -approved-reviews-by~=author + - check-success=Validate PR title + - base=main + actions: + comment: + message: Thank you for contributing! Your pull request contains mergify + configuration changes and needs manual merge from a maintainer (be + sure to [allow changes to be pushed to your + fork](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork)). + label: + add: + - ⚠️ mergify/review-config diff --git a/generate-workflows.main.w b/generate-workflows.main.w index de383b0d..e28750a1 100644 --- a/generate-workflows.main.w +++ b/generate-workflows.main.w @@ -1,6 +1,8 @@ bring fs; bring "./library.w" as l; bring "./stale.w" as stale; +bring "./mergify.w" as mergify; +bring "./pr-lint.w" as prlint; // clean up let workflowdir = ".github/workflows"; @@ -17,3 +19,5 @@ for file in fs.readdir(".") { } new stale.StaleWorkflow(workflowdir); +new mergify.MergifyWorkflow(); +new prlint.PullRequestLintWorkflow(workflowdir); diff --git a/mergify.w b/mergify.w new file mode 100644 index 00000000..95db165d --- /dev/null +++ b/mergify.w @@ -0,0 +1,72 @@ +bring fs; + +pub class MergifyWorkflow { + new() { + fs.writeYaml(".mergify.yml", { + "queue_rules": [ + { + "name": "default", + "speculative_checks": 2, + "conditions": [ + "-files=.mergify.yml", + ] + } + ], + "pull_request_rules": [ + { + "name": "automatic merge", + "actions": { + "comment": { + "message": "Thanks for contributing, @\{\{author\}\}! This PR will now be added to the [merge queue](https://mergify.com/merge-queue), or immediately merged if `\{\{head\}\}` is up-to-date with `\{\{base\}\}` and the queue is empty.\n" + }, + "queue": { + "name": "default", + "method": "squash", + "commit_message_template": "\{\{ title \}\} (#\{\{ number \}\})\n\{\{ body \}\}" + } + }, + "conditions": [ + "-files=.mergify.yml", + "-title~=(?i)wip", + "-label~=(🚧 pr/do-not-merge|⚠️ pr/review-mutation)", + "-merged", + "-closed", + "branch-protection-review-decision=APPROVED", + "#approved-reviews-by>=1", + "#changes-requested-reviews-by=0", + "#review-threads-unresolved=0", + "-approved-reviews-by~=author", + "check-success=Validate PR title", + "base=main", + ] + }, + { + "name": "requires manual merge", + "conditions": [ + "files=.mergify.yml", + "-title~=(?i)wip", + "-label~=(🚧 pr/do-not-merge|⚠️ pr/review-mutation|⚠️ mergify/review-config)", + "-merged", + "-closed", + "#approved-reviews-by>=1", + "#changes-requested-reviews-by=0", + "#review-threads-unresolved=0", + "-approved-reviews-by~=author", + "check-success=Validate PR title", + "base=main" + ], + "actions": { + "comment": { + "message": "Thank you for contributing! Your pull request contains mergify configuration changes and needs manual merge from a maintainer (be sure to [allow changes to be pushed to your fork](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork))." + }, + "label": { + "add": [ + "⚠️ mergify/review-config" + ] + }, + } + } + ] + }); + } +} diff --git a/pr-lint.w b/pr-lint.w new file mode 100644 index 00000000..2c220bb7 --- /dev/null +++ b/pr-lint.w @@ -0,0 +1,35 @@ +bring fs; + +pub class PullRequestLintWorkflow { + new(workflowdir: str) { + fs.writeYaml("{workflowdir}/pull-request-lint.yaml", { + name: "Pull Request Lint", + on: { + pull_request_target: { + types: ["opened", "synchronize", "reopened", "edited"], + "branches-ignore": ["mergify/merge-queue/*"], + }, + }, + "jobs": { + "validate": { + "name": "Validate PR title", + "runs-on": "ubuntu-latest", + "steps": [ + { + "uses": "amannn/action-semantic-pull-request@v5.2.0", + "env": { + "GITHUB_TOKEN": "$\{\{ secrets.GITHUB_TOKEN \}\}" + }, + "with": { + "types": "feat\nfix\ndocs\nchore\nrfc\nrevert", + "subjectPattern": "^[^A-Z][^:]+[^.]$", + "subjectPatternError": "Subject must start with a lowercase, should not include ':' and should not end with a period", + "requireScope": false + } + } + ] + } + } + }); + } +}