-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-template.sh
More file actions
72 lines (65 loc) · 1.89 KB
/
test-template.sh
File metadata and controls
72 lines (65 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
# Needs two arguments:
#
# 1. type: 'r' or 'general'
# Argument naming -----
type="${1}"
if [ -z "$type" ]; then
echo "Usage: sh $0 <type>"
echo "Example: sh $0 r"
exit 1
fi
# Set up variables and functions for the test -----
test_name="test-workshop"
test_dir="$(pwd)/_temp/$type/$test_name"
template_dir="$(pwd)"
# Needs three arguments:
#
# 1. Template directory
# 2. Destination directory
copy () {
# vcs-ref means the current commit/head. This includes uncommitted changes.
uvx copier copy $1 $2 \
-r HEAD \
--defaults \
--data workshop_type="$type" \
--data github_user="first-last" \
--data author_given_name="First" \
--data author_family_name="Last" \
--data github_board_number=22 \
--overwrite \
--skip-tasks \
--trust
}
# Pre-test setup -----
# Remove the leftover directory from previous runs
rm -rf $test_dir
mkdir -p $test_dir
# Check initial creation -----
# TODO: Find some way to test the `update` command
# Any step that fails will exit the script with an error and not continue
echo "Testing copy for new projects when: 'type'='$type' -----------"
(
cd $test_dir &&
copy $template_dir $test_dir &&
git init -b main &&
git add . &&
git commit --quiet -m "test: initial copy" &&
# Check that recopy works -----
echo "Testing recopy when: 'type'='$type' -----------" &&
rm .cz.toml &&
git add . &&
git commit --quiet -m "test: preparing to recopy from the template" &&
uvx copier recopy \
-r HEAD \
--defaults \
--overwrite \
--skip-tasks \
--trust &&
# Check that copying onto an existing website works -----
echo "Testing copy in existing projects when: 'type'='$type' -----------" &&
rm .cz.toml .copier-answers.yml &&
git add . &&
git commit --quiet -m "test: preparing to copy onto an existing website" &&
copy $template_dir $test_dir
)