0
0
mirror of https://github.com/thegeeklab/wp-github-comment.git synced 2024-06-03 04:49:40 +02:00

Compare commits

...

119 Commits
v1.0.1 ... main

Author SHA1 Message Date
renovate[bot]
98836fcb37
chore(deps): update docker.io/library/alpine docker tag to v3.20 (#122)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-01 13:21:53 +02:00
renovate[bot]
ade88cd306 chore(deps): update dependency golangci/golangci-lint to v1.59.0 2024-05-27 05:18:01 +00:00
renovate[bot]
9d20be9b37
fix(deps): update module github.com/rs/zerolog to v1.33.0 (#123)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-24 09:26:08 +02:00
renovate[bot]
636bc9ef4a chore(deps): update dependency golangci/golangci-lint to v1.58.2 2024-05-20 10:02:31 +00:00
3dfa592e96
chore: migrate to wp-plugin-go v3 (#120) 2024-05-17 21:50:16 +02:00
renovate[bot]
a47fc5926c
chore(docker): update docker.io/library/golang:1.22 docker digest to f43c6f0 (#118)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-16 13:41:14 +02:00
renovate[bot]
bc436f2940 chore(deps): update dependency golangci/golangci-lint to v1.58.1 2024-05-13 04:37:35 +00:00
23ed67963d
ci: fix golangci-lint deprecations 2024-05-12 11:08:27 +02:00
96d603d111
test: use static errors 2024-05-12 10:59:19 +02:00
renovate[bot]
6ddf49beb4
fix(deps): update module github.com/google/go-github/v61 to v62 (#116)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-11 11:05:13 +02:00
07d0b5405b
refactor: use dedicated github package (#115) 2024-05-11 10:25:19 +02:00
renovate[bot]
b0333e8700 chore(docker): update docker.io/library/golang:1.22 docker digest to b1e05e2 2024-05-08 05:16:37 +00:00
caafe6c2cf
refactor: rework github client and comment methods (#113) 2024-05-07 21:52:18 +02:00
4138e06711
docs: hide system flags and refactor generator (#112) 2024-05-07 15:03:20 +02:00
renovate[bot]
8ce857b9f9
fix(deps): update module golang.org/x/oauth2 to v0.20.0 (#109)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-07 12:16:08 +02:00
renovate[bot]
14441d18c4 chore(deps): update dependency golangci/golangci-lint to v1.58.0 2024-05-06 03:24:05 +00:00
renovate[bot]
495b0aa272
fix(deps): update module github.com/urfave/cli/v2 to v2.27.2 (#107)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-29 10:25:43 +02:00
renovate[bot]
87d4a691d6 chore(docker): update docker.io/library/golang:1.22 docker digest to d5302d4 2024-04-25 04:37:10 +00:00
renovate[bot]
97608ceb68
fix(deps): update module github.com/thegeeklab/wp-plugin-go to v1.7.1 (#105)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-22 12:38:51 +02:00
renovate[bot]
5c2c1e2fc6 chore(docker): update docker.io/library/golang:1.22 docker digest to 450e382 2024-04-11 07:26:10 +00:00
renovate[bot]
728c0c7c5f chore(docker): update docker.io/library/golang:1.22 docker digest to 3cb9b4d 2024-04-10 07:10:22 +00:00
renovate[bot]
72f7226872
fix(deps): update module golang.org/x/oauth2 to v0.19.0 (#102)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-05 08:51:44 +02:00
renovate[bot]
dbff861000 chore(docker): update docker.io/library/golang:1.22 docker digest to c4fb952 2024-04-04 05:11:20 +00:00
renovate[bot]
5df7056ddc
fix(deps): update module github.com/google/go-github/v60 to v61 (#100)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-02 09:05:49 +02:00
renovate[bot]
6dcf31ac98 chore(deps): update dependency golangci/golangci-lint to v1.57.2 2024-04-01 04:29:56 +00:00
renovate[bot]
79d21f32d5
fix(deps): update module github.com/thegeeklab/wp-plugin-go to v1.7.0 (#95)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-27 08:56:03 +01:00
renovate[bot]
2428e80890
chore(deps): update quay.io/thegeeklab/wp-docker-buildx docker tag to v4 (#98)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-27 08:43:15 +01:00
renovate[bot]
c458a6306b chore(deps): update dependency golangci/golangci-lint to v1.57.1 2024-03-25 03:16:35 +00:00
renovate[bot]
e97f4335f4 chore(docker): update docker.io/library/golang:1.22 docker digest to 0b55ab8 2024-03-13 06:14:58 +00:00
abc57db69a
cleanup docs and examples 2024-03-12 20:43:36 +01:00
renovate[bot]
568738a12a
fix(deps): update module github.com/thegeeklab/wp-plugin-go to v1.6.1 (#94)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-07 21:26:28 +01:00
renovate[bot]
9b53f9a7c1
fix(deps): update module golang.org/x/oauth2 to v0.18.0 (#92)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-06 14:43:04 +01:00
renovate[bot]
9c5c91a665 chore(docker): update docker.io/library/golang:1.22 docker digest to 34ce21a 2024-03-06 03:49:30 +00:00
renovate[bot]
3a0a9261f1
fix(deps): update module github.com/google/go-github/v59 to v60 (#91)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-02 14:49:00 +01:00
renovate[bot]
658fb631b0 chore(deps): update dependency golangci/golangci-lint to v1.56.2 2024-02-19 04:41:48 +00:00
renovate[bot]
0d2addd0f9 chore(docker): update docker.io/library/golang:1.22 docker digest to 7b297d9 2024-02-16 04:18:26 +00:00
ea72a8a7a4
[skip ci] revert renovate automerge config 2024-02-15 12:19:28 +01:00
cf7cda3da8
chore: use file.ReadStringOrFile from plugin lib (#88) 2024-02-09 22:10:10 +01:00
renovate[bot]
a6af05c8a4
fix(deps): update module github.com/thegeeklab/wp-plugin-go to v1.6.0 (#86)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-09 21:55:34 +01:00
renovate[bot]
a7cc02bd42
fix(deps): update module github.com/google/go-github/v58 to v59 (#87)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-09 21:53:01 +01:00
renovate[bot]
e4ebab49f2
fix(deps): update module golang.org/x/oauth2 to v0.17.0 (#85)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-08 21:52:25 +01:00
renovate[bot]
1403a0ae1f
chore(deps): update docker.io/library/golang docker tag to v1.22 (#83)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
2024-02-07 22:33:14 +01:00
07aff0af29
harmonize container image refs and use fqin 2024-02-07 09:40:49 +01:00
9288674b9e
run ci on renovate auto branches 2024-02-07 09:10:10 +01:00
95e98a1c8b
ci: enable ci run on renovate branches 2024-02-05 08:58:28 +01:00
renovate[bot]
d6476cc16c
fix(deps): update module github.com/rs/zerolog to v1.32.0 (#82)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-05 08:45:25 +01:00
renovate[bot]
a57c303b61 chore(docker): update golang:1.21 docker digest to 7b575fe 2024-02-03 06:34:44 +00:00
renovate[bot]
3b7a307713 chore(deps): update dependency mvdan/gofumpt to v0.6.0 2024-01-30 08:38:56 +00:00
renovate[bot]
39f399305b chore(docker): update alpine:3.19 docker digest to c5b1261 2024-01-28 07:16:19 +00:00
renovate[bot]
85f7b37c99 chore(docker): update golang:1.21 docker digest to 76aadd9 2024-01-25 06:09:05 +00:00
renovate[bot]
6ea798c89c
chore(deps): update quay.io/thegeeklab/wp-docker-buildx docker tag to v3 (#77)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-22 12:38:12 +01:00
renovate[bot]
89e8773282 chore(docker): update golang:1.21 docker digest to 5f5d61d 2024-01-17 09:34:36 +00:00
renovate[bot]
714d84b7f6 chore(docker): update golang:1.21 docker digest to 6fbd2d3 2024-01-12 01:27:34 +00:00
renovate[bot]
fdc4447885 chore(docker): update golang:1.21 docker digest to ffbb0b8 2024-01-11 04:09:48 +00:00
renovate[bot]
8f762c962a
fix(deps): update module github.com/google/go-github/v57 to v58 (#73)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-10 08:13:07 +01:00
renovate[bot]
778e29350f chore(docker): update golang:1.21 docker digest to 7026fb7 2024-01-10 04:41:17 +00:00
renovate[bot]
c7f4007f85
fix(deps): update module golang.org/x/oauth2 to v0.16.0 (#71)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-08 20:53:12 +01:00
ab048c2694
docs: fix default value property in data file 2024-01-03 23:26:15 +01:00
794b54d19d
use fqcn in docs 2024-01-03 23:10:08 +01:00
4e89e96c60
chore: cleanup docs (#70) 2024-01-03 22:49:33 +01:00
renovate[bot]
5b7f51cb33
fix(deps): update module github.com/thegeeklab/wp-plugin-go to v1.5.0 (#69)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-03 21:24:43 +01:00
renovate[bot]
b7e6baf2b3
fix(deps): update module github.com/urfave/cli/v2 to v2.27.1 (#68)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-01 16:21:30 +01:00
866147aa8b
use list style synatx and cleanup (#67) 2023-12-23 23:45:08 +01:00
renovate[bot]
469db2f48c
fix(deps): update module github.com/thegeeklab/wp-plugin-go to v1.3.0 (#66)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-21 15:21:01 +01:00
renovate[bot]
67510cbfcb chore(docker): update golang:1.21 docker digest to 672a228 2023-12-21 07:54:56 +00:00
renovate[bot]
ec3f09db9f chore(docker): update golang:1.21 docker digest to fb02af5 2023-12-20 18:49:10 +00:00
renovate[bot]
5be12f3e0a chore(docker): update golang:1.21 docker digest to 1a9d253 2023-12-20 06:23:19 +00:00
renovate[bot]
00986f6e0c chore(docker): update golang:1.21 docker digest to 11dc65e 2023-12-20 01:09:57 +00:00
renovate[bot]
4bda038ff7 chore(docker): update golang:1.21 docker digest to b172263 2023-12-19 15:22:33 +00:00
b10c877c4e
ci: add missing test group 2023-12-15 22:34:47 +01:00
renovate[bot]
b48a8b3a8f chore(docker): update golang:1.21 docker digest to 2ff79bc 2023-12-13 07:32:58 +00:00
renovate[bot]
da6781b749 chore(docker): update golang:1.21 docker digest to ae34fbf 2023-12-09 10:46:36 +00:00
renovate[bot]
0aad7b4d9d
chore(deps): update alpine docker tag to v3.19 (#58)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-08 08:37:44 +01:00
renovate[bot]
32eb7d541e
chore(deps): update quay.io/thegeeklab/wp-docker-buildx docker tag to v2 (#57)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-07 08:39:52 +01:00
renovate[bot]
cffbbcd475
fix(deps): update module github.com/thegeeklab/wp-plugin-go to v1.2.0 (#56)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-06 23:10:41 +01:00
3b814cd74a
fix: replace logrus by zerolog (#55) 2023-12-06 09:29:34 +01:00
renovate[bot]
74cf96d40e chore(docker): update golang:1.21 docker digest to 58e14a9 2023-12-06 01:18:34 +00:00
renovate[bot]
9ecd5402e4
fix(deps): update module github.com/thegeeklab/wp-plugin-go to v1.1.0 (#53)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-05 14:32:20 +01:00
b75c9d8063
ci: exclude dockerhub from linkcheck due to rate limiting 2023-12-05 11:24:33 +01:00
renovate[bot]
c8eecec6f7
fix(deps): update module github.com/google/go-github/v56 to v57 (#51)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-04 09:01:07 +01:00
renovate[bot]
3ab85def72
fix(deps): update module github.com/urfave/cli/v2 to v2.26.0 (#52)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-04 09:00:59 +01:00
renovate[bot]
59c9375466 chore(docker): update alpine:3.18 docker digest to 34871e7 2023-12-01 06:14:48 +00:00
renovate[bot]
eda2e78f7f
fix(deps): update module golang.org/x/oauth2 to v0.15.0 (#49)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-28 09:47:15 +01:00
renovate[bot]
553d4b721a chore(docker): update golang:1.21 docker digest to 9baee0e 2023-11-22 22:49:51 +00:00
renovate[bot]
2a56b76594 chore(docker): update golang:1.21 docker digest to daa9d10 2023-11-22 14:21:31 +00:00
renovate[bot]
eb4e8990fb chore(docker): update golang:1.21 docker digest to 4521f9d 2023-11-22 07:52:34 +00:00
renovate[bot]
7bade7fd6c chore(docker): update golang:1.21 docker digest to 57bf74a 2023-11-16 13:06:50 +00:00
renovate[bot]
edbcc24f81
fix(deps): update module golang.org/x/oauth2 to v0.14.0 (#44)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-14 16:18:54 +01:00
a162fdb98b
remove deprecated go version from golangci config 2023-11-08 09:25:29 +01:00
renovate[bot]
6b251b00b7 chore(docker): update golang:1.21 docker digest to 81cd210 2023-11-08 03:08:53 +00:00
renovate[bot]
99e699c84b chore(deps): update dependency golangci/golangci-lint to v1.55.2 2023-11-06 03:14:59 +00:00
renovate[bot]
4bc7b07603
chore(docker): update golang:1.21 docker digest to b113af1 (#41)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-04 16:02:59 +01:00
renovate[bot]
fe99566447 chore(docker): update golang:1.21 docker digest to 5206873 2023-11-02 07:05:46 +00:00
renovate[bot]
85b98f8a4b chore(docker): update golang:1.21 docker digest to 84e41b3 2023-11-01 21:05:37 +00:00
renovate[bot]
2074033a07 chore(deps): update dependency golangci/golangci-lint to v1.55.1 2023-10-30 03:53:52 +00:00
cf6577d2c6
ci: use gotestsum for better test output (#37) 2023-10-29 16:04:52 +01:00
48ad6c6bc5
use uppercase title for breaking changes in changelog 2023-10-28 22:59:51 +02:00
renovate[bot]
64c8e95fb3 chore(deps): update dependency golangci/golangci-lint to v1.55.0 2023-10-23 03:40:40 +00:00
7e5345bf96
ci: fix changelog generation for tag events (#34) 2023-10-17 14:04:03 +02:00
renovate[bot]
6de4a9160f
fix(deps): update module github.com/thegeeklab/wp-plugin-go to v1.0.2 (#33)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-17 08:56:48 +02:00
eac5c9ccc9
ci: fix releases and add linkcheck (#32) 2023-10-17 00:40:32 +02:00
renovate[bot]
e7df3c20f2 chore(docker): update golang:1.21 docker digest to 24a0937 2023-10-13 04:28:12 +00:00
renovate[bot]
eca150f107 chore(docker): update golang:1.21 docker digest to f94cb10 2023-10-12 21:34:29 +00:00
renovate[bot]
ae006c95d5
fix(deps): update module github.com/google/go-github/v55 to v56 (#29)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-12 13:32:42 +02:00
renovate[bot]
1dcc181de7 chore(docker): update golang:1.21 docker digest to 02d7116 2023-10-11 06:47:09 +00:00
renovate[bot]
aea7bda5e1 chore(docker): update golang:1.21 docker digest to 4d5cf6c 2023-10-11 00:05:32 +00:00
renovate[bot]
784f14e819
fix(deps): update module golang.org/x/oauth2 to v0.13.0 (#26)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-09 14:23:33 +02:00
renovate[bot]
000c29ffc0 chore(docker): update golang:1.21 docker digest to e9ebfe9 2023-10-06 06:14:29 +00:00
renovate[bot]
23ba64e462 chore(docker): update alpine:3.18 docker digest to eece025 2023-09-29 03:29:04 +00:00
renovate[bot]
af7064472a
fix(deps): update module github.com/rs/zerolog to v1.31.0 (#22)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-27 13:45:26 +02:00
renovate[bot]
69e4b3b1e9 chore(docker): update golang:1.21 docker digest to 19600fd 2023-09-27 07:00:50 +00:00
renovate[bot]
4aca035b64 chore(docker): update golang:1.21 docker digest to c416cee 2023-09-22 09:49:30 +00:00
renovate[bot]
9fd0392520 chore(docker): update golang:1.21 docker digest to afccce4 2023-09-21 14:47:34 +00:00
renovate[bot]
8756658b76 chore(docker): update golang:1.21 docker digest to 2270a40 2023-09-21 03:47:17 +00:00
renovate[bot]
5369c46cdb chore(docker): update golang:1.21 docker digest to 6974950 2023-09-20 22:17:46 +00:00
renovate[bot]
2f406912f5 chore(docker): update golang:1.21 docker digest to cffaba7 2023-09-13 07:15:05 +00:00
renovate[bot]
902f1b857b chore(docker): update golang:1.21 docker digest to d2aad22 2023-09-08 22:41:42 +00:00
renovate[bot]
38bb86e65d chore(docker): update golang:1.21 docker digest to 62e5883 2023-09-08 07:04:21 +00:00
renovate[bot]
74d03004ca chore(docker): update golang:1.21 docker digest to 970907c 2023-09-07 01:38:19 +00:00
30 changed files with 1045 additions and 415 deletions

View File

@ -1,23 +0,0 @@
# Changelog
{{ range .Versions -}}
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }})
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ (regexReplaceAll "(.*)/issues/(.*)" (regexReplaceAll "(Co-\\w*-by.*)" .Subject "") "${1}/pull/${2}") | trim }}
{{ end }}
{{- end -}}
{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

View File

@ -1,25 +0,0 @@
style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/thegeeklab/wp-github-comment
options:
commit_groups:
title_maps:
feat: Features
fix: Bug Fixes
perf: Performance Improvements
refactor: Code Refactoring
chore: Others
test: Testing
ci: CI Pipeline
docs: Documentation
header:
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
pattern_maps:
- Type
- Scope
- Subject
notes:
keywords:
- BREAKING CHANGE

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
/dist
/release
/wp-github-comment*
docs/data/data-raw.yaml
coverage.out
CHANGELOG.md

47
.gitsv/config.yml Normal file
View File

@ -0,0 +1,47 @@
---
version: "1.1"
versioning:
update-major: []
update-minor: [feat]
update-patch: [fix, perf, refactor, chore, test, ci, docs]
tag:
pattern: "v%d.%d.%d"
release-notes:
sections:
- name: Features
commit-types: [feat]
section-type: commits
- name: Bug Fixes
commit-types: [fix]
section-type: commits
- name: Performance Improvements
commit-types: [perf]
section-type: commits
- name: Code Refactoring
commit-types: [refactor]
section-type: commits
- name: Others
commit-types: [chore]
section-type: commits
- name: Testing
commit-types: [test]
section-type: commits
- name: CI Pipeline
commit-types: [ci]
section-type: commits
- name: Documentation
commit-types: [docs]
section-type: commits
- name: BREAKING CHANGES
section-type: breaking-changes
commit-message:
footer:
issue:
key: issue
add-value-prefix: "#"
issue:
regex: "#?[0-9]+"

View File

@ -23,7 +23,6 @@ linters:
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
- exportloopref
- forcetypeassert
@ -37,12 +36,12 @@ linters:
- gocyclo
- godot
- godox
- goerr113
- err113
- gofmt
- gofumpt
- goheader
- goimports
- gomnd
- mnd
- gomoddirectives
- gomodguard
- goprintffuncname
@ -86,6 +85,7 @@ linters:
# - wastedassign
- whitespace
- wsl
- zerologlint
fast: false
run:
@ -94,4 +94,3 @@ run:
linters-settings:
gofumpt:
extra-rules: true
lang-version: "1.21"

1
.lycheeignore Normal file
View File

@ -0,0 +1 @@
https://hub.docker.com/r/thegeeklab/*

6
.mockery.yaml Normal file
View File

@ -0,0 +1,6 @@
---
all: True
dir: "{{.PackageName}}/mocks"
outpkg: "mocks"
packages:
github.com/thegeeklab/wp-github-comment/github:

View File

@ -6,8 +6,8 @@ when:
- ${CI_REPO_DEFAULT_BRANCH}
steps:
dryrun:
image: quay.io/thegeeklab/wp-docker-buildx:1
- name: dryrun
image: quay.io/thegeeklab/wp-docker-buildx:4
settings:
containerfile: Containerfile.multiarch
dry_run: true
@ -19,9 +19,9 @@ steps:
when:
- event: [pull_request]
publish-dockerhub:
- name: publish-dockerhub
image: quay.io/thegeeklab/wp-docker-buildx:4
group: container
image: quay.io/thegeeklab/wp-docker-buildx:1
settings:
auto_tag: true
containerfile: Containerfile.multiarch
@ -40,9 +40,9 @@ steps:
branch:
- ${CI_REPO_DEFAULT_BRANCH}
publish-quay:
- name: publish-quay
image: quay.io/thegeeklab/wp-docker-buildx:4
group: container
image: quay.io/thegeeklab/wp-docker-buildx:1
settings:
auto_tag: true
containerfile: Containerfile.multiarch

View File

@ -6,39 +6,36 @@ when:
- ${CI_REPO_DEFAULT_BRANCH}
steps:
build:
image: docker.io/techknowlogick/xgo:go-1.21.x
- name: build
image: docker.io/techknowlogick/xgo:go-1.22.x
commands:
- ln -s $(pwd) /source
- make release
executable:
- name: executable
image: quay.io/thegeeklab/alpine-tools
commands:
- $(find dist/ -executable -type f -iname ${CI_REPO_NAME}-linux-amd64) --help
changelog-generate:
image: quay.io/thegeeklab/git-chglog
- name: changelog
image: quay.io/thegeeklab/git-sv
commands:
- git fetch -tq
- git-chglog --no-color --no-emoji -o CHANGELOG.md ${CI_COMMIT_TAG:---next-tag unreleased unreleased}
- git sv current-version
- git sv release-notes -t ${CI_COMMIT_TAG:-next} -o CHANGELOG.md
- cat CHANGELOG.md
changelog-format:
image: quay.io/thegeeklab/alpine-tools
commands:
- prettier CHANGELOG.md
- prettier -w CHANGELOG.md
publish-github:
- name: publish-github
image: docker.io/plugins/github-release
settings:
api_key:
from_secret: github_token
files:
- dist/*
note: CHANGELOG.md
overwrite: true
title: ${CI_COMMIT_TAG}
when:
- event: [tag]
- event: [tag]
depends_on:
- test

View File

@ -6,20 +6,27 @@ when:
- ${CI_REPO_DEFAULT_BRANCH}
steps:
markdownlint:
- name: markdownlint
image: quay.io/thegeeklab/markdownlint-cli
group: test
commands:
- markdownlint 'README.md' 'CONTRIBUTING.md'
spellcheck:
- name: spellcheck
image: quay.io/thegeeklab/alpine-tools
group: test
commands:
- spellchecker --files '_docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls
- spellchecker --files 'docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls
environment:
FORCE_COLOR: "true"
NPM_CONFIG_LOGLEVEL: "error"
publish:
- name: link-validation
image: docker.io/lycheeverse/lychee
group: test
commands:
- lychee --no-progress --format detailed docs/content README.md
- name: publish
image: quay.io/thegeeklab/wp-git-action
settings:
action:
@ -30,19 +37,20 @@ steps:
message: "[skip ci] auto-update documentation"
netrc_password:
from_secret: github_token
pages_directory: _docs/
pages_directory: docs/
when:
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
status: [success, failure]
pushrm-dockerhub:
- name: pushrm-dockerhub
image: docker.io/chko/docker-pushrm:1
secrets:
- source: docker_password
target: DOCKER_PASS
target: DOCKER_PASS
- source: docker_username
target: DOCKER_USER
target: DOCKER_USER
environment:
PUSHRM_FILE: README.md
PUSHRM_SHORT: Woodpecker CI plugin to add comments to GitHub Issues and Pull Requests
@ -53,7 +61,7 @@ steps:
- ${CI_REPO_DEFAULT_BRANCH}
status: [success]
pushrm-quay:
- name: pushrm-quay
image: docker.io/chko/docker-pushrm:1
secrets:
- source: quay_token

View File

@ -8,7 +8,7 @@ when:
runs_on: [success, failure]
steps:
matrix:
- name: matrix
image: quay.io/thegeeklab/wp-matrix
settings:
homeserver:

View File

@ -6,12 +6,12 @@ when:
- ${CI_REPO_DEFAULT_BRANCH}
steps:
lint:
image: docker.io/library/golang:1.21
- name: lint
image: docker.io/library/golang:1.22
commands:
- make lint
test:
image: docker.io/library/golang:1.21
- name: test
image: docker.io/library/golang:1.22
commands:
- make test

View File

@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM golang:1.21@sha256:b490ae1f0ece153648dd3c5d25be59a63f966b5f9e1311245c947de4506981aa as build
FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.22@sha256:f43c6f049f04cbbaeb28f0aad3eea15274a7d0a7899a617d0037aec48d7ab010 as build
ARG TARGETOS
ARG TARGETARCH
@ -8,7 +8,7 @@ WORKDIR /src
RUN make build
FROM alpine:3.18@sha256:7144f7bab3d4c2648d7e59409f15ec52a18006a128c733fcff20d3a4a54ba44a
FROM docker.io/library/alpine:3.20@sha256:77726ef6b57ddf65bb551896826ec38bc3e53f75cdde31354fbffb4f25238ebd
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"

View File

@ -1,7 +1,7 @@
# renovate: datasource=github-releases depName=mvdan/gofumpt
GOFUMPT_PACKAGE_VERSION := v0.5.0
GOFUMPT_PACKAGE_VERSION := v0.6.0
# renovate: datasource=github-releases depName=golangci/golangci-lint
GOLANGCI_LINT_PACKAGE_VERSION := v1.54.2
GOLANGCI_LINT_PACKAGE_VERSION := v1.59.0
EXECUTABLE := wp-github-comment
@ -17,9 +17,10 @@ SOURCES ?= $(shell find . -name "*.go" -type f)
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@$(GOFUMPT_PACKAGE_VERSION)
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_PACKAGE_VERSION)
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
GOTESTSUM_PACKAGE ?= gotest.tools/gotestsum@latest
MOCKERY_PACKAGE ?= github.com/vektra/mockery/v2@latest
GENERATE ?=
XGO_VERSION := go-1.21.x
XGO_VERSION := go-1.22.x
XGO_TARGETS ?= linux/amd64,linux/arm-6,linux/arm-7,linux/arm64
TARGETOS ?= linux
@ -64,11 +65,12 @@ lint: golangci-lint
.PHONY: generate
generate:
$(GO) generate $(GENERATE)
$(GO) generate $(PACKAGES)
$(GO) run $(MOCKERY_PACKAGE)
.PHONY: test
test:
$(GO) test -v -coverprofile coverage.out $(PACKAGES)
$(GO) run $(GOTESTSUM_PACKAGE) --no-color=false -- -coverprofile=coverage.out $(PACKAGES)
.PHONY: build
build: $(DIST)/$(EXECUTABLE)
@ -99,3 +101,4 @@ deps:
$(GO) install $(GOFUMPT_PACKAGE)
$(GO) install $(GOLANGCI_LINT_PACKAGE)
$(GO) install $(XGO_PACKAGE)
$(GO) install $(GOTESTSUM_PACKAGE)

View File

@ -1,34 +0,0 @@
---
properties:
- name: api_key
description: Personal Access token to access the GitHub API.
type: string
required: true
- name: base_url
description: API URL. Only need to be changed for GitHub enterprise in most cases
defaultValue: https://api.github.com
type: string
required: false
- name: key
description: Unique identifier to assign to a comment. The identifier is used to update an existing comment.
type: string
required: false
- name: message
description: Path to file or string that contains the comment text.
type: string
required: true
- name: update
description: Enables update of an existing comment that matches the key.
defaultValue: false
type: bool
required: false
- name: skip_missing
description: Skips comment creation if the given message file does not exist
defaultValue: false
type: bool
required: false

View File

@ -1,59 +0,0 @@
package main
import (
"github.com/thegeeklab/wp-github-comment/plugin"
"github.com/urfave/cli/v2"
)
// settingsFlags has the cli.Flags for the plugin.Settings.
func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "api-key",
EnvVars: []string{"PLUGIN_API_KEY", "GITHUB_COMMENT_API_KEY"},
Usage: "personal access token access github api",
Destination: &settings.APIKey,
Category: category,
Required: true,
},
&cli.StringFlag{
Name: "base-url",
EnvVars: []string{"PLUGIN_BASE_URL", "GITHUB_COMMENT_BASE_URL"},
Usage: "api url",
Value: "https://api.github.com/",
Destination: &settings.BaseURL,
Category: category,
},
&cli.StringFlag{
Name: "key",
EnvVars: []string{"PLUGIN_KEY", "GITHUB_COMMENT_KEY"},
Usage: "unique identifier to assign to comment",
Destination: &settings.Key,
Category: category,
},
&cli.StringFlag{
Name: "message",
EnvVars: []string{"PLUGIN_MESSAGE", "GITHUB_COMMENT_MESSAGE"},
Usage: "file or string that holds the comment text",
Destination: &settings.Message,
Category: category,
Required: true,
},
&cli.BoolFlag{
Name: "update",
EnvVars: []string{"PLUGIN_UPDATE", "GITHUB_COMMENT_UPDATE"},
Usage: "update existing comment that matches the key",
Value: false,
Destination: &settings.Update,
Category: category,
},
&cli.BoolFlag{
Name: "skip-missing",
EnvVars: []string{"PLUGIN_SKIP_MISSING", "GITHUB_COMMENT_SKIP_MISSING"},
Usage: "skip creation of comment if message file does not exist",
Value: false,
Destination: &settings.SkipMissing,
Category: category,
},
}
}

View File

@ -1,11 +1,7 @@
package main
import (
"fmt"
"github.com/thegeeklab/wp-github-comment/plugin"
wp "github.com/thegeeklab/wp-plugin-go/plugin"
)
//nolint:gochecknoglobals
@ -15,14 +11,5 @@ var (
)
func main() {
settings := &plugin.Settings{}
options := wp.Options{
Name: "wp-github-comment",
Description: "Add comments to GitHub Issues and Pull Requests",
Version: BuildVersion,
VersionMetadata: fmt.Sprintf("date=%s", BuildDate),
Flags: settingsFlags(settings, wp.FlagsPluginCategory),
}
plugin.New(options, settings).Run()
plugin.New(nil, BuildVersion, BuildDate).Run()
}

View File

@ -29,14 +29,11 @@ Only pull request events are supported by this plugin. Running the plugin on oth
{{< /hint >}}
```YAML
kind: pipeline
name: default
steps:
- name: pr-comment
image: thegeeklab/wp-github-comment
image: quay.io/thegeeklab/wp-github-comment
settings:
api_key: ghp_3LbMg9Kncpdkhjp3bh3dMnKNXLjVMTsXk4sM
api_key: ghp_randomstring
message: "CI run completed successfully"
update: true
```
@ -71,7 +68,7 @@ docker run --rm \
-e CI_REPO_OWNER=octocat \
-e CI_REPO_NAME=foo \
-e CI_COMMIT_PULL_REQUEST=1
-e PLUGIN_API_KEY=abc123 \
-e PLUGIN_API_KEY=ghp_randomstring \
-e PLUGIN_MESSAGE="Demo comment" \
-v $(pwd):/build:z \
-w /build \

58
docs/data/data.yaml Normal file
View File

@ -0,0 +1,58 @@
---
properties:
- name: api_key
description: |
Personal access token to access the GitHub API.
type: string
required: true
- name: base_url
description: |
Api url.
Only need to be changed for GitHub enterprise in most cases.
type: string
defaultValue: "https://api.github.com/"
required: false
- name: insecure_skip_verify
description: |
Skip SSL verification.
type: bool
defaultValue: false
required: false
- name: key
description: |
Unique identifier to assign to a comment.
The identifier is used to update an existing comment.
type: string
required: false
- name: log_level
description: |
Plugin log level.
type: string
defaultValue: "info"
required: false
- name: message
description: |
Path to file or string that contains the comment text.
type: string
required: true
- name: skip_missing
description: |
Skip comment creation if the given message file does not exist.
type: bool
defaultValue: false
required: false
- name: update
description: |
Enable update of an existing comment that matches the key.
type: bool
defaultValue: false
required: false

41
github/api.go Normal file
View File

@ -0,0 +1,41 @@
package github
import (
"context"
"github.com/google/go-github/v62/github"
)
// APIClient is an interface that wraps the GitHub API client.
//
//nolint:lll
type IssueService interface {
CreateComment(ctx context.Context, owner, repo string, number int, comment *github.IssueComment) (*github.IssueComment, *github.Response, error)
EditComment(ctx context.Context, owner, repo string, commentID int64, comment *github.IssueComment) (*github.IssueComment, *github.Response, error)
ListComments(ctx context.Context, owner, repo string, number int, opts *github.IssueListCommentsOptions) ([]*github.IssueComment, *github.Response, error)
}
type IssueServiceImpl struct {
client *github.Client
}
// CreateComment wraps the CreateComment method of the github.IssuesService.
//
//nolint:lll
func (s *IssueServiceImpl) CreateComment(ctx context.Context, owner, repo string, number int, comment *github.IssueComment) (*github.IssueComment, *github.Response, error) {
return s.client.Issues.CreateComment(ctx, owner, repo, number, comment)
}
// EditComment wraps the EditComment method of the github.IssuesService.
//
//nolint:lll
func (s *IssueServiceImpl) EditComment(ctx context.Context, owner, repo string, commentID int64, comment *github.IssueComment) (*github.IssueComment, *github.Response, error) {
return s.client.Issues.EditComment(ctx, owner, repo, commentID, comment)
}
// ListComments wraps the ListComments method of the github.IssuesService.
//
//nolint:lll
func (s *IssueServiceImpl) ListComments(ctx context.Context, owner, repo string, number int, opts *github.IssueListCommentsOptions) ([]*github.IssueComment, *github.Response, error) {
return s.client.Issues.ListComments(ctx, owner, repo, number, opts)
}

117
github/github.go Normal file
View File

@ -0,0 +1,117 @@
package github
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"strings"
"github.com/google/go-github/v62/github"
"golang.org/x/oauth2"
)
var ErrCommentNotFound = errors.New("comment not found")
type Client struct {
client *github.Client
Issue *Issue
}
type Issue struct {
client IssueService
Opt IssueOptions
}
type IssueOptions struct {
Number int
Message string
Key string
Repo string
Owner string
Update bool
}
// NewGitHubClient creates a new GitHubClient instance that wraps the provided GitHub API client.
// The GitHubClient provides a higher-level interface for interacting with the GitHub API,
// including methods for managing GitHub issues.
func NewClient(ctx context.Context, url *url.URL, token string, client *http.Client) *Client {
ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token})
tc := oauth2.NewClient(
context.WithValue(ctx, oauth2.HTTPClient, client),
ts,
)
c := github.NewClient(tc)
c.BaseURL = url
return &Client{
client: c,
Issue: &Issue{
client: &IssueServiceImpl{client: c},
Opt: IssueOptions{},
},
}
}
// AddComment adds a new comment or updates an existing comment on a GitHub issue.
// If the Update field is true, it will append a unique identifier to the comment
// body and attempt to find and update the existing comment with that identifier.
// Otherwise, it will create a new comment on the issue.
func (i *Issue) AddComment(ctx context.Context) (*github.IssueComment, error) {
issueComment := &github.IssueComment{
Body: &i.Opt.Message,
}
if i.Opt.Update {
// Append plugin comment ID to comment message so we can search for it later
*issueComment.Body = fmt.Sprintf("%s\n<!-- id: %s -->\n", i.Opt.Message, i.Opt.Key)
comment, err := i.FindComment(ctx)
if err != nil && !errors.Is(err, ErrCommentNotFound) {
return nil, err
}
if comment != nil {
comment, _, err = i.client.EditComment(ctx, i.Opt.Owner, i.Opt.Repo, *comment.ID, issueComment)
return comment, err
}
}
comment, _, err := i.client.CreateComment(ctx, i.Opt.Owner, i.Opt.Repo, i.Opt.Number, issueComment)
return comment, err
}
// FindComment returns the GitHub issue comment that contains the specified key, or nil if no such comment exists.
// It retrieves all comments on the issue and searches for one that contains the specified key in the comment body.
func (i *Issue) FindComment(ctx context.Context) (*github.IssueComment, error) {
var allComments []*github.IssueComment
opts := &github.IssueListCommentsOptions{}
for {
comments, resp, err := i.client.ListComments(ctx, i.Opt.Owner, i.Opt.Repo, i.Opt.Number, opts)
if err != nil {
return nil, err
}
allComments = append(allComments, comments...)
if resp == nil || resp.NextPage == 0 {
break
}
opts.Page = resp.NextPage
}
for _, comment := range allComments {
if strings.Contains(*comment.Body, fmt.Sprintf("<!-- id: %s -->", i.Opt.Key)) {
return comment, nil
}
}
return nil, fmt.Errorf("%w: failed to find comment with key %s", ErrCommentNotFound, i.Opt.Key)
}

212
github/github_test.go Normal file
View File

@ -0,0 +1,212 @@
package github
import (
"context"
"errors"
"fmt"
"testing"
"github.com/google/go-github/v62/github"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/thegeeklab/wp-github-comment/github/mocks"
)
var ErrInternalServerError = errors.New("internal server error")
func TestGithubIssue_FindComment(t *testing.T) {
tests := []struct {
name string
issueOpt IssueOptions
comments []*github.IssueComment
want *github.IssueComment
wantErr error
}{
{
name: "no comments",
issueOpt: IssueOptions{
Key: "test-key",
Owner: "test-owner",
Repo: "test-repo",
},
wantErr: ErrCommentNotFound,
},
{
name: "comment found",
issueOpt: IssueOptions{
Key: "test-key",
Owner: "test-owner",
Repo: "test-repo",
},
comments: []*github.IssueComment{
{Body: github.String("<!-- id: test-key -->\ntest comment\n")},
},
want: &github.IssueComment{
Body: github.String("<!-- id: test-key -->\ntest comment\n"),
},
},
{
name: "comment not found",
issueOpt: IssueOptions{
Key: "test-key",
Owner: "test-owner",
Repo: "test-repo",
},
comments: []*github.IssueComment{
{Body: github.String("other comment")},
},
wantErr: ErrCommentNotFound,
},
{
name: "multiple comments",
issueOpt: IssueOptions{
Key: "test-key",
Owner: "test-owner",
Repo: "test-repo",
},
comments: []*github.IssueComment{
{Body: github.String("other comment")},
{Body: github.String("<!-- id: test-key -->\ntest comment\n")},
{Body: github.String("another comment")},
},
want: &github.IssueComment{Body: github.String("<!-- id: test-key -->\ntest comment\n")},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
mockClient := mocks.NewMockIssueService(t)
issue := &Issue{
client: mockClient,
Opt: tt.issueOpt,
}
mockClient.
On("ListComments", mock.Anything, tt.issueOpt.Owner, tt.issueOpt.Repo, mock.Anything, mock.Anything).
Return(tt.comments, nil, nil)
got, err := issue.FindComment(context.Background())
if tt.wantErr != nil {
assert.Error(t, err)
assert.Equal(t, tt.want, got)
return
}
assert.NoError(t, err)
assert.Equal(t, tt.want, got)
})
}
}
func TestGithubIssue_AddComment(t *testing.T) {
tests := []struct {
name string
issueOpt IssueOptions
comments []*github.IssueComment
want *github.IssueComment
wantErr error
}{
{
name: "create new comment",
issueOpt: IssueOptions{
Key: "test-key",
Owner: "test-owner",
Repo: "test-repo",
Message: "test message",
Update: false,
},
want: &github.IssueComment{
Body: github.String("<!-- id: test-key -->\ntest message\n"),
},
},
{
name: "update existing comment",
issueOpt: IssueOptions{
Key: "test-key",
Owner: "test-owner",
Repo: "test-repo",
Message: "test message",
Update: true,
},
comments: []*github.IssueComment{
{ID: github.Int64(123), Body: github.String("<!-- id: test-key -->\ntest message\n")},
},
want: &github.IssueComment{
Body: github.String("<!-- id: test-key -->\ntest message\n"),
},
},
{
name: "update non-existing comment",
issueOpt: IssueOptions{
Key: "test-key",
Owner: "test-owner",
Repo: "test-repo",
Message: "test message",
Update: true,
},
want: &github.IssueComment{
Body: github.String("<!-- id: test-key -->\ntest message\n"),
},
},
{
name: "create new comment with error",
issueOpt: IssueOptions{
Key: "test-key",
Owner: "test-owner",
Repo: "test-repo",
Message: "test message",
Update: false,
},
wantErr: ErrInternalServerError,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
mockClient := mocks.NewMockIssueService(t)
issue := &Issue{
client: mockClient,
Opt: tt.issueOpt,
}
if tt.issueOpt.Update {
mockClient.
On("ListComments", mock.Anything, tt.issueOpt.Owner, tt.issueOpt.Repo, mock.Anything, mock.Anything).
Return(tt.comments, nil, nil)
}
if tt.issueOpt.Update && tt.comments != nil {
mockClient.
On("EditComment", mock.Anything, tt.issueOpt.Owner, tt.issueOpt.Repo, mock.Anything, mock.Anything).
Return(&github.IssueComment{
Body: github.String(fmt.Sprintf("<!-- id: %s -->\n%s\n", tt.issueOpt.Key, tt.issueOpt.Message)),
}, nil, nil)
}
if tt.comments == nil {
var comment *github.IssueComment
if tt.wantErr == nil {
comment = &github.IssueComment{
Body: github.String(fmt.Sprintf("<!-- id: %s -->\n%s\n", tt.issueOpt.Key, tt.issueOpt.Message)),
}
}
mockClient.
On("CreateComment", mock.Anything, tt.issueOpt.Owner, tt.issueOpt.Repo, mock.Anything, mock.Anything).
Return(comment, nil, tt.wantErr)
}
got, err := issue.AddComment(context.Background())
if tt.wantErr != nil {
assert.Error(t, err)
assert.Equal(t, tt.want, got)
return
}
assert.NoError(t, err)
assert.Equal(t, tt.want, got)
})
}
}

View File

@ -0,0 +1,250 @@
// Code generated by mockery v2.43.0. DO NOT EDIT.
package mocks
import (
context "context"
github "github.com/google/go-github/v62/github"
mock "github.com/stretchr/testify/mock"
)
// MockIssueService is an autogenerated mock type for the IssueService type
type MockIssueService struct {
mock.Mock
}
type MockIssueService_Expecter struct {
mock *mock.Mock
}
func (_m *MockIssueService) EXPECT() *MockIssueService_Expecter {
return &MockIssueService_Expecter{mock: &_m.Mock}
}
// CreateComment provides a mock function with given fields: ctx, owner, repo, number, comment
func (_m *MockIssueService) CreateComment(ctx context.Context, owner string, repo string, number int, comment *github.IssueComment) (*github.IssueComment, *github.Response, error) {
ret := _m.Called(ctx, owner, repo, number, comment)
if len(ret) == 0 {
panic("no return value specified for CreateComment")
}
var r0 *github.IssueComment
var r1 *github.Response
var r2 error
if rf, ok := ret.Get(0).(func(context.Context, string, string, int, *github.IssueComment) (*github.IssueComment, *github.Response, error)); ok {
return rf(ctx, owner, repo, number, comment)
}
if rf, ok := ret.Get(0).(func(context.Context, string, string, int, *github.IssueComment) *github.IssueComment); ok {
r0 = rf(ctx, owner, repo, number, comment)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*github.IssueComment)
}
}
if rf, ok := ret.Get(1).(func(context.Context, string, string, int, *github.IssueComment) *github.Response); ok {
r1 = rf(ctx, owner, repo, number, comment)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*github.Response)
}
}
if rf, ok := ret.Get(2).(func(context.Context, string, string, int, *github.IssueComment) error); ok {
r2 = rf(ctx, owner, repo, number, comment)
} else {
r2 = ret.Error(2)
}
return r0, r1, r2
}
// MockIssueService_CreateComment_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateComment'
type MockIssueService_CreateComment_Call struct {
*mock.Call
}
// CreateComment is a helper method to define mock.On call
// - ctx context.Context
// - owner string
// - repo string
// - number int
// - comment *github.IssueComment
func (_e *MockIssueService_Expecter) CreateComment(ctx interface{}, owner interface{}, repo interface{}, number interface{}, comment interface{}) *MockIssueService_CreateComment_Call {
return &MockIssueService_CreateComment_Call{Call: _e.mock.On("CreateComment", ctx, owner, repo, number, comment)}
}
func (_c *MockIssueService_CreateComment_Call) Run(run func(ctx context.Context, owner string, repo string, number int, comment *github.IssueComment)) *MockIssueService_CreateComment_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(int), args[4].(*github.IssueComment))
})
return _c
}
func (_c *MockIssueService_CreateComment_Call) Return(_a0 *github.IssueComment, _a1 *github.Response, _a2 error) *MockIssueService_CreateComment_Call {
_c.Call.Return(_a0, _a1, _a2)
return _c
}
func (_c *MockIssueService_CreateComment_Call) RunAndReturn(run func(context.Context, string, string, int, *github.IssueComment) (*github.IssueComment, *github.Response, error)) *MockIssueService_CreateComment_Call {
_c.Call.Return(run)
return _c
}
// EditComment provides a mock function with given fields: ctx, owner, repo, commentID, comment
func (_m *MockIssueService) EditComment(ctx context.Context, owner string, repo string, commentID int64, comment *github.IssueComment) (*github.IssueComment, *github.Response, error) {
ret := _m.Called(ctx, owner, repo, commentID, comment)
if len(ret) == 0 {
panic("no return value specified for EditComment")
}
var r0 *github.IssueComment
var r1 *github.Response
var r2 error
if rf, ok := ret.Get(0).(func(context.Context, string, string, int64, *github.IssueComment) (*github.IssueComment, *github.Response, error)); ok {
return rf(ctx, owner, repo, commentID, comment)
}
if rf, ok := ret.Get(0).(func(context.Context, string, string, int64, *github.IssueComment) *github.IssueComment); ok {
r0 = rf(ctx, owner, repo, commentID, comment)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*github.IssueComment)
}
}
if rf, ok := ret.Get(1).(func(context.Context, string, string, int64, *github.IssueComment) *github.Response); ok {
r1 = rf(ctx, owner, repo, commentID, comment)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*github.Response)
}
}
if rf, ok := ret.Get(2).(func(context.Context, string, string, int64, *github.IssueComment) error); ok {
r2 = rf(ctx, owner, repo, commentID, comment)
} else {
r2 = ret.Error(2)
}
return r0, r1, r2
}
// MockIssueService_EditComment_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EditComment'
type MockIssueService_EditComment_Call struct {
*mock.Call
}
// EditComment is a helper method to define mock.On call
// - ctx context.Context
// - owner string
// - repo string
// - commentID int64
// - comment *github.IssueComment
func (_e *MockIssueService_Expecter) EditComment(ctx interface{}, owner interface{}, repo interface{}, commentID interface{}, comment interface{}) *MockIssueService_EditComment_Call {
return &MockIssueService_EditComment_Call{Call: _e.mock.On("EditComment", ctx, owner, repo, commentID, comment)}
}
func (_c *MockIssueService_EditComment_Call) Run(run func(ctx context.Context, owner string, repo string, commentID int64, comment *github.IssueComment)) *MockIssueService_EditComment_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(int64), args[4].(*github.IssueComment))
})
return _c
}
func (_c *MockIssueService_EditComment_Call) Return(_a0 *github.IssueComment, _a1 *github.Response, _a2 error) *MockIssueService_EditComment_Call {
_c.Call.Return(_a0, _a1, _a2)
return _c
}
func (_c *MockIssueService_EditComment_Call) RunAndReturn(run func(context.Context, string, string, int64, *github.IssueComment) (*github.IssueComment, *github.Response, error)) *MockIssueService_EditComment_Call {
_c.Call.Return(run)
return _c
}
// ListComments provides a mock function with given fields: ctx, owner, repo, number, opts
func (_m *MockIssueService) ListComments(ctx context.Context, owner string, repo string, number int, opts *github.IssueListCommentsOptions) ([]*github.IssueComment, *github.Response, error) {
ret := _m.Called(ctx, owner, repo, number, opts)
if len(ret) == 0 {
panic("no return value specified for ListComments")
}
var r0 []*github.IssueComment
var r1 *github.Response
var r2 error
if rf, ok := ret.Get(0).(func(context.Context, string, string, int, *github.IssueListCommentsOptions) ([]*github.IssueComment, *github.Response, error)); ok {
return rf(ctx, owner, repo, number, opts)
}
if rf, ok := ret.Get(0).(func(context.Context, string, string, int, *github.IssueListCommentsOptions) []*github.IssueComment); ok {
r0 = rf(ctx, owner, repo, number, opts)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*github.IssueComment)
}
}
if rf, ok := ret.Get(1).(func(context.Context, string, string, int, *github.IssueListCommentsOptions) *github.Response); ok {
r1 = rf(ctx, owner, repo, number, opts)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*github.Response)
}
}
if rf, ok := ret.Get(2).(func(context.Context, string, string, int, *github.IssueListCommentsOptions) error); ok {
r2 = rf(ctx, owner, repo, number, opts)
} else {
r2 = ret.Error(2)
}
return r0, r1, r2
}
// MockIssueService_ListComments_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListComments'
type MockIssueService_ListComments_Call struct {
*mock.Call
}
// ListComments is a helper method to define mock.On call
// - ctx context.Context
// - owner string
// - repo string
// - number int
// - opts *github.IssueListCommentsOptions
func (_e *MockIssueService_Expecter) ListComments(ctx interface{}, owner interface{}, repo interface{}, number interface{}, opts interface{}) *MockIssueService_ListComments_Call {
return &MockIssueService_ListComments_Call{Call: _e.mock.On("ListComments", ctx, owner, repo, number, opts)}
}
func (_c *MockIssueService_ListComments_Call) Run(run func(ctx context.Context, owner string, repo string, number int, opts *github.IssueListCommentsOptions)) *MockIssueService_ListComments_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(int), args[4].(*github.IssueListCommentsOptions))
})
return _c
}
func (_c *MockIssueService_ListComments_Call) Return(_a0 []*github.IssueComment, _a1 *github.Response, _a2 error) *MockIssueService_ListComments_Call {
_c.Call.Return(_a0, _a1, _a2)
return _c
}
func (_c *MockIssueService_ListComments_Call) RunAndReturn(run func(context.Context, string, string, int, *github.IssueListCommentsOptions) ([]*github.IssueComment, *github.Response, error)) *MockIssueService_ListComments_Call {
_c.Call.Return(run)
return _c
}
// NewMockIssueService creates a new instance of MockIssueService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
func NewMockIssueService(t interface {
mock.TestingT
Cleanup(func())
}) *MockIssueService {
mock := &MockIssueService{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}

46
go.mod
View File

@ -1,29 +1,39 @@
module github.com/thegeeklab/wp-github-comment
go 1.21
go 1.22
require (
github.com/google/go-github/v55 v55.0.0
github.com/rs/zerolog v1.30.0
github.com/thegeeklab/wp-plugin-go v1.0.1
github.com/urfave/cli/v2 v2.25.7
golang.org/x/oauth2 v0.12.0
github.com/google/go-github/v62 v62.0.0
github.com/rs/zerolog v1.33.0
github.com/stretchr/testify v1.9.0
github.com/thegeeklab/wp-plugin-go/v3 v3.0.2
github.com/urfave/cli/v2 v2.27.2
golang.org/x/oauth2 v0.20.0
)
require (
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/crypto v0.13.0 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/sys v0.12.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

134
go.sum
View File

@ -1,70 +1,110 @@
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA=
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g=
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
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.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-github/v55 v55.0.0 h1:4pp/1tNMB9X/LuAhs5i0KQAE40NmiR/y6prLNb9x9cg=
github.com/google/go-github/v55 v55.0.0/go.mod h1:JLahOTA1DnXzhxEymmFF5PP2tSS9JVNj68mSZNDwskA=
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/v62 v62.0.0 h1:/6mGCaRywZz9MuHyw9gD1CwsbmBX8GWsbFkwMmHdhl4=
github.com/google/go-github/v62 v62.0.0/go.mod h1:EMxeUqGJq2xRu9DYBMwel/mr7kZrzUOfQmmpYrZn2a4=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4=
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY=
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c=
github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/thegeeklab/wp-plugin-go v1.0.1 h1:n0z+UVghSfTyOpwo75aAdV0EPhLbIr2DqIEqiXHKOAU=
github.com/thegeeklab/wp-plugin-go v1.0.1/go.mod h1:y0k5zaKWjdGbgkaOHhEPFEL6p+yOLOjqHy0LWOrv0MM=
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/thegeeklab/wp-plugin-go/v3 v3.0.2 h1:Mv5i8S1WY+BUNjTjX6lOnB3p8S9mvM+XwfY4R98gx0g=
github.com/thegeeklab/wp-plugin-go/v3 v3.0.2/go.mod h1:ij1iJcAVgzerBTqXnmq0bu1VA+hhVVwzXKqiqfoGjjg=
github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI=
github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
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.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/oauth2 v0.12.0 h1:smVPGxink+n1ZI5pkQa8y6fZT0RW0MgCO5bFpepy4B4=
golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba4=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo=
golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
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-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
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/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
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.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

42
internal/doc/main.go Normal file
View File

@ -0,0 +1,42 @@
//go:build generate
// +build generate
package main
import (
"context"
"flag"
"net/http"
"os"
"time"
"github.com/thegeeklab/wp-github-comment/plugin"
plugin_docs "github.com/thegeeklab/wp-plugin-go/v3/docs"
plugin_template "github.com/thegeeklab/wp-plugin-go/v3/template"
)
func main() {
tmpl := "https://raw.githubusercontent.com/thegeeklab/woodpecker-plugins/main/templates/docs-data.yaml.tmpl"
client := http.Client{
Timeout: 30 * time.Second,
}
p := plugin.New(nil)
out, err := plugin_template.Render(context.Background(), client, tmpl, plugin_docs.GetTemplateData(p.App))
if err != nil {
panic(err)
}
outputFile := flag.String("output", "", "Output file path")
flag.Parse()
if *outputFile == "" {
panic("no output file specified")
}
err = os.WriteFile(*outputFile, []byte(out), 0o644)
if err != nil {
panic(err)
}
}

View File

@ -1,84 +0,0 @@
package plugin
import (
"context"
"fmt"
"strings"
"github.com/google/go-github/v55/github"
)
type commentClient struct {
Message string
Update bool
Key string
Repo string
Owner string
IssueNum int
*github.Client
}
func (cc *commentClient) issueComment(ctx context.Context) error {
var (
err error
comment *github.IssueComment
resp *github.Response
)
issueComment := &github.IssueComment{
Body: &cc.Message,
}
if cc.Update {
// Append plugin comment ID to comment message so we can search for it later
message := fmt.Sprintf("%s\n<!-- id: %s -->\n", cc.Message, cc.Key)
issueComment.Body = &message
comment, err = cc.comment(ctx)
if err == nil && comment != nil {
_, resp, err = cc.Client.Issues.EditComment(ctx, cc.Owner, cc.Repo, *comment.ID, issueComment)
}
}
if err == nil && resp == nil {
_, _, err = cc.Client.Issues.CreateComment(ctx, cc.Owner, cc.Repo, cc.IssueNum, issueComment)
}
if err != nil {
return err
}
return nil
}
func (cc *commentClient) comment(ctx context.Context) (*github.IssueComment, error) {
var allComments []*github.IssueComment
opts := &github.IssueListCommentsOptions{}
for {
comments, resp, err := cc.Client.Issues.ListComments(ctx, cc.Owner, cc.Repo, cc.IssueNum, opts)
if err != nil {
return nil, err
}
allComments = append(allComments, comments...)
if resp.NextPage == 0 {
break
}
opts.Page = resp.NextPage
}
for _, comment := range allComments {
if strings.Contains(*comment.Body, fmt.Sprintf("<!-- id: %s -->", cc.Key)) {
return comment, nil
}
}
//nolint:nilnil
return nil, nil
}

View File

@ -8,9 +8,9 @@ import (
"net/url"
"strings"
"github.com/google/go-github/v55/github"
"github.com/rs/zerolog/log"
"golang.org/x/oauth2"
gh "github.com/thegeeklab/wp-github-comment/github"
plugin_file "github.com/thegeeklab/wp-plugin-go/v3/file"
)
var ErrPluginEventNotSupported = errors.New("event not supported")
@ -21,7 +21,6 @@ func (p *Plugin) run(ctx context.Context) error {
return fmt.Errorf("validation failed: %w", err)
}
//nolint:contextcheck
if err := p.Execute(); err != nil {
return fmt.Errorf("execution failed: %w", err)
}
@ -38,7 +37,7 @@ func (p *Plugin) Validate() error {
}
if p.Settings.Message != "" {
if p.Settings.Message, p.Settings.IsFile, err = readStringOrFile(p.Settings.Message); err != nil {
if p.Settings.Message, p.Settings.IsFile, err = plugin_file.ReadStringOrFile(p.Settings.Message); err != nil {
return fmt.Errorf("error while reading %s: %w", p.Settings.Message, err)
}
}
@ -58,7 +57,7 @@ func (p *Plugin) Validate() error {
p.Settings.Key = fmt.Sprintf("%x", hash)
}
if p.Settings.Key, _, err = readStringOrFile(p.Settings.Key); err != nil {
if p.Settings.Key, _, err = plugin_file.ReadStringOrFile(p.Settings.Key); err != nil {
return fmt.Errorf("error while reading %s: %w", p.Settings.Key, err)
}
@ -67,23 +66,14 @@ func (p *Plugin) Validate() error {
// Execute provides the implementation of the plugin.
func (p *Plugin) Execute() error {
ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: p.Settings.APIKey})
tc := oauth2.NewClient(
context.WithValue(p.Network.Context, oauth2.HTTPClient, p.Network.Client),
ts,
)
client := github.NewClient(tc)
client.BaseURL = p.Settings.baseURL
commentClient := commentClient{
Client: client,
Repo: p.Metadata.Repository.Name,
Owner: p.Metadata.Repository.Owner,
Message: p.Settings.Message,
Update: p.Settings.Update,
Key: p.Settings.Key,
IssueNum: p.Metadata.Curr.PullRequest,
client := gh.NewClient(p.Network.Context, p.Settings.baseURL, p.Settings.APIKey, p.Network.Client)
client.Issue.Opt = gh.IssueOptions{
Repo: p.Metadata.Repository.Name,
Owner: p.Metadata.Repository.Owner,
Message: p.Settings.Message,
Update: p.Settings.Update,
Key: p.Settings.Key,
Number: p.Metadata.Curr.PullRequest,
}
if p.Settings.SkipMissing && !p.Settings.IsFile {
@ -93,7 +83,7 @@ func (p *Plugin) Execute() error {
return nil
}
err := commentClient.issueComment(p.Network.Context)
_, err := client.Issue.AddComment(p.Network.Context)
if err != nil {
return fmt.Errorf("failed to create or update comment: %w", err)
}

View File

@ -1,14 +1,18 @@
package plugin
import (
"fmt"
"net/url"
wp "github.com/thegeeklab/wp-plugin-go/plugin"
plugin_base "github.com/thegeeklab/wp-plugin-go/v3/plugin"
"github.com/urfave/cli/v2"
)
//go:generate go run ../internal/doc/main.go -output=../docs/data/data-raw.yaml
// Plugin implements provide the plugin.
type Plugin struct {
*wp.Plugin
*plugin_base.Plugin
Settings *Settings
}
@ -26,13 +30,85 @@ type Settings struct {
baseURL *url.URL
}
func New(options wp.Options, settings *Settings) *Plugin {
p := &Plugin{}
func New(e plugin_base.ExecuteFunc, build ...string) *Plugin {
p := &Plugin{
Settings: &Settings{},
}
options.Execute = p.run
options := plugin_base.Options{
Name: "wp-github-comment",
Description: "Add comments to GitHub Issues and Pull Requests",
Flags: Flags(p.Settings, plugin_base.FlagsPluginCategory),
Execute: p.run,
HideWoodpeckerFlags: true,
}
p.Plugin = wp.New(options)
p.Settings = settings
if len(build) > 0 {
options.Version = build[0]
}
if len(build) > 1 {
options.VersionMetadata = fmt.Sprintf("date=%s", build[1])
}
if e != nil {
options.Execute = e
}
p.Plugin = plugin_base.New(options)
return p
}
// Flags returns a slice of CLI flags for the plugin.
func Flags(settings *Settings, category string) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "api-key",
EnvVars: []string{"PLUGIN_API_KEY", "GITHUB_COMMENT_API_KEY"},
Usage: "personal access token to access the GitHub API",
Destination: &settings.APIKey,
Category: category,
Required: true,
},
&cli.StringFlag{
Name: "base-url",
EnvVars: []string{"PLUGIN_BASE_URL", "GITHUB_COMMENT_BASE_URL"},
Usage: "API URL",
Value: "https://api.github.com/",
Destination: &settings.BaseURL,
Category: category,
},
&cli.StringFlag{
Name: "key",
EnvVars: []string{"PLUGIN_KEY", "GITHUB_COMMENT_KEY"},
Usage: "unique identifier to assign to a comment",
Destination: &settings.Key,
Category: category,
},
&cli.StringFlag{
Name: "message",
EnvVars: []string{"PLUGIN_MESSAGE", "GITHUB_COMMENT_MESSAGE"},
Usage: "path to file or string that contains the comment text",
Destination: &settings.Message,
Category: category,
Required: true,
},
&cli.BoolFlag{
Name: "update",
EnvVars: []string{"PLUGIN_UPDATE", "GITHUB_COMMENT_UPDATE"},
Usage: "enable update of an existing comment that matches the key",
Value: false,
Destination: &settings.Update,
Category: category,
},
&cli.BoolFlag{
Name: "skip-missing",
EnvVars: []string{"PLUGIN_SKIP_MISSING", "GITHUB_COMMENT_SKIP_MISSING"},
Usage: "skip comment creation if the given message file does not exist",
Value: false,
Destination: &settings.SkipMissing,
Category: category,
},
}
}

View File

@ -1,27 +0,0 @@
package plugin
import (
"os"
)
func readStringOrFile(input string) (string, bool, error) {
//nolint:gomnd
if len(input) > 255 {
return input, false, nil
}
// Check if input is a file path
if _, err := os.Stat(input); err != nil && os.IsNotExist(err) {
// No file found => use input as result
return input, false, nil
} else if err != nil {
return "", false, err
}
result, err := os.ReadFile(input)
if err != nil {
return "", true, err
}
return string(result), true, nil
}