-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update test sample workspaces to accomodate subDir behavior change.
Signed-off-by: Angel Misevski <[email protected]>
- Loading branch information
Showing
3 changed files
with
112 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters