Skip to content

Commit 1ab76d0

Browse files
Fix ShellCheck findings in lib-deps-check and update-doc-db workflows (RustPython#7669)
Clear four of the five ShellCheck findings reported in RustPython#7653. The fifth finding is in upgrade-pylib.lock.yml — a gh-aw-generated file marked "DO NOT EDIT" whose source .md does not contain the flagged pattern — and is out of scope here; it will resolve via the in-flight gh-aw version bump (RustPython#7650). lib-deps-check.yaml: * SC2076: replace `=~ " $module "` (quoted regex interpreted literally) with `== *" $module "*` glob match. Same intent (literal substring), same semantics across regex metachars. * SC2086: quote `$GITHUB_OUTPUT` in the output redirect. update-doc-db.yml: * SC2129: collapse the eight sequential `echo ... >> $OUTPUT_FILE` lines (plus one `cat ... >> $OUTPUT_FILE`) into a single grouped redirect `{ ...; } > "$OUTPUT_FILE"`. Drops the now-redundant `echo -n '' > $OUTPUT_FILE` truncate. * SC2016: add `# shellcheck disable=SC2016` above the block; the backticks in the auto-generated-header comment are literal Markdown, not command substitution. Verified locally with shellcheck 0.11.0: both modified blocks produce no ShellCheck output. Semantic equivalence of the lib-deps-check change confirmed across six test inputs including regex metachars and glob-meaningful characters.
1 parent f0acc67 commit 1ab76d0

2 files changed

Lines changed: 12 additions & 13 deletions

File tree

.github/workflows/lib-deps-check.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ jobs:
7171
# Lib files: Lib/foo.py -> foo, Lib/foo/__init__.py -> foo
7272
module=$(echo "$file" | sed -E 's|^Lib/||; s|/__init__\.py$||; s|\.py$||; s|/.*||')
7373
fi
74-
if [[ -n "$module" && ! " $modules " =~ " $module " ]]; then
74+
if [[ -n "$module" && " $modules " != *" $module "* ]]; then
7575
modules="$modules $module"
7676
fi
7777
done
7878
7979
modules=$(echo "$modules" | xargs) # trim whitespace
8080
echo "Detected modules: $modules"
81-
echo "modules=$modules" >> $GITHUB_OUTPUT
81+
echo "modules=$modules" >> "$GITHUB_OUTPUT"
8282
8383
- name: Setup Python
8484
if: steps.changed-files.outputs.modules != ''

.github/workflows/update-doc-db.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,16 @@ jobs:
8787
8888
OUTPUT_FILE='crates/doc/src/data.inc.rs'
8989
90-
echo -n '' > $OUTPUT_FILE
91-
92-
echo '// This file was auto-generated by `.github/workflows/update-doc-db.yml`.' >> $OUTPUT_FILE
93-
echo "// CPython version: ${PYTHON_VERSION}" >> $OUTPUT_FILE
94-
echo '// spell-checker: disable' >> $OUTPUT_FILE
95-
96-
echo '' >> $OUTPUT_FILE
97-
98-
echo "pub static DB: phf::Map<&'static str, &'static str> = phf::phf_map! {" >> $OUTPUT_FILE
99-
cat crates/doc/generated/raw_entries.txt >> $OUTPUT_FILE
100-
echo '};' >> $OUTPUT_FILE
90+
# shellcheck disable=SC2016
91+
{
92+
echo '// This file was auto-generated by `.github/workflows/update-doc-db.yml`.'
93+
echo "// CPython version: ${PYTHON_VERSION}"
94+
echo '// spell-checker: disable'
95+
echo ''
96+
echo "pub static DB: phf::Map<&'static str, &'static str> = phf::phf_map! {"
97+
cat crates/doc/generated/raw_entries.txt
98+
echo '};'
99+
} > "$OUTPUT_FILE"
101100
102101
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
103102
with:

0 commit comments

Comments
 (0)