Skip to content

Commit 244c490

Browse files
authored
Merge branch 'main' into tt-1927-fix-nethermind-startup
2 parents 9eca8ce + d9a9a59 commit 244c490

File tree

12 files changed

+236
-81
lines changed

12 files changed

+236
-81
lines changed

.github/workflows/rc-breaking-changes.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ jobs:
1616
with:
1717
fetch-depth: 0
1818
fetch-tags: true
19-
- name: Set up Go 1.22.6
19+
- name: Set up Go 1.23.3
2020
uses: actions/setup-go@v5
2121
with:
22-
go-version: '1.22.6'
22+
go-version: '1.23.3'
2323
- name: Install gorelease tool
2424
run: |
2525
go install golang.org/x/exp/cmd/gorelease@latest
2626
- name: Run Breaking Changes Script
2727
run: |
28-
go run ./tools/breakingchanges/cmd/main.go --ignore tools
28+
cd ./tools/breakingchanges
29+
go mod tidy
30+
go run cmd/main.go --ignore tools --root ../../

.github/workflows/release-go-module.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
fi
5252
5353
# Extract the version part of the last tag
54-
LAST_TAG_VERSION="${LAST_TAG##*/}"
54+
LAST_TAG_VERSION="${LAST_TAG##*/}"
5555
echo "Last tag version: $LAST_TAG_VERSION"
5656
echo "LAST_TAG_VERSION=${LAST_TAG_VERSION}" >> "$GITHUB_ENV"
5757
@@ -69,7 +69,7 @@ jobs:
6969
- name: Set up Go
7070
uses: actions/setup-go@v5
7171
with:
72-
go-version: '1.22.6'
72+
go-version: '1.23.3'
7373
- name: Install gorelease tool
7474
run: |
7575
go install golang.org/x/exp/cmd/gorelease@latest

framework/examples/myproject/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/ethereum/go-ethereum v1.14.11
1515
github.com/go-resty/resty/v2 v2.15.3
1616
github.com/smartcontractkit/chainlink-testing-framework/framework v0.0.0-00010101000000-000000000000
17-
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.9
17+
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.10
1818
github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.2
1919
github.com/stretchr/testify v1.10.0
2020
github.com/testcontainers/testcontainers-go v0.34.0

framework/examples/myproject/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,8 +856,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ
856856
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
857857
github.com/smartcontractkit/chainlink-testing-framework/lib/grafana v1.50.0 h1:VIxK8u0Jd0Q/VuhmsNm6Bls6Tb31H/sA3A/rbc5hnhg=
858858
github.com/smartcontractkit/chainlink-testing-framework/lib/grafana v1.50.0/go.mod h1:lyAu+oMXdNUzEDScj2DXB2IueY+SDXPPfyl/kb63tMM=
859-
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.9 h1:yB1x5UXvpZNka+5h57yo1/GrKfXKCqMzChCISpldZx4=
860-
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.9/go.mod h1:lJk0atEJ5Zyo3Tqrmf1Pl9jUEe79EgDb9bD3K5OTUBI=
859+
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.10 h1:Yf+n3T/fnUWcYyfe7bsygV4sWAkNo0QhN58APJFIKIc=
860+
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.10/go.mod h1:05duR85P8YHuIfIkA7sn2bvrhKo/pDpFKV2rliYHNOo=
861861
github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js=
862862
github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0=
863863
github.com/sony/gobreaker v0.5.0 h1:dRCvqm0P490vZPmy7ppEk2qCnCieBooFJ+YoXGYB+yg=

lib/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ require (
3232
github.com/prometheus/common v0.60.0
3333
github.com/rs/zerolog v1.33.0
3434
github.com/slack-go/slack v0.15.0
35-
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.9
35+
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.10
3636
github.com/spf13/cobra v1.8.1
3737
github.com/spf13/pflag v1.0.5
3838
github.com/stretchr/testify v1.9.0

lib/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ
463463
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
464464
github.com/slack-go/slack v0.15.0 h1:LE2lj2y9vqqiOf+qIIy0GvEoxgF1N5yLGZffmEZykt0=
465465
github.com/slack-go/slack v0.15.0/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw=
466-
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.9 h1:yB1x5UXvpZNka+5h57yo1/GrKfXKCqMzChCISpldZx4=
467-
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.9/go.mod h1:lJk0atEJ5Zyo3Tqrmf1Pl9jUEe79EgDb9bD3K5OTUBI=
466+
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.10 h1:Yf+n3T/fnUWcYyfe7bsygV4sWAkNo0QhN58APJFIKIc=
467+
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.10/go.mod h1:05duR85P8YHuIfIkA7sn2bvrhKo/pDpFKV2rliYHNOo=
468468
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
469469
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
470470
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=

tools/breakingchanges/cmd/main.go

Lines changed: 104 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ import (
1010
"os/exec"
1111
"path/filepath"
1212
"regexp"
13+
"sort"
1314
"strings"
15+
16+
"github.com/Masterminds/semver/v3"
17+
"golang.org/x/mod/modfile"
1418
)
1519

1620
const (
@@ -47,31 +51,101 @@ func findGoModDirs(rootFolder, subDir string) ([]string, error) {
4751
return goModDirs, nil
4852
}
4953

50-
func getLastTag(pathPrefix string) (string, error) {
54+
func getRetractedTags(goModPath string) ([]*semver.Constraints, error) {
55+
data, err := os.ReadFile(goModPath)
56+
if err != nil {
57+
return nil, fmt.Errorf("error reading go.mod file: %w", err)
58+
}
59+
60+
modFile, err := modfile.Parse("go.mod", data, nil)
61+
if err != nil {
62+
return nil, fmt.Errorf("error parsing go.mod file: %w", err)
63+
}
64+
65+
var retractedTags []*semver.Constraints
66+
for _, retract := range modFile.Retract {
67+
lowVersion, err := semver.NewVersion(retract.Low)
68+
if err != nil {
69+
return nil, fmt.Errorf("error parsing retracted version: %w", err)
70+
}
71+
highVersion, err := semver.NewVersion(retract.High)
72+
if err != nil {
73+
return nil, fmt.Errorf("error parsing retracted version: %w", err)
74+
}
75+
constraint, err := semver.NewConstraint(fmt.Sprintf(">= %s, <= %s", lowVersion.String(), highVersion.String()))
76+
if err != nil {
77+
return nil, fmt.Errorf("error parsing retracted version: %w", err)
78+
}
79+
retractedTags = append(retractedTags, constraint)
80+
fmt.Printf("Retracted version: %s\n", constraint)
81+
}
82+
83+
return retractedTags, nil
84+
}
85+
86+
func getLatestTag(pathPrefix string, retractedTags []*semver.Constraints) (string, error) {
87+
// use regex to find exact matches, as otherwise might include pre-release versions
88+
// or versions that partially match the path prefix, e.g. when seraching for 'lib'
89+
// we won't make sure we won't include tags like `lib/grafana/v1.0.0`
90+
grepRegex := fmt.Sprintf("^%s/v[0-9]+\\.[0-9]+\\.[0-9]+$", pathPrefix)
91+
5192
//nolint
52-
cmd := exec.Command("sh", "-c", fmt.Sprintf("git tag | grep '%s' | tail -1", pathPrefix))
93+
cmd := exec.Command("sh", "-c", fmt.Sprintf("git tag | grep -E '%s'", grepRegex))
5394
var out bytes.Buffer
5495
cmd.Stdout = &out
5596
err := cmd.Run()
5697
if err != nil {
5798
return "", fmt.Errorf("error fetching tags: %w", err)
5899
}
59100

60-
tag := strings.TrimSpace(out.String())
61-
if tag == "" {
62-
return "", nil
101+
tags := strings.Split(strings.TrimSpace(out.String()), "\n")
102+
if len(tags) == 0 {
103+
return "", fmt.Errorf("no tags found for regex: %s", grepRegex)
63104
}
64105

65-
// Use regex to find the version tag starting with 'v'
66-
re := regexp.MustCompile(`v\d+\.\d+\.\d+`)
67-
matches := re.FindStringSubmatch(tag)
68-
if len(matches) > 0 {
69-
tag = matches[0]
70-
} else {
71-
return "", fmt.Errorf("no valid version tag found in '%s'", tag)
106+
// Parse the tags into semver versions
107+
var allTags []*semver.Version
108+
for _, tag := range tags {
109+
v, err := semver.NewVersion(strings.TrimPrefix(tag, pathPrefix+"/"))
110+
if err != nil {
111+
return "", fmt.Errorf("error parsing version tag: %w", err)
112+
}
113+
allTags = append(allTags, v)
114+
}
115+
116+
// Sort the tags in descending order
117+
sort.Sort(sort.Reverse(semver.Collection(allTags)))
118+
119+
if len(retractedTags) == 0 {
120+
tag := fmt.Sprintf("v%s", allTags[0].String())
121+
return tag, nil
122+
}
123+
124+
// Find the latest tag that doesn't match any of the retracted tags
125+
for _, tag := range allTags {
126+
isRetracted := false
127+
for _, constraint := range retractedTags {
128+
if constraint.Check(tag) {
129+
isRetracted = true
130+
break
131+
}
132+
}
133+
134+
if !isRetracted {
135+
tag := fmt.Sprintf("v%s", tag.String())
136+
fmt.Printf("Found non-retracted tag: %s\n", tag)
137+
return tag, nil
138+
}
72139
}
73140

74-
return tag, nil
141+
fmt.Println("No non-retracted tags found")
142+
fmt.Printf("All tags: %s\n", strings.Join(tags, ", "))
143+
fmt.Println("Retracted tags:")
144+
for _, constraint := range retractedTags {
145+
fmt.Printf("%s\n", constraint)
146+
}
147+
148+
return "", fmt.Errorf("failed to find a non-retracted tag got path prefix: %s", pathPrefix)
75149
}
76150

77151
func checkBreakingChanges(tag string) (string, string, error) {
@@ -94,13 +168,15 @@ func getIgnoredDirs(flag *string) []string {
94168
return ignoredDirs
95169
}
96170

97-
func isIgnoredDirPrefix(pathPrefix string, ignoredDirs []string) bool {
171+
func isIgnoredDirRegex(pathPrefix string, ignoredDirs []string) bool {
98172
for _, d := range ignoredDirs {
99173
if d == "" {
100174
continue
101175
}
102-
fmt.Printf("Checking prefix: %s, path: %s\n", d, pathPrefix)
103-
if strings.HasPrefix(pathPrefix, d) {
176+
177+
fmt.Printf("Checking regex: %s, path: %s\n", d, pathPrefix)
178+
re := regexp.MustCompile(d)
179+
if re.MatchString(pathPrefix) {
104180
fmt.Printf("Path is ignored, skipping: %s\n", pathPrefix)
105181
return true
106182
}
@@ -111,7 +187,7 @@ func isIgnoredDirPrefix(pathPrefix string, ignoredDirs []string) bool {
111187
func main() {
112188
rootFolder := flag.String("root", ".", "The root folder to start scanning from")
113189
subDir := flag.String("subdir", "", "The subdirectory inside the root folder to scan for modules")
114-
ignoreDirs := flag.String("ignore", "", "Ignore directory paths starting with prefix")
190+
ignoreDirs := flag.String("ignore", "", "Ignore directory paths matching regex (comma-separated)")
115191
flag.Parse()
116192

117193
absRootFolder, err := filepath.Abs(*rootFolder)
@@ -133,24 +209,30 @@ func main() {
133209
// Convert the stripped path back to absolute
134210
pathPrefix := strings.TrimPrefix(dirPath, absRootFolder+string(os.PathSeparator))
135211

136-
if isIgnoredDirPrefix(pathPrefix, ignoredDirs) {
212+
if isIgnoredDirRegex(pathPrefix, ignoredDirs) {
213+
continue
214+
}
215+
216+
retractedVersions, err := getRetractedTags(filepath.Join(dirPath, "go.mod"))
217+
if err != nil {
218+
fmt.Printf("Error getting retracted versions: %v\n", err)
137219
continue
138220
}
139221

140-
lastTag, err := getLastTag(pathPrefix)
222+
latestTag, err := getLatestTag(pathPrefix, retractedVersions)
141223
if err != nil {
142-
fmt.Printf("Error finding last tag: %v\n", err)
224+
fmt.Printf("Error finding latest tag: %v\n", err)
143225
continue
144226
}
145227

146-
if lastTag != "" {
228+
if latestTag != "" {
147229
fmt.Printf("%sProcessing directory: %s%s\n", Yellow, dirPath, Reset)
148230
if err := os.Chdir(dirPath); err != nil {
149231
fmt.Printf("Error changing directory: %v\n", err)
150232
continue
151233
}
152234

153-
stdout, stderr, err := checkBreakingChanges(lastTag)
235+
stdout, stderr, err := checkBreakingChanges(latestTag)
154236
if err != nil {
155237
fmt.Printf("Error running gorelease: %v\n", err)
156238
breakingChanges = true

tools/breakingchanges/go.mod

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
module github.com/smartcontractkit/chainlink-testing-framework/tools/breakingchanges
22

3-
go 1.22.6
3+
go 1.23.3
44

55
retract [v1.999.0-test-release, v1.999.999-test-release]
6+
7+
require (
8+
github.com/Masterminds/semver/v3 v3.3.1
9+
golang.org/x/mod v0.22.0
10+
)

tools/breakingchanges/go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4=
2+
github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
3+
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
4+
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=

tools/flakeguard/reports/data.go

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package reports
22

33
import (
44
"fmt"
5-
"math"
65
"sort"
76
"strings"
87
"time"
@@ -121,6 +120,7 @@ type SplunkTestResultEvent struct {
121120

122121
func GenerateSummaryData(tests []TestResult, maxPassRatio float64) SummaryData {
123122
var runs, passes, fails, skips, panickedTests, racedTests, flakyTests, skippedTests int
123+
124124
for _, result := range tests {
125125
runs += result.Runs
126126
passes += result.Successes
@@ -143,30 +143,47 @@ func GenerateSummaryData(tests []TestResult, maxPassRatio float64) SummaryData {
143143
}
144144
}
145145

146+
// Calculate the raw pass ratio
146147
passPercentage := 100.0
147-
flakePercentage := 0.0
148-
149148
if runs > 0 {
150-
passPercentage = math.Floor((float64(passes)/float64(runs)*100)*100) / 100 // Truncate to 2 decimal places
149+
passPercentage = (float64(passes) / float64(runs)) * 100
151150
}
152151

152+
// Calculate the raw flake ratio
153153
totalTests := len(tests)
154+
flakePercentage := 0.0
154155
if totalTests > 0 {
155-
flakePercentage = math.Floor((float64(flakyTests)/float64(totalTests)*100)*100) / 100 // Truncate to 2 decimal places
156+
flakePercentage = (float64(flakyTests) / float64(totalTests)) * 100
156157
}
157158

159+
// Helper function to convert a float ratio into a trimmed string
160+
formatRatio := func(val float64) string {
161+
// Format with 4 decimal places
162+
s := fmt.Sprintf("%.4f", val)
163+
// Trim trailing zeros
164+
s = strings.TrimRight(s, "0")
165+
// Trim trailing '.' if needed (in case we have an integer)
166+
s = strings.TrimRight(s, ".")
167+
return s + "%"
168+
}
169+
170+
passRatioStr := formatRatio(passPercentage)
171+
flakeTestRatioStr := formatRatio(flakePercentage)
172+
158173
return SummaryData{
159174
TotalTests: totalTests,
160175
PanickedTests: panickedTests,
161176
RacedTests: racedTests,
162177
FlakyTests: flakyTests,
163-
FlakyTestRatio: fmt.Sprintf("%.2f%%", flakePercentage),
164-
TotalRuns: runs,
165-
PassedRuns: passes,
166-
FailedRuns: fails,
167-
SkippedRuns: skips,
168-
PassRatio: fmt.Sprintf("%.2f%%", passPercentage),
169-
MaxPassRatio: maxPassRatio,
178+
FlakyTestRatio: flakeTestRatioStr,
179+
180+
TotalRuns: runs,
181+
PassedRuns: passes,
182+
FailedRuns: fails,
183+
SkippedRuns: skips,
184+
185+
PassRatio: passRatioStr,
186+
MaxPassRatio: maxPassRatio,
170187
}
171188
}
172189

0 commit comments

Comments
 (0)