Skip to content

Commit

Permalink
Expand GIT CLONE tests to validate --branch works (#3469)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Couture-Beil <[email protected]>
  • Loading branch information
alexcb authored Nov 8, 2023
1 parent 25c7e32 commit 1f1a422
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 0 deletions.
116 changes: 116 additions & 0 deletions ast/tests/git-clone.ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,35 @@
"targets": [
{
"name": "test",
"recipe": [
{
"command": {
"args": [
"+test-default"
],
"name": "BUILD"
}
},
{
"command": {
"args": [
"+test-branch"
],
"name": "BUILD"
}
},
{
"command": {
"args": [
"+test-sha"
],
"name": "BUILD"
}
}
]
},
{
"name": "test-default",
"recipe": [
{
"command": {
Expand Down Expand Up @@ -87,6 +116,93 @@
}
}
]
},
{
"name": "test-branch",
"recipe": [
{
"command": {
"args": [
"/test"
],
"name": "WORKDIR"
}
},
{
"command": {
"args": [
"--branch",
"v0.7.20",
"[email protected]:earthly/earthly.git",
"myrepo"
],
"name": "GIT CLONE"
}
},
{
"command": {
"args": [
"/test/myrepo"
],
"name": "WORKDIR"
}
},
{
"command": {
"args": [
"test",
"\"$(cat CHANGELOG.md | grep '## v' | head -n 1)\"",
"=",
"\"## v0.7.20 - 2023-10-03\""
],
"name": "RUN"
}
}
]
},
{
"name": "test-sha",
"recipe": [
{
"command": {
"args": [
"/test"
],
"name": "WORKDIR"
}
},
{
"command": {
"args": [
"--branch",
"f862451125039f2071f26168ae9bc0e69ec24bf3",
"[email protected]:earthly/earthly.git",
"myrepo"
],
"docs": "git rev-parse v0.7.10 --> f862451125039f2071f26168ae9bc0e69ec24bf3\n",
"name": "GIT CLONE"
}
},
{
"command": {
"args": [
"/test/myrepo"
],
"name": "WORKDIR"
}
},
{
"command": {
"args": [
"test",
"\"$(cat CHANGELOG.md | grep '## v' | head -n 1)\"",
"=",
"\"## v0.7.10 - 2023-07-05\""
],
"name": "RUN"
}
}
]
}
],
"version": {
Expand Down
19 changes: 19 additions & 0 deletions tests/git-clone.earth
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
VERSION 0.7
FROM alpine/git:1.0.7

test:
BUILD +test-default
BUILD +test-branch
BUILD +test-sha

test-default:
WORKDIR /test
GIT CLONE https://github.com/moby/buildkit.git buildkit
RUN test "$(pwd)" = "/test"
Expand All @@ -9,3 +15,16 @@ test:
RUN git status
RUN git branch
RUN test -f README.md

test-branch:
WORKDIR /test
GIT CLONE --branch v0.7.20 [email protected]:earthly/earthly.git myrepo
WORKDIR /test/myrepo
RUN test "$(cat CHANGELOG.md | grep '## v' | head -n 1)" = "## v0.7.20 - 2023-10-03"

test-sha:
WORKDIR /test
# git rev-parse v0.7.10 --> f862451125039f2071f26168ae9bc0e69ec24bf3
GIT CLONE --branch f862451125039f2071f26168ae9bc0e69ec24bf3 [email protected]:earthly/earthly.git myrepo
WORKDIR /test/myrepo
RUN test "$(cat CHANGELOG.md | grep '## v' | head -n 1)" = "## v0.7.10 - 2023-07-05"

0 comments on commit 1f1a422

Please sign in to comment.