-
Notifications
You must be signed in to change notification settings - Fork 1.9k
158 lines (155 loc) · 5.43 KB
/
lint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
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@v1
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@v1
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