-
Notifications
You must be signed in to change notification settings - Fork 41
152 lines (150 loc) · 5.05 KB
/
lint.yml
File metadata and controls
152 lines (150 loc) · 5.05 KB
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
name: Lint
on:
push:
branches:
- master
- 'releases/**'
pull_request:
branches:
- '*'
jobs:
typecheck-build:
name: lint.python.typecheck-build
container:
image: vowpalwabbit/rl-manylinux-2_28-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: |
export OPENSSL_ROOT_DIR=/usr/local/openssl
export OPENSSL_LIBRARIES=/usr/local/openssl/lib
export OPENSSL_INCLUDE_DIR=/usr/local/openssl/include
${{ matrix.config.base_path }}bin/pip wheel . -w wheel_output/ --verbose
auditwheel repair wheel_output/*whl -w audit_output/
- name: Upload built wheel
# v1 must be used because newer versions require a node.js version that will not run on this old image.
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@v3
with:
submodules: recursive
- name: Download Wheel
uses: actions/download-artifact@v4
with:
name: wheel_${{ matrix.config.version }}
path: ${{ github.workspace }}/wheel_${{ matrix.config.version }}
- name: Install dependencies
shell: bash
run: |
pip install pytype
- 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 ./bindings/python/ --verbosity=2
python -m pytype ./examples/python/ --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@v4
with:
python-version: 3.9
- run: pip install black black[jupyter]
- name: Run python formatting
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-latest
steps:
# Must use v1 or else git diff breaks
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Install clang-format
shell: bash
run: |
sudo apt update
sudo apt install clang-format
clang-format --version
- name: Check code formatting for codebase
shell: bash
run: ./.scripts/linux/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 -- :^/ext_libs | 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: \"./.scripts/linux/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
container:
image: vowpalwabbit/ubuntu2004-dev:latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install dependencies
shell: bash
run: |
apt update
apt install -y libspdlog-dev libfmt-dev libboost-math-dev
apt install -y jq
- name: Run clang tidy
shell: bash
run: ./.scripts/linux/run-clang-tidy.sh