mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-05-14 11:53:24 +02:00
Bumps `github.com/avast/retry-go` v4.7.0 -> v5.0.0, `golangci-lint` v2.11.4 -> v2.12.2 (aligns with gitea/gitea), and pins `govulncheck` to v1.3.0. - `retry-go` v5 replaces the package-level `retry.Do(fn, opts...)` with a builder API `retry.New(opts...).Do(fn)`. The single call site in `internal/pkg/report/reporter.go` was migrated. - `golangci-lint` v2.12.2 surfaces three new findings in `act/` (modernize/slicesbackward, govet/inline): one backward loop now uses `slices.Backward`, and the deprecated `reflect.Ptr` alias is replaced with `reflect.Pointer`. - `go.mod`: the two direct-`require` blocks are merged into one, and a stray `gopkg.in/yaml.v3 // indirect` is moved into the indirect block. Purely cosmetic; `go.sum` is unchanged. --- This PR was written with the help of Claude Opus 4.7 Reviewed-on: https://gitea.com/gitea/runner/pulls/965 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-committed-by: silverwind <me@silverwind.io>
61 lines
1.1 KiB
Go
61 lines
1.1 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// Copyright 2020 The nektos/act Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package common
|
|
|
|
import "slices"
|
|
|
|
// CartesianProduct takes map of lists and returns list of unique tuples
|
|
func CartesianProduct(mapOfLists map[string][]any) []map[string]any {
|
|
listNames := make([]string, 0)
|
|
lists := make([][]any, 0)
|
|
for k, v := range mapOfLists {
|
|
listNames = append(listNames, k)
|
|
lists = append(lists, v)
|
|
}
|
|
|
|
listCart := cartN(lists...)
|
|
|
|
rtn := make([]map[string]any, 0)
|
|
for _, list := range listCart {
|
|
vMap := make(map[string]any)
|
|
for i, v := range list {
|
|
vMap[listNames[i]] = v
|
|
}
|
|
rtn = append(rtn, vMap)
|
|
}
|
|
return rtn
|
|
}
|
|
|
|
func cartN(a ...[]any) [][]any {
|
|
c := 1
|
|
for _, a := range a {
|
|
c *= len(a)
|
|
}
|
|
if c == 0 || len(a) == 0 {
|
|
return nil
|
|
}
|
|
p := make([][]any, c)
|
|
b := make([]any, c*len(a))
|
|
n := make([]int, len(a))
|
|
s := 0
|
|
for i := range p {
|
|
e := s + len(a)
|
|
pi := b[s:e]
|
|
p[i] = pi
|
|
s = e
|
|
for j, n := range n {
|
|
pi[j] = a[j][n]
|
|
}
|
|
for j := range slices.Backward(n) {
|
|
n[j]++
|
|
if n[j] < len(a[j]) {
|
|
break
|
|
}
|
|
n[j] = 0
|
|
}
|
|
}
|
|
return p
|
|
}
|