Skip to content

Commit d168bfe

Browse files
committed
feat: Add issue template validation support.
1 parent 1a305c8 commit d168bfe

File tree

10 files changed

+300
-75
lines changed

10 files changed

+300
-75
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: release
1+
name: draft
22

33
on:
44
push:
@@ -7,6 +7,11 @@ on:
77
branches: [master]
88
types: [opened, reopened, synchronize]
99

10+
# Cancel old builds when pushing new commits.
11+
concurrency:
12+
group: draft-${{ github.event.pull_request.number || github.ref }}
13+
cancel-in-progress: true
14+
1015
jobs:
1116
release:
1217
uses: TokTok/ci-tools/.github/workflows/release-drafter.yml@master

.reviewable/completion.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// jshint esversion: 6
2+
3+
// This code will check that the pull request has been approved via GitHub
4+
// review approval by a minimum number of reviewers and by all assignees, and
5+
// that no changes were requested by any reviewers. Only reviewers with write
6+
// access to the repository are considered.
7+
//
8+
// This is very similar to GitHub's built-in branch protection option to require
9+
// pull request reviews before merging, but allows for much more flexibility and
10+
// customization.
11+
12+
// dependencies: lodash4
13+
14+
// Helper function to check if a user is a bot.
15+
function isBotAuthor(author) {
16+
return (
17+
author.username.endsWith("[bot]") || author.username.startsWith("toktok-")
18+
);
19+
}
20+
21+
function equals(a) {
22+
return (b) => a === b;
23+
}
24+
25+
// The number of approvals required to merge: at least 2 humans must approve the
26+
// code. If the author is a bot, then 2 approvals are required; otherwise, only
27+
// 1 approval is required (because 1 human wrote the code, so they approve).
28+
let numApprovalsRequired = isBotAuthor(review.pullRequest.author) ? 2 : 1;
29+
30+
const approvals = review.pullRequest.approvals;
31+
32+
let numApprovals = _.filter(approvals, equals("approved")).length;
33+
const numRejections = _.filter(approvals, equals("changes_requested")).length;
34+
35+
const discussionBlockers = _(review.discussions)
36+
.filter((x) => !x.resolved)
37+
.flatMap("participants")
38+
.filter((x) => !x.resolved)
39+
.map((user) => _.pick(user, "username"))
40+
.value();
41+
42+
let pendingReviewers = _(discussionBlockers)
43+
.map((user) => _.pick(user, "username"))
44+
.concat(review.pullRequest.requestedReviewers)
45+
.value();
46+
47+
const required = _.map(review.pullRequest.assignees, "username");
48+
_.pull(required, review.pullRequest.author.username);
49+
if (required.length) {
50+
numApprovalsRequired = _.max([required.length, numApprovalsRequired]);
51+
numApprovals =
52+
_(approvals).pick(required).filter(equals("approved")).size() +
53+
_.min([numApprovals, numApprovalsRequired - required.length]);
54+
pendingReviewers = _(required)
55+
.reject((username) => approvals[username] === "approved")
56+
.reject((username) => pendingReviewers.length && approvals[username])
57+
.map((username) => ({ username }))
58+
.concat(pendingReviewers)
59+
.value();
60+
}
61+
62+
pendingReviewers = _.uniqBy(pendingReviewers, "username");
63+
64+
const description =
65+
(numRejections ? `${numRejections} change requests, ` : "") +
66+
`${numApprovals} of ${numApprovalsRequired} approvals obtained`;
67+
const shortDescription =
68+
(numRejections ? `${numRejections} ✗, ` : "") +
69+
`${numApprovals} of ${numApprovalsRequired} ✓`;
70+
71+
return {
72+
completed: numApprovals >= numApprovalsRequired,
73+
description,
74+
shortDescription,
75+
pendingReviewers,
76+
};

.reviewable/settings.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Reviewable settings file. Read the docs at https://docs.reviewable.io/repositories.html#store-repository-settings-using-the-reviewable-directory
2+
approval-text: ":lgtm_strong:"
3+
github-status:
4+
updates: always

admin/org.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ teams:
6767
jin-eld: member
6868
kitech: member
6969
Mikhael-Danilov: member
70+
nickolay168: member
7071
nbraud: member
7172
nurupo: member
7273
Nyoroon: member
@@ -109,7 +110,6 @@ teams:
109110
parent: { name: "Contributors" }
110111
members:
111112
toktok-releaser: member
112-
iphydf: maintainer
113113

