diff --git a/.gitea/workflows/checks.yml b/.gitea/workflows/checks.yml index b83710b8..597334af 100644 --- a/.gitea/workflows/checks.yml +++ b/.gitea/workflows/checks.yml @@ -34,18 +34,6 @@ jobs: - uses: actions/checkout@v5 with: fetch-depth: 2 - - name: Cleanup Docker Engine - run: | - docker ps -a --format '{{ if eq (truncate .Names 4) "act-" }} - {{ .ID }} - {{end}}' | xargs -r docker rm -f || : - docker volume ls --format '{{ if eq (truncate .Name 4) "act-" }} - {{ .Name }} - {{ end }}' | xargs -r docker volume rm -f || : - docker images --format '{{ if eq (truncate .Repository 4) "act-" }} - {{ .ID }} - {{ end }}' | xargs -r docker rmi -f || : - docker images -q | xargs -r docker rmi || : - name: Set up QEMU if: '!env.NO_QEMU' uses: docker/setup-qemu-action@v3 @@ -78,9 +66,9 @@ jobs: env: SERVER_URL: ${{ github.server_url }} - name: Run act from cli - run: go run main.go exec -i node:16-buster-slim -C ./pkg/runner/testdata/ -W ./basic/push.yml + run: go run ./internal/app/act-cli -P ubuntu-latest=node:16-buster-slim -C ./pkg/runner/testdata/ -W ./basic/push.yml - name: Run act from cli without docker support - run: go run -tags WITHOUT_DOCKER main.go exec -i "-self-hosted" -C ./pkg/runner/testdata/ -W ./local-action-js/push.yml + run: go run -tags WITHOUT_DOCKER ./internal/app/act-cli exec -i "-self-hosted" -C ./pkg/runner/testdata/ -W ./local-action-js/push.yml snapshot: name: snapshot diff --git a/.gitignore b/.gitignore index 1631a8c3..2f5d7ccd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /act_runner +/act .env .runner coverage.txt diff --git a/Makefile b/Makefile index 733fd5be..7f231798 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ DIST := dist EXECUTABLE := act_runner +ACT_EXECUTABLE := act GOFMT ?= gofumpt -l DIST_DIRS := $(DIST)/binaries $(DIST)/release GO ?= go @@ -137,7 +138,7 @@ tidy-check: tidy fi test: fmt-check security-check - @$(GO) test -v -cover -coverprofile coverage.txt ./... && echo "\n==>\033[32m Ok\033[m\n" || exit 1 + @$(GO) test -test.short -v -cover -coverprofile coverage.txt ./... && echo "\n==>\033[32m Ok\033[m\n" || exit 1 .PHONY: vet vet: @@ -148,11 +149,14 @@ vet: install: $(GOFILES) $(GO) install -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -build: go-check $(EXECUTABLE) +build: go-check $(EXECUTABLE) $(ACT_EXECUTABLE) $(EXECUTABLE): $(GOFILES) $(GO) build -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o $@ +$(ACT_EXECUTABLE): $(GOFILES) + $(GO) build -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o $@ ./internal/app/act-cli + .PHONY: deps-backend deps-backend: $(GO) mod download diff --git a/cmd/root_test.go b/cmd/root_test.go index c03720f3..a01e087b 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -39,6 +39,10 @@ func TestListOptions(t *testing.T) { } func TestRun(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + rootCmd := createRootCommand(context.Background(), &Input{}, "") err := newRunCommand(context.Background(), &Input{ platforms: []string{"ubuntu-latest=node:16-buster-slim"}, @@ -49,6 +53,9 @@ func TestRun(t *testing.T) { } func TestRunPush(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } rootCmd := createRootCommand(context.Background(), &Input{}, "") err := newRunCommand(context.Background(), &Input{ platforms: []string{"ubuntu-latest=node:16-buster-slim"}, @@ -59,6 +66,9 @@ func TestRunPush(t *testing.T) { } func TestRunPushJsonLogger(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } rootCmd := createRootCommand(context.Background(), &Input{}, "") err := newRunCommand(context.Background(), &Input{ platforms: []string{"ubuntu-latest=node:16-buster-slim"}, @@ -70,6 +80,9 @@ func TestRunPushJsonLogger(t *testing.T) { } func TestFlags(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } for _, f := range []string{"graph", "list", "bug-report", "man-page"} { t.Run("TestFlag-"+f, func(t *testing.T) { rootCmd := createRootCommand(context.Background(), &Input{}, "") @@ -86,6 +99,9 @@ func TestFlags(t *testing.T) { } func TestWorkflowCall(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } rootCmd := createRootCommand(context.Background(), &Input{}, "") err := newRunCommand(context.Background(), &Input{ platforms: []string{"ubuntu-latest=node:16-buster-slim"}, @@ -97,6 +113,9 @@ func TestWorkflowCall(t *testing.T) { } func TestLocalRepositories(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } wd, _ := filepath.Abs("../pkg/runner/testdata/") rootCmd := createRootCommand(context.Background(), &Input{}, "") err := newRunCommand(context.Background(), &Input{ diff --git a/pkg/container/docker_run_test.go b/pkg/container/docker_run_test.go index d924db43..52b2b5a9 100644 --- a/pkg/container/docker_run_test.go +++ b/pkg/container/docker_run_test.go @@ -20,6 +20,10 @@ import ( ) func TestDocker(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + ctx := context.Background() client, err := GetDockerClient(ctx) require.NoError(t, err) diff --git a/pkg/container/docker_socket_test.go b/pkg/container/docker_socket_test.go index 7e493941..c7984b22 100644 --- a/pkg/container/docker_socket_test.go +++ b/pkg/container/docker_socket_test.go @@ -44,6 +44,10 @@ func TestGetSocketAndHostNoSocket(t *testing.T) { } func TestGetSocketAndHostOnlySocket(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + // Arrange socketURI := "/path/to/my.socket" os.Unsetenv("DOCKER_HOST") @@ -75,6 +79,10 @@ func TestGetSocketAndHostDontMount(t *testing.T) { } func TestGetSocketAndHostNoHostNoSocket(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + // Arrange CommonSocketLocations = originalCommonSocketLocations os.Unsetenv("DOCKER_HOST") @@ -93,6 +101,10 @@ func TestGetSocketAndHostNoHostNoSocket(t *testing.T) { // > Your code breaks setting DOCKER_HOST if shouldMount is false. // > This happens if neither DOCKER_HOST nor --container-daemon-socket has a value, but socketLocation() returns a URI func TestGetSocketAndHostNoHostNoSocketDefaultLocation(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + // Arrange mySocketFile, tmpErr := os.CreateTemp(t.TempDir(), "act-*.sock") mySocket := mySocketFile.Name() @@ -115,6 +127,10 @@ func TestGetSocketAndHostNoHostNoSocketDefaultLocation(t *testing.T) { } func TestGetSocketAndHostNoHostInvalidSocket(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + // Arrange os.Unsetenv("DOCKER_HOST") mySocket := "/my/socket/path.sock" diff --git a/pkg/runner/job_executor_test.go b/pkg/runner/job_executor_test.go index e44a035a..dbb49733 100644 --- a/pkg/runner/job_executor_test.go +++ b/pkg/runner/job_executor_test.go @@ -16,6 +16,10 @@ import ( ) func TestJobExecutor(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + tables := []TestJobFileInfo{ {workdir, "uses-and-run-in-one-step", "push", "Invalid run/uses syntax for job:test step:Test", platforms, secrets}, {workdir, "uses-github-empty", "push", "Expected format {org}/{repo}[/path]@ref", platforms, secrets}, @@ -31,7 +35,9 @@ func TestJobExecutor(t *testing.T) { ctx := common.WithDryrun(context.Background(), true) for _, table := range tables { t.Run(table.workflowPath, func(t *testing.T) { - table.runTest(ctx, t, &Config{}) + table.runTest(ctx, t, &Config{ + ContainerArchitecture: nativeContainerArchitecture, + }) }) } } diff --git a/pkg/runner/run_context_test.go b/pkg/runner/run_context_test.go index cadb53b3..71e7a08f 100644 --- a/pkg/runner/run_context_test.go +++ b/pkg/runner/run_context_test.go @@ -344,6 +344,10 @@ func TestRunContext_GetBindsAndMounts(t *testing.T) { } func TestGetGitHubContext(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + log.SetLevel(log.DebugLevel) cwd, err := os.Getwd()