mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-03-20 03:46:09 +08:00
Force linux/amd64 for tests running on amd64 renble tests
This commit is contained in:
@@ -26,11 +26,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
baseImage = "node:24-bookworm-slim"
|
baseImage = "node:24-bookworm-slim"
|
||||||
platforms map[string]string
|
platforms map[string]string
|
||||||
logLevel = log.DebugLevel
|
logLevel = log.DebugLevel
|
||||||
workdir = "testdata"
|
workdir = "testdata"
|
||||||
secrets map[string]string
|
secrets map[string]string
|
||||||
|
nativeContainerArchitecture = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -43,6 +44,12 @@ func init() {
|
|||||||
"self-hosted": "-self-hosted",
|
"self-hosted": "-self-hosted",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force the correct docker container architecture
|
||||||
|
// otherwise it may fail to start containers without qemu
|
||||||
|
if runtime.GOARCH == "amd64" {
|
||||||
|
nativeContainerArchitecture = "linux/amd64"
|
||||||
|
}
|
||||||
|
|
||||||
if l := os.Getenv("ACT_TEST_LOG_LEVEL"); l != "" {
|
if l := os.Getenv("ACT_TEST_LOG_LEVEL"); l != "" {
|
||||||
if lvl, err := log.ParseLevel(l); err == nil {
|
if lvl, err := log.ParseLevel(l); err == nil {
|
||||||
logLevel = lvl
|
logLevel = lvl
|
||||||
@@ -229,7 +236,7 @@ func TestRunEvent(t *testing.T) {
|
|||||||
t.Skip("skipping integration test")
|
t.Skip("skipping integration test")
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := t.Context()
|
||||||
|
|
||||||
tables := []TestJobFileInfo{
|
tables := []TestJobFileInfo{
|
||||||
// Shells
|
// Shells
|
||||||
@@ -237,8 +244,7 @@ func TestRunEvent(t *testing.T) {
|
|||||||
// TODO: figure out why it fails
|
// TODO: figure out why it fails
|
||||||
// {workdir, "shells/custom", "push", "", map[string]string{"ubuntu-latest": "catthehacker/ubuntu:pwsh-latest"}, }, // custom image with pwsh
|
// {workdir, "shells/custom", "push", "", map[string]string{"ubuntu-latest": "catthehacker/ubuntu:pwsh-latest"}, }, // custom image with pwsh
|
||||||
{workdir, "shells/pwsh", "push", "", map[string]string{"ubuntu-latest": "catthehacker/ubuntu:pwsh-latest"}, secrets}, // custom image with pwsh
|
{workdir, "shells/pwsh", "push", "", map[string]string{"ubuntu-latest": "catthehacker/ubuntu:pwsh-latest"}, secrets}, // custom image with pwsh
|
||||||
// Disabled: fails in CI with "container is not running" due to Docker lifecycle timing
|
{workdir, "shells/bash", "push", "", platforms, secrets},
|
||||||
// {workdir, "shells/bash", "push", "", platforms, secrets},
|
|
||||||
{workdir, "shells/python", "push", "", map[string]string{"ubuntu-latest": "node:16-buster"}, secrets}, // slim doesn't have python
|
{workdir, "shells/python", "push", "", map[string]string{"ubuntu-latest": "node:16-buster"}, secrets}, // slim doesn't have python
|
||||||
{workdir, "shells/sh", "push", "", platforms, secrets},
|
{workdir, "shells/sh", "push", "", platforms, secrets},
|
||||||
|
|
||||||
@@ -263,9 +269,8 @@ func TestRunEvent(t *testing.T) {
|
|||||||
|
|
||||||
// Eval
|
// Eval
|
||||||
{workdir, "evalmatrix", "push", "", platforms, secrets},
|
{workdir, "evalmatrix", "push", "", platforms, secrets},
|
||||||
// Disabled: fails in CI with 'container is not running' causing log.Fatal crash in matrix evaluation
|
{workdir, "evalmatrixneeds", "push", "", platforms, secrets},
|
||||||
// {workdir, "evalmatrixneeds", "push", "", platforms, secrets},
|
{workdir, "evalmatrixneeds2", "push", "", platforms, secrets},
|
||||||
// {workdir, "evalmatrixneeds2", "push", "", platforms, secrets},
|
|
||||||
{workdir, "evalmatrix-merge-map", "push", "", platforms, secrets},
|
{workdir, "evalmatrix-merge-map", "push", "", platforms, secrets},
|
||||||
{workdir, "evalmatrix-merge-array", "push", "", platforms, secrets},
|
{workdir, "evalmatrix-merge-array", "push", "", platforms, secrets},
|
||||||
// Disabled: github.repository_owner resolves inconsistently between env and step expressions in CI
|
// Disabled: github.repository_owner resolves inconsistently between env and step expressions in CI
|
||||||
@@ -352,8 +357,9 @@ func TestRunEvent(t *testing.T) {
|
|||||||
for _, table := range tables {
|
for _, table := range tables {
|
||||||
t.Run(table.workflowPath, func(t *testing.T) {
|
t.Run(table.workflowPath, func(t *testing.T) {
|
||||||
config := &Config{
|
config := &Config{
|
||||||
Secrets: table.secrets,
|
Secrets: table.secrets,
|
||||||
Parallel: 8,
|
Parallel: 8,
|
||||||
|
ContainerArchitecture: nativeContainerArchitecture,
|
||||||
}
|
}
|
||||||
|
|
||||||
eventFile := filepath.Join(workdir, table.workflowPath, "event.json")
|
eventFile := filepath.Join(workdir, table.workflowPath, "event.json")
|
||||||
@@ -419,7 +425,8 @@ func TestPullAndPostStepFailureIsJobFailure(t *testing.T) {
|
|||||||
factory := &captureJobLoggerFactory{}
|
factory := &captureJobLoggerFactory{}
|
||||||
|
|
||||||
config := &Config{
|
config := &Config{
|
||||||
Secrets: table.secrets,
|
Secrets: table.secrets,
|
||||||
|
ContainerArchitecture: nativeContainerArchitecture,
|
||||||
}
|
}
|
||||||
|
|
||||||
eventFile := filepath.Join(workdir, table.workflowPath, "event.json")
|
eventFile := filepath.Join(workdir, table.workflowPath, "event.json")
|
||||||
@@ -489,7 +496,8 @@ func TestFetchFailureIsJobFailure(t *testing.T) {
|
|||||||
factory := &captureJobLoggerFactory{}
|
factory := &captureJobLoggerFactory{}
|
||||||
|
|
||||||
config := &Config{
|
config := &Config{
|
||||||
Secrets: table.secrets,
|
Secrets: table.secrets,
|
||||||
|
ContainerArchitecture: nativeContainerArchitecture,
|
||||||
}
|
}
|
||||||
|
|
||||||
eventFile := filepath.Join(workdir, table.workflowPath, "event.json")
|
eventFile := filepath.Join(workdir, table.workflowPath, "event.json")
|
||||||
@@ -739,7 +747,6 @@ func (f *maskJobLoggerFactory) WithJobLogger() *log.Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMaskValues(t *testing.T) {
|
func TestMaskValues(t *testing.T) {
|
||||||
t.Skip("Disabled: fails in CI with 'container is not running' due to Docker lifecycle timing")
|
|
||||||
assertNoSecret := func(text string, _ string) {
|
assertNoSecret := func(text string, _ string) {
|
||||||
found := strings.Contains(text, "composite secret")
|
found := strings.Contains(text, "composite secret")
|
||||||
if found {
|
if found {
|
||||||
@@ -763,7 +770,9 @@ func TestMaskValues(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger := &maskJobLoggerFactory{}
|
logger := &maskJobLoggerFactory{}
|
||||||
tjfi.runTest(WithJobLoggerFactory(common.WithLogger(context.Background(), logger.WithJobLogger()), logger), t, &Config{})
|
tjfi.runTest(WithJobLoggerFactory(common.WithLogger(context.Background(), logger.WithJobLogger()), logger), t, &Config{
|
||||||
|
ContainerArchitecture: nativeContainerArchitecture,
|
||||||
|
})
|
||||||
output := logger.Output.String()
|
output := logger.Output.String()
|
||||||
|
|
||||||
assertNoSecret(output, "secret value")
|
assertNoSecret(output, "secret value")
|
||||||
@@ -771,7 +780,6 @@ func TestMaskValues(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRunEventSecrets(t *testing.T) {
|
func TestRunEventSecrets(t *testing.T) {
|
||||||
t.Skip("Disabled: fails in CI with 'container is not running' due to Docker lifecycle timing")
|
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("skipping integration test")
|
t.Skip("skipping integration test")
|
||||||
}
|
}
|
||||||
@@ -790,11 +798,14 @@ func TestRunEventSecrets(t *testing.T) {
|
|||||||
secrets, _ := godotenv.Read(filepath.Join(workdir, workflowPath, ".secrets"))
|
secrets, _ := godotenv.Read(filepath.Join(workdir, workflowPath, ".secrets"))
|
||||||
require.NoError(t, err, "Failed to read .secrets")
|
require.NoError(t, err, "Failed to read .secrets")
|
||||||
|
|
||||||
tjfi.runTest(context.Background(), t, &Config{Secrets: secrets, Env: env})
|
tjfi.runTest(context.Background(), t, &Config{
|
||||||
|
Secrets: secrets,
|
||||||
|
Env: env,
|
||||||
|
ContainerArchitecture: nativeContainerArchitecture,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRunActionInputs(t *testing.T) {
|
func TestRunActionInputs(t *testing.T) {
|
||||||
t.Skip("Disabled: fails in CI with 'container is not running' due to Docker lifecycle timing")
|
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("skipping integration test")
|
t.Skip("skipping integration test")
|
||||||
}
|
}
|
||||||
@@ -812,11 +823,13 @@ func TestRunActionInputs(t *testing.T) {
|
|||||||
"SOME_INPUT": "input",
|
"SOME_INPUT": "input",
|
||||||
}
|
}
|
||||||
|
|
||||||
tjfi.runTest(context.Background(), t, &Config{Inputs: inputs})
|
tjfi.runTest(context.Background(), t, &Config{
|
||||||
|
Inputs: inputs,
|
||||||
|
ContainerArchitecture: nativeContainerArchitecture,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRunEventPullRequest(t *testing.T) {
|
func TestRunEventPullRequest(t *testing.T) {
|
||||||
t.Skip("Disabled: fails in CI with nil PR number and 'container is not running' due to Docker lifecycle timing")
|
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("skipping integration test")
|
t.Skip("skipping integration test")
|
||||||
}
|
}
|
||||||
@@ -831,11 +844,13 @@ func TestRunEventPullRequest(t *testing.T) {
|
|||||||
platforms: platforms,
|
platforms: platforms,
|
||||||
}
|
}
|
||||||
|
|
||||||
tjfi.runTest(context.Background(), t, &Config{EventPath: filepath.Join(workdir, workflowPath, "event.json")})
|
tjfi.runTest(context.Background(), t, &Config{
|
||||||
|
EventPath: filepath.Join(workdir, workflowPath, "event.json"),
|
||||||
|
ContainerArchitecture: nativeContainerArchitecture,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRunMatrixWithUserDefinedInclusions(t *testing.T) {
|
func TestRunMatrixWithUserDefinedInclusions(t *testing.T) {
|
||||||
t.Skip("Disabled: fails in CI with 'container is not running' due to Docker lifecycle timing")
|
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("skipping integration test")
|
t.Skip("skipping integration test")
|
||||||
}
|
}
|
||||||
@@ -859,5 +874,8 @@ func TestRunMatrixWithUserDefinedInclusions(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
tjfi.runTest(context.Background(), t, &Config{Matrix: matrix})
|
tjfi.runTest(context.Background(), t, &Config{
|
||||||
|
Matrix: matrix,
|
||||||
|
ContainerArchitecture: nativeContainerArchitecture,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user