114114
"Reviewers":
115115
<<: *team

admin/repos.yaml

Lines changed: 75 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ _common:
4949
enforcement: "active"
5050
conditions:
5151
ref_name:
52-
exclude: []
52+
exclude:
53+
- "refs/heads/release/v*"
5354
include:
5455
- "~ALL"
5556
rules:
@@ -80,6 +81,38 @@ _common:
8081
bypass_mode: "always"
8182
current_user_can_bypass: "never"
8283

84+
"releases":
85+
target: "branch"
86+
enforcement: "active"
87+
conditions:
88+
ref_name:
89+
exclude: []
90+
include:
91+
- "refs/heads/release/v*"
92+
rules:
93+
- type: "deletion"
94+
- type: "non_fast_forward"
95+
- type: "creation"
96+
- type: "required_linear_history"
97+
- type: "required_signatures"
98+
- type: "pull_request"
99+
parameters:
100+
required_approving_review_count: 1
101+
dismiss_stale_reviews_on_push: false
102+
require_code_owner_review: true
103+
require_last_push_approval: false
104+
required_review_thread_resolution: true
105+
automatic_copilot_code_review_enabled: false
106+
allowed_merge_methods:
107+
- "squash"
108+
- "rebase"
109+
bypass_actors:
110+
# Automation
111+
- actor_id: 3772038
112+
actor_type: "Team"
113+
bypass_mode: "always"
114+
current_user_can_bypass: "never"
115+
83116
# GitHub Issue/PR labels.
84117
labels: &labels
85118
#############################################################################
@@ -301,7 +334,6 @@ ci-tools:
301334
- "common / restyled"
302335
- "release / update_release_draft"
303336
# Custom
304-
- "checks / check-release"
305337

306338
c-toxcore:
307339
editRepo:
@@ -353,16 +385,30 @@ c-toxcore:
353385
- "common / restyled"
354386
- "release / update_release_draft"
355387
# Custom
388+
- "Android (arm64-v8a)"
389+
- "Android (armeabi-v7a)"
390+
- "Android (x86)"
391+
- "Android (x86_64)"
356392
- "CodeFactor"
393+
- "Fuzzing (address)"
394+
- "Fuzzing (memory)"
395+
- "Fuzzing (undefined)"
396+
- "Linux (aarch64)"
397+
- "Linux (x86_64)"
398+
- "Prepare / Update nightly release tag"
399+
- "Prepare / Validate PR"
400+
- "Single file / Build"
401+
- "Source tarball / Build"
357402
- "TokTok.c-toxcore"
358403
- "TokTok.c-toxcore (vcpkg shared)"
359404
- "TokTok.c-toxcore (vcpkg static)"
405+
- "WebAssembly"
406+
- "Xcode Framework"
360407
- "analysis (autotools)"
361408
- "analysis (clang-tidy)"
362409
- "analysis (compcert)"
363410
- "analysis (cppcheck)"
364411
- "analysis (doxygen)"
365-
- "analysis (freebsd)"
366412
- "analysis (goblint)"
367413
- "analysis (infer)"
368414
- "analysis (misra)"
@@ -377,30 +423,35 @@ c-toxcore:
377423
- "build-netbsd"
378424
- "build-windows-msvc (2019)"
379425
- "build-windows-msvc (2022)"
380-
- "bazel-dbg"
381-
- "bazel-msan"
382-
- "bazel-opt"
383-
- "build-android"
384426
- "build-macos"
385427
- "checks / check-release"
386428
- "ci/circleci: bazel-asan"
429+
- "ci/circleci: bazel-dbg"
430+
- "ci/circleci: bazel-msan"
431+
- "ci/circleci: bazel-opt"
387432
- "ci/circleci: cimplefmt"
388433
- "ci/circleci: clang-analyze"
389434
- "ci/circleci: cpplint"
390435
- "ci/circleci: generate-events"
391436
- "ci/circleci: static-analysis"
392-
- "cimple"
437+
- "ci/circleci: cimple"
393438
- "circleci"
394439
- "coverage-linux"
395440
- "docker-bootstrap-node"
396441
- "docker-bootstrap-node-websocket"
397442
- "docker-clusterfuzz"
398443
- "docker-esp32"
399444
- "docker-fuzzer"
400-
- "docker-toxcore-js"
401445
- "docker-windows-mingw (32)"
402446
- "docker-windows-mingw (64)"
403447
- "freebsd"
448+
- "iOS (ios-arm64)"
449+
- "iOS (ios-armv7)"
450+
- "iOS (ios-armv7s)"
451+
- "iOS (iphonesimulator-arm64)"
452+
- "iOS (iphonesimulator-x86_64)"
453+
- "macOS (arm64)"
454+
- "macOS (x86_64)"
404455
- "mypy"
405456
- "sanitizer (asan)"
406457
- "sanitizer (tsan)"
@@ -608,7 +659,6 @@ hs-cimple:
608659
- "common / restyled"
609660
- "release / update_release_draft"
610661
# Custom
611-
- "bazel-opt"
612662
- "build / stack"
613663
- "checks / check-release"
614664

@@ -880,7 +930,6 @@ hs-tokstyle:
880930
- "common / restyled"
881931
- "release / update_release_draft"
882932
# Custom
883-
- "bazel-opt"
884933
- "build / stack"
885934
- "checks / check-release"
886935

@@ -996,11 +1045,6 @@ js-toxcore-c:
9961045
# Custom
9971046
- "DeepScan"
9981047
- "Hound"
999-
- "build (12.x)"
1000-
- "build (13.x)"
1001-
- "docker"
1002-
- "codecov/patch"
1003-
- "codecov/project"
10041048
- "security/snyk (TokTok)"
10051049

10061050
jvm-toxcore-c:
@@ -1059,8 +1103,6 @@ py-toxcore-c:
10591103
- "common / restyled"
10601104
- "release / update_release_draft"
10611105
# Custom
1062-
- "bazel-opt"
1063-
- "build_linux"
10641106
- "docker"
10651107

10661108
qTox:
@@ -1088,29 +1130,30 @@ qTox:
10881130
- "common / restyled"
10891131
- "release / update_release_draft"
10901132
# Custom
1091-
- "bazel-opt"
10921133
- "Alpine (full, Debug)"
10931134
- "Alpine (static) (Release)"
1094-
- "AppImage on Alpine (full, Release)"
1095-
- "Android (arm64-v8a, Release, 6.2.4)"
1135+
- "Android / Build (arm64-v8a, Release, 6.2.4)"
1136+
- "AppImage / Build on Alpine (x86_64)"
1137+
- "AppImage / Test on Ubuntu (x86_64)"
1138+
- "Build RPM package on Fedora"
10961139
- "Check for translatable strings"
10971140
- "Clang-Tidy"
10981141
- "Debian (minimal, Debug)"
10991142
- "Docs"
11001143
- "Fedora with ASAN (full, Debug)"
1101-
- "Flatpak"
1102-
- "Test AppImage"
1103-
- "Test Flatpak"
1104-
- "Test Windows (x86_64, Release)"
1105-
- "Test macOS distributable (arm64)"
1144+
- "Flatpak / Build (x86_64)"
1145+
- "Flatpak / Test (x86_64)"
1146+
- "Prepare / Update nightly release tag"
1147+
- "Prepare / Validate PR"
11061148
- "Ubuntu LTS (full, Release)"
1107-
- "Update nightly release tag"
1108-
- "Validate PR"
1109-
- "Verify release/signatures"
1110-
- "Windows (x86_64, Release)"
1111-
- "macOS distributable (arm64)"
1149+
- "WebAssembly"
1150+
- "Windows / Build (x86_64, Release)"
1151+
- "Windows / Test (x86_64, Release)"
1152+
- "ci/circleci: bazel-opt"
1153+
- "circleci"
1154+
- "macOS / Build (arm64, 10.15)"
11121155
- "macOS user (x86_64)"
1113-
- "release-soon / check"
1156+
- "netlify / deploy"
11141157

11151158
spec:
11161159
editRepo:
@@ -1223,7 +1266,6 @@ toxic:
12231266
# Custom
12241267
- "build"
12251268
- "build-static"
1226-
- "bazel-opt"
12271269
- "infer"
12281270
- "integration-test"
12291271

github-tools.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ library
126126
GitHub.Types.Events.WatchEvent
127127
GitHub.Types.Events.WorkflowJobEvent
128128
GitHub.Types.Events.WorkflowRunEvent
129+
GitHub.Types.IssueTemplate
130+
GitHub.Types.Json
129131
GitHub.Types.PayloadParser
130132
GitHub.Types.Settings
131133
GitHub.Types.Workflow

0 commit comments

Comments
 (0)