Skip to content

Commit cb392a5

Browse files
committed
Simplify
1 parent 0d4ac38 commit cb392a5

File tree

8 files changed

+13
-33
lines changed

8 files changed

+13
-33
lines changed

bot/go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ require (
1717
github.com/pmezard/go-difflib v1.0.0 // indirect
1818
github.com/sirupsen/logrus v1.9.3 // indirect
1919
golang.org/x/crypto v0.17.0 // indirect
20-
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
2120
golang.org/x/net v0.17.0 // indirect
2221
golang.org/x/sys v0.15.0 // indirect
2322
golang.org/x/term v0.15.0 // indirect

bot/go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU
8282
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
8383
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
8484
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
85-
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
86-
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
8785
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
8886
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
8987
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=

bot/internal/bot/backport.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@ import (
2525
"os/exec"
2626
"path"
2727
"regexp"
28+
"slices"
2829
"sort"
2930
"strconv"
3031
"strings"
3132
"text/template"
3233

33-
"github.com/gravitational/trace"
34-
"golang.org/x/exp/slices"
35-
3634
"github.com/gravitational/shared-workflows/bot/internal/github"
35+
"github.com/gravitational/trace"
3736
)
3837

3938
// Backport will create backport Pull Requests (if requested) when a Pull

bot/internal/bot/bloat.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import (
1010
"log"
1111
"os"
1212
"path/filepath"
13+
"slices"
1314
"strings"
1415
"unicode/utf8"
1516

1617
"github.com/gravitational/trace"
17-
"golang.org/x/exp/slices"
1818
)
1919

2020
const (
@@ -98,15 +98,15 @@ func (b *Bot) BloatCheck(ctx context.Context, baseStats, current string, artifac
9898
log.Printf("artifact %s has a current size of %d", artifact, stats.currentSize)
9999

100100
status := "✅"
101-
if skipped := slices.Contains(skip, artifact); skipped {
101+
if slices.Contains(skip, artifact) {
102102
status += " skipped by admin"
103103
} else {
104104
if stats.diff > int64(warnThreshold) {
105105
status = "⚠️"
106106
}
107107
if stats.diff > int64(errorThreshold) {
108108
status = "❌"
109-
failure = !skipped
109+
failure = true
110110
}
111111
}
112112

bot/internal/bot/bot.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ import (
2020
"context"
2121
"path/filepath"
2222
"regexp"
23+
"slices"
2324
"strings"
2425

25-
"github.com/gravitational/trace"
26-
"golang.org/x/exp/slices"
27-
2826
"github.com/gravitational/shared-workflows/bot/internal/env"
2927
"github.com/gravitational/shared-workflows/bot/internal/github"
3028
"github.com/gravitational/shared-workflows/bot/internal/review"
29+
"github.com/gravitational/trace"
3130
)
3231

3332
// isCRDRegex matches Teleport operator CRD file paths.

bot/internal/bot/changelog.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import (
2020
"context"
2121
"log"
2222
"regexp"
23+
"slices"
2324
"strings"
2425
"unicode"
2526

2627
"github.com/gravitational/trace"
27-
"golang.org/x/exp/slices"
2828
)
2929

3030
const NoChangelogLabel string = "no-changelog"

bot/internal/bot/skip.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package bot
33
import (
44
"context"
55
"log"
6+
"slices"
67
"strings"
78

89
"github.com/gravitational/trace"
9-
"golang.org/x/exp/slices"
1010
)
1111

1212
// skipItems finds any comments from an admin with the skipPrefix

bot/internal/review/review.go

+4-19
Original file line numberDiff line numberDiff line change
@@ -435,31 +435,15 @@ func (r *Assignments) CheckInternal(e *env.Environment, reviews []github.Review,
435435
return nil
436436
}
437437

438-
switch {
439-
case changes.Docs && changes.Code:
440-
log.Printf("Check: Found docs and code changes.")
441-
if err := r.checkInternalReviews(e, changes, reviews, files); err != nil {
442-
return trace.Wrap(err)
443-
}
444-
case !changes.Docs && changes.Code:
445-
log.Printf("Check: Found code changes.")
446-
if err := r.checkInternalReviews(e, changes, reviews, files); err != nil {
447-
return trace.Wrap(err)
448-
}
449-
case changes.Docs && !changes.Code:
450-
log.Printf("Check: Found docs changes.")
451-
if err := r.checkInternalReviews(e, changes, reviews, files); err != nil {
452-
return trace.Wrap(err)
453-
}
454438
// Strange state, an empty commit? Check admins.
455-
case !changes.Docs && !changes.Code:
456-
log.Printf("Check: Found no docs or code changes.")
439+
if !changes.Docs && !changes.Code {
440+
log.Printf("Check: Found no docs or code changes, requiring admin approvals")
457441
if checkN(r.GetAdminCheckers(e.Author), reviews) < 2 {
458442
return trace.BadParameter("requires two admin approvals")
459443
}
460444
}
461445

462-
return nil
446+
return trace.Wrap(r.checkInternalReviews(e, changes, reviews, files))
463447
}
464448

465449
func (r *Assignments) checkInternalReleaseReviews(reviews []github.Review) error {
@@ -484,6 +468,7 @@ func (r *Assignments) checkInternalReviews(e *env.Environment, changes env.Chang
484468
// Add them to set B, as docs reviewers are not required so long as we get
485469
// the appropriate number of approvals.
486470
if changes.Docs {
471+
log.Printf("Check: PR contains docs changes, adding docs reviewers to group 2")
487472
setB = append(setB, r.getDocsReviewers(e, files)...)
488473
}
489474

0 commit comments

Comments
 (0)