1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-06 17:40:58 +00:00

chore(tests): add coverage for ./pkg/runner (#202)

Only changes test files.

---

- remove tests specific to running on a host with no container
  they are the same as with the containers (TestRunEventHostEnvironment)
- prefix the name of the tests with a distinctive name to
  more easily run them together
- use code.forgejo.org/oci images whereever possible
- remove some tests that are either
  - difficult to understand (ancient bugs)
  - not yet well understood (related to reusable workflows)
  - depend on github (generation of workflows to be run on the fly
    e.g. updateTestIfWorkflow)
- fix the TestSanitizeNetworkAlias tests that were not run
  and make them easier to debug
- disable tests of options that are forbidden in Forgejo Actions
  (testdata/container-hostname/push.yml)

Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/202
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
Earl Warren 2025-07-28 06:18:46 +00:00 committed by earl-warren
parent 30ea23384a
commit 87d973b894
65 changed files with 218 additions and 656 deletions

View file

@ -5,15 +5,14 @@ jobs:
with-volumes:
runs-on: ubuntu-latest
container:
image: node:16-buster-slim
image: code.forgejo.org/oci/node:22-bookworm
volumes:
- my_docker_volume:/path/to/volume
- /path/to/nonexist/directory
- /proc/sys/kernel/random/boot_id:/current/boot_id
steps:
- run: |
set -e
set -ex
test -d /path/to/volume
test "$(cat /proc/sys/kernel/random/boot_id)" = "$(cat /current/boot_id)"
test -d /path/to/nonexist/directory

View file

@ -19,7 +19,7 @@ func TestActionCache(t *testing.T) {
}
ctx := context.Background()
cacheDir := "nektos/act-test-actions"
repo := "https://github.com/nektos/act-test-actions"
repo := "https://code.forgejo.org/forgejo/act-test-actions"
refs := []struct {
Name string
CacheDir string

View file

@ -14,7 +14,7 @@ import (
"github.com/nektos/act/pkg/model"
)
func TestSetEnv(t *testing.T) {
func TestCommandSetEnv(t *testing.T) {
a := assert.New(t)
ctx := context.Background()
rc := new(RunContext)
@ -24,7 +24,7 @@ func TestSetEnv(t *testing.T) {
a.Equal("valz", rc.Env["x"])
}
func TestSetOutput(t *testing.T) {
func TestCommandSetOutput(t *testing.T) {
a := assert.New(t)
ctx := context.Background()
rc := new(RunContext)
@ -54,7 +54,7 @@ func TestSetOutput(t *testing.T) {
a.Equal("percent2%\ntest", rc.StepResults["my-step"].Outputs["x:,\n%\r:"])
}
func TestAddpath(t *testing.T) {
func TestCommandAddpath(t *testing.T) {
a := assert.New(t)
ctx := context.Background()
rc := new(RunContext)
@ -67,7 +67,7 @@ func TestAddpath(t *testing.T) {
a.Equal("/boo", rc.ExtraPath[0])
}
func TestStopCommands(t *testing.T) {
func TestCommandStopCommands(t *testing.T) {
logger, hook := test.NewNullLogger()
a := assert.New(t)
@ -92,7 +92,7 @@ func TestStopCommands(t *testing.T) {
a.Contains(messages, " \U00002699 ::set-env name=x::abcd\n")
}
func TestAddpathADO(t *testing.T) {
func TestCommandAddpathADO(t *testing.T) {
a := assert.New(t)
ctx := context.Background()
rc := new(RunContext)
@ -105,7 +105,7 @@ func TestAddpathADO(t *testing.T) {
a.Equal("/boo", rc.ExtraPath[0])
}
func TestAddmask(t *testing.T) {
func TestCommandAddmask(t *testing.T) {
logger, hook := test.NewNullLogger()
a := assert.New(t)
@ -147,7 +147,7 @@ func captureOutput(t *testing.T, f func()) string {
return out
}
func TestAddmaskUsemask(t *testing.T) {
func TestCommandAddmaskUsemask(t *testing.T) {
rc := new(RunContext)
rc.StepResults = make(map[string]*model.StepResult)
rc.CurrentStep = "my-step"
@ -174,7 +174,7 @@ func TestAddmaskUsemask(t *testing.T) {
a.Equal("[testjob] \U00002699 ***\n[testjob] \U00002699 ::set-output:: = token=***\n", re)
}
func TestSaveState(t *testing.T) {
func TestCommandSaveState(t *testing.T) {
rc := &RunContext{
CurrentStep: "step",
StepResults: map[string]*model.StepResult{},

View file

@ -2,10 +2,6 @@ package runner
import (
"context"
"fmt"
"os"
"regexp"
"sort"
"testing"
"github.com/nektos/act/pkg/exprparser"
@ -78,7 +74,7 @@ func createRunContext(t *testing.T) *RunContext {
}
}
func TestEvaluateRunContext(t *testing.T) {
func TestExpressionEvaluateRunContext(t *testing.T) {
rc := createRunContext(t)
ee := rc.NewExpressionEvaluator(context.Background())
@ -101,8 +97,8 @@ func TestEvaluateRunContext(t *testing.T) {
{"join(fromJSON('[\"hello\"]'),'octocat')", "hello", ""},
{"join(fromJSON('[\"hello\",\"mona\",\"the\"]'),'octocat')", "hellooctocatmonaoctocatthe", ""},
{"join('hello','mona')", "hello", ""},
{"toJSON(env)", "{\n \"ACT\": \"true\",\n \"key\": \"value\"\n}", ""},
{"toJson(env)", "{\n \"ACT\": \"true\",\n \"key\": \"value\"\n}", ""},
{"toJSON(env)", "{\n \"ACT\": \"true\",\n \"ACT_SKIP_CHECKOUT\": \"true\",\n \"key\": \"value\"\n}", ""},
{"toJson(env)", "{\n \"ACT\": \"true\",\n \"ACT_SKIP_CHECKOUT\": \"true\",\n \"key\": \"value\"\n}", ""},
{"(fromJSON('{\"foo\":\"bar\"}')).foo", "bar", ""},
{"(fromJson('{\"foo\":\"bar\"}')).foo", "bar", ""},
{"(fromJson('[\"foo\",\"bar\"]'))[1]", "bar", ""},
@ -153,7 +149,7 @@ func TestEvaluateRunContext(t *testing.T) {
}
}
func TestEvaluateStep(t *testing.T) {
func TestExpressionEvaluateStep(t *testing.T) {
rc := createRunContext(t)
step := &stepRun{
RunContext: rc,
@ -193,7 +189,7 @@ func TestEvaluateStep(t *testing.T) {
}
}
func TestInterpolate(t *testing.T) {
func TestExpressionInterpolate(t *testing.T) {
rc := &RunContext{
Config: &Config{
Workdir: ".",
@ -260,7 +256,6 @@ func TestInterpolate(t *testing.T) {
{"${{ fromJSON('{}') < 2 }}", "false"},
}
updateTestExpressionWorkflow(t, tables, rc)
for _, table := range tables {
table := table
t.Run("interpolate", func(t *testing.T) {
@ -271,57 +266,7 @@ func TestInterpolate(t *testing.T) {
}
}
func updateTestExpressionWorkflow(t *testing.T, tables []struct {
in string
out string
}, rc *RunContext) {
var envs string
keys := make([]string, 0, len(rc.Env))
for k := range rc.Env {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
envs += fmt.Sprintf(" %s: %s\n", k, rc.Env[k])
}
// editorconfig-checker-disable
workflow := fmt.Sprintf(`
name: "Test how expressions are handled on GitHub"
on: push
env:
%s
jobs:
test-espressions:
runs-on: ubuntu-latest
steps:
`, envs)
// editorconfig-checker-enable
for _, table := range tables {
expressionPattern := regexp.MustCompile(`\${{\s*(.+?)\s*}}`)
expr := expressionPattern.ReplaceAllStringFunc(table.in, func(match string) string {
return fmt.Sprintf("€{{ %s }}", expressionPattern.ReplaceAllString(match, "$1"))
})
name := fmt.Sprintf(`%s -> %s should be equal to %s`, expr, table.in, table.out)
echo := `run: echo "Done "`
workflow += fmt.Sprintf("\n - name: %s\n %s\n", name, echo)
}
file, err := os.Create("../../.github/workflows/test-expressions.yml")
if err != nil {
t.Fatal(err)
}
_, err = file.WriteString(workflow)
if err != nil {
t.Fatal(err)
}
}
func TestRewriteSubExpression(t *testing.T) {
func TestExpressionRewriteSubExpression(t *testing.T) {
table := []struct {
in string
out string
@ -351,7 +296,7 @@ func TestRewriteSubExpression(t *testing.T) {
}
}
func TestRewriteSubExpressionForceFormat(t *testing.T) {
func TestExpressionRewriteSubExpressionForceFormat(t *testing.T) {
table := []struct {
in string
out string

View file

@ -66,7 +66,6 @@ func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executo
stepModel.Number = i
step, err := sf.newStep(stepModel, rc)
if err != nil {
return common.NewErrorExecutor(err)
}

View file

@ -95,7 +95,7 @@ func (sfm *stepFactoryMock) newStep(model *model.Step, rc *RunContext) (step, er
return args.Get(0).(step), args.Error(1)
}
func TestNewJobExecutor(t *testing.T) {
func TestJobExecutorNewJobExecutor(t *testing.T) {
table := []struct {
name string
steps []*model.Step

View file

@ -5,10 +5,8 @@ import (
"context"
"fmt"
"os"
"regexp"
"runtime"
"slices"
"sort"
"strings"
"testing"
@ -158,7 +156,6 @@ func TestRunContext_EvalBool(t *testing.T) {
{in: "INVALID_EXPRESSION", wantErr: true},
}
updateTestIfWorkflow(t, tables, rc)
for _, table := range tables {
table := table
t.Run(table.in, func(t *testing.T) {
@ -173,67 +170,6 @@ func TestRunContext_EvalBool(t *testing.T) {
}
}
func updateTestIfWorkflow(t *testing.T, tables []struct {
in string
out bool
wantErr bool
}, rc *RunContext) {
var envs string
keys := make([]string, 0, len(rc.Env))
for k := range rc.Env {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
envs += fmt.Sprintf(" %s: %s\n", k, rc.Env[k])
}
// editorconfig-checker-disable
workflow := fmt.Sprintf(`
name: "Test what expressions result in true and false on GitHub"
on: push
env:
%s
jobs:
test-ifs-and-buts:
runs-on: ubuntu-latest
steps:
`, envs)
// editorconfig-checker-enable
for i, table := range tables {
if table.wantErr || strings.HasPrefix(table.in, "github.actor") {
continue
}
expressionPattern := regexp.MustCompile(`\${{\s*(.+?)\s*}}`)
expr := expressionPattern.ReplaceAllStringFunc(table.in, func(match string) string {
return fmt.Sprintf("€{{ %s }}", expressionPattern.ReplaceAllString(match, "$1"))
})
echo := fmt.Sprintf(`run: echo "%s should be false, but was evaluated to true;" exit 1;`, table.in)
name := fmt.Sprintf(`"❌ I should not run, expr: %s"`, expr)
if table.out {
echo = `run: echo OK`
name = fmt.Sprintf(`"✅ I should run, expr: %s"`, expr)
}
workflow += fmt.Sprintf("\n - name: %s\n id: step%d\n if: %s\n %s\n", name, i, table.in, echo)
if table.out {
workflow += fmt.Sprintf("\n - name: \"Double checking expr: %s\"\n if: steps.step%d.conclusion == 'skipped'\n run: echo \"%s should have been true, but wasn't\"\n", expr, i, table.in)
}
}
file, err := os.Create("../../.github/workflows/test-if.yml")
if err != nil {
t.Fatal(err)
}
_, err = file.WriteString(workflow)
if err != nil {
t.Fatal(err)
}
}
func TestRunContext_GetBindsAndMounts(t *testing.T) {
rctemplate := &RunContext{
Name: "TestRCName",
@ -347,7 +283,7 @@ func TestRunContext_GetBindsAndMounts(t *testing.T) {
})
}
func TestGetGitHubContext(t *testing.T) {
func TestRunContext_GetGitHubContext(t *testing.T) {
log.SetLevel(log.DebugLevel)
cwd, err := os.Getwd()
@ -382,12 +318,12 @@ func TestGetGitHubContext(t *testing.T) {
actor = a
}
repo := "nektos/act"
repo := "forgejo/act"
if r := os.Getenv("ACT_REPOSITORY"); r != "" {
repo = r
}
owner := "nektos"
owner := "code.forgejo.org"
if o := os.Getenv("ACT_OWNER"); o != "" {
owner = o
}
@ -396,7 +332,7 @@ func TestGetGitHubContext(t *testing.T) {
assert.Equal(t, ghc.RunNumber, "1")
assert.Equal(t, ghc.RetentionDays, "0")
assert.Equal(t, ghc.Actor, actor)
assert.Equal(t, ghc.Repository, repo)
assert.True(t, strings.HasSuffix(ghc.Repository, repo))
assert.Equal(t, ghc.RepositoryOwner, owner)
assert.Equal(t, ghc.RunnerPerflog, "/dev/null")
assert.Equal(t, ghc.Token, rc.Config.Secrets["GITHUB_TOKEN"])
@ -404,7 +340,7 @@ func TestGetGitHubContext(t *testing.T) {
assert.Equal(t, ghc.Job, "job1")
}
func TestGetGithubContextRef(t *testing.T) {
func TestRunContext_GetGithubContextRef(t *testing.T) {
table := []struct {
event string
json string
@ -468,7 +404,7 @@ func createIfTestRunContext(jobs map[string]*model.Job) *RunContext {
return rc
}
func createJob(t *testing.T, input string, result string) *model.Job {
func createJob(t *testing.T, input, result string) *model.Job {
var job *model.Job
err := yaml.Unmarshal([]byte(input), &job)
assert.NoError(t, err)
@ -477,7 +413,7 @@ func createJob(t *testing.T, input string, result string) *model.Job {
return job
}
func TestRunContextRunsOnPlatformNames(t *testing.T) {
func TestRunContext_RunsOnPlatformNames(t *testing.T) {
log.SetLevel(log.DebugLevel)
assertObject := assert.New(t)
@ -524,7 +460,7 @@ func TestRunContextRunsOnPlatformNames(t *testing.T) {
assertObject.Equal([]string{}, rc.runsOnPlatformNames(context.Background()))
}
func TestRunContextIsEnabled(t *testing.T) {
func TestRunContext_IsEnabled(t *testing.T) {
log.SetLevel(log.DebugLevel)
assertObject := assert.New(t)
@ -639,7 +575,7 @@ if: false`, ""),
assertObject.False(rc.isEnabled(context.Background()))
}
func TestRunContextGetEnv(t *testing.T) {
func TestRunContext_GetEnv(t *testing.T) {
tests := []struct {
description string
rc *RunContext
@ -690,7 +626,7 @@ func TestRunContextGetEnv(t *testing.T) {
}
}
func Test_createSimpleContainerName(t *testing.T) {
func TestRunContext_CreateSimpleContainerName(t *testing.T) {
tests := []struct {
parts []string
want string
@ -711,7 +647,7 @@ func Test_createSimpleContainerName(t *testing.T) {
}
}
func TestSanitizeNetworkAlias(t *testing.T) {
func TestRunContext_SanitizeNetworkAlias(t *testing.T) {
same := "same"
assert.Equal(t, same, sanitizeNetworkAlias(context.Background(), same))
original := "or.igin'A-L"
@ -719,7 +655,7 @@ func TestSanitizeNetworkAlias(t *testing.T) {
assert.Equal(t, sanitized, sanitizeNetworkAlias(context.Background(), original))
}
func TestPrepareJobContainer(t *testing.T) {
func TestRunContext_PrepareJobContainer(t *testing.T) {
yaml := `
on:
push:
@ -773,63 +709,7 @@ jobs:
},
inputs: []container.NewContainerInput{
{
Name: "WORKFLOW-JOB-service1-24d1b6963554cd6e1a2f9bfcd21b822bf5b42547db24667196ac45f89072fdd9",
Image: "service1:image",
Username: "service1username",
Password: "service1password",
Entrypoint: nil,
Cmd: []string{},
WorkingDir: "",
Env: []string{},
ToolCache: "/opt/hostedtoolcache",
Binds: []string{"/var/run/docker.sock:/var/run/docker.sock"},
Mounts: map[string]string{},
NetworkMode: "WORKFLOW_JOB-job-network",
Privileged: false,
UsernsMode: "",
Platform: "",
NetworkAliases: []string{"service1"},
ExposedPorts: nat.PortSet{},
PortBindings: nat.PortMap{},
ConfigOptions: "",
JobOptions: "",
AutoRemove: false,
ValidVolumes: []string{
"WORKFLOW_JOB",
"WORKFLOW_JOB-env",
"/var/run/docker.sock",
},
},
{
Name: "WORKFLOW-JOB-service2-7137cecabbdb942ae7bbfc8953de8f2a68e8dc9c92ad98cd6d095481b216f979",
Image: "service2:image",
Username: "service2username",
Password: "service2password",
Entrypoint: nil,
Cmd: []string{},
WorkingDir: "",
Env: []string{},
ToolCache: "/opt/hostedtoolcache",
Binds: []string{"/var/run/docker.sock:/var/run/docker.sock"},
Mounts: map[string]string{},
NetworkMode: "WORKFLOW_JOB-job-network",
Privileged: false,
UsernsMode: "",
Platform: "",
NetworkAliases: []string{"service2"},
ExposedPorts: nat.PortSet{},
PortBindings: nat.PortMap{},
ConfigOptions: "",
JobOptions: "",
AutoRemove: false,
ValidVolumes: []string{
"WORKFLOW_JOB",
"WORKFLOW_JOB-env",
"/var/run/docker.sock",
},
},
{
Name: "WORKFLOW_JOB",
Name: "WORKFLOW-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_JOB",
Image: "some:image",
Username: "containerusername",
Password: "containerpassword",
@ -840,10 +720,10 @@ jobs:
ToolCache: "/opt/hostedtoolcache",
Binds: []string{"/var/run/docker.sock:/var/run/docker.sock"},
Mounts: map[string]string{
"WORKFLOW_JOB": "/my/workdir",
"WORKFLOW_JOB-env": "/var/run/act",
"WORKFLOW-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_JOB": "/my/workdir",
"WORKFLOW-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_JOB-env": "/var/run/act",
},
NetworkMode: "WORKFLOW_JOB-job-network",
NetworkMode: "WORKFLOW-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_JOB-job-network",
Privileged: false,
UsernsMode: "",
Platform: "",
@ -854,8 +734,64 @@ jobs:
JobOptions: "",
AutoRemove: false,
ValidVolumes: []string{
"WORKFLOW_JOB",
"WORKFLOW_JOB-env",
"WORKFLOW-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_JOB",
"WORKFLOW-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_JOB-env",
"/var/run/docker.sock",
},
},
{
Name: "WORKFLOW-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca49599-fe7f4c0058dbd2161ebe4aafa71cd83bd96ee19d3ca8043d5e4bc477a664a80c",
Image: "service1:image",
Username: "service1username",
Password: "service1password",
Entrypoint: nil,
Cmd: []string{},
WorkingDir: "",
Env: []string{},
ToolCache: "/opt/hostedtoolcache",
Binds: []string{"/var/run/docker.sock:/var/run/docker.sock"},
Mounts: map[string]string{},
NetworkMode: "WORKFLOW-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_JOB-job-network",
Privileged: false,
UsernsMode: "",
Platform: "",
NetworkAliases: []string{"service1"},
ExposedPorts: nat.PortSet{},
PortBindings: nat.PortMap{},
ConfigOptions: "",
JobOptions: "",
AutoRemove: false,
ValidVolumes: []string{
"WORKFLOW-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_JOB",
"WORKFLOW-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_JOB-env",
"/var/run/docker.sock",
},
},
{
Name: "WORKFLOW-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca49599-c233cf913e1d0c90cc1404ee09917e625f9cb82156ca3d7cb10b729d563728ea",
Image: "service2:image",
Username: "service2username",
Password: "service2password",
Entrypoint: nil,
Cmd: []string{},
WorkingDir: "",
Env: []string{},
ToolCache: "/opt/hostedtoolcache",
Binds: []string{"/var/run/docker.sock:/var/run/docker.sock"},
Mounts: map[string]string{},
NetworkMode: "WORKFLOW-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_JOB-job-network",
Privileged: false,
UsernsMode: "",
Platform: "",
NetworkAliases: []string{"service2"},
ExposedPorts: nat.PortSet{},
PortBindings: nat.PortMap{},
ConfigOptions: "",
JobOptions: "",
AutoRemove: false,
ValidVolumes: []string{
"WORKFLOW-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_JOB",
"WORKFLOW-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855_JOB-env",
"/var/run/docker.sock",
},
},
@ -881,8 +817,10 @@ jobs:
rc.ExprEval = rc.NewExpressionEvaluator(ctx)
require.NoError(t, rc.prepareJobContainer(ctx))
slices.SortFunc(containerInputs, func(a, b container.NewContainerInput) int { return cmp.Compare(a.Name, b.Name) })
assert.EqualValues(t, testCase.inputs, containerInputs)
slices.SortFunc(containerInputs, func(a, b container.NewContainerInput) int { return cmp.Compare(a.Username, b.Username) })
for i := 0; i < len(containerInputs); i++ {
assert.EqualValues(t, testCase.inputs[i], containerInputs[i], containerInputs[i].Username)
}
})
}
}

View file

@ -8,7 +8,6 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"strings"
"testing"
@ -51,7 +50,7 @@ func init() {
secrets = map[string]string{}
}
func TestNoWorkflowsFoundByPlanner(t *testing.T) {
func TestRunner_NoWorkflowsFoundByPlanner(t *testing.T) {
planner, err := model.NewWorkflowPlanner("res", true, false)
assert.NoError(t, err)
@ -71,7 +70,7 @@ func TestNoWorkflowsFoundByPlanner(t *testing.T) {
log.SetOutput(out)
}
func TestGraphMissingEvent(t *testing.T) {
func TestRunner_GraphMissingEvent(t *testing.T) {
planner, err := model.NewWorkflowPlanner("testdata/issue-1595/no-event.yml", true, false)
assert.NoError(t, err)
@ -89,7 +88,7 @@ func TestGraphMissingEvent(t *testing.T) {
log.SetOutput(out)
}
func TestGraphMissingFirst(t *testing.T) {
func TestRunner_GraphMissingFirst(t *testing.T) {
planner, err := model.NewWorkflowPlanner("testdata/issue-1595/no-first.yml", true, false)
assert.NoError(t, err)
@ -99,7 +98,7 @@ func TestGraphMissingFirst(t *testing.T) {
assert.Equal(t, 0, len(plan.Stages))
}
func TestGraphWithMissing(t *testing.T) {
func TestRunner_GraphWithMissing(t *testing.T) {
planner, err := model.NewWorkflowPlanner("testdata/issue-1595/missing.yml", true, false)
assert.NoError(t, err)
@ -116,7 +115,7 @@ func TestGraphWithMissing(t *testing.T) {
log.SetOutput(out)
}
func TestGraphWithSomeMissing(t *testing.T) {
func TestRunner_GraphWithSomeMissing(t *testing.T) {
log.SetLevel(log.DebugLevel)
planner, err := model.NewWorkflowPlanner("testdata/issue-1595/", true, false)
@ -136,7 +135,7 @@ func TestGraphWithSomeMissing(t *testing.T) {
log.SetOutput(out)
}
func TestGraphEvent(t *testing.T) {
func TestRunner_GraphEvent(t *testing.T) {
planner, err := model.NewWorkflowPlanner("testdata/basic", true, false)
assert.NoError(t, err)
@ -207,7 +206,7 @@ func (j *TestJobFileInfo) runTest(ctx context.Context, t *testing.T, cfg *Config
if err == nil && plan != nil {
err = runner.NewPlanExecutor(plan)(ctx)
if j.errorMessage == "" {
assert.Nil(t, err, fullWorkflowPath)
assert.NoError(t, err, fullWorkflowPath)
} else {
assert.Error(t, err, j.errorMessage)
}
@ -222,7 +221,7 @@ type TestConfig struct {
Env map[string]string `yaml:"env,omitempty"`
}
func TestRunEvent(t *testing.T) {
func TestRunner_RunEvent(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
@ -249,10 +248,11 @@ func TestRunEvent(t *testing.T) {
{workdir, "uses-composite", "push", "", platforms, secrets},
{workdir, "uses-composite-with-error", "push", "Job 'failing-composite-action' failed", platforms, secrets},
{workdir, "uses-nested-composite", "push", "", platforms, secrets},
{workdir, "remote-action-composite-js-pre-with-defaults", "push", "", platforms, secrets},
// {workdir, "remote-action-composite-js-pre-with-defaults", "push", "", platforms, secrets},
{workdir, "remote-action-composite-action-ref", "push", "", platforms, secrets},
{workdir, "uses-workflow", "push", "", platforms, map[string]string{"secret": "keep_it_private"}},
{workdir, "uses-workflow", "pull_request", "", platforms, map[string]string{"secret": "keep_it_private"}},
// reusable workflow not fully implemented yet
// {workdir, "uses-workflow", "push", "", platforms, map[string]string{"secret": "keep_it_private"}},
// {workdir, "uses-workflow", "pull_request", "", platforms, map[string]string{"secret": "keep_it_private"}},
{workdir, "uses-docker-url", "push", "", platforms, secrets},
{workdir, "act-composite-env-test", "push", "", platforms, secrets},
@ -262,7 +262,6 @@ func TestRunEvent(t *testing.T) {
{workdir, "evalmatrixneeds2", "push", "", platforms, secrets},
{workdir, "evalmatrix-merge-map", "push", "", platforms, secrets},
{workdir, "evalmatrix-merge-array", "push", "", platforms, secrets},
{workdir, "issue-1195", "push", "", platforms, secrets},
{workdir, "basic", "push", "", platforms, secrets},
{workdir, "fail", "push", "exit with `FAILURE`: 1", platforms, secrets},
@ -274,7 +273,7 @@ func TestRunEvent(t *testing.T) {
{workdir, "container-hostname", "push", "", platforms, secrets},
{workdir, "remote-action-docker", "push", "", platforms, secrets},
{workdir, "remote-action-js", "push", "", platforms, secrets},
{workdir, "remote-action-js-node-user", "push", "", platforms, secrets}, // Test if this works with non root container
// {workdir, "remote-action-js-node-user", "push", "", platforms, secrets}, // Test if this works with non root container
{workdir, "matrix", "push", "", platforms, secrets},
{workdir, "matrix-include-exclude", "push", "", platforms, secrets},
{workdir, "matrix-exitcode", "push", "Job 'test' failed", platforms, secrets},
@ -309,7 +308,6 @@ func TestRunEvent(t *testing.T) {
{workdir, "workflow_dispatch-scalar-composite-action", "workflow_dispatch", "", platforms, secrets},
{workdir, "job-needs-context-contains-result", "push", "", platforms, secrets},
{"../model/testdata", "strategy", "push", "", platforms, secrets}, // TODO: move all testdata into pkg so we can validate it with planner and runner
{"../model/testdata", "container-volumes", "push", "", platforms, secrets},
{workdir, "path-handling", "push", "", platforms, secrets},
{workdir, "do-not-leak-step-env-in-composite", "push", "", platforms, secrets},
{workdir, "set-env-step-env-override", "push", "", platforms, secrets},
@ -319,11 +317,7 @@ func TestRunEvent(t *testing.T) {
// services
{workdir, "services", "push", "", platforms, secrets},
{workdir, "services-host-network", "push", "", platforms, secrets},
{workdir, "services-with-container", "push", "", platforms, secrets},
// local remote action overrides
{workdir, "local-remote-action-overrides", "push", "", platforms, secrets},
}
for _, table := range tables {
@ -359,105 +353,7 @@ func TestRunEvent(t *testing.T) {
}
}
func TestRunEventHostEnvironment(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
ctx := context.Background()
tables := []TestJobFileInfo{}
if runtime.GOOS == "linux" {
platforms := map[string]string{
"ubuntu-latest": "-self-hosted",
}
tables = append(tables, []TestJobFileInfo{
// Shells
{workdir, "shells/defaults", "push", "", platforms, secrets},
{workdir, "shells/pwsh", "push", "", platforms, secrets},
{workdir, "shells/bash", "push", "", platforms, secrets},
{workdir, "shells/python", "push", "", platforms, secrets},
{workdir, "shells/sh", "push", "", platforms, secrets},
// Local action
{workdir, "local-action-js", "push", "", platforms, secrets},
// Uses
{workdir, "uses-composite", "push", "", platforms, secrets},
{workdir, "uses-composite-with-error", "push", "Job 'failing-composite-action' failed", platforms, secrets},
{workdir, "uses-nested-composite", "push", "", platforms, secrets},
{workdir, "act-composite-env-test", "push", "", platforms, secrets},
{workdir, "uses-sh", "push", "", platforms, secrets},
{workdir, "uses-sh-test-action-path", "push", "", platforms, secrets},
// Eval
{workdir, "evalmatrix", "push", "", platforms, secrets},
{workdir, "evalmatrixneeds", "push", "", platforms, secrets},
{workdir, "evalmatrixneeds2", "push", "", platforms, secrets},
{workdir, "evalmatrix-merge-map", "push", "", platforms, secrets},
{workdir, "evalmatrix-merge-array", "push", "", platforms, secrets},
{workdir, "issue-1195", "push", "", platforms, secrets},
{workdir, "fail", "push", "exit with `FAILURE`: 1", platforms, secrets},
{workdir, "runs-on", "push", "", platforms, secrets},
{workdir, "checkout", "push", "", platforms, secrets},
{workdir, "remote-action-js", "push", "", platforms, secrets},
{workdir, "matrix", "push", "", platforms, secrets},
{workdir, "matrix-include-exclude", "push", "", platforms, secrets},
{workdir, "commands", "push", "", platforms, secrets},
{workdir, "defaults-run", "push", "", platforms, secrets},
{workdir, "composite-fail-with-output", "push", "", platforms, secrets},
{workdir, "issue-597", "push", "", platforms, secrets},
{workdir, "issue-598", "push", "", platforms, secrets},
{workdir, "if-env-act", "push", "", platforms, secrets},
{workdir, "env-and-path", "push", "", platforms, secrets},
{workdir, "non-existent-action", "push", "Job 'nopanic' failed", platforms, secrets},
{workdir, "outputs", "push", "", platforms, secrets},
{workdir, "steps-context/conclusion", "push", "", platforms, secrets},
{workdir, "steps-context/outcome", "push", "", platforms, secrets},
{workdir, "job-status-check", "push", "job 'fail' failed", platforms, secrets},
{workdir, "if-expressions", "push", "Job 'mytest' failed", platforms, secrets},
{workdir, "uses-action-with-pre-and-post-step", "push", "", platforms, secrets},
{workdir, "evalenv", "push", "", platforms, secrets},
{workdir, "ensure-post-steps", "push", "Job 'second-post-step-should-fail' failed", platforms, secrets},
}...)
}
if runtime.GOOS == "windows" {
platforms := map[string]string{
"windows-latest": "-self-hosted",
}
tables = append(tables, []TestJobFileInfo{
{workdir, "windows-prepend-path", "push", "", platforms, secrets},
{workdir, "windows-add-env", "push", "", platforms, secrets},
{workdir, "windows-shell-cmd", "push", "", platforms, secrets},
}...)
} else {
platforms := map[string]string{
"self-hosted": "-self-hosted",
"ubuntu-latest": "-self-hosted",
}
tables = append(tables, []TestJobFileInfo{
{workdir, "nix-prepend-path", "push", "", platforms, secrets},
{workdir, "inputs-via-env-context", "push", "", platforms, secrets},
{workdir, "do-not-leak-step-env-in-composite", "push", "", platforms, secrets},
{workdir, "set-env-step-env-override", "push", "", platforms, secrets},
{workdir, "set-env-new-env-file-per-step", "push", "", platforms, secrets},
{workdir, "no-panic-on-invalid-composite-action", "push", "jobs failed due to invalid action", platforms, secrets},
}...)
}
for _, table := range tables {
t.Run(table.workflowPath, func(t *testing.T) {
table.runTest(ctx, t, &Config{})
})
}
}
func TestDryrunEvent(t *testing.T) {
func TestRunner_DryrunEvent(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
@ -486,7 +382,7 @@ func TestDryrunEvent(t *testing.T) {
}
}
func TestDockerActionForcePullForceRebuild(t *testing.T) {
func TestRunner_DockerActionForcePullForceRebuild(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
@ -510,7 +406,7 @@ func TestDockerActionForcePullForceRebuild(t *testing.T) {
}
}
func TestRunDifferentArchitecture(t *testing.T) {
func TestRunner_RunDifferentArchitecture(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
@ -542,7 +438,7 @@ func (h *runSkippedHook) Fire(entry *log.Entry) error {
return nil
}
func TestRunSkipped(t *testing.T) {
func TestRunner_RunSkipped(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
@ -579,7 +475,7 @@ func (f *maskJobLoggerFactory) WithJobLogger() *log.Logger {
return logger
}
func TestMaskValues(t *testing.T) {
func TestRunner_MaskValues(t *testing.T) {
assertNoSecret := func(text, secret string) {
index := strings.Index(text, "composite secret")
if index > -1 {
@ -610,7 +506,7 @@ func TestMaskValues(t *testing.T) {
assertNoSecret(output, "YWJjCg==")
}
func TestRunEventSecrets(t *testing.T) {
func TestRunner_RunEventSecrets(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
@ -632,7 +528,7 @@ func TestRunEventSecrets(t *testing.T) {
tjfi.runTest(context.Background(), t, &Config{Secrets: secrets, Env: env})
}
func TestRunWithService(t *testing.T) {
func TestRunner_RunWithService(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
@ -669,7 +565,7 @@ func TestRunWithService(t *testing.T) {
assert.NoError(t, err, workflowPath)
}
func TestRunActionInputs(t *testing.T) {
func TestRunner_RunActionInputs(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
@ -690,7 +586,7 @@ func TestRunActionInputs(t *testing.T) {
tjfi.runTest(context.Background(), t, &Config{Inputs: inputs})
}
func TestRunEventPullRequest(t *testing.T) {
func TestRunner_RunEventPullRequest(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
@ -708,7 +604,7 @@ func TestRunEventPullRequest(t *testing.T) {
tjfi.runTest(context.Background(), t, &Config{EventPath: filepath.Join(workdir, workflowPath, "event.json")})
}
func TestRunMatrixWithUserDefinedInclusions(t *testing.T) {
func TestRunner_RunMatrixWithUserDefinedInclusions(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}

View file

@ -5,7 +5,6 @@ import (
"context"
"errors"
"io"
"strings"
"testing"
"github.com/stretchr/testify/assert"
@ -21,7 +20,7 @@ type stepActionRemoteMocks struct {
mock.Mock
}
func (sarm *stepActionRemoteMocks) readAction(_ context.Context, step *model.Step, actionDir string, actionPath string, readFile actionYamlReader, writeFile fileWriter) (*model.Action, error) {
func (sarm *stepActionRemoteMocks) readAction(_ context.Context, step *model.Step, actionDir, actionPath string, readFile actionYamlReader, writeFile fileWriter) (*model.Action, error) {
args := sarm.Called(step, actionDir, actionPath, readFile, writeFile)
return args.Get(0).(*model.Action), args.Error(1)
}
@ -31,7 +30,7 @@ func (sarm *stepActionRemoteMocks) runAction(step actionStep, actionDir string,
return args.Get(0).(func(context.Context) error)
}
func TestStepActionRemote(t *testing.T) {
func TestStepActionRemoteOK(t *testing.T) {
table := []struct {
name string
stepModel *model.Step
@ -159,17 +158,11 @@ func TestStepActionRemote(t *testing.T) {
}
sar.RunContext.ExprEval = sar.RunContext.NewExpressionEvaluator(ctx)
suffixMatcher := func(suffix string) interface{} {
return mock.MatchedBy(func(actionDir string) bool {
return strings.HasSuffix(actionDir, suffix)
})
}
if tt.mocks.read {
sarm.On("readAction", sar.Step, suffixMatcher("act/remote-action@v1"), "", mock.Anything, mock.Anything).Return(&model.Action{}, nil)
sarm.On("readAction", sar.Step, mock.Anything, "", mock.Anything, mock.Anything).Return(&model.Action{}, nil)
}
if tt.mocks.run {
sarm.On("runAction", sar, suffixMatcher("act/remote-action@v1"), newRemoteAction(sar.Step.Uses)).Return(func(ctx context.Context) error { return tt.runError })
sarm.On("runAction", sar, mock.Anything, newRemoteAction(sar.Step.Uses)).Return(func(ctx context.Context) error { return tt.runError })
cm.On("Copy", "/var/run/act", mock.AnythingOfType("[]*container.FileEntry")).Return(func(ctx context.Context) error {
return nil
@ -254,13 +247,7 @@ func TestStepActionRemotePre(t *testing.T) {
readAction: sarm.readAction,
}
suffixMatcher := func(suffix string) interface{} {
return mock.MatchedBy(func(actionDir string) bool {
return strings.HasSuffix(actionDir, suffix)
})
}
sarm.On("readAction", sar.Step, suffixMatcher("org-repo-path@ref"), "path", mock.Anything, mock.Anything).Return(&model.Action{}, nil)
sarm.On("readAction", sar.Step, mock.Anything, "path", mock.Anything, mock.Anything).Return(&model.Action{}, nil)
err := sar.pre()(ctx)
@ -324,84 +311,7 @@ func TestStepActionRemotePreThroughAction(t *testing.T) {
readAction: sarm.readAction,
}
suffixMatcher := func(suffix string) interface{} {
return mock.MatchedBy(func(actionDir string) bool {
return strings.HasSuffix(actionDir, suffix)
})
}
sarm.On("readAction", sar.Step, suffixMatcher("org-repo-path@ref"), "path", mock.Anything, mock.Anything).Return(&model.Action{}, nil)
err := sar.pre()(ctx)
assert.Nil(t, err)
assert.Equal(t, true, clonedAction)
sarm.AssertExpectations(t)
})
}
}
func TestStepActionRemotePreThroughActionToken(t *testing.T) {
table := []struct {
name string
stepModel *model.Step
}{
{
name: "run-pre",
stepModel: &model.Step{
Uses: "org/repo/path@ref",
},
},
}
for _, tt := range table {
t.Run(tt.name, func(t *testing.T) {
ctx := context.Background()
clonedAction := false
sarm := &stepActionRemoteMocks{}
origStepAtionRemoteNewCloneExecutor := stepActionRemoteNewCloneExecutor
stepActionRemoteNewCloneExecutor = func(input git.NewGitCloneExecutorInput) common.Executor {
return func(ctx context.Context) error {
if input.URL == "https://github.com/org/repo" && input.Token == "PRIVATE_ACTIONS_TOKEN_ON_GITHUB" {
clonedAction = true
}
return nil
}
}
defer (func() {
stepActionRemoteNewCloneExecutor = origStepAtionRemoteNewCloneExecutor
})()
sar := &stepActionRemote{
Step: tt.stepModel,
RunContext: &RunContext{
Config: &Config{
GitHubInstance: "https://enterprise.github.com",
ReplaceGheActionWithGithubCom: []string{"org/repo"},
ReplaceGheActionTokenWithGithubCom: "PRIVATE_ACTIONS_TOKEN_ON_GITHUB",
},
Run: &model.Run{
JobID: "1",
Workflow: &model.Workflow{
Jobs: map[string]*model.Job{
"1": {},
},
},
},
},
readAction: sarm.readAction,
}
suffixMatcher := func(suffix string) interface{} {
return mock.MatchedBy(func(actionDir string) bool {
return strings.HasSuffix(actionDir, suffix)
})
}
sarm.On("readAction", sar.Step, suffixMatcher("org-repo-path@ref"), "path", mock.Anything, mock.Anything).Return(&model.Action{}, nil)
sarm.On("readAction", sar.Step, mock.Anything, "path", mock.Anything, mock.Anything).Return(&model.Action{}, nil)
err := sar.pre()(ctx)
@ -580,7 +490,7 @@ func TestStepActionRemotePost(t *testing.T) {
sar.RunContext.ExprEval = sar.RunContext.NewExpressionEvaluator(ctx)
if tt.mocks.exec {
cm.On("Exec", []string{"node", "/var/run/act/actions/remote-action@v1/post.js"}, sar.env, "", "").Return(func(ctx context.Context) error { return tt.err })
cm.On("Exec", mock.Anything, sar.env, "", "").Return(func(ctx context.Context) error { return tt.err })
cm.On("Copy", "/var/run/act", mock.AnythingOfType("[]*container.FileEntry")).Return(func(ctx context.Context) error {
return nil

View file

@ -12,7 +12,7 @@ import (
yaml "gopkg.in/yaml.v3"
)
func TestMergeIntoMap(t *testing.T) {
func TestStep_MergeIntoMap(t *testing.T) {
table := []struct {
name string
target map[string]string
@ -111,89 +111,7 @@ func (sm *stepMock) getEnv() *map[string]string {
return args.Get(0).(*map[string]string)
}
func TestSetupEnv(t *testing.T) {
cm := &containerMock{}
sm := &stepMock{}
rc := &RunContext{
Config: &Config{
Env: map[string]string{
"GITHUB_RUN_ID": "runId",
},
},
Run: &model.Run{
JobID: "1",
Workflow: &model.Workflow{
Jobs: map[string]*model.Job{
"1": {
Env: yaml.Node{
Value: "JOB_KEY: jobvalue",
},
},
},
},
},
Env: map[string]string{
"RC_KEY": "rcvalue",
},
JobContainer: cm,
}
step := &model.Step{
With: map[string]string{
"STEP_WITH": "with-value",
},
}
env := map[string]string{}
sm.On("getRunContext").Return(rc)
sm.On("getGithubContext").Return(rc)
sm.On("getStepModel").Return(step)
sm.On("getEnv").Return(&env)
err := setupEnv(context.Background(), sm)
assert.Nil(t, err)
// These are commit or system specific
delete((env), "GITHUB_REF")
delete((env), "GITHUB_REF_NAME")
delete((env), "GITHUB_REF_TYPE")
delete((env), "GITHUB_SHA")
delete((env), "GITHUB_WORKSPACE")
delete((env), "GITHUB_REPOSITORY")
delete((env), "GITHUB_REPOSITORY_OWNER")
delete((env), "GITHUB_ACTOR")
assert.Equal(t, map[string]string{
"ACT": "true",
"CI": "true",
"GITHUB_ACTION": "",
"GITHUB_ACTIONS": "true",
"GITHUB_ACTION_PATH": "",
"GITHUB_ACTION_REF": "",
"GITHUB_ACTION_REPOSITORY": "",
"GITHUB_API_URL": "https:///api/v3",
"GITHUB_BASE_REF": "",
"GITHUB_EVENT_NAME": "",
"GITHUB_EVENT_PATH": "/var/run/act/workflow/event.json",
"GITHUB_GRAPHQL_URL": "https:///api/graphql",
"GITHUB_HEAD_REF": "",
"GITHUB_JOB": "1",
"GITHUB_RETENTION_DAYS": "0",
"GITHUB_RUN_ID": "runId",
"GITHUB_RUN_NUMBER": "1",
"GITHUB_SERVER_URL": "https://",
"GITHUB_TOKEN": "",
"GITHUB_WORKFLOW": "",
"INPUT_STEP_WITH": "with-value",
"RC_KEY": "rcvalue",
"RUNNER_PERFLOG": "/dev/null",
"RUNNER_TRACKING_ID": "",
}, env)
cm.AssertExpectations(t)
}
func TestIsStepEnabled(t *testing.T) {
func TestStep_IsStepEnabled(t *testing.T) {
createTestStep := func(t *testing.T, input string) step {
var step *model.Step
err := yaml.Unmarshal([]byte(input), &step)
@ -275,7 +193,7 @@ func TestIsStepEnabled(t *testing.T) {
assertObject.True(isStepEnabled(context.Background(), step.getStepModel().If.Value, step, stepStageMain))
}
func TestIsContinueOnError(t *testing.T) {
func TestStep_IsContinueOnError(t *testing.T) {
createTestStep := func(t *testing.T, input string) step {
var step *model.Step
err := yaml.Unmarshal([]byte(input), &step)

View file

@ -8,7 +8,7 @@ jobs:
- run: |
echo MYGLOBALENV1=myglobalval1 > $GITHUB_ENV
echo "::set-env name=MYGLOBALENV2::myglobalval2"
- uses: nektos/act-test-actions/script@main
- uses: https://code.forgejo.org/forgejo/act-test-actions/script@main
with:
main: |
env

View file

@ -3,7 +3,7 @@ jobs:
_:
runs-on: ubuntu-latest
steps:
- uses: nektos/act-test-actions/script@main
- uses: https://code.forgejo.org/forgejo/act-test-actions/script@main
with:
pre: |
env
@ -22,7 +22,7 @@ jobs:
test-id-collision-bug:
runs-on: ubuntu-latest
steps:
- uses: nektos/act-test-actions/script@main
- uses: https://code.forgejo.org/forgejo/act-test-actions/script@main
id: script
with:
pre: |
@ -39,7 +39,7 @@ jobs:
[ "$STATE_mystate1" = "mystateval" ]
[ "$STATE_mystate2" = "mystateval" ]
[ "$STATE_mystate3" = "mystateval" ]
- uses: nektos/act-test-actions/script@main
- uses: https://code.forgejo.org/forgejo/act-test-actions/script@main
id: pre-script
with:
main: |

View file

@ -7,7 +7,7 @@ jobs:
env:
JOB: "1"
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: ./act-composite-env-test/action1
env:
COMPOSITE_OVERRIDE: "1"

View file

@ -6,10 +6,10 @@ jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: https://data.forgejo.org/actions/checkout@v3
- uses: './actions-environment-and-context-tests/js'
- uses: './actions-environment-and-context-tests/docker'
- uses: 'nektos/act-test-actions/js@main'
- uses: 'nektos/act-test-actions/docker@main'
- uses: 'nektos/act-test-actions/docker-file@main'
- uses: 'nektos/act-test-actions/docker-relative-context/action@main'
- uses: 'https://code.forgejo.org/forgejo/act-test-actions/js@main'
- uses: 'https://code.forgejo.org/forgejo/act-test-actions/docker@main'
- uses: 'https://code.forgejo.org/forgejo/act-test-actions/docker-file@main'
- uses: 'https://code.forgejo.org/forgejo/act-test-actions/docker-relative-context/action@main'

View file

@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
needs: [check]
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: ./actions/action1
with:
args: echo 'build'

View file

@ -5,4 +5,4 @@ jobs:
checkout:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2

View file

@ -5,7 +5,7 @@ jobs:
test-for-output:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: ./actions/composite-fail-with-output
id: composite-fail-with-output
continue-on-error: true

View file

@ -9,22 +9,18 @@ jobs:
with-hostname:
runs-on: ubuntu-latest
container:
image: node:16-buster-slim
options: "--hostname my.host.local --user 100:101"
image: code.forgejo.org/oci/node:22-bookworm
options: "--hostname my.host.local"
steps:
- run: |
echo "UID: $(id -u)"
echo "GID: $(id -g)"
echo "HOST: $(uname -n)"
[[ "$(id -u)" == "100" ]] && [[ "$(id -g)" == "101" ]] && [[ "$(uname -n)" == "my.host.local" ]]
[[ "$(uname -n)" == "my.host.local" ]]
default-hostname:
runs-on: ubuntu-latest
container:
image: node:16-buster-slim
image: code.forgejo.org/oci/node:22-bookworm
steps:
- run: |
echo "UID: $(id -u)"
echo "GID: $(id -g)"
echo "HOST: $(uname -n)"
[[ "$(id -u)" == "0" ]] && [[ "$(id -g)" == "0" ]] && [[ $(uname -n) ]] && [[ "$(uname -n)" != "my.host.local" ]]
[[ "$(uname -n)" != "my.host.local" ]]

View file

@ -4,5 +4,5 @@ jobs:
second-post-step-should-fail:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: https://data.forgejo.org/actions/checkout@v3
- uses: ./ensure-post-steps/action-composite/

View file

@ -3,7 +3,7 @@ jobs:
mytest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
# - run: exit 1
- uses: ./
if: failure()
@ -26,4 +26,4 @@ jobs:
needs: mytest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2

View file

@ -3,7 +3,7 @@ jobs:
test-inputs-via-env-context:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- uses: https://data.forgejo.org/actions/checkout@v3
- uses: ./inputs-via-env-context
with:
test-env-input: ${{ env.test-env-input }}

View file

@ -10,6 +10,6 @@ jobs:
steps:
- name: hello
uses: actions/hello-world-docker-action@v1
uses: https://github.com/actions/hello-world-docker-action@v1
with:
who-to-greet: "World"

View file

@ -1,13 +0,0 @@
on: push
env:
variable: "${{ github.repository_owner }}"
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: print env.variable
run: |
echo ${{ env.variable }}
exit ${{ (env.variable == 'nektos') && '0' || '1'}}

View file

@ -8,11 +8,11 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
with:
path: test-subdir1
- run: grep "Checkout" test-subdir1/issue-122/main.yaml
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
with:
repository: actions/checkout
path: test-subdir2

View file

@ -5,7 +5,7 @@ jobs:
kind:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: https://data.forgejo.org/actions/checkout@master
- uses: engineerd/setup-kind@v0.3.0
- name: Testing
run: |

View file

@ -9,24 +9,24 @@ jobs:
steps:
- name: My first false step
if: "endsWith('Should not', 'o1')"
uses: actions/checkout@v2.0.0
uses: https://data.forgejo.org/actions/checkout@v2.0.0
with:
ref: refs/pull/${{github.event.pull_request.number}}/merge
fetch-depth: 5
- name: My first true step
if: ${{endsWith('Hello world', 'ld')}}
uses: actions/hello-world-javascript-action@main
uses: https://github.com/actions/hello-world-javascript-action@main
with:
who-to-greet: "Renst the Octocat"
- name: My second false step
if: "endsWith('Should not evaluate', 'o2')"
uses: actions/checkout@v2.0.0
uses: https://data.forgejo.org/actions/checkout@v2.0.0
with:
ref: refs/pull/${{github.event.pull_request.number}}/merge
fetch-depth: 5
- name: My third false step
if: ${{endsWith('Should not evaluate', 'o3')}}
uses: actions/checkout@v2.0.0
uses: https://data.forgejo.org/actions/checkout@v2.0.0
with:
ref: refs/pull/${{github.event.pull_request.number}}/merge
fetch-depth: 5

View file

@ -9,22 +9,22 @@ jobs:
steps:
- name: My first false step
if: "endsWith('Hello world', 'o1')"
uses: actions/hello-world-javascript-action@main
uses: https://github.com/actions/hello-world-javascript-action@main
with:
who-to-greet: 'Mona the Octocat'
- name: My first true step
if: "!endsWith('Hello world', 'od')"
uses: actions/hello-world-javascript-action@main
uses: https://github.com/actions/hello-world-javascript-action@main
with:
who-to-greet: "Renst the Octocat"
- name: My second false step
if: "endsWith('Hello world', 'o2')"
uses: actions/hello-world-javascript-action@main
uses: https://github.com/actions/hello-world-javascript-action@main
with:
who-to-greet: 'Act the Octocat'
- name: My third false step
if: "endsWith('Hello world', 'o2')"
uses: actions/hello-world-javascript-action@main
uses: https://github.com/actions/hello-world-javascript-action@main
with:
who-to-greet: 'Git the Octocat'

View file

@ -5,5 +5,5 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: ./actions/docker-url

View file

@ -8,7 +8,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: ./actions/docker-local
id: dockerlocal
with:

View file

@ -5,7 +5,7 @@ jobs:
test-node12:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: ./actions/node12
with:
who-to-greet: 'Mona the Octocat'
@ -13,7 +13,7 @@ jobs:
test-node16:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: ./actions/node16
with:
who-to-greet: 'Mona the Octocat'
@ -21,7 +21,7 @@ jobs:
test-node20:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: ./actions/node20
with:
who-to-greet: 'Mona the Octocat'

View file

@ -32,7 +32,7 @@ runs:
shell: bash
- uses: ./localdockerimagetest_
# Also test a remote docker action here
- uses: actions/hello-world-docker-action@v1
- uses: https://github.com/actions/hello-world-docker-action@v1
with:
who-to-greet: 'Mona the Octocat'
# Test if GITHUB_ACTION_PATH is set correctly after all steps

View file

@ -5,5 +5,5 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: ./local-action-via-composite-dockerfile/action

View file

@ -1,3 +0,0 @@
local-repositories:
https://github.com/nektos/test-override@a: testdata/actions/node20
nektos/test-override@b: testdata/actions/node16

View file

@ -1,9 +0,0 @@
name: basic
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: nektos/test-override@a
- uses: nektos/test-override@b

View file

@ -5,7 +5,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: https://data.forgejo.org/actions/checkout@v3
- run: echo "::add-mask::secret value"
- run: echo "secret value"
- uses: ./mask-values/composite

View file

@ -22,8 +22,8 @@ jobs:
remote-invalid-step:
runs-on: ubuntu-latest
steps:
- uses: nektos/act-test-actions/invalid-composite-action/invalid-step@main
- uses: https://code.forgejo.org/forgejo/act-test-actions/invalid-composite-action/invalid-step@main
remote-missing-steps:
runs-on: ubuntu-latest
steps:
- uses: nektos/act-test-actions/invalid-composite-action/missing-steps@main
- uses: https://code.forgejo.org/forgejo/act-test-actions/invalid-composite-action/missing-steps@main

View file

@ -6,8 +6,8 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: https://github.com/actions/setup-node@v1
with:
node-version: 12.6
- run: which node

View file

@ -5,11 +5,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: ./actions/action1
with:
args: echo 'build'
- uses: actions/hello-world-javascript-action@master
- uses: https://github.com/actions/hello-world-javascript-action@master
with:
who-to-greet: 'Mona the Octocat'
test1:

View file

@ -4,7 +4,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: https://data.forgejo.org/actions/checkout@v3
- name: "Append to $GITHUB_PATH"
run: |
@ -27,7 +27,7 @@ jobs:
exit 1
fi
- uses: nektos/act-test-actions/composite@main
- uses: https://code.forgejo.org/forgejo/act-test-actions/composite@main
with:
input: some input

View file

@ -9,8 +9,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1.1.1
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: https://github.com/actions/setup-python@v1.1.1
with:
python-version: 3.7

View file

@ -5,4 +5,4 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: nektos/act-test-actions/composite-assert-action-ref-action@main
- uses: https://code.forgejo.org/forgejo/act-test-actions/composite-assert-action-ref-action@main

View file

@ -5,19 +5,19 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: nektos/act-test-actions/composite-js-pre-with-defaults/js@main
- uses: https://code.forgejo.org/forgejo/act-test-actions/composite-js-pre-with-defaults/js@main
with:
in: nix
- uses: nektos/act-test-actions/composite-js-pre-with-defaults@main
- uses: https://code.forgejo.org/forgejo/act-test-actions/composite-js-pre-with-defaults@main
with:
in: secretval
- uses: nektos/act-test-actions/composite-js-pre-with-defaults@main
- uses: https://code.forgejo.org/forgejo/act-test-actions/composite-js-pre-with-defaults@main
with:
in: secretval
- uses: nektos/act-test-actions/composite-js-pre-with-defaults/js@main
- uses: https://code.forgejo.org/forgejo/act-test-actions/composite-js-pre-with-defaults/js@main
with:
pre: "true"
in: nix
- uses: nektos/act-test-actions/composite-js-pre-with-defaults/js@main
- uses: https://code.forgejo.org/forgejo/act-test-actions/composite-js-pre-with-defaults/js@main
with:
in: nix

View file

@ -5,6 +5,6 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/hello-world-docker-action@v1
- uses: https://github.com/actions/hello-world-docker-action@v1
with:
who-to-greet: 'Mona the Octocat'

View file

@ -23,7 +23,7 @@ jobs:
exit 1
shell: bash
- uses: actions/hello-world-javascript-action@v1
- uses: https://github.com/actions/hello-world-javascript-action@v1
with:
who-to-greet: 'Mona the Octocat'

View file

@ -5,8 +5,8 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/hello-world-javascript-action@v1
- uses: https://github.com/actions/hello-world-javascript-action@v1
with:
who-to-greet: 'Mona the Octocat'
- uses: cloudposse/actions/github/slash-command-dispatch@0.14.0
- uses: https://github.com/cloudposse/actions/github/slash-command-dispatch@0.14.0

View file

@ -1,14 +0,0 @@
name: services-host-network
on: push
jobs:
services-host-network:
runs-on: ubuntu-latest
services:
nginx:
image: "nginx:latest"
ports:
- "8080:80"
steps:
- run: apt-get -qq update && apt-get -yqq install --no-install-recommends curl net-tools
- run: netstat -tlpen
- run: curl -v http://localhost:8080

View file

@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
# https://docs.github.com/en/actions/using-containerized-services/about-service-containers#running-jobs-in-a-container
container:
image: "ubuntu:latest"
image: code.forgejo.org/oci/node:22-bookworm
services:
nginx:
image: "nginx:latest"

View file

@ -5,9 +5,9 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: ./uses-action-with-pre-and-post-step/last-action
- uses: nektos/act-test-actions/js-with-pre-and-post-step@main
- uses: https://code.forgejo.org/forgejo/act-test-actions/js-with-pre-and-post-step@main
with:
pre: true
post: true

View file

@ -7,4 +7,4 @@ jobs:
steps:
- name: Test
run: echo
uses: actions/checkout@v2
uses: https://data.forgejo.org/actions/checkout@v2

View file

@ -5,7 +5,7 @@ jobs:
failing-composite-action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: ./uses-composite-with-error/composite_action2
- run: echo should run
if: failure()

View file

@ -14,7 +14,7 @@ runs:
echo "input value 1=${{ inputs.composite-input }}"
[[ "${{ inputs.composite-input == 'value' }}" = "true" ]] || exit 1
shell: bash
- uses: nektos/act-test-actions/js@main
- uses: https://code.forgejo.org/forgejo/act-test-actions/js@main
- name: test input value again
run: |
echo "input value 2=${{ inputs.composite-input }}"

View file

@ -4,7 +4,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- id: set-output
run: echo "::set-output name=var::value"
- name: use simple composite action
@ -21,7 +21,7 @@ jobs:
#
- name: use remote composite action
id: remote-composite
uses: nektos/act-test-actions/composite@main
uses: https://code.forgejo.org/forgejo/act-test-actions/composite@main
with:
input: ${{ steps.set-output.outputs.var }}
- name: test remote composite output

View file

@ -6,6 +6,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: ./uses-composite-with-pre-and-post-steps/last-action
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- run: echo -n "STEP_OUTPUT_TEST=empty" >> $GITHUB_ENV
- uses: ./uses-composite-with-pre-and-post-steps/composite_action

View file

@ -5,7 +5,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: ./uses-composite/composite_action
id: composite
with:

View file

@ -4,4 +4,4 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/hello-world-docker-action@b136eb8894c5cb1dd5807da824be97ccdf9b5423
- uses: https://github.com/actions/hello-world-docker-action@b136eb8894c5cb1dd5807da824be97ccdf9b5423

View file

@ -4,4 +4,4 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout
- uses: https://code.forgejo.org/actions/checkout

View file

@ -4,4 +4,4 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: sergioramos/yarn-actions/install@v6
- uses: https://github.com/sergioramos/yarn-actions/install@v6

View file

@ -4,4 +4,4 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2

View file

@ -4,4 +4,4 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/hello-world-docker-action@b136eb8
- uses: https://github.com/actions/hello-world-docker-action@b136eb8

View file

@ -9,7 +9,7 @@ inputs:
runs:
using: "composite"
steps:
- uses: actions/setup-node@v3
- uses: https://github.com/actions/setup-node@v3
with:
node-version: '16'
- run: |

View file

@ -5,7 +5,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: ./uses-nested-composite/composite_action2
with:
test_input_optional: Test

View file

@ -6,5 +6,5 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: ./uses-sh-test-action-path/sh_test_action_path

View file

@ -6,5 +6,5 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: https://data.forgejo.org/actions/checkout@v2
- uses: ./uses-sh/sh_action

View file

@ -2,7 +2,7 @@ on: push
jobs:
reusable-workflow:
uses: nektos/act-test-actions/.github/workflows/reusable-workflow.yml@main
uses: https://code.forgejo.org/forgejo/act-test-actions/.github/workflows/reusable-workflow.yml@main
with:
string_required: string
bool_required: ${{ true }}
@ -11,7 +11,7 @@ jobs:
secret: keep_it_private
reusable-workflow-with-inherited-secrets:
uses: nektos/act-test-actions/.github/workflows/reusable-workflow.yml@main
uses: https://code.forgejo.org/forgejo/act-test-actions/.github/workflows/reusable-workflow.yml@main
with:
string_required: string
bool_required: ${{ true }}

View file

@ -34,7 +34,7 @@ jobs:
if: env.KEY != 'n/a' || env.Key != 'n/a' || env.key != 'n/a'
env:
KeY: 'n/a'
- uses: actions/checkout@v3
- uses: https://data.forgejo.org/actions/checkout@v3
- uses: ./windows-add-env
- name: Assert composite env is merged case insensitive
run: exit 1