Merge pull request #491 from TomChv/tests-random

Move random string generation from tests to his own file
This commit is contained in:
Andrea Luzzardi 2021-05-25 12:46:44 -07:00 committed by GitHub
commit 52a1a6bac0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 140 additions and 120 deletions

View File

@ -12,20 +12,6 @@ registry: {
} }
TestPushContainer: { TestPushContainer: {
// Generate a random number
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "echo -n $RANDOM > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}
// Push an image with a random tag // Push an image with a random tag
push: { push: {
ref: "daggerio/ci-test:\(random)" ref: "daggerio/ci-test:\(random)"
@ -66,20 +52,6 @@ TestPushContainer: {
// Ensures image metadata is preserved in a push // Ensures image metadata is preserved in a push
TestPushContainerMetadata: { TestPushContainerMetadata: {
// Generate a random number
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "echo -n $RANDOM > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}
// `docker build` using an `ENV` and push the image // `docker build` using an `ENV` and push the image
push: { push: {
ref: "daggerio/ci-test:\(random)-dockerbuild" ref: "daggerio/ci-test:\(random)-dockerbuild"

View File

@ -0,0 +1,20 @@
package testing
import (
"dagger.io/alpine"
"dagger.io/dagger/op"
)
// Generate a random number
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "cat /dev/urandom | tr -dc 'a-z' | fold -w 10 | head -n 1 | tr -d '\n' > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}

View File

@ -3,7 +3,6 @@ package ecr
import ( import (
"dagger.io/aws" "dagger.io/aws"
"dagger.io/aws/ecr" "dagger.io/aws/ecr"
"dagger.io/alpine"
"dagger.io/dagger/op" "dagger.io/dagger/op"
) )
@ -11,20 +10,6 @@ TestConfig: awsConfig: aws.#Config & {
region: "us-east-2" region: "us-east-2"
} }
// Generate a random number
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "cat /dev/urandom | tr -dc 'a-z' | fold -w 10 | head -n 1 | tr -d '\n' > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}
TestECR: { TestECR: {
repository: "125635003186.dkr.ecr.\(TestConfig.awsConfig.region).amazonaws.com/dagger-ci" repository: "125635003186.dkr.ecr.\(TestConfig.awsConfig.region).amazonaws.com/dagger-ci"
tag: "test-ecr-\(random)" tag: "test-ecr-\(random)"

View File

@ -0,0 +1,20 @@
package ecr
import (
"dagger.io/alpine"
"dagger.io/dagger/op"
)
// Generate a random number
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "cat /dev/urandom | tr -dc 'a-z' | fold -w 10 | head -n 1 | tr -d '\n' > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}

View File

@ -15,20 +15,6 @@ registry: {
} }
TestPushAndPull: { TestPushAndPull: {
// Generate a random number
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "cat /dev/urandom | tr -dc 'a-z' | fold -w 10 | head -n 1 | tr -d '\n' > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}
ref: "daggerio/ci-test:\(random)" ref: "daggerio/ci-test:\(random)"
// Create image // Create image

View File

@ -0,0 +1,20 @@
package docker
import (
"dagger.io/alpine"
"dagger.io/dagger/op"
)
// Generate a random number
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "cat /dev/urandom | tr -dc 'a-z' | fold -w 10 | head -n 1 | tr -d '\n' > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}

View File

@ -3,26 +3,11 @@ package gcr
import ( import (
"dagger.io/gcp" "dagger.io/gcp"
"dagger.io/gcp/gcr" "dagger.io/gcp/gcr"
"dagger.io/alpine"
"dagger.io/dagger/op" "dagger.io/dagger/op"
) )
TestConfig: gcpConfig: gcp.#Config TestConfig: gcpConfig: gcp.#Config
// Generate a random number
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "cat /dev/urandom | tr -dc 'a-z' | fold -w 10 | head -n 1 | tr -d '\n' > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}
TestGCR: { TestGCR: {
repository: "gcr.io/dagger-ci/test" repository: "gcr.io/dagger-ci/test"
tag: "test-gcr-\(random)" tag: "test-gcr-\(random)"

View File

@ -0,0 +1,20 @@
package gcr
import (
"dagger.io/alpine"
"dagger.io/dagger/op"
)
// Generate a random number
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "cat /dev/urandom | tr -dc 'a-z' | fold -w 10 | head -n 1 | tr -d '\n' > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}

View File

@ -2,8 +2,6 @@ package helm
import ( import (
"dagger.io/dagger" "dagger.io/dagger"
"dagger.io/dagger/op"
"dagger.io/alpine"
"dagger.io/file" "dagger.io/file"
"dagger.io/kubernetes/helm" "dagger.io/kubernetes/helm"
) )
@ -18,20 +16,6 @@ config: file.#Read & {
from: kubeconfig from: kubeconfig
} }
// Generate random string
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "cat /dev/urandom | tr -dc 'a-z' | fold -w 10 | head -n 1 | tr -d '\n' > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}
// Deploy user local chart // Deploy user local chart
TestHelmSimpleChart: { TestHelmSimpleChart: {
// Deploy chart // Deploy chart

View File

@ -0,0 +1,20 @@
package helm
import (
"dagger.io/alpine"
"dagger.io/dagger/op"
)
// Generate a random number
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "cat /dev/urandom | tr -dc 'a-z' | fold -w 10 | head -n 1 | tr -d '\n' > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}

View File

@ -3,8 +3,6 @@ package kubernetes
import ( import (
"encoding/yaml" "encoding/yaml"
"dagger.io/dagger" "dagger.io/dagger"
"dagger.io/dagger/op"
"dagger.io/alpine"
"dagger.io/file" "dagger.io/file"
"dagger.io/kubernetes" "dagger.io/kubernetes"
) )
@ -19,22 +17,6 @@ config: file.#Read & {
from: kubeconfig from: kubeconfig
} }
// Generate a random number
// It trigger a "cycle error" if I put it in TestKubeApply ?!
// failed to up deployment: buildkit solve: TestKubeApply.#up: cycle error
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "cat /dev/urandom | tr -dc 'a-z' | fold -w 10 | head -n 1 | tr -d '\n' > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}
TestKubeApply: { TestKubeApply: {
// Pod spec // Pod spec
kubeSrc: { kubeSrc: {

View File

@ -0,0 +1,20 @@
package kubernetes
import (
"dagger.io/alpine"
"dagger.io/dagger/op"
)
// Generate a random number
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "cat /dev/urandom | tr -dc 'a-z' | fold -w 10 | head -n 1 | tr -d '\n' > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}

View File

@ -7,20 +7,6 @@ import (
) )
TestNetlify: { TestNetlify: {
// Generate a random number
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "echo -n $RANDOM > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}
// Generate a website containing the random number // Generate a website containing the random number
html: #up: [ html: #up: [
op.#WriteFile & { op.#WriteFile & {

View File

@ -0,0 +1,20 @@
package netlify
import (
"dagger.io/alpine"
"dagger.io/dagger/op"
)
// Generate a random number
random: {
string
#up: [
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "cat /dev/urandom | tr -dc 'a-z' | fold -w 10 | head -n 1 | tr -d '\n' > /rand"]
},
op.#Export & {
source: "/rand"
},
]
}