Skip to content

Commit

Permalink
staco and lib/github: add utility for stable comments. (#772)
Browse files Browse the repository at this point in the history
Background:
The owner BOT (separate draft PR) requires maintaining
a comment in the PR stream with up to date information
on who the best and necessary reviewers are across all
the changes on the PR. No need to append a new comment
every time a commit is pushed, or something is changed.

But this functionality is useful on it's own to create
"mini dashboards" that are update dynamically in the
comment stream of a PR.

In this PR, I took the code out of that owner bot branch,
and turned it into a free standing utility and library.

Specifically, this PR:
- introduces a "staco" tool to handle stable comments.
  See the README under staco to learn how to use it.
- introduces a lib/github directory with some useful
  wrappers around github (always enforcing retry, timeout
  and making the API slightly more friendly).
- introduces a stablecomment library to programmaticaly
  handle stable comments.

If this looks reasonable enough, I want to include
a built in binary of staco in our dev container, and
start updating dashboards from our CI/CD jobs.
  • Loading branch information
ccontavalli authored Nov 17, 2022
1 parent 2679dd9 commit 79a8285
Show file tree
Hide file tree
Showing 19 changed files with 2,152 additions and 24 deletions.
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ multirun(
name = "binaries_release",
commands = [
"//enkit:deploy",
"//staco:deploy",
"//faketree:astore_push",
"//flextape/server:astore_push",
# TODO(scott): Move the main to //flextape/client, delete this dir
Expand Down
119 changes: 98 additions & 21 deletions bazel/go_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -887,8 +887,8 @@ def go_repositories():
go_repository(
name = "com_github_go_openapi_jsonpointer",
importpath = "github.com/go-openapi/jsonpointer",
sum = "h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w=",
version = "v0.19.3",
sum = "h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY=",
version = "v0.19.5",
)
go_repository(
name = "com_github_go_openapi_jsonreference",
Expand All @@ -905,8 +905,8 @@ def go_repositories():
go_repository(
name = "com_github_go_openapi_swag",
importpath = "github.com/go-openapi/swag",
sum = "h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY=",
version = "v0.19.5",
sum = "h1:wm0rhTb5z7qpJRHBdPOMuY4QjVUMbF6/kwoYeRAOrKU=",
version = "v0.21.1",
)

go_repository(
Expand Down Expand Up @@ -1196,18 +1196,18 @@ def go_repositories():
)
go_repository(
name = "com_github_google_cel_go",
build_directives = [
# We are consistently using proto-generated code, rather than the
# genproto pre-generated repo where conflicts exist.
"gazelle:resolve go google.golang.org/genproto/googleapis/rpc/status @go_googleapis//google/rpc:status_go_proto",
],
# BUILD file generation needs to be forced on, since:
# * this repo is bazel-aware and comes with BUILD files already
# * we want to override certain import -> dep mappints with directives
# below
build_file_generation = "on",
build_naming_convention = "go_default_library",
importpath = "github.com/google/cel-go",
build_directives = [
# We are consistently using proto-generated code, rather than the
# genproto pre-generated repo where conflicts exist.
"gazelle:resolve go google.golang.org/genproto/googleapis/rpc/status @go_googleapis//google/rpc:status_go_proto",
],
sum = "h1:MnUpbcMtr/eA8vRTEYSru+fyCAgGUYLrY/49vUvphbI=",
version = "v0.11.3",
)
Expand Down Expand Up @@ -1544,6 +1544,13 @@ def go_repositories():
sum = "h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=",
version = "v1.0.0",
)
go_repository(
name = "com_github_huandu_xstrings",
importpath = "github.com/huandu/xstrings",
sum = "h1:4jgBlKK6tLKFvO8u5pmYjG91cqytmDCDvGh7ECVFfFs=",
version = "v1.3.1",
)

go_repository(
name = "com_github_hudl_fargo",
importpath = "github.com/hudl/fargo",
Expand All @@ -1561,8 +1568,8 @@ def go_repositories():
go_repository(
name = "com_github_imdario_mergo",
importpath = "github.com/imdario/mergo",
sum = "h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg=",
version = "v0.3.9",
sum = "h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA=",
version = "v0.3.11",
)
go_repository(
name = "com_github_improbable_eng_grpc_web",
Expand All @@ -1589,6 +1596,18 @@ def go_repositories():
sum = "h1:7tIFeCGmpyrMx9qvT0EgYUi7cxVW48a0mMvnIL17bPM=",
version = "v1.0.7",
)
go_repository(
name = "com_github_itchyny_gojq",
importpath = "github.com/itchyny/gojq",
sum = "h1:biKpbKwMxVYhCU1d6mR7qMr3f0Hn9F5k5YykCVb3gmM=",
version = "v0.12.9",
)
go_repository(
name = "com_github_itchyny_timefmt_go",
importpath = "github.com/itchyny/timefmt-go",
sum = "h1:hFEfWVdwsEi+CY8xY2FtgWHGQaBaC3JeHd+cve0ynVM=",
version = "v0.1.4",
)

go_repository(
name = "com_github_jbenet_go_context",
Expand Down Expand Up @@ -1659,6 +1678,19 @@ def go_repositories():
sum = "h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo=",
version = "v0.1.0",
)
go_repository(
name = "com_github_josephburnett_jd",
importpath = "github.com/josephburnett/jd",
sum = "h1:Uzqhcje4WqvVyp85F3Oj0ezISPTlnhnr/KaLZIy8qh0=",
version = "v1.6.1",
)
go_repository(
name = "com_github_josharian_intern",
importpath = "github.com/josharian/intern",
sum = "h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=",
version = "v1.0.0",
)

go_repository(
name = "com_github_jpillora_backoff",
importpath = "github.com/jpillora/backoff",
Expand Down Expand Up @@ -1865,8 +1897,8 @@ def go_repositories():
go_repository(
name = "com_github_mailru_easyjson",
importpath = "github.com/mailru/easyjson",
sum = "h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM=",
version = "v0.7.0",
sum = "h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=",
version = "v0.7.7",
)

go_repository(
Expand All @@ -1875,12 +1907,32 @@ def go_repositories():
sum = "h1:QtJ5ZjqapShm0w5DosRjg0PRlSdAdlx+W6cCKoALdbQ=",
version = "v1.0.1",
)
go_repository(
name = "com_github_masterminds_goutils",
importpath = "github.com/Masterminds/goutils",
sum = "h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=",
version = "v1.1.1",
)

go_repository(
name = "com_github_masterminds_semver",
importpath = "github.com/Masterminds/semver",
sum = "h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=",
version = "v1.5.0",
)
go_repository(
name = "com_github_masterminds_semver_v3",
importpath = "github.com/Masterminds/semver/v3",
sum = "h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=",
version = "v3.1.1",
)
go_repository(
name = "com_github_masterminds_sprig_v3",
importpath = "github.com/Masterminds/sprig/v3",
sum = "h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8=",
version = "v3.2.2",
)

go_repository(
name = "com_github_matoous_godox",
importpath = "github.com/matoous/godox",
Expand All @@ -1897,15 +1949,15 @@ def go_repositories():
go_repository(
name = "com_github_mattn_go_isatty",
importpath = "github.com/mattn/go-isatty",
sum = "h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=",
version = "v0.0.14",
sum = "h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=",
version = "v0.0.16",
)

go_repository(
name = "com_github_mattn_go_runewidth",
importpath = "github.com/mattn/go-runewidth",
sum = "h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54=",
version = "v0.0.7",
sum = "h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=",
version = "v0.0.13",
)
go_repository(
name = "com_github_mattn_go_sqlite3",
Expand Down Expand Up @@ -1977,6 +2029,12 @@ def go_repositories():
sum = "h1:tEElEatulEHDeedTxwckzyYMA5c86fbmNIUL1hBIiTg=",
version = "v1.1.0",
)
go_repository(
name = "com_github_mitchellh_copystructure",
importpath = "github.com/mitchellh/copystructure",
sum = "h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=",
version = "v1.0.0",
)

go_repository(
name = "com_github_mitchellh_go_homedir",
Expand Down Expand Up @@ -2015,6 +2073,13 @@ def go_repositories():
sum = "h1:6h7AQ0yhTcIsmFmnAwQls75jp2Gzs4iB8W7pjMO+rqo=",
version = "v1.4.2",
)
go_repository(
name = "com_github_mitchellh_reflectwalk",
importpath = "github.com/mitchellh/reflectwalk",
sum = "h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY=",
version = "v1.0.0",
)

go_repository(
name = "com_github_modern_go_concurrent",
importpath = "github.com/modern-go/concurrent",
Expand Down Expand Up @@ -2454,6 +2519,12 @@ def go_repositories():
sum = "h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ=",
version = "v0.0.0-20181016184325-3113b8401b8a",
)
go_repository(
name = "com_github_rivo_uniseg",
importpath = "github.com/rivo/uniseg",
sum = "h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=",
version = "v0.2.0",
)

go_repository(
name = "com_github_robertkrimen_godocdown",
Expand Down Expand Up @@ -2586,6 +2657,12 @@ def go_repositories():
sum = "h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc=",
version = "v2.1.4+incompatible",
)
go_repository(
name = "com_github_shopspring_decimal",
importpath = "github.com/shopspring/decimal",
sum = "h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=",
version = "v1.2.0",
)

go_repository(
name = "com_github_shurcool_go",
Expand Down Expand Up @@ -2673,8 +2750,8 @@ def go_repositories():
go_repository(
name = "com_github_spf13_cast",
importpath = "github.com/spf13/cast",
sum = "h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=",
version = "v1.3.0",
sum = "h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=",
version = "v1.3.1",
)
go_repository(
name = "com_github_spf13_cobra",
Expand Down Expand Up @@ -3777,8 +3854,8 @@ def go_repositories():
go_repository(
name = "in_gopkg_yaml_v3",
importpath = "gopkg.in/yaml.v3",
sum = "h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=",
version = "v3.0.0-20210107192922-496545a6307b",
sum = "h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=",
version = "v3.0.1",
)

go_repository(
Expand Down
14 changes: 11 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
cloud.google.com/go/storage v1.27.0
github.com/GoogleCloudPlatform/cloud-build-notifiers v0.0.0-20221005190102-4a3420d331aa // indirect
github.com/KohlsTechnology/prometheus_bigquery_remote_storage_adapter v0.4.6 // indirect
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
github.com/Microsoft/go-winio v0.4.16 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6 // indirect
Expand Down Expand Up @@ -45,9 +46,12 @@ require (
github.com/google/go-querystring v1.0.0 // indirect
github.com/google/uuid v1.3.0
github.com/googleapis/go-type-adapters v1.0.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.1.0 // indirect
github.com/gorilla/websocket v1.4.2
github.com/improbable-eng/grpc-web v0.13.0
github.com/jackpal/gateway v1.0.7 // indirect
github.com/itchyny/gojq v0.12.9 // indirect
github.com/josephburnett/jd v1.6.1
github.com/kataras/muxie v1.1.1
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f
github.com/klauspost/compress v1.15.1 // indirect
Expand Down Expand Up @@ -78,11 +82,15 @@ require (
github.com/xor-gate/ar v0.0.0-20170530204233-5c72ae81e2b7
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77 // indirect
go.uber.org/zap v1.19.1
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783
golang.org/x/crypto v0.0.0-20210915214749-c084706c2272
// BUG(INFRA-1801): Last version that supports go1.16 is golang.org/x/net v0.0.0-20211020060615-d418f374d309
golang.org/x/net v0.0.0-20211020060615-d418f374d309
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect
// BUG(INFRA-1801): Last version that supports go1.16 is golang.org/x/sys v0.0.0-20220908164124-27713097b956
golang.org/x/sys v0.0.0-20220908164124-27713097b956 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/tools v0.1.9 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.100.0
google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c // indirect
Expand Down
Loading

0 comments on commit 79a8285

Please sign in to comment.