Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/tests/configure-test-env.sh
6446 views
1
# Check R environment ---
2
3
echo ">>>> Configuring R environment"
4
r_exists=$(command -v Rscript)
5
6
if [ -z $r_exists ]
7
then
8
echo "No Rscript found in PATH - Check your PATH or install R and add to PATH."
9
else
10
echo " > Restoring renv project"
11
Rscript -e 'renv::restore()'
12
echo " > Installing dev knitr and rmarkdown"
13
Rscript -e "install.packages('rmarkdown', repos = c('https://rstudio.r-universe.dev', getOption('repos')))"
14
Rscript -e "install.packages('knitr', repos = c('https://yihui.r-universe.dev', getOption('repos')))"
15
fi
16
17
18
# Check python test environment ---
19
echo ">>>> Configuring Python environment"
20
# Prefer uv is available
21
uv_exist=$(command -v uv)
22
if [ -z $uv_exist ]
23
then
24
echo "No uv found - Install uv please: https://docs.astral.sh/uv/getting-started/installation/."
25
echo "Using 'uv' is the prefered way. You can still use python and create a .venv in the project."
26
else
27
echo "Setting up python environnement with uv"
28
# create or sync the virtual env in the project
29
uv sync --frozen
30
fi
31
32
# Check Julia environment ---
33
echo ">>>> Configuring Julia environment"
34
julia_exists=$(command -v julia)
35
if [ -z $julia_exists ]
36
then
37
echo "No julia found in PATH - Check your PATH or install julia and add to PATH."
38
else
39
echo "Setting up Julia environment"
40
if [ -z $uv_exist ]
41
then
42
uv run --frozen julia --color=yes --project=. -e 'import Pkg; Pkg.instantiate(); Pkg.build("IJulia"); Pkg.precompile()'
43
else
44
julia --color=yes --project=. -e 'import Pkg; Pkg.instantiate(); Pkg.build("IJulia"); Pkg.precompile()'
45
fi
46
fi
47
48
# Update tinytex
49
echo ">>>> Configuring TinyTeX environment"
50
if [[ -z $GH_TOKEN && -n $(command -v gh) ]]
51
then
52
echo "Setting GH_TOKEN env var for Github Download."
53
export GH_TOKEN=$(gh auth token)
54
fi
55
56
if [ -n $(command -v quarto) ]
57
then
58
quarto install tinytex
59
fi
60
61
# Check for veraPDF (and Java) as the tool is required for PDF standard validation tests
62
echo ">>>> Checking Java for veraPDF"
63
java_exists=$(command -v java)
64
if [ -z $java_exists ]
65
then
66
echo "No java found in PATH - veraPDF requires Java to be installed."
67
echo "Install Java and add to PATH if you need PDF standard validation tests."
68
echo "See: https://www.java.com/en/download/"
69
else
70
echo "Java found: $(java -version 2>&1 | head -n 1)"
71
fi
72
73
# Install veraPDF for PDF standard validation ---
74
echo ">>>> Installing veraPDF for PDF standard validation"
75
if [ -n $(command -v quarto) ]
76
then
77
if [ -n "$java_exists" ]
78
then
79
quarto install verapdf
80
else
81
echo "Skipping veraPDF installation (Java not found)"
82
fi
83
else
84
echo "Skipping veraPDF installation (quarto not found)"
85
fi
86
87
# Check Node.js and npm ---
88
echo ">>>> Configuring npm for MECA testing environment"
89
node_exists=$(command -v node)
90
npm_exists=$(command -v npm)
91
if [ -z $node_exists ]
92
then
93
echo "No node found - will skip any tests that require npm (e.g. JATS / MECA validation)"
94
elif [ -z $npm_exists ]
95
then
96
echo "No npm found - npm is required but node is present"
97
else
98
# Check Node.js version
99
node_version=$(node -v | sed 's/v//' | cut -d. -f1)
100
echo "Node.js version: $(node -v)"
101
if [ "$node_version" -lt 18 ]; then
102
echo "Warning: Node.js version $node_version is older than recommended (18+)"
103
echo "Some tests may fail. Consider upgrading Node.js."
104
fi
105
echo "Setting up npm testing environment"
106
npm install -g meca --loglevel=error --no-audit
107
fi
108
109
# Setup Playwright for browser testing ---
110
echo ">>>> Configuring Playwright for integration tests"
111
if [ -n "$npm_exists" ]
112
then
113
echo "Installing Playwright dependencies..."
114
pushd integration/playwright > /dev/null
115
npm install --loglevel=error --no-audit
116
# Install multiplex server dependencies
117
echo "Installing multiplex server dependencies..."
118
pushd multiplex-server > /dev/null
119
npm install --loglevel=error --no-audit
120
popd > /dev/null
121
# Try to install browsers with --with-deps (may require sudo on Linux/macOS)
122
echo "Installing Playwright browsers..."
123
npx playwright install --with-deps || echo "Note: Browser installation may require sudo. Run manually: npx playwright install --with-deps"
124
popd > /dev/null
125
else
126
echo "Skipping Playwright setup (npm not found)"
127
fi
128
129
# Check pdftotext ---
130
echo ">>>> Do you have pdftotext installed (from poppler) ?"
131
pdftotext_exists=$(command -v pdftotext)
132
if [ -z $pdftotext_exists ]
133
then
134
echo "No pdftotext found - Some tests will require it, so you may want to install it."
135
fi
136
137
# Check rsvg-convert for SVG conversion ---
138
echo ">>>> Do you have rsvg-convert installed (from librsvg) ?"
139
rsvg_exists=$(command -v rsvg-convert)
140
if [ -z $rsvg_exists ]
141
then
142
echo "No rsvg-convert found - Some PDF tests with SVG images will be skipped."
143
echo "Install librsvg to enable SVG to PDF conversion tests:"
144
echo " - Ubuntu/Debian: sudo apt-get install librsvg2-bin"
145
echo " - macOS: brew install librsvg"
146
echo " - Windows: scoop install librsvg"
147
fi
148