MCPcopy
hub / github.com/nektos/act / updateTestExpressionWorkflow

Function updateTestExpressionWorkflow

pkg/runner/expression_test.go:271–319  ·  view source on GitHub ↗
(t *testing.T, tables []struct {
	in  string
	out string
}, rc *RunContext)

Source from the content-addressed store, hash-verified

269}
270
271func updateTestExpressionWorkflow(t *testing.T, tables []struct {
272 in string
273 out string
274}, rc *RunContext) {
275 var envs string
276 keys := make([]string, 0, len(rc.Env))
277 for k := range rc.Env {
278 keys = append(keys, k)
279 }
280 sort.Strings(keys)
281 for _, k := range keys {
282 envs += fmt.Sprintf(" %s: %s\n", k, rc.Env[k])
283 }
284
285 // editorconfig-checker-disable
286 workflow := fmt.Sprintf(`
287name: "Test how expressions are handled on GitHub"
288on: push
289
290env:
291%s
292
293jobs:
294 test-espressions:
295 runs-on: ubuntu-latest
296 steps:
297`, envs)
298 // editorconfig-checker-enable
299 for _, table := range tables {
300 expressionPattern := regexp.MustCompile(`\${{\s*(.+?)\s*}}`)
301
302 expr := expressionPattern.ReplaceAllStringFunc(table.in, func(match string) string {
303 return fmt.Sprintf("€{{ %s }}", expressionPattern.ReplaceAllString(match, "$1"))
304 })
305 name := fmt.Sprintf(`%s -> %s should be equal to %s`, expr, table.in, table.out)
306 echo := `run: echo "Done "`
307 workflow += fmt.Sprintf("\n - name: %s\n %s\n", name, echo)
308 }
309
310 file, err := os.Create("../../.github/workflows/test-expressions.yml")
311 if err != nil {
312 t.Fatal(err)
313 }
314
315 _, err = file.WriteString(workflow)
316 if err != nil {
317 t.Fatal(err)
318 }
319}
320
321func TestRewriteSubExpression(t *testing.T) {
322 table := []struct {

Callers 1

TestInterpolateFunction · 0.85

Calls 2

makeFunction · 0.85
CreateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…