fix: suggested fixes for FMT #5897
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: Lint | |
on: | |
push: | |
branches: | |
- master | |
- 'releases/**' | |
pull_request: | |
branches: | |
- '*' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }} | |
cancel-in-progress: true | |
jobs: | |
typecheck-build: | |
name: lint.python.typecheck-build | |
container: | |
image: vowpalwabbit/manylinux2010-build:latest | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
config: | |
- { version: "3.9", base_path: /opt/python/cp39-cp39/, include_dir_name: python3.9/ } | |
steps: | |
# v1 must be used because newer versions require a node.js version that will not run on this old image. | |
- uses: actions/checkout@v1 | |
with: | |
submodules: recursive | |
- name: Build wheel | |
shell: bash | |
run: | | |
${{ matrix.config.base_path }}bin/pip wheel . -w wheel_output/ --global-option --cmake-options="-DSTATIC_LINK_VW_JAVA=On;-DPython_INCLUDE_DIR='${{ matrix.config.base_path }}include/${{ matrix.config.include_dir_name }}'" --verbose | |
auditwheel repair wheel_output/*whl -w audit_output/ | |
- name: Upload built wheel | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheel_${{ matrix.config.version }} | |
path: audit_output/ | |
typecheck-check: | |
name: lint.python.typecheck-check | |
needs: typecheck-build | |
container: | |
image: python:${{ matrix.config.version }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
config: | |
- { version: "3.9" } | |
steps: | |
- uses: actions/checkout@v1 | |
with: | |
submodules: recursive | |
- name: Download Wheel | |
uses: actions/download-artifact@v4 | |
with: | |
name: wheel_${{ matrix.config.version }} | |
- name: Install dependencies | |
shell: bash | |
run: | | |
pip install -r requirements.txt | |
pip install pytype | |
# required for test and utl directory typecheck | |
pip install hyperopt matplotlib seaborn | |
- name: Install wheel | |
shell: bash | |
run: | | |
export wheel_files=(wheel_${{ matrix.config.version }}/*) | |
export wheel_file="${wheel_files[0]}" | |
echo Installing ${wheel_file}... | |
pip install ${wheel_file} | |
- name: Run pytype | |
shell: bash | |
run: | | |
python -m pytype ./python/vowpalwabbit/ --verbosity=2 | |
python -m pytype ./test/ --verbosity=2 | |
python -m pytype ./utl/ --verbosity=2 | |
python-formatting: | |
name: lint.python.formatting | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Setup python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- run: pip install black black[jupyter] | |
- shell: bash | |
run: | | |
python -m black --check . --exclude ext_libs/ || (echo -e "---\nTo fix, run:\n\tpython -m black . --exclude ext_libs"; exit 1) | |
cpp-formatting: | |
name: lint.c++.formatting | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install clang-format | |
# This is only needed if the diff check runs as it installs 'clang-format-diff' | |
# 'clang-format' is available by default | |
if: github.event_name == 'pull_request' | |
shell: bash | |
run: | | |
sudo apt update | |
sudo apt install clang-format | |
clang-format --version | |
- name: Check code formatting for codebase | |
shell: bash | |
run: ./utl/clang-format.sh check | |
env: | |
GH_WORKFLOW_LOGGING: true | |
- name: Check code formatting for diff | |
# Only run the diff check for pull requests | |
if: github.event_name == 'pull_request' | |
shell: bash | |
run: | | |
if [[ ! -f .clang-format ]]; then | |
echo "Cannot find .clang-format file!" | |
exit 1 | |
fi | |
git diff origin/master...HEAD -U0 --no-color | clang-format-diff -r '^.*\.(cc|h)$' -p1 > clang_format_diff.txt | |
if [ -s clang_format_diff.txt ]; then | |
cat clang_format_diff.txt | |
echo "::error:: Formatting issues found" | |
echo "To fix:" | |
echo -e "\tUse the clang-format.sh script in docker mode:" | |
echo -e "\t\tRun: \"./utl/clang-format.sh docker fix\"" | |
echo -e "\tOr, install the right verson of clang-format locally" | |
echo -e "\t\tRun: \"git diff upstream/master...HEAD -U0 --no-color | clang-format-diff -r '^.*\.(cc|h)$' -p1 -i\"" | |
echo -e "\tBe sure to check your version of clang-format. The version used here is..." | |
clang-format --version | |
exit 1 | |
else | |
echo "No formatting issues found in the PR diff." | |
fi | |
run-clang-tidy: | |
name: lint.c++.clang-tidy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: cachix/install-nix-action@v18 | |
- name: Run clang-tidy | |
run: | | |
echo "::group::nix develop -c vw-clang-tidy" | |
nix develop -c vw-clang-tidy | tee tidy_out.txt || true | |
# Prevent false positives for THROW("error: ...") by using the prepended : | |
grep -A 3 ": error: " tidy_out.txt > tidy_onlyerrors.txt || true | |
echo "::endgroup::" | |
if [ -s tidy_onlyerrors.txt ]; then | |
# file has contents | |
echo "::group::clang-tidy errors" | |
cat tidy_onlyerrors.txt | |
echo "::endgroup::" | |
exit 11 | |
fi |