forked from dmlc/xgboost
-
Notifications
You must be signed in to change notification settings - Fork 1
144 lines (130 loc) · 4.02 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
name: XGBoost CI (Lint)
on: [push, pull_request]
permissions:
contents: read # to fetch code (actions/checkout)
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
BRANCH_NAME: >-
${{ github.event.pull_request.number && 'PR-' }}${{ github.event.pull_request.number || github.ref_name }}
jobs:
build-containers:
name: Build CI containers (${{ matrix.container_id }})
runs-on:
- runs-on=${{ github.run_id }}
- runner=${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- container_id: xgb-ci.clang_tidy
runner: linux-amd64-cpu
steps:
# Restart Docker daemon so that it recognizes the ephemeral disks
- run: sudo systemctl restart docker
- uses: actions/checkout@v4.2.2
with:
submodules: "true"
- name: Build ${{ matrix.container_id }}
run: bash ops/docker_build.sh
env:
CONTAINER_ID: ${{ matrix.container_id }}
clang-tidy:
name: Run clang-tidy
needs: build-containers
runs-on:
- runs-on=${{ github.run_id }}
- runner=linux-amd64-cpu
steps:
# Restart Docker daemon so that it recognizes the ephemeral disks
- run: sudo systemctl restart docker
- uses: actions/checkout@v4.2.2
with:
submodules: "true"
- name: Fetch container from cache
run: bash ops/docker_build.sh
env:
CONTAINER_ID: xgb-ci.clang_tidy
- run: bash ops/pipeline/run-clang-tidy.sh
python-mypy-lint:
runs-on: ubuntu-latest
name: Type and format checks for the Python package
steps:
- uses: actions/checkout@v4.2.2
with:
submodules: 'true'
- uses: conda-incubator/setup-miniconda@v3.1.0
with:
miniforge-variant: Miniforge3
miniforge-version: latest
activate-environment: python_lint
environment-file: ops/conda_env/python_lint.yml
use-mamba: true
- name: Display Conda env
shell: bash -el {0}
run: |
conda info
conda list
- name: Run mypy
shell: bash -el {0}
run: |
python ops/script/lint_python.py --format=0 --type-check=1 --pylint=0
- name: Run formatter
shell: bash -el {0}
run: |
python ops/script/lint_python.py --format=1 --type-check=0 --pylint=0
- name: Run pylint
shell: bash -el {0}
run: |
python ops/script/lint_python.py --format=0 --type-check=0 --pylint=1
cpp-lint:
runs-on: ubuntu-latest
name: Code linting for C++
steps:
- uses: actions/checkout@v4.2.2
with:
submodules: 'true'
- uses: actions/setup-python@v5.3.0
with:
python-version: "3.10"
architecture: 'x64'
- name: Install Python packages
run: |
python -m pip install wheel setuptools cmakelint cpplint==1.6.1 pylint
- name: Run lint
run: |
python3 ops/script/lint_cpp.py
bash ops/script/lint_cmake.sh
lintr:
runs-on: ${{ matrix.os }}
name: Run R linters on OS ${{ matrix.os }}, R ${{ matrix.r }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
r: "release"
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
steps:
- uses: actions/checkout@v4.2.2
with:
submodules: 'true'
- uses: r-lib/actions/setup-r@v2.11.0
with:
r-version: ${{ matrix.r }}
- name: Cache R packages
uses: actions/cache@v4.1.2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-r-${{ matrix.r }}-7-${{ hashFiles('R-package/DESCRIPTION') }}
restore-keys: ${{ runner.os }}-r-${{ matrix.r }}-7-${{ hashFiles('R-package/DESCRIPTION') }}
- name: Install dependencies
shell: Rscript {0}
run: |
source("./R-package/tests/helper_scripts/install_deps.R")
- name: Run lintr
run: |
MAKEFLAGS="-j$(nproc)" R CMD INSTALL R-package/
Rscript ops/script/lint_r.R $(pwd)