Add test on git.#Commit
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
committed by
Guillaume de Rouville
parent
c8e3755188
commit
4ad2c8e7e5
@@ -12,7 +12,7 @@ import (
|
||||
// Repository source code
|
||||
source: dagger.#Artifact
|
||||
|
||||
// Repository remote URL (e.g https://github.com/dagger/dagger.git)
|
||||
// Repository remote URL
|
||||
remote: dagger.#Input & {string}
|
||||
|
||||
// Github PAT
|
||||
@@ -59,18 +59,18 @@ import (
|
||||
"/input/content": from: content
|
||||
}
|
||||
env: {
|
||||
"USER_NAME": name
|
||||
"USER_EMAIL": email
|
||||
"COMMIT_MESSAGE": message
|
||||
"GIT_BRANCH": repository.branch
|
||||
"GIT_REMOTE": repository.remote
|
||||
USER_NAME: name
|
||||
USER_EMAIL: email
|
||||
COMMIT_MESSAGE: message
|
||||
GIT_BRANCH: repository.branch
|
||||
GIT_REMOTE: repository.remote
|
||||
if force {
|
||||
"OPT_FORCE": "-f"
|
||||
OPT_FORCE: "-f"
|
||||
}
|
||||
|
||||
}
|
||||
if repository.PAT != null {
|
||||
env: "GIT_ASKPASS": "/get_gitPAT"
|
||||
env: GIT_ASKPASS: "/get_gitPAT"
|
||||
files: "/get_gitPAT": {
|
||||
content: "cat /secret/github_pat"
|
||||
mode: 0o500
|
||||
|
@@ -9,8 +9,7 @@ import (
|
||||
|
||||
// A git repository
|
||||
#Repository: {
|
||||
// Git remote.
|
||||
// Example: `"https://github.com/dagger/dagger"`
|
||||
// Git remote link
|
||||
remote: dagger.#Input & {string}
|
||||
|
||||
// Git ref: can be a commit, tag or branch.
|
||||
|
@@ -5,7 +5,5 @@ import (
|
||||
)
|
||||
|
||||
#Image: alpine.#Image & {
|
||||
package: {
|
||||
git: true
|
||||
}
|
||||
package: git: true
|
||||
}
|
||||
|
81
stdlib/git/tests/commit/commit.cue
Normal file
81
stdlib/git/tests/commit/commit.cue
Normal file
@@ -0,0 +1,81 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"alpha.dagger.io/dagger"
|
||||
"alpha.dagger.io/os"
|
||||
"alpha.dagger.io/random"
|
||||
)
|
||||
|
||||
TestPAT: dagger.#Input & {dagger.#Secret}
|
||||
|
||||
TestRemote: dagger.#Input & {*"https://github.com/dagger/test.git" | string}
|
||||
|
||||
TestRepository: #Repository & {
|
||||
remote: TestRemote
|
||||
ref: "main"
|
||||
keepGitDir: true
|
||||
authToken: TestPAT
|
||||
}
|
||||
|
||||
TestData: {
|
||||
random.#String & {
|
||||
seed: "git-commit"
|
||||
}
|
||||
}.out
|
||||
|
||||
TestFile: os.#Dir & {
|
||||
from: os.#Container & {
|
||||
command: #"""
|
||||
mkdir -p /output
|
||||
echo "$MESSAGE" >> /output/test.md
|
||||
"""#
|
||||
env: MESSAGE: TestData
|
||||
}
|
||||
path: "/output"
|
||||
}
|
||||
|
||||
TestCommit: #Commit & {
|
||||
repository: {
|
||||
remote: TestRemote
|
||||
PAT: TestPAT
|
||||
source: TestRepository
|
||||
branch: "ci/test-commit"
|
||||
}
|
||||
content: TestFile
|
||||
message: "This is a commit from the CI to test the repository"
|
||||
name: "Dagger CI"
|
||||
email: "daggerci@dagger.io"
|
||||
force: true
|
||||
}
|
||||
|
||||
TestCheck: {
|
||||
_TestRepo: #Repository & {
|
||||
remote: TestCommit.repository.remote
|
||||
ref: TestCommit.repository.branch
|
||||
keepGitDir: true
|
||||
authToken: TestCommit.repository.PAT
|
||||
}
|
||||
|
||||
_TestHash: TestCommit.hash
|
||||
|
||||
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 file
|
||||
echo "$MESSAGE" >> expect.md
|
||||
diff test.md expect.md
|
||||
"""#
|
||||
dir: "/input/repo"
|
||||
mount: "/input/repo": from: _TestRepo
|
||||
env: {
|
||||
MESSAGE: TestData
|
||||
// Force dependency
|
||||
// GIT_HASH: TestCommit.hash
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user