cilium / github-actions

Repository dedicated for the GitHub actions logic executed in cilium/cilium. Also known as the maintainer's little helper (MLH).
Apache License 2.0
5 stars 6 forks source link

regexp for require msgs in commit #62

Closed kaworu closed 1 year ago

kaworu commented 1 year ago

Add regexpMsg to require-msgs-in-commit, a regular expression alternative to msg. Also brings client mode support for require-msgs-in-commit on the way so I could manually test the patch.

client mode tests

Got a complain when checking for a missing msg:

% cat check-msg-for-co-authored-by.yaml
require-msgs-in-commit:
  - msg: "Co-authored-by"
    helper: "https://docs.cilium.io/en/stable/contributing/contributing/#developer-s-certificate-of-origin"
    set-labels:
      - "dont-merge/needs-sign-off"
% ./github-actions -client-mode -org kaworu -repo cilium -branch master -pr 287 -config check-msg-for-co-authored-by.yaml

No complain on https://github.com/kaworu/cilium/pull/283 for an existing msg:

% cat check-msg-for-signed-off-by.yaml
require-msgs-in-commit:
  - msg: "Signed-off-by"
    helper: "https://docs.cilium.io/en/stable/contributing/contributing/#developer-s-certificate-of-origin"
    set-labels:
      - "dont-merge/needs-sign-off"
% ./github-actions -client-mode -org kaworu -repo cilium -branch master -pr 283 -config check-msg-for-signed-off-by.yaml

Got an error when neither msg or regexpMsg is configured:

% cat check-none.yaml
require-msgs-in-commit:
  - helper: "https://docs.cilium.io/en/stable/contributing/contributing/#developer-s-certificate-of-origin"
    set-labels:
      - "dont-merge/needs-sign-off"
% ./github-actions -client-mode -org kaworu -repo cilium -branch master -pr 281 -config check-none.yaml
Getting PRs from GH
panic: no msg or regexpMsg configured

goroutine 1 [running]:
main.runClient()
    /home/alex/go/src/github.com/cilium/github-actions/cmd/client.go:106 +0x748
main.main()
    /home/alex/go/src/github.com/cilium/github-actions/cmd/main.go:34 +0x18

Complains about no regexpMsg match:

% cat check-regexpmsg-for-co-authored-by.yaml
require-msgs-in-commit:
  - regexpMsg: "(?m)^Co-authored-by:"
    helper: "https://docs.cilium.io/en/stable/contributing/contributing/#developer-s-certificate-of-origin"
    set-labels:
      - "dont-merge/needs-sign-off"
% ./github-actions -client-mode -org kaworu -repo cilium -branch master -pr 280 -config check-regexpmsg-for-co-authored-by.yaml

No complain on https://github.com/kaworu/cilium/pull/277 when regexpMsg matches:

% cat check-regexpmsg-for-signed-off-by.yaml
require-msgs-in-commit:
  - regexpMsg: "(?m)^Signed-off-by:"
    helper: "https://docs.cilium.io/en/stable/contributing/contributing/#developer-s-certificate-of-origin"
    set-labels:
      - "dont-merge/needs-sign-off"
% ./github-actions -client-mode -org kaworu -repo cilium -branch master -pr 277 -config check-regexpmsg-for-signed-off-by.yaml