docs: python 3.8 #77
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Linting | |
on: [push, pull_request] | |
jobs: | |
ruff: | |
name: ruff | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version-file: pyproject.toml | |
- name: Install ruff and requirements | |
run: | | |
pip3 install -r <(grep '^ruff==' deps/x86_64-unknown-linux-gnu/requirements_dev.txt) | |
- name: Run ruff (code annotation) | |
run: | | |
set +e # Do not exit shell on ruff failure | |
ruff check --output-format=github | |
exit 0 | |
- name: Run ruff (summary) | |
run: | | |
set +e # Do not exit shell on ruff failure | |
nonzero_exit=0 | |
files=$(find . -type f -name "*.py" | sort) | |
while read -r file; do | |
out=$(ruff check --force-exclude "$file" 2> ruff_stderr.txt) | |
exit_code=$? | |
err=$(<ruff_stderr.txt) | |
if [[ $exit_code -ne 0 ]]; then | |
nonzero_exit=$exit_code | |
fi | |
if [[ -n "$out" ]]; then | |
# Display the raw output in the step | |
echo "${out}" | |
# Display the Markdown output in the job summary | |
{ echo "\`\`\`python"; echo "${out}"; echo "\`\`\`"; } >> "$GITHUB_STEP_SUMMARY" | |
fi | |
if [[ -n "$err" ]]; then | |
echo "${err}" | |
{ echo "\`\`\`python"; echo "${err}"; echo "\`\`\`"; } >> "$GITHUB_STEP_SUMMARY" | |
fi | |
out=$(ruff check --diff --force-exclude "$file" 2> ruff_stderr.txt) | |
err=$(<ruff_stderr.txt) | |
if [[ -n "$out" ]]; then | |
# Display the raw output in the step | |
echo "${out}" | |
# Display the Markdown output in the job summary | |
{ echo "\`\`\`python"; echo "${out}"; echo "\`\`\`"; } >> "$GITHUB_STEP_SUMMARY" | |
fi | |
if [[ -n "$err" ]]; then | |
echo "${err}" | |
{ echo "\`\`\`python"; echo "${err}"; echo "\`\`\`"; } >> "$GITHUB_STEP_SUMMARY" | |
fi | |
done <<< "$files" | |
# Exit with the first non-zero exit-code returned by ruff | |
# or just zero if all passed | |
exit ${nonzero_exit} |