Skip to content

Commit 13cb423

Browse files
committed
Update
1 parent 885a7ae commit 13cb423

File tree

1 file changed

+39
-6
lines changed

1 file changed

+39
-6
lines changed

.github/workflows/spelling.yml

+39-6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
}
4646
4747
core.setOutput('skip', skipCheck.toString());
48-
core.setOutput('files', changedFiles.join(' '));
48+
core.setOutput('files', changedFiles.join('\n'));
4949
core.setOutput('is-pr', (context.eventName === 'pull_request').toString());
5050
5151
- uses: actions/checkout@v4
@@ -60,7 +60,9 @@ jobs:
6060
id: push-files
6161
run: |
6262
CHANGED_FILES=$(git diff --name-only HEAD^..HEAD -- '*.py' '*.rst' '*.md')
63-
echo "files=$CHANGED_FILES" >> $GITHUB_OUTPUT
63+
echo "files<<EOF" >> $GITHUB_OUTPUT
64+
echo "$CHANGED_FILES" >> $GITHUB_OUTPUT
65+
echo "EOF" >> $GITHUB_OUTPUT
6466
6567
- name: Check if relevant files changed
6668
if: steps.check-files.outputs.skip != 'true'
@@ -97,14 +99,45 @@ jobs:
9799
pip install pyspelling
98100
sudo apt-get install aspell aspell-en
99101
100-
- name: Run pyspelling
102+
- name: Run spell check on each file
101103
if: |
102104
steps.check-files.outputs.skip != 'true' &&
103105
steps.check.outputs.skip != 'true'
104106
run: |
107+
# Get the list of files into an array
105108
if [ "${{ steps.check-files.outputs.is-pr }}" == "true" ]; then
106-
FILES="${{ steps.check-files.outputs.files }}"
109+
mapfile -t FILES <<< "${{ steps.check-files.outputs.files }}"
107110
else
108-
FILES="${{ steps.push-files.outputs.files }}"
111+
mapfile -t FILES <<< "${{ steps.push-files.outputs.files }}"
112+
fi
113+
114+
# Check each file individually
115+
FINAL_EXIT_CODE=0
116+
for file in "${FILES[@]}"; do
117+
if [ -n "$file" ]; then
118+
echo "Checking spelling in $file"
119+
# Create a temporary config file based on the existing one
120+
python3 - <<EOF > temp_config.yml
121+
import yaml
122+
123+
with open('.pyspelling.yml', 'r') as f:
124+
config = yaml.safe_load(f)
125+
126+
# Modify only the sources in each matrix entry
127+
for matrix in config['matrix']:
128+
matrix['sources'] = ['$file']
129+
130+
with open('temp_config.yml', 'w') as f:
131+
yaml.dump(config, f, default_flow_style=False)
132+
EOF
133+
134+
if ! pyspelling -c temp_config.yml; then
135+
FINAL_EXIT_CODE=1
136+
fi
137+
fi
138+
done
139+
140+
if [ $FINAL_EXIT_CODE -ne 0 ]; then
141+
echo "Spell check failed!"
142+
exit 1
109143
fi
110-
pyspelling --source "$FILES"

0 commit comments

Comments
 (0)