Add experimental way to set a target platform when building
Add an --experimental-platform flag to the do command to allow overriding the default auto-detected build platform until we find the time to think about the definitive multi-platform builds UX Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com>
This commit is contained in:
@@ -228,15 +228,17 @@ setup() {
|
||||
}
|
||||
|
||||
@test "plan/platform" {
|
||||
|
||||
cd "$TESTDIR"
|
||||
|
||||
# Run with amd64 platform
|
||||
run "$DAGGER" "do" -p./plan/platform/config_platform_linux_amd64.cue verify
|
||||
|
||||
# Run with arm64 platform
|
||||
run "$DAGGER" "do" -p./plan/platform/config_platform_linux_arm64.cue verify
|
||||
|
||||
# Run with invalid platform
|
||||
run "$DAGGER" "do" -p./plan/platform/config_platform_failure_invalid_platform.cue verify
|
||||
# Run with invalid platform format
|
||||
run "$DAGGER" "do" --experimental-platform invalid -p./plan/platform/platform.cue test
|
||||
assert_failure
|
||||
assert_output --partial "unknown operating system or architecture: invalid argument"
|
||||
|
||||
|
||||
# Run with non-existing platform
|
||||
run "$DAGGER" "do" --experimental-platform invalid/invalid -p./plan/platform/platform.cue test
|
||||
assert_failure
|
||||
assert_output --partial "no match for platform in manifest"
|
||||
}
|
||||
|
@@ -1,33 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/dagger/core"
|
||||
)
|
||||
|
||||
dagger.#Plan & {
|
||||
platform: "linux/unknown"
|
||||
|
||||
actions: {
|
||||
image: core.#Pull & {
|
||||
source: "alpine:3.15.0"
|
||||
}
|
||||
|
||||
writeArch: core.#Exec & {
|
||||
input: image.output
|
||||
always: true
|
||||
args: [
|
||||
"sh", "-c", #"""
|
||||
echo -n $(uname -m) >> /arch.txt
|
||||
"""#,
|
||||
]
|
||||
}
|
||||
|
||||
verify: core.#ReadFile & {
|
||||
input: writeArch.output
|
||||
path: "/arch.txt"
|
||||
} & {
|
||||
contents: "s390x"
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/dagger/core"
|
||||
)
|
||||
|
||||
dagger.#Plan & {
|
||||
platform: "linux/amd64"
|
||||
|
||||
actions: {
|
||||
image: core.#Pull & {
|
||||
source: "alpine:3.15.0"
|
||||
}
|
||||
|
||||
writeArch: core.#Exec & {
|
||||
input: image.output
|
||||
always: true
|
||||
args: [
|
||||
"sh", "-c", #"""
|
||||
echo -n $(uname -m) >> /arch.txt
|
||||
"""#,
|
||||
]
|
||||
}
|
||||
|
||||
verify: core.#ReadFile & {
|
||||
input: writeArch.output
|
||||
path: "/arch.txt"
|
||||
} & {
|
||||
contents: "x86_64"
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/dagger/core"
|
||||
)
|
||||
|
||||
dagger.#Plan & {
|
||||
platform: "linux/arm64"
|
||||
|
||||
actions: {
|
||||
image: core.#Pull & {
|
||||
source: "alpine:3.15.0"
|
||||
}
|
||||
|
||||
writeArch: core.#Exec & {
|
||||
input: image.output
|
||||
always: true
|
||||
args: [
|
||||
"sh", "-c", #"""
|
||||
echo -n $(uname -m) >> /arch.txt
|
||||
"""#,
|
||||
]
|
||||
}
|
||||
|
||||
verify: core.#ReadFile & {
|
||||
input: writeArch.output
|
||||
path: "/arch.txt"
|
||||
} & {
|
||||
contents: "aarch64"
|
||||
}
|
||||
}
|
||||
}
|
12
tests/plan/platform/platform.cue
Normal file
12
tests/plan/platform/platform.cue
Normal file
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/dagger/core"
|
||||
)
|
||||
|
||||
dagger.#Plan & {
|
||||
actions: test: image: core.#Pull & {
|
||||
source: "alpine:3.15.0"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user