Skip to content

Commit 5a01be1

Browse files
authored
[Nova] Lint job on GHA (#1114)
1 parent 697a278 commit 5a01be1

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

.github/workflows/lint.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- nightly
8+
- main
9+
- release/*
10+
workflow_dispatch:
11+
12+
jobs:
13+
python-source-and-configs:
14+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
15+
with:
16+
repository: pytorch/rl
17+
script: |
18+
set -euo pipefail
19+
20+
echo '::group::Setup environment'
21+
CONDA_PATH=$(which conda)
22+
eval "$(${CONDA_PATH} shell.bash hook)"
23+
conda create --name ci --quiet --yes python=3.8 pip
24+
conda activate ci
25+
echo '::endgroup::'
26+
27+
echo '::group::Install lint tools'
28+
pip install --progress-bar=off pre-commit
29+
echo '::endgroup::'
30+
31+
echo '::group::Lint Python source and configs'
32+
set +e
33+
pre-commit run --all-files
34+
35+
if [ $? -ne 0 ]; then
36+
git --no-pager diff
37+
exit 1
38+
fi
39+
echo '::endgroup::'
40+
41+
c-source:
42+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
43+
with:
44+
repository: pytorch/rl
45+
script: |
46+
set -euo pipefail
47+
48+
echo '::group::Setup environment'
49+
CONDA_PATH=$(which conda)
50+
eval "$(${CONDA_PATH} shell.bash hook)"
51+
conda create --name ci --quiet --yes -c conda-forge python=3.8 ncurses=5 libgcc
52+
conda activate ci
53+
export LD_LIBRARY_PATH="${CONDA_PREFIX}/lib:${LD_LIBRARY_PATH}"
54+
echo '::endgroup::'
55+
56+
echo '::group::Install lint tools'
57+
curl https://oss-clang-format.s3.us-east-2.amazonaws.com/linux64/clang-format-linux64 -o ./clang-format
58+
chmod +x ./clang-format
59+
echo '::endgroup::'
60+
61+
echo '::group::Lint C source'
62+
set +e
63+
./.circleci/unittest/linux/scripts/run-clang-format.py -r torchrl/csrc --clang-format-executable ./clang-format
64+
65+
if [ $? -ne 0 ]; then
66+
git --no-pager diff
67+
exit 1
68+
fi
69+
echo '::endgroup::'

0 commit comments

Comments
 (0)