Skip to content

Commit

Permalink
Update test sample workspaces to accomodate subDir behavior change.
Browse files Browse the repository at this point in the history
Signed-off-by: Angel Misevski <[email protected]>
  • Loading branch information
amisevsk committed Jun 23, 2023
1 parent f9955f2 commit 4636360
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ spec:
fi
echo "Project is on $branch_name, tracking $tracking_branch, with remotes configured"
echo "Test succeeded. Sleeping indefinitely"
echo "[SUCCESS] Test succeeded. Sleeping indefinitely"
tail -f /dev/null
106 changes: 106 additions & 0 deletions project-clone/test/sparse-clone-test.devworkspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
apiVersion: workspace.devfile.io/v1alpha2
kind: DevWorkspace
metadata:
name: sparse-clone-project-test
labels:
app.kubernetes.io/name: devworkspace-project-clone-tests
app.kubernetes.io/part-of: devworkspace-operator
annotations:
controller.devfile.io/debug-start: "true"
spec:
started: true
routingClass: 'basic'
template:
attributes:
controller.devfile.io/storage-type: ephemeral
variables:
test_runner_image: quay.io/devfile/project-clone:next # Requires git, bash
main_repo: https://github.com/devfile/devworkspace-operator.git
fork_repo: https://github.com/amisevsk/devworkspace-operator.git
checkout_branch: 0.21.x
project_subdir: project-clone
default_branch_name: main
projects:
- name: default-project-setup
git:
remotes:
main-origin: "{{main_repo}}"
- name: sparse-clone-project-1
attributes:
sparseCheckout: "project-clone" # Can't use variable here as they are not replaced in attributes
git:
checkoutFrom:
remote: origin
revision: "{{checkout_branch}}"
remotes:
origin: "{{main_repo}}"
components:
- name: test-project-clone
container:
image: "{{test_runner_image}}"
memoryLimit: 512Mi
mountSources: true
command:
- "/bin/bash"
- "-c"
- |
set -e
fail() {
echo "[ERROR] $1"
echo "[ERROR] See project-clone logs: "
echo "[ERROR] oc logs -n $DEVWORKSPACE_NAMESPACE deploy/$DEVWORKSPACE_ID -c project-clone"
exit 1
}
if [ -f "${PROJECTS_ROOT}/project-clone-errors.log" ]; then
echo "==== BEGIN PROJECT CLONE LOGS ===="
sed 's/^/ /g' "${PROJECTS_ROOT}/project-clone-errors.log"
echo "==== END PROJECT CLONE LOGS ===="
echo -e "\n\n"
fi
for project_dir in "default-project-setup" "sparse-clone-project-1"; do
if [ ! -d "${PROJECTS_ROOT}/${project_dir}" ]; then
fail "Project $project_dir not cloned successfully"
fi
done
echo "Testing default project set up"
cd "${PROJECTS_ROOT}/default-project-setup"
branch_name=$(git rev-parse --abbrev-ref HEAD)
if [ "$branch_name" != "{{default_branch_name}}" ]; then
fail "Project does not have default branch checked out"
fi
tracking_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u})
if [ "$tracking_branch" != "main-origin/{{default_branch_name}}" ]; then
fail "Default project's branch does not track remote branch"
fi
remote_url=$(git config remote.main-origin.url)
if [ "$remote_url" != "{{main_repo}}" ]; then
fail "Remote 'main-origin' not configured"
fi
echo "Project is on $branch_name, tracking $tracking_branch, with remotes configured"
echo "Testing sparse-clone project is set up"
cd "${PROJECTS_ROOT}/sparse-clone-project-1"
branch_name=$(git rev-parse --abbrev-ref HEAD)
if [ "$branch_name" != "{{checkout_branch}}" ]; then
fail "Project does not have {{checkout_branch}} branch checked out"
fi
tracking_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u})
if [ "$tracking_branch" != "origin/{{checkout_branch}}" ]; then
fail "Checked out branch does not track remote branch origin/{{checkout_branch}}"
fi
remote_url=$(git config remote.origin.url)
if [ "$remote_url" != "{{main_repo}}" ]; then
fail "Remote 'origin' not configured"
fi
sparse_checkout_dirs=$(git sparse-checkout list)
if [ "$sparse_checkout_dirs" != "{{project_subdir}}" ]; then
fail "Sparse checkout is not configured"
fi
echo "Project is on $branch_name, tracking $tracking_branch, with remotes and sparse checkout configured"
echo "[SUCCESS] Test succeeded. Sleeping indefinitely"
tail -f /dev/null
21 changes: 5 additions & 16 deletions project-clone/test/starter-project-test.devworkspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,12 @@ spec:
echo "Testing starter project is set up"
cd "${PROJECTS_ROOT}/starter-project-1"
branch_name=$(git rev-parse --abbrev-ref HEAD)
if [ "$branch_name" != "{{checkout_branch}}" ]; then
fail "Project does not have {{checkout_branch}} branch checked out"
fi
tracking_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u})
if [ "$tracking_branch" != "origin/{{checkout_branch}}" ]; then
fail "Checked out branch does not track remote branch origin/{{checkout_branch}}"
fi
remote_url=$(git config remote.origin.url)
if [ "$remote_url" != "{{main_repo}}" ]; then
fail "Remote 'origin' not configured"
fi
sparse_checkout_dirs=$(git sparse-checkout list)
if [ "$sparse_checkout_dirs" != "{{project_subdir}}" ]; then
fail "Sparse checkout is not configured"
if [ $(git rev-parse --is-inside-work-tree) == "true" ]; then
fail "Do not expect subDir starter project to be a git repository"
fi
echo "Project is on $branch_name, tracking $tracking_branch, with remotes and sparse checkout configured"
echo "Files inside starter project directory:"
ls -l
echo "Project directory is present"
echo "[SUCCESS] Test succeeded. Sleeping indefinitely"
tail -f /dev/null

0 comments on commit 4636360

Please sign in to comment.