-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_projects.sh
More file actions
executable file
·78 lines (63 loc) · 1.76 KB
/
test_projects.sh
File metadata and controls
executable file
·78 lines (63 loc) · 1.76 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
73
74
75
76
77
78
#!/bin/bash
RED="$(tput setaf 1)" && readonly RED
GREEN="$(tput setaf 2)" && readonly GREEN
YELLOW="$(tput setaf 3)" && readonly YELLOW
END="$(tput sgr0)" && readonly END
warn() { echo "$YELLOW$*$END"; } >&2
die() { echo; echo "$RED$*$END"; echo; exit 1; } >&2
SOURCE_ROOT="$(cd "$(dirname "$0")" && pwd)" && readonly SOURCE_ROOT
APPLICATION="$(cd "$SOURCE_ROOT/react-application" && pwd)" \
&& readonly APPLICATION
LIBRARY="$(cd "$SOURCE_ROOT/react-library" && pwd)" && readonly LIBRARY
build_website() {
cd 'website' || exit 1
bundle install
bundle exec jekyll build
}
COVERAGE_FILE='test-report.junit.xml' && readonly COVERAGE_FILE
JSDOC_DIR='docs/' && readonly JSDOC_DIR
JEKYLL_DIR='website/_site/' && readonly JEKYLL_DIR
warn 'Testing application...'
echo '(1/3) Running PNPM commands'
cd "$APPLICATION" || exit 1
pnpm i
pnpm lint
pnpm test
pnpm coverage
build_website
cd "$APPLICATION" || exit 1
echo '(2/3) Checking coverage file'
coverage_file='test-report.junit.xml'
if [[ ! -e "$coverage_file" ]]; then
die 'Coverage not found.'
fi
echo '(3/3) Checking website directory'
if [[ ! -e "$JEKYLL_DIR" ]]; then
die 'Website not built.'
fi
warn 'Testing library...'
echo '(1/4) Running PNPM commands'
cd "$LIBRARY" || exit 1
pnpm i
pnpm lint
pnpm -r test
pnpm -r coverage
pnpm doc
build_website
cd "$LIBRARY" || exit 1
echo '(2/4) Checking coverage file'
if [[ ! -e "packages/library/$COVERAGE_FILE" ||
! -e "packages/library-extension/$COVERAGE_FILE" ]]; then
die 'Coverage not found.'
fi
echo '(3/4) Checking documentation directory'
if [[ ! -e "$JSDOC_DIR" ]]; then
die 'Documentation not built.'
fi
echo '(4/4) Checking website directory'
if [[ ! -e "$JEKYLL_DIR" ]]; then
die 'Website not built.'
fi
echo "${GREEN}Tests complete.$END"
echo
echo 'Goodbye!'