From 54fc10abeb8e58ec0fd8da358c582d2f2d1e37a1 Mon Sep 17 00:00:00 2001 From: Galo Navarro Date: Tue, 2 Apr 2024 10:45:32 +0200 Subject: [PATCH 1/8] Dockerfile: pin stable to v1.10.1 (#139) --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index df3d842..312e576 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,6 @@ LABEL "com.github.actions.name"="Condition-based Pull Request labeller" \ "repository"="https://github.com/srvaroa/labeler" WORKDIR / -ARG ASSET_URL=https://github.com/srvaroa/labeler/releases/download/v1.10.0/action.tar.gz +ARG ASSET_URL=https://github.com/srvaroa/labeler/releases/download/v1.10.1/action.tar.gz RUN wget -q -O- $ASSET_URL | tar xzvf - ENTRYPOINT ["/action"] From 1dad3ac057e88a902e689ff81607b7b7f879a449 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:00:45 +0200 Subject: [PATCH 2/8] Bump golang.org/x/oauth2 from 0.18.0 to 0.19.0 (#140) Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.18.0 to 0.19.0. - [Commits](https://github.com/golang/oauth2/compare/v0.18.0...v0.19.0) --- updated-dependencies: - dependency-name: golang.org/x/oauth2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +----- go.sum | 22 ++-------------------- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/go.mod b/go.mod index ba80aee..902c7a0 100644 --- a/go.mod +++ b/go.mod @@ -7,20 +7,16 @@ require ( github.com/google/go-cmp v0.6.0 github.com/google/go-github/v50 v50.2.0 github.com/waigani/diffparser v0.0.0-20190828052634-7391f219313d - golang.org/x/oauth2 v0.18.0 + golang.org/x/oauth2 v0.19.0 ) require ( github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect github.com/cloudflare/circl v1.3.7 // indirect - github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/kr/pretty v0.1.0 // indirect golang.org/x/crypto v0.21.0 // indirect - golang.org/x/net v0.22.0 // indirect golang.org/x/sys v0.18.0 // indirect - google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.33.0 // indirect gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 911506b..ea87ec8 100644 --- a/go.sum +++ b/go.sum @@ -9,12 +9,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-yaml/yaml v2.1.0+incompatible h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwnTLB6vQiq+o= github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github/v50 v50.2.0 h1:j2FyongEHlO9nxXLc+LP3wuBSVU9mVxfpdYUexMpIfk= @@ -33,34 +28,21 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/waigani/diffparser v0.0.0-20190828052634-7391f219313d h1:xQcF7b7cZLWZG/+7A4G7un1qmEDYHIvId9qxRS1mZMs= github.com/waigani/diffparser v0.0.0-20190828052634-7391f219313d/go.mod h1:BzSc3WEF8R+lCaP5iGFRxd5kIXy4JKOZAwNe1w0cdc0= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= -golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg= +golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 855d7091de339575ce45aa67e6ad0923ed6837b8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 12:46:41 +0200 Subject: [PATCH 3/8] Bump golang.org/x/oauth2 from 0.19.0 to 0.20.0 (#141) Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.19.0 to 0.20.0. - [Commits](https://github.com/golang/oauth2/compare/v0.19.0...v0.20.0) --- updated-dependencies: - dependency-name: golang.org/x/oauth2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 902c7a0..83a5576 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/google/go-cmp v0.6.0 github.com/google/go-github/v50 v50.2.0 github.com/waigani/diffparser v0.0.0-20190828052634-7391f219313d - golang.org/x/oauth2 v0.19.0 + golang.org/x/oauth2 v0.20.0 ) require ( diff --git a/go.sum b/go.sum index ea87ec8..ae9a684 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg= -golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8= +golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= +golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= From 5c0264dbe6fbf1ad72ae3112ca2e5e5ec8c8486a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 15:45:51 +0200 Subject: [PATCH 4/8] Bump golang.org/x/oauth2 from 0.20.0 to 0.21.0 (#142) Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.20.0 to 0.21.0. - [Commits](https://github.com/golang/oauth2/compare/v0.20.0...v0.21.0) --- updated-dependencies: - dependency-name: golang.org/x/oauth2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 83a5576..465fefb 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/google/go-cmp v0.6.0 github.com/google/go-github/v50 v50.2.0 github.com/waigani/diffparser v0.0.0-20190828052634-7391f219313d - golang.org/x/oauth2 v0.20.0 + golang.org/x/oauth2 v0.21.0 ) require ( diff --git a/go.sum b/go.sum index ae9a684..3e43f05 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= -golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= +golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= From c7f131182b92274cc54ed18b2452c8e7ec05bfe3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 10:10:50 +0200 Subject: [PATCH 5/8] Bump golang.org/x/oauth2 from 0.21.0 to 0.22.0 (#143) Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.21.0 to 0.22.0. - [Commits](https://github.com/golang/oauth2/compare/v0.21.0...v0.22.0) --- updated-dependencies: - dependency-name: golang.org/x/oauth2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 465fefb..c0c5721 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/google/go-cmp v0.6.0 github.com/google/go-github/v50 v50.2.0 github.com/waigani/diffparser v0.0.0-20190828052634-7391f219313d - golang.org/x/oauth2 v0.21.0 + golang.org/x/oauth2 v0.22.0 ) require ( diff --git a/go.sum b/go.sum index 3e43f05..c3fb7bd 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= -golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= +golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= From b42a2b2463c3b1e168d30417293f21beffa69f2b Mon Sep 17 00:00:00 2001 From: Mystic <215104920@qq.com> Date: Wed, 28 Aug 2024 14:39:41 +0800 Subject: [PATCH 6/8] feat: add a more comprehensive labeler example for self-use and demonstration (#148) --- .github/labeler.yml | 68 +++++++++++++++++++++++++++--- .github/workflows/apply_labels.yml | 3 +- 2 files changed, 63 insertions(+), 8 deletions(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index d385683..f4ed978 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,9 +1,63 @@ version: 1 + labels: - - label: "TestLabel" - title: ".*" - - label: "TestFileMatch" - files: - - "cmd/.*.go" - - "pkg/.*.go" - + # Type: Build-related changes + - label: "@type/build" + title: '^build(?:\(.+\))?\!?:' + + # Type: CI-related changes + - label: "@type/ci" + title: '^ci(?:\(.+\))?\!?:' + files: + - '\.github/.+' + + # Type: Documentation changes + - label: "@type/docs" + title: '^docs(?:\(.+\))?\!?:' + files: + - "docs/.+" + - "**/*.md" + + # Type: New feature + - label: "@type/feature" + title: '^feat(?:\(.+\))?\!?:' + + # Type: Bug fix + - label: "@type/fix" + title: '^fix(?:\(.+\))?\!?:' + + # Type: Improvements such as style changes, refactoring, or performance improvements + - label: "@type/improve" + title: '^(style|refactor|perf)(?:\(.+\))?\!?:' + + # Type: Dependency changes + - label: "@type/dependency" + title: '^(chore|build)(?:\(deps\))?\!?:' + + # Type: Test-related changes + - label: "@type/test" + title: '^test(?:\(.+\))?\!?:' + files: + - "tests/.+" + - "spec/.+" + + # Type: Security-related changes + - label: "@type/security" + title: '^security(?:\(.+\))?\!?:' + files: + - "**/security/.+" + + # Issue Type Only: Feature Request + - label: "Feature Request" + type: issue + title: "^Feature Request:" + + # Issue Type Only: Documentation + - label: "Documentation" + type: issue + title: "^.*(\b[Dd]ocumentation|doc(s)?\b).*" + + # Issue Type Only: Bug Report + - label: "Bug Report" + type: issue + title: "^.*(\b[Bb]ug|b(u)?g(s)?\b).*" diff --git a/.github/workflows/apply_labels.yml b/.github/workflows/apply_labels.yml index bd09a7a..9ac9858 100644 --- a/.github/workflows/apply_labels.yml +++ b/.github/workflows/apply_labels.yml @@ -1,7 +1,8 @@ name: Label PRs with published action as canary on: - pull_request: + - pull_request + - issues jobs: apply_labels: From b48bedc8a021a7aad0efc55cded997988128817c Mon Sep 17 00:00:00 2001 From: Galo Navarro Date: Fri, 6 Sep 2024 09:53:24 +0200 Subject: [PATCH 7/8] Support last-modified (#149) Signed-off-by: Galo Navarro --- .github/labeler.yml | 10 ++++ README.md | 38 +++++++++++++++ pkg/condition_age.go | 25 ---------- pkg/condition_last_modified.go | 53 +++++++++++++++++++++ pkg/labeler.go | 7 +++ pkg/labeler_test.go | 18 +++++++ pkg/util.go | 30 ++++++++++++ pkg/{condition_age_test.go => util_test.go} | 0 8 files changed, 156 insertions(+), 25 deletions(-) create mode 100644 pkg/condition_last_modified.go create mode 100644 pkg/util.go rename pkg/{condition_age_test.go => util_test.go} (100%) diff --git a/.github/labeler.yml b/.github/labeler.yml index f4ed978..a2d9951 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,6 +1,16 @@ version: 1 labels: + # Type: Recent changes + - label: "@type/new" + last-modified: + at-most: 1d + + # Type: Old changes + - label: "@type/old" + last-modified: + at-least: 30d + # Type: Build-related changes - label: "@type/build" title: '^build(?:\(.+\))?\!?:' diff --git a/README.md b/README.md index 9ba325c..922baa1 100644 --- a/README.md +++ b/README.md @@ -309,6 +309,9 @@ alphabetical order. Some important considerations: This condition is satisfied when the age of the PR or Issue are larger than the given one. The age is calculated from the creation date. +If you're looking to evaluate on the modification date of the issue or PR, +check on + This condition is best used when with a schedule trigger. Example: @@ -407,6 +410,41 @@ regular expressions (Regex). Special characters need to be escaped with double backslashes. This is because the backslash in Go strings is an escape character and therefore must be escaped itself to appear as a literal in the regex. +### Last Modified (PRs and Issues) + +This condition evaluates the modification date of the PR or Issue. + +If you're looking to evaluate on the creation date of the issue or PR, +check on + +This condition is best used when with a schedule trigger. + +Examples: + +```yaml +last-modified: + at-most: 1d +``` +Will label PRs or issues that were last modified at most one day ago + +```yaml +last-modified: + at-least: 1d +``` + +Will label PRs or issues that were last modified at least one day ago + +The syntax for values is based on a number, followed by a suffix: + +* s: seconds +* m: minutes +* h: hours +* d: days +* w: weeks +* y: years + +For example, `2d` means 2 days, `4w` means 4 weeks, and so on. + ### Mergeable status (PRs only) This condition is satisfied when the [mergeable diff --git a/pkg/condition_age.go b/pkg/condition_age.go index b27de0b..be04a36 100644 --- a/pkg/condition_age.go +++ b/pkg/condition_age.go @@ -2,8 +2,6 @@ package labeler import ( "fmt" - "strconv" - "strings" "time" ) @@ -36,26 +34,3 @@ func AgeCondition(l *Labeler) Condition { }, } } - -func parseExtendedDuration(s string) (time.Duration, error) { - multiplier := time.Hour * 24 // default to days - - if strings.HasSuffix(s, "w") { - multiplier = time.Hour * 24 * 7 // weeks - s = strings.TrimSuffix(s, "w") - } else if strings.HasSuffix(s, "y") { - multiplier = time.Hour * 24 * 365 // years - s = strings.TrimSuffix(s, "y") - } else if strings.HasSuffix(s, "d") { - s = strings.TrimSuffix(s, "d") // days - } else { - return time.ParseDuration(s) // default to time.ParseDuration for hours, minutes, seconds - } - - value, err := strconv.Atoi(s) - if err != nil { - return 0, err - } - - return time.Duration(value) * multiplier, nil -} diff --git a/pkg/condition_last_modified.go b/pkg/condition_last_modified.go new file mode 100644 index 0000000..3012b6f --- /dev/null +++ b/pkg/condition_last_modified.go @@ -0,0 +1,53 @@ +package labeler + +import ( + "fmt" + "time" + + "github.com/google/go-github/v50/github" +) + +func LastModifiedCondition(l *Labeler) Condition { + return Condition{ + GetName: func() string { + return "Last modification of issue/PR" + }, + CanEvaluate: func(target *Target) bool { + return target.ghIssue != nil || target.ghPR != nil + }, + Evaluate: func(target *Target, matcher LabelMatcher) (bool, error) { + if matcher.LastModified == nil { + return false, fmt.Errorf("no last modified conditions are set in config") + } + // Determine the last modification time of the issue or PR + var lastModifiedAt *github.Timestamp + if target.ghIssue != nil { + lastModifiedAt = target.ghIssue.UpdatedAt + } else if target.ghPR != nil { + lastModifiedAt = target.ghPR.UpdatedAt + } else { + return false, fmt.Errorf("no issue or PR found in target") + } + duration := time.Since(lastModifiedAt.Time) + + if matcher.LastModified.AtMost != "" { + maxDuration, err := parseExtendedDuration(matcher.LastModified.AtMost) + if err != nil { + return false, fmt.Errorf("failed to parse `last-modified.at-most` parameter in configuration: %v", err) + } + return duration <= maxDuration, nil + } + + if matcher.LastModified.AtLeast != "" { + minDuration, err := parseExtendedDuration(matcher.LastModified.AtLeast) + if err != nil { + return false, fmt.Errorf("failed to parse `last-modified.at-least` parameter in configuration: %v", err) + } + return duration >= minDuration, nil + } + + return false, fmt.Errorf("no last modified conditions are set in config") + + }, + } +} diff --git a/pkg/labeler.go b/pkg/labeler.go index eb19ef7..21250b5 100644 --- a/pkg/labeler.go +++ b/pkg/labeler.go @@ -7,6 +7,11 @@ import ( gh "github.com/google/go-github/v50/github" ) +type DurationConfig struct { + AtLeast string `yaml:"at-least"` + AtMost string `yaml:"at-most"` +} + type SizeConfig struct { ExcludeFiles []string `yaml:"exclude-files"` Above string @@ -23,6 +28,7 @@ type LabelMatcher struct { Draft string Files []string Label string + LastModified *DurationConfig `yaml:"last-modified"` Mergeable string Negate bool Size *SizeConfig @@ -223,6 +229,7 @@ func (l *Labeler) findMatches(target *Target, config *LabelerConfigV1) (LabelUpd BodyCondition(), BranchCondition(), FilesCondition(l), + LastModifiedCondition(l), IsDraftCondition(), IsMergeableCondition(), SizeCondition(l), diff --git a/pkg/labeler_test.go b/pkg/labeler_test.go index 402a930..6a24c92 100644 --- a/pkg/labeler_test.go +++ b/pkg/labeler_test.go @@ -965,6 +965,24 @@ func TestHandleEvent(t *testing.T) { initialLabels: []string{"Meh"}, expectedLabels: []string{"Meh", "Test"}, }, + { + event: "pull_request", + payloads: []string{"create_pr"}, + name: "Add a label to pull request when last-modified.at-least matches", + config: LabelerConfigV1{ + Version: 1, + Labels: []LabelMatcher{ + { + Label: "Test", + LastModified: &DurationConfig{ + AtLeast: "1d", + }, + }, + }, + }, + initialLabels: []string{"Meh"}, + expectedLabels: []string{"Meh", "Test"}, + }, } for _, tc := range testCases { diff --git a/pkg/util.go b/pkg/util.go new file mode 100644 index 0000000..3d2988b --- /dev/null +++ b/pkg/util.go @@ -0,0 +1,30 @@ +package labeler + +import ( + "strconv" + "strings" + "time" +) + +func parseExtendedDuration(s string) (time.Duration, error) { + multiplier := time.Hour * 24 // default to days + + if strings.HasSuffix(s, "w") { + multiplier = time.Hour * 24 * 7 // weeks + s = strings.TrimSuffix(s, "w") + } else if strings.HasSuffix(s, "y") { + multiplier = time.Hour * 24 * 365 // years + s = strings.TrimSuffix(s, "y") + } else if strings.HasSuffix(s, "d") { + s = strings.TrimSuffix(s, "d") // days + } else { + return time.ParseDuration(s) // default to time.ParseDuration for hours, minutes, seconds + } + + value, err := strconv.Atoi(s) + if err != nil { + return 0, err + } + + return time.Duration(value) * multiplier, nil +} diff --git a/pkg/condition_age_test.go b/pkg/util_test.go similarity index 100% rename from pkg/condition_age_test.go rename to pkg/util_test.go From bfe288801b8091b6a70e67f3ce7c9e87c88921cf Mon Sep 17 00:00:00 2001 From: Galo Navarro Date: Fri, 6 Sep 2024 09:59:04 +0200 Subject: [PATCH 8/8] Support author-in-team (#150) Signed-off-by: Galo Navarro --- README.md | 12 +++++++++ cmd/action.go | 7 ++++++ pkg/condition_author_in_team.go | 23 +++++++++++++++++ pkg/labeler.go | 9 ++++--- pkg/labeler_test.go | 44 +++++++++++++++++++++++++++++++++ 5 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 pkg/condition_author_in_team.go diff --git a/README.md b/README.md index 922baa1..456511e 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ configurable matching rules. Available conditions: * [Age](#age): label based on the age of a PR or Issue. * [Author can merge](#author-can-merge): label based on whether the author can merge the PR +* [Author is member of team](#author-in-team): label based on whether the author is an active member of the given team * [Authors](#authors): label based on the PR/Issue authors * [Base branch](#base-branch): label based on the PR's base branch name * [Body](#body): label based on the PR/Issue body @@ -339,6 +340,17 @@ This is implemented by checking if the author is an owner of the repo. ```yaml author-can-merge: True ``` + + +### Author is member (PRs and Issues) + +This condition is satisfied when the author of the PR is an active +member of the given team. + +```yaml +author-is-member: CoreTeam +``` + ### Authors (PRs and Issues) This condition is satisfied when the author of the PR or Issue matches diff --git a/cmd/action.go b/cmd/action.go index 97a1c66..137be2d 100644 --- a/cmd/action.go +++ b/cmd/action.go @@ -244,6 +244,13 @@ func newLabeler(gh *github.Client, config *labeler.LabelerConfigV1) *labeler.Lab owner, repo, &github.PullRequestListOptions{}) return prs, err }, + IsUserMemberOfTeam: func(user, team string) (bool, error) { + membership, _, err := gh.Organizations.GetOrgMembership(ctx, user, team) + if err != nil { + return false, err + } + return membership.GetState() == "active", nil + }, }, Client: labeler.NewDefaultHttpClient(), } diff --git a/pkg/condition_author_in_team.go b/pkg/condition_author_in_team.go new file mode 100644 index 0000000..96c53d9 --- /dev/null +++ b/pkg/condition_author_in_team.go @@ -0,0 +1,23 @@ +package labeler + +import ( + "fmt" +) + +func AuthorInTeamCondition(l *Labeler) Condition { + return Condition{ + GetName: func() string { + return "Author is member of team" + }, + CanEvaluate: func(target *Target) bool { + return true + }, + Evaluate: func(target *Target, matcher LabelMatcher) (bool, error) { + if len(matcher.AuthorInTeam) <= 0 { + return false, fmt.Errorf("author-in-team is not set in config") + } + // check if author is a member of team + return l.GitHubFacade.IsUserMemberOfTeam(target.Author, matcher.AuthorInTeam) + }, + } +} diff --git a/pkg/labeler.go b/pkg/labeler.go index 21250b5..1f61624 100644 --- a/pkg/labeler.go +++ b/pkg/labeler.go @@ -22,6 +22,7 @@ type LabelMatcher struct { Age string AuthorCanMerge string `yaml:"author-can-merge"` Authors []string + AuthorInTeam string `yaml:"author-in-team"` BaseBranch string `yaml:"base-branch"` Body string Branch string @@ -65,9 +66,10 @@ type LabelUpdates struct { // Just to make this mockable.. type GitHubFacade struct { - GetRawDiff func(owner, repo string, prNumber int) (string, error) - ListIssuesByRepo func(owner, repo string) ([]*gh.Issue, error) - ListPRs func(owner, repo string) ([]*gh.PullRequest, error) + GetRawDiff func(owner, repo string, prNumber int) (string, error) + ListIssuesByRepo func(owner, repo string) ([]*gh.Issue, error) + ListPRs func(owner, repo string) ([]*gh.PullRequest, error) + IsUserMemberOfTeam func(user, team string) (bool, error) } type Labeler struct { @@ -225,6 +227,7 @@ func (l *Labeler) findMatches(target *Target, config *LabelerConfigV1) (LabelUpd AgeCondition(l), AuthorCondition(), AuthorCanMergeCondition(), + AuthorInTeamCondition(l), BaseBranchCondition(), BodyCondition(), BranchCondition(), diff --git a/pkg/labeler_test.go b/pkg/labeler_test.go index 6a24c92..50316b6 100644 --- a/pkg/labeler_test.go +++ b/pkg/labeler_test.go @@ -983,6 +983,46 @@ func TestHandleEvent(t *testing.T) { initialLabels: []string{"Meh"}, expectedLabels: []string{"Meh", "Test"}, }, + { + event: "issues", + payloads: []string{"issue_open"}, + name: "Add a label to issue when author is in team", + config: LabelerConfigV1{ + Version: 1, + Labels: []LabelMatcher{ + { + Label: "ShouldAppear", + AuthorInTeam: "team-with-srvaroa", + }, + { + Label: "ShouldNotAppear", + AuthorInTeam: "team-with", + }, + }, + }, + initialLabels: []string{"Meh"}, + expectedLabels: []string{"Meh", "ShouldAppear"}, + }, + { + event: "pull_request", + payloads: []string{"create_pr"}, + name: "Add a label to PR when author is in team", + config: LabelerConfigV1{ + Version: 1, + Labels: []LabelMatcher{ + { + Label: "ShouldAppear", + AuthorInTeam: "team-with-srvaroa", + }, + { + Label: "ShouldNotAppear", + AuthorInTeam: "team-with", + }, + }, + }, + initialLabels: []string{"Meh"}, + expectedLabels: []string{"Meh", "ShouldAppear"}, + }, } for _, tc := range testCases { @@ -1034,6 +1074,10 @@ func NewTestLabeler(t *testing.T, tc TestCase) Labeler { data, err := ioutil.ReadAll(file) return string(data), nil }, + // Will return true whenever team contains the given user name + IsUserMemberOfTeam: func(user, team string) (bool, error) { + return strings.Contains(team, user), nil + }, }, } }