diff --git a/cmd/platforms.go b/cmd/platforms.go index 45724d752dc..aa8a42b7ef6 100644 --- a/cmd/platforms.go +++ b/cmd/platforms.go @@ -7,6 +7,7 @@ import ( func (i *Input) newPlatforms() map[string]string { platforms := map[string]string{ "ubuntu-latest": "node:16-buster-slim", + "ubuntu-slim": "node:16-buster-slim", "ubuntu-22.04": "node:16-bullseye-slim", "ubuntu-20.04": "node:16-buster-slim", "ubuntu-18.04": "node:16-buster-slim", diff --git a/cmd/platforms_test.go b/cmd/platforms_test.go new file mode 100644 index 00000000000..886518067f5 --- /dev/null +++ b/cmd/platforms_test.go @@ -0,0 +1,31 @@ +package cmd + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestNewPlatformsDefaults(t *testing.T) { + i := &Input{} + platforms := i.newPlatforms() + + // ubuntu-latest must be present and resolve to a default image + latest, ok := platforms["ubuntu-latest"] + assert.True(t, ok, "ubuntu-latest should be a default platform") + assert.NotEmpty(t, latest) + + // ubuntu-slim should fall back to the same image as ubuntu-latest + // (GitHub's 1-vCPU runner uses the same base distro, see issue #6003) + slim, ok := platforms["ubuntu-slim"] + assert.True(t, ok, "ubuntu-slim should be a default platform") + assert.Equal(t, latest, slim, "ubuntu-slim should default to the same image as ubuntu-latest") +} + +func TestNewPlatformsUserOverride(t *testing.T) { + i := &Input{platforms: []string{"ubuntu-slim=catthehacker/ubuntu:act-latest"}} + platforms := i.newPlatforms() + + assert.Equal(t, "catthehacker/ubuntu:act-latest", platforms["ubuntu-slim"], + "user-supplied -P value should override the default") +}