Files
zeekayandHanzo Dev 873e28c9b4 fork act model + exprparser from gitea.com/gitea/runner
The forge needs to PARSE and EVALUATE workflows: model, exprparser, and the two
small helper packages they use. It does not need to run them — that is the
runner process, and a container runtime is 12000 of the 15754 lines in the
upstream act subtree.

So this is the 3619 lines that a forge actually calls, not a fork of the whole
engine. gitea.com/gitea/runner was the last gitea.com dependency in
hanzoai/git.

Pins match upstream (actionlint v1.7.12 with go.yaml.in/yaml/v4 v4.0.0-rc.3 —
the two are version-coupled and a free resolution of actionlint does not build)
and go 1.26, which exprparser needs for reflect.Fields.

Upstream MIT notices retained; ours added above them.

All four packages green.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-27 18:44:23 -07:00

62 lines
1.2 KiB
Go

// Copyright 2026 Hanzo AI, Inc. All rights reserved.
// 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
}