Skip to content

Commit a45a87d

Browse files
style: fix lint errors (#246)
1 parent f85f62a commit a45a87d

File tree

2 files changed

+81
-96
lines changed

2 files changed

+81
-96
lines changed

.github/workflows/jekyll-build.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
env:
124124
TMPDIR: /home/runner/work/tmp
125125
run: |
126-
mkdir -p ${TMPDIR}
126+
mkdir -p "${TMPDIR}"
127127
128128
base_dirs=(
129129
./theme/third-party/beautiful-jekyll
@@ -148,22 +148,22 @@ jobs:
148148
149149
for base_dir in "${base_dirs[@]}"; do
150150
for target in "${targets[@]}"; do
151-
if [ -e "$base_dir/$target" ]; then
152-
cp -rf "$base_dir/$target" ${TMPDIR}/
151+
if [ -e "${base_dir}/${target}" ]; then
152+
cp -rf "${base_dir}/${target}" "${TMPDIR}/"
153153
fi
154154
done
155155
done
156156
157157
# copy project directory, they should only come from the project repo
158-
cp -RTf ./project/ ${TMPDIR}/
158+
cp -RTf ./project/ "${TMPDIR}/"
159159
160160
# remove the workspace
161161
cd ..
162-
rm -rf ${GITHUB_WORKSPACE}
162+
rm -rf "${GITHUB_WORKSPACE}"
163163
164164
# move the temporary directory to the workspace
165-
mv ${TMPDIR} ${GITHUB_WORKSPACE}
166-
cd ${GITHUB_WORKSPACE}
165+
mv "${TMPDIR}" "${GITHUB_WORKSPACE}"
166+
cd "${GITHUB_WORKSPACE}"
167167
168168
# debug contents recursively
169169
ls -Ra
@@ -183,14 +183,14 @@ jobs:
183183
- name: Setup CI config
184184
run: |
185185
config_file="_config_ci.yml"
186-
echo "---" > $config_file
186+
echo "---" > "${config_file}"
187187
if [ "${{ inputs.base_url }}" == '_auto' ]; then
188188
echo "baseurl: '${{ steps.configure-pages.outputs.base_path }}'" >> $config_file
189189
else
190-
echo "baseurl: '${{ inputs.base_url }}'" >> $config_file
190+
echo "baseurl: '${{ inputs.base_url }}'" >> "${config_file}"
191191
fi
192192
193-
cat $config_file
193+
cat "${config_file}"
194194
195195
- name: Build site
196196
env:

scripts/readthedocs_build.sh

Lines changed: 71 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2,79 +2,64 @@
22
set -e
33

44
# REQUIRED ENVIRONMENT VARIABLES (for subprojects)
5-
github_workflow=$(echo "$GITHUB_WORKFLOW" | tr -d "'")
6-
site_artifact=$(echo "$SITE_ARTIFACT" | tr -d "'")
5+
github_workflow=$(echo "${GITHUB_WORKFLOW:-}" | tr -d "'")
6+
site_artifact=$(echo "${SITE_ARTIFACT:-}" | tr -d "'")
77

88
# OPTIONAL ENVIRONMENT VARIABLES (for subprojects)
9-
config_file=$(echo "$CONFIG_FILE" | tr -d "'")
10-
extract_archive=$(echo "$EXTRACT_ARCHIVE" | tr -d "'")
11-
github_timeout=$GITHUB_TIMEOUT
12-
theme_ref=$THEME_REF
9+
config_file=$(echo "${CONFIG_FILE:-_config.yml}" | tr -d "'")
10+
extract_archive=$(echo "${EXTRACT_ARCHIVE:-}" | tr -d "'")
11+
github_timeout="${GITHUB_TIMEOUT:-10}"
12+
theme_ref="${THEME_REF:-master}"
1313

1414
# From ReadTheDocs
15-
git_sha=$READTHEDOCS_GIT_COMMIT_HASH
16-
github_url=$READTHEDOCS_GIT_CLONE_URL
15+
git_sha=${READTHEDOCS_GIT_COMMIT_HASH}
16+
github_url=${READTHEDOCS_GIT_CLONE_URL}
1717

18-
if [[ $github_url == git@* ]]; then
18+
if [[ ${github_url} == git@* ]]; then
1919
# SSH URL format: [email protected]:user/repo.git
20-
github_user=$(echo "$github_url" | cut -d: -f2 | cut -d/ -f1)
21-
github_repo=$(echo "$github_url" | cut -d/ -f2 | sed 's/\.git$//')
20+
github_user=$(echo "${github_url}" | cut -d: -f2 | cut -d/ -f1)
21+
github_repo=$(echo "${github_url}" | cut -d/ -f2 | sed 's/\.git$//')
2222
else
2323
# HTTPS URL format: https://github.com/user/repo
24-
github_user=$(echo "$github_url" | cut -d/ -f4)
25-
github_repo=$(echo "$github_url" | cut -d/ -f5 | sed 's/\.git$//')
24+
github_user=$(echo "${github_url}" | cut -d/ -f4)
25+
github_repo=$(echo "${github_url}" | cut -d/ -f5 | sed 's/\.git$//')
2626
fi
2727

2828
export PAGES_REPO_NWO="${github_user}/${github_repo}"
2929

30-
# if timeout is not set then default to 10 minutes
31-
if [ -z "$github_timeout" ]; then
32-
github_timeout=10
33-
fi
34-
35-
# if config file is not set then default to _config.yml
36-
if [ -z "$config_file" ]; then
37-
config_file="_config.yml"
38-
fi
39-
40-
# if theme ref is not set then default to master
41-
if [ -z "$theme_ref" ]; then
42-
theme_ref="master"
43-
fi
44-
45-
echo "git sha: $git_sha"
46-
echo "github url: $github_url"
47-
echo "github user: $github_user"
48-
echo "github repo: $github_repo"
30+
echo "git sha: ${git_sha}"
31+
echo "github url: ${github_url}"
32+
echo "github user: ${github_user}"
33+
echo "github repo: ${github_repo}"
4934

5035
# set default directories
5136
project_dir="."
5237
theme_dir="."
5338

5439
# if not the theme project then we need to clone the theme with submodules
5540
sub_project="false"
56-
if [ "$READTHEDOCS_PROJECT" != "lizardbyte-gh-pages-main" ]; then
41+
if [ "${READTHEDOCS_PROJECT}" != "lizardbyte-gh-pages-main" ]; then
5742
sub_project="true"
58-
echo "Building a subproject: $READTHEDOCS_PROJECT"
59-
echo "github workflow: $github_workflow"
60-
echo "site artifact: $site_artifact"
61-
echo "github timeout: $github_timeout"
62-
echo "extract archive: $extract_archive"
63-
echo "config file: $config_file"
64-
echo "theme ref: $theme_ref"
43+
echo "Building a subproject: ${READTHEDOCS_PROJECT}"
44+
echo "github workflow: ${github_workflow}"
45+
echo "site artifact: ${site_artifact}"
46+
echo "github timeout: ${github_timeout}"
47+
echo "extract archive: ${extract_archive}"
48+
echo "config file: ${config_file}"
49+
echo "theme ref: ${theme_ref}"
6550

6651
start_time=$(date +%s)
6752
max_time=$((start_time + 60 * github_timeout))
6853
sleep_interval=10
6954

7055
# fail if the workflow is not set
71-
if [ -z "$github_workflow" ]; then
56+
if [ -z "${github_workflow}" ]; then
7257
echo "github_workflow is not set"
7358
exit 1
7459
fi
7560

7661
# fail if the site artifact is not set
77-
if [ -z "$site_artifact" ]; then
62+
if [ -z "${site_artifact}" ]; then
7863
echo "site_artifact is not set"
7964
exit 1
8065
fi
@@ -90,75 +75,75 @@ if [ "$READTHEDOCS_PROJECT" != "lizardbyte-gh-pages-main" ]; then
9075
git submodule update --init --recursive
9176
popd
9277

93-
encoded_workflow=$(echo "$github_workflow" | sed 's/ /%20/g')
78+
encoded_workflow="${github_workflow// /%20}"
9479
check_api_url="https://api.github.com/repos/${github_user}/${github_repo}/commits/${git_sha}/check-runs?check_name=${encoded_workflow}"
95-
echo "Check API URL: $check_api_url"
80+
echo "Check API URL: ${check_api_url}"
9681

9782
# Wait for check runs to be available
9883
count=1
9984
while true; do
10085
current_time=$(date +%s)
101-
if [ $current_time -gt $max_time ]; then
86+
if [ "${current_time}" -gt ${max_time} ]; then
10287
echo "Timeout waiting for check runs"
10388
exit 1
10489
fi
105-
echo "Checking check runs: $count"
90+
echo "Checking check runs: ${count}"
10691

107-
response=$(curl -s -H "Accept: application/vnd.github.v3+json" "$check_api_url")
108-
check_runs=$(echo "$response" | jq -r '.check_runs')
109-
check_run_count=$(echo "$check_runs" | jq -r 'length')
92+
response=$(curl -s -H "Accept: application/vnd.github.v3+json" "${check_api_url}")
93+
check_runs=$(echo "${response}" | jq -r '.check_runs')
94+
check_run_count=$(echo "${check_runs}" | jq -r 'length')
11095

111-
echo "Check runs count: $check_run_count"
96+
echo "Check runs count: ${check_run_count}"
11297

113-
if [ "$check_run_count" -gt 0 ]; then
114-
check_run=$(echo "$check_runs" | jq -r '.[0]')
115-
check_job_id=$(echo "$check_run" | jq -r '.id')
116-
check_run_html_url=$(echo "$check_run" | jq -r '.html_url')
117-
echo "Check job id: $check_job_id"
118-
echo "Check run URL: $check_run_html_url"
98+
if [ "${check_run_count}" -gt 0 ]; then
99+
check_run=$(echo "${check_runs}" | jq -r '.[0]')
100+
check_job_id=$(echo "${check_run}" | jq -r '.id')
101+
check_run_html_url=$(echo "${check_run}" | jq -r '.html_url')
102+
echo "Check job id: ${check_job_id}"
103+
echo "Check run URL: ${check_run_html_url}"
119104
break
120105
fi
121106

122107
echo "Waiting for check runs to be available..."
123-
sleep $sleep_interval
108+
sleep ${sleep_interval}
124109
count=$((count + 1))
125110
done
126111

127112
# get the run id from the html url
128113
# e.g. https://github.com/LizardByte/LizardByte.github.io/actions/runs/13687305039/job/38273540489
129-
check_run_id=$(echo "$check_run_html_url" | cut -d/ -f8)
130-
echo "Check run id: $check_run_id"
114+
check_run_id=$(echo "${check_run_html_url}" | cut -d/ -f8)
115+
echo "Check run id: ${check_run_id}"
131116

132117
# wait for the check run to complete, cancelled, timed out, etc.
133118
check_run_api_url="https://api.github.com/repos/${github_user}/${github_repo}/actions/runs/${check_run_id}"
134-
echo "Check run API URL: $check_run_api_url"
119+
echo "Check run API URL: ${check_run_api_url}"
135120

136121
count=1
137122
while true; do
138123
current_time=$(date +%s)
139-
if [ $current_time -gt $max_time ]; then
124+
if [ "${current_time}" -gt ${max_time} ]; then
140125
echo "Timeout waiting for check runs"
141126
exit 1
142127
fi
143-
echo "Checking check run status: $count"
128+
echo "Checking check run status: ${count}"
144129

145-
check_run_response=$(curl -s -H "Accept: application/vnd.github.v3+json" "$check_run_api_url")
130+
check_run_response=$(curl -s -H "Accept: application/vnd.github.v3+json" "${check_run_api_url}")
146131

147-
check_run_status=$(echo "$check_run_response" | jq -r '.status')
148-
check_run_conclusion=$(echo "$check_run_response" | jq -r '.conclusion')
132+
check_run_status=$(echo "${check_run_response}" | jq -r '.status')
133+
check_run_conclusion=$(echo "${check_run_response}" | jq -r '.conclusion')
149134

150-
echo "Check run status: $check_run_status"
151-
if [ "$check_run_status" == "completed" ]; then
135+
echo "Check run status: ${check_run_status}"
136+
if [ "${check_run_status}" == "completed" ]; then
152137
break
153138
fi
154139

155140
echo "Waiting for check run to complete..."
156-
sleep $sleep_interval
141+
sleep ${sleep_interval}
157142
count=$((count + 1))
158143
done
159144

160145
# if not successful then exit
161-
if [ "$check_run_conclusion" != "success" ]; then
146+
if [ "${check_run_conclusion}" != "success" ]; then
162147
echo "Check run did not complete successfully"
163148
exit 1
164149
fi
@@ -167,29 +152,29 @@ if [ "$READTHEDOCS_PROJECT" != "lizardbyte-gh-pages-main" ]; then
167152
artifact_url="https://nightly.link/${github_user}/${github_repo}/actions/runs/${check_run_id}/${site_artifact}"
168153

169154
# download and extract the ZIP artifact
170-
curl -sL "$artifact_url" -o "${project_dir}/artifact.zip"
155+
curl -sL "${artifact_url}" -o "${project_dir}/artifact.zip"
171156
7z x "${project_dir}/artifact.zip" -o"${project_dir}"
172157
rm "${project_dir}/artifact.zip"
173158

174159
# if there is a name provided for extract_artifact, then we will extract the nested archive
175-
if [ -n "$extract_archive" ]; then
160+
if [ -n "${extract_archive}" ]; then
176161
pushd "${project_dir}"
177-
case "$extract_archive" in
162+
case "${extract_archive}" in
178163
*.tar.gz|*.tgz)
179-
tar -xzf "$extract_archive" -C .
164+
tar -xzf "${extract_archive}" -C .
180165
;;
181166
*.tar)
182-
tar -xf "$extract_archive" -C .
167+
tar -xf "${extract_archive}" -C .
183168
;;
184169
*.zip)
185-
7z x "$extract_archive" -o.
170+
7z x "${extract_archive}" -o.
186171
;;
187172
*)
188173
echo "Unsupported archive format"
189174
exit 1
190175
;;
191176
esac
192-
rm -f "$extract_archive"
177+
rm -f "${extract_archive}"
193178
popd
194179
fi
195180
fi
@@ -220,8 +205,8 @@ targets=(
220205

221206
for base_dir in "${base_dirs[@]}"; do
222207
for target in "${targets[@]}"; do
223-
if [ -e "$base_dir/$target" ]; then
224-
cp -rf "$base_dir/$target" "${TMPDIR}/"
208+
if [ -e "${base_dir}/${target}" ]; then
209+
cp -rf "${base_dir}/${target}" "${TMPDIR}/"
225210
fi
226211
done
227212
done
@@ -233,31 +218,31 @@ cd "${TMPDIR}"
233218

234219
gem install bundle
235220
bundle install
236-
echo "baseurl: $READTHEDOCS_VERSION" > _config_rtd.yml
221+
echo "baseurl: ${READTHEDOCS_VERSION}" > _config_rtd.yml
237222
echo "_config_rtd.yml:"
238223
cat _config_rtd.yml
239224
echo "_config_theme.yml:"
240225
cat _config_theme.yml
241226

242227
config_files=_config_rtd.yml,_config_theme.yml
243-
if [ -n "$config_file" ] && [ -e "$config_file" ]; then
244-
config_files="${config_files},$config_file"
245-
echo "config file: $config_file"
246-
cat "$config_file"
228+
if [ -n "${config_file}" ] && [ -e "${config_file}" ]; then
229+
config_files="${config_files},${config_file}"
230+
echo "config file: ${config_file}"
231+
cat "${config_file}"
247232
fi
248233

249234
bundle exec jekyll build \
250235
--future \
251-
--config $config_files \
236+
--config "${config_files}" \
252237
--destination "${READTHEDOCS_OUTPUT}html"
253238

254239
# mimic gh-pages
255-
if [ "$sub_project" == "true" ]; then
240+
if [ "${sub_project}" == "true" ]; then
256241
mkdir -p "${READTHEDOCS_OUTPUT}html/${github_repo}/assets"
257242
cp -RTf "${READTHEDOCS_OUTPUT}html/assets" "${READTHEDOCS_OUTPUT}html/${github_repo}/assets"
258243
fi
259244

260245
echo "Build finished"
261246
echo "Output directory: ${READTHEDOCS_OUTPUT}html"
262247
echo "Listing output directory:"
263-
ls -Ra "$READTHEDOCS_OUTPUT"
248+
ls -Ra "${READTHEDOCS_OUTPUT}"

0 commit comments

Comments
 (0)