Improve git package according to Sam comments
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
committed by
Guillaume de Rouville
parent
4ad2c8e7e5
commit
95040d8320
@@ -1,12 +1,14 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"alpha.dagger.io/alpine"
|
||||
"alpha.dagger.io/dagger"
|
||||
"alpha.dagger.io/dagger/op"
|
||||
"alpha.dagger.io/os"
|
||||
"alpha.dagger.io/random"
|
||||
)
|
||||
|
||||
TestPAT: dagger.#Input & {dagger.#Secret}
|
||||
TestAuthToken: dagger.#Input & {dagger.#Secret}
|
||||
|
||||
TestRemote: dagger.#Input & {*"https://github.com/dagger/test.git" | string}
|
||||
|
||||
@@ -14,7 +16,7 @@ TestRepository: #Repository & {
|
||||
remote: TestRemote
|
||||
ref: "main"
|
||||
keepGitDir: true
|
||||
authToken: TestPAT
|
||||
authToken: TestAuthToken
|
||||
}
|
||||
|
||||
TestData: {
|
||||
@@ -23,23 +25,39 @@ TestData: {
|
||||
}
|
||||
}.out
|
||||
|
||||
TestFile: os.#Dir & {
|
||||
from: os.#Container & {
|
||||
command: #"""
|
||||
mkdir -p /output
|
||||
echo "$MESSAGE" >> /output/test.md
|
||||
"""#
|
||||
env: MESSAGE: TestData
|
||||
}
|
||||
path: "/output"
|
||||
}
|
||||
// FIXME Currently throw a structural cycle error
|
||||
//TestFile: os.#Dir & {
|
||||
// from: os.#Container & {
|
||||
// image: alpine.#Image
|
||||
// command: #"""
|
||||
// mkdir -p /output
|
||||
// echo "$MESSAGE" >> /output/test.md
|
||||
// """#
|
||||
// env: MESSAGE: TestData
|
||||
// }
|
||||
// path: "/output"
|
||||
//}
|
||||
|
||||
TestFile: #up: [
|
||||
op.#Load & {from: alpine.#Image},
|
||||
op.#Mkdir & {
|
||||
path: "/output"
|
||||
},
|
||||
op.#WriteFile & {
|
||||
content: TestData
|
||||
dest: "/output/test.md"
|
||||
},
|
||||
op.#Subdir & {
|
||||
dir: "/output"
|
||||
},
|
||||
]
|
||||
|
||||
TestCommit: #Commit & {
|
||||
repository: {
|
||||
remote: TestRemote
|
||||
PAT: TestPAT
|
||||
source: TestRepository
|
||||
branch: "ci/test-commit"
|
||||
remote: TestRemote
|
||||
authToken: TestAuthToken
|
||||
source: TestRepository
|
||||
branch: "ci/test-commit"
|
||||
}
|
||||
content: TestFile
|
||||
message: "This is a commit from the CI to test the repository"
|
||||
@@ -50,32 +68,28 @@ TestCommit: #Commit & {
|
||||
|
||||
TestCheck: {
|
||||
_TestRepo: #Repository & {
|
||||
remote: TestCommit.repository.remote
|
||||
ref: TestCommit.repository.branch
|
||||
remote: TestRemote
|
||||
ref: "ci/test-commit"
|
||||
keepGitDir: true
|
||||
authToken: TestCommit.repository.PAT
|
||||
authToken: TestAuthToken
|
||||
}
|
||||
|
||||
_TestHash: TestCommit.hash
|
||||
|
||||
os.#Container & {
|
||||
image: #Image
|
||||
_ctr: os.#Container & {
|
||||
image: #Image
|
||||
command: #"""
|
||||
# Check commit
|
||||
# FIXME Interpolate because there is an empty disjuction error
|
||||
# when given to env
|
||||
git rev-parse --verify HEAD | grep \#(TestCommit.hash)
|
||||
# Check commit
|
||||
git rev-parse --verify HEAD | grep "$GIT_HASH"
|
||||
|
||||
# Check file
|
||||
echo "$MESSAGE" >> expect.md
|
||||
diff test.md expect.md
|
||||
"""#
|
||||
dir: "/input/repo"
|
||||
# Check file
|
||||
echo -n "$EXPECTED_MESSAGE" >> expect.md
|
||||
diff test.md expect.md
|
||||
"""#
|
||||
dir: "/input/repo"
|
||||
mount: "/input/repo": from: _TestRepo
|
||||
env: {
|
||||
MESSAGE: TestData
|
||||
EXPECTED_MESSAGE: TestData
|
||||
// Force dependency
|
||||
// GIT_HASH: TestCommit.hash
|
||||
GIT_HASH: TestCommit.hash
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user