Skip to content

Fix/signature lints

Fix/signature lints #6

Workflow file for this run

name: Lint
on:
pull_request:
branches: [main]
types: [opened, synchronize]
permissions: read-all
jobs:
whitespace-lint:
runs-on: ubuntu-latest
name: Lint whitespace
steps:
- name: Check out source repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Detect empty lines at end of file and trailing whitespace
run: |
set -euxo pipefail # No -x here!
failed=0
# First, check for empty files at end
for file in $(for f in $(git ls-files --eol | grep 'i/[cr]*lf' | awk '{print $4}'); do egrep -l "^$" $file; done); do
line=$(wc -l "$file" | cut -d ' ' -f1)
echo "::error file=$file,line=$line::File $file has empty lines at end. Please remove."
failed=$((failed + 1))
done
# Next, check for files with whitespace at end of line. Remove CRLF files.
for file in $(git ls-files --eol | grep 'i/lf' | awk '{print $4}'); do
for line in $(grep -n '[[:space:]]$' "$file" | cut -d: -f1); do
echo "::error file=$file,line=$line::File $file has trailing whitespace at line $line. Please remove."
failed=$((failed + 1))
done
done
# Finally, check for missing endline at end of file, for any text file.
for file in $(git ls-files | grep 'i/lf' | awk '{print $4}'); do
if [[ -n "$(tail -c 1 "$file")" ]]; then
line=$(wc -l "$file" | cut -d ' ' -f1)
echo "::error file=$file,line=$line::File $file needs an endline at the end. Please add."
failed=$((failed + 1))
fi
done
# Report status
if [[ $failed -ne 0 ]]; then
echo "::error Found $failed whitespace errors, failing"
exit 1
fi
pytype-lint:
runs-on: ubuntu-latest
name: Type Check
steps:
- name: Check out source repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Python environment
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: "3.11"
- name: run pytype
run: |
python -m venv venv
.github/workflows/scripts/venv_activate.sh
pip install -r model_signing/install/requirements_Linux.txt
pip install -r model_signing/install/requirements_test_Linux.txt
pip install -r model_signing/install/requirements_dev_Linux.txt
# TODO: https://github.com/sigstore/model-transparency/issues/231 - Support all repo
pytype --keep-going model_signing/{hashing,manifest,serialization,signature}
pylint-lint:
runs-on: ubuntu-latest
name: Python lint
steps:
- name: Check out source repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Python environment
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: "3.11"
- name: run pylint
run: |
python -m venv venv
.github/workflows/scripts/venv_activate.sh
pip install -r model_signing/install/requirements_Linux.txt
pip install -r model_signing/install/requirements_test_Linux.txt
pip install -r model_signing/install/requirements_dev_Linux.txt
# TODO: https://github.com/sigstore/model-transparency/issues/231 - Support all repo
# We should actually migrate to ruff, but that's configured via pyproject.toml which we use when we release the wheel
pylint --disable C0114,C0115,C0116,R0801,R0903,R0904,R0913,R0914,R1721,R1737,W0107,W0212,W0223,W0231,W0511,W0621 model_signing/{hashing,manifest,serialization,signature}