From 407ee6e9eeea388a8c87eae6306a7048891c9f10 Mon Sep 17 00:00:00 2001 From: Guillaume de Rouville Date: Wed, 16 Jun 2021 10:00:01 +0200 Subject: [PATCH] docs: git package uniformization + tests implementation Signed-off-by: Guillaume de Rouville --- stdlib/.dagger/env/git/.gitignore | 2 + stdlib/.dagger/env/git/plan/git.cue | 63 +++++++++++++++++++++++++++++ stdlib/.dagger/env/git/values.yaml | 21 ++++++++++ stdlib/git/git.cue | 9 +---- stdlib/universe.bats | 4 ++ 5 files changed, 92 insertions(+), 7 deletions(-) create mode 100644 stdlib/.dagger/env/git/.gitignore create mode 100644 stdlib/.dagger/env/git/plan/git.cue create mode 100644 stdlib/.dagger/env/git/values.yaml diff --git a/stdlib/.dagger/env/git/.gitignore b/stdlib/.dagger/env/git/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/stdlib/.dagger/env/git/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/stdlib/.dagger/env/git/plan/git.cue b/stdlib/.dagger/env/git/plan/git.cue new file mode 100644 index 00000000..67ae3cff --- /dev/null +++ b/stdlib/.dagger/env/git/plan/git.cue @@ -0,0 +1,63 @@ +package git + +import ( + "strings" + + "dagger.io/git" + "dagger.io/alpine" + "dagger.io/os" + "dagger.io/dagger/op" +) + +repo: git.#Repository & { + remote: "https://github.com/blocklayerhq/acme-clothing.git" + ref: "master" + + #up: [ + op.#FetchGit & { + keepGitDir: true + }, + ] +} + +branch: git.#CurrentBranch & { + repository: repo +} + +tagsList: git.#Tags & { + repository: repo +} + +TestRepository: os.#Container & { + image: alpine.#Image & { + package: bash: "=5.1.0-r0" + package: git: true + } + mount: "/repo1": from: repo + dir: "/repo1" + command: """ + [ -d .git ] + """ +} + +TestCurrentBranch: os.#Container & { + image: alpine.#Image & { + package: bash: "=5.1.0-r0" + package: git: true + } + env: BRANCH_NAME: branch.name + command: """ + [ $BRANCH_NAME = "master" ] + """ +} + +TestCurrentTags: os.#Container & { + image: alpine.#Image & { + package: bash: "=5.1.0-r0" + package: git: true + } + env: TAGS: strings.Join([ for k, v in tagsList.tags {"\(k)=\(v)"}], "\n") + command: """ + [ $TAGS = "0=master" ] + """ +} diff --git a/stdlib/.dagger/env/git/values.yaml b/stdlib/.dagger/env/git/values.yaml new file mode 100644 index 00000000..2fd0d4a4 --- /dev/null +++ b/stdlib/.dagger/env/git/values.yaml @@ -0,0 +1,21 @@ +name: git +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBRVm9VbnZLQzl0LzBjYUkw + cXBwTlJWeXpCellCenJFcEFBejVGREpIaVdZCkV1U3BMK1BUOStvUThUd09DVUNK + OXJ4Yjl4WEtSMHlpeG5TVUNwQU5iMXcKLS0tIE1HS0U0YWxYS3V5UXFmUUxTVGlk + TmhJNisyamw3d244aGVJSEVFVUVLZGsKvd+nowA0CLXQbdvyI4J0lBjs9vdISWlo + gGvR49uul3Z8raVWXFUzsyQ8xTvYNg0ovynFG2KdagSKr1DlhKMBEQ== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-06-15T14:34:51Z" + mac: ENC[AES256_GCM,data:phQpRQlHv9c3VRcqZ7OkSfW4a9oPnTD2ucsB8TJatgzLrbP1+erj9x2jrPex0T2MExIFFzNynSAiWwueLYqCzUvuG2DfIokvM9erNfdpbIBTtJeWO9+hVIkzoQ6xeKg1wLb0q3U7Cbbe6GBFA3oabPN2kyzGbgS2LO2Ou77NMLk=,iv:sS0MRNEGBWos6XNAQEYK2UmaK9g0rd+Nx1xBNeh6w+M=,tag:DIcqzBvChde/C7T/yAhn+w==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/stdlib/git/git.cue b/stdlib/git/git.cue index b9b8e588..8148e144 100644 --- a/stdlib/git/git.cue +++ b/stdlib/git/git.cue @@ -9,7 +9,6 @@ import ( // A git repository #Repository: { - // Git remote. // Example: `"https://github.com/dagger/dagger"` remote: string @dagger(input) @@ -36,14 +35,12 @@ import ( // Get the name of the current checked out branch or tag #CurrentBranch: { - // Git repository repository: dagger.#Artifact @dagger(input) // Git branch name name: { string - @dagger(output) #up: [ op.#Load & { @@ -74,19 +71,17 @@ import ( format: "string" }, ] - } + } @dagger(output) } // List tags of a repository #Tags: { - // Git repository repository: dagger.#Artifact @dagger(input) // Repository tags tags: { [...string] - @dagger(output) #up: [ op.#Load & { @@ -118,5 +113,5 @@ import ( format: "json" }, ] - } + } @dagger(output) } diff --git a/stdlib/universe.bats b/stdlib/universe.bats index b9ecc22f..b9327d6d 100644 --- a/stdlib/universe.bats +++ b/stdlib/universe.bats @@ -16,6 +16,10 @@ setup() { dagger -e netlify up } +@test "git" { + dagger -e git up +} + @test "aws: ecr" { dagger -e aws-ecr up }