This repository has been archived by the owner on Nov 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
163 lines (156 loc) · 5.42 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
159
160
161
162
163
name: Lint
on:
push:
branches:
- main
pull_request:
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
lint:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.9.x
architecture: x64
- name: Fetch ParlAI
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Fix git
run: |
set -eux
git fetch origin main
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
git branch -f main origin/main
fi
- name: Run flake8
run: |
set -eux
pip install -q flake8 flake8-bugbear flake8-black docformatter==1.3.0 black==22.3.0
python setup.py develop --no-deps # get our custom flake8 errors
python -c 'import parlai'
flake8 --version
bash autoformat.sh -c -f | tee ${GITHUB_WORKSPACE}/output-annotations.txt
- name: Add annotations
uses: pytorch/add-annotations-github-action@master
with:
check_name: 'lint'
linter_output_path: 'output-annotations.txt'
commit_sha: ${{ github.event.pull_request.head.sha }}
regex: '^(?<filename>.*?):(?<lineNumber>\d+):(?<columnNumber>\d+): (?<errorCode>\w+\d+) (?<errorDesc>.*)'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Failure check
run: |
if [ "$(cat ${GITHUB_WORKSPACE}/output-annotations.txt | wc -l)" != "0" ]
then
exit 1
fi
mypy:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.9.x
architecture: x64
- name: Fetch ParlAI
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Fix git
run: |
set -eux
git fetch origin main
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
git branch -f main origin/main
fi
- name: Get head SHA
run: |
HEAD_SHA="NONE"
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
else
HEAD_SHA="${{ github.event.push.head.sha }}"
fi
echo $HEAD_SHA
echo "HEAD_SHA=${HEAD_SHA}" >> $GITHUB_ENV
- name: caching dependencies
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: pip-20200712--${{ hashFiles('**/requirements.txt') }}
id: cache
- name: install dependencies
run: |
pip install -q -r requirements.txt
pip install -q mypy mypy-extensions
pip install -q git+https://github.com/numpy/numpy-stubs.git
pip install -q torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
- name: mypy
run: |
set -eux
mypy | sort | grep -v '^Found ' > typeerrors-HEAD.txt
forkpoint=$(git merge-base main HEAD)
git checkout -f $forkpoint
mypy | sort | grep -v '^Found ' > typeerrors-main.txt
diff -u typeerrors-main.txt typeerrors-HEAD.txt | grep -v '^+++' | grep '^+' > typeerrors-CHANGED.txt || true
cat typeerrors-CHANGED.txt | sed 's/^+//' | sed 's/: error:/:1: mypy:/' | tee ${GITHUB_WORKSPACE}/output-annotations.txt
- name: Add annotations
uses: stephenroller/add-annotations-github-action@master
with:
check_name: 'mypy'
linter_output_path: 'output-annotations.txt'
commit_sha: ${{ env.HEAD_SHA }}
regex: '^(?<filename>.*?):(?<lineNumber>\d+):(?<columnNumber>\d+): (?<errorCode>\w+): (?<errorDesc>.*)'
annotation_level: warning
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jslint:
runs-on: ubuntu-latest
steps:
- name: Fetch ParlAI
uses: actions/checkout@v1
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Get head SHA
run: |
HEAD_SHA="NONE"
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
else
HEAD_SHA="${{ github.event.push.head.sha }}"
fi
echo $HEAD_SHA
echo "HEAD_SHA=${HEAD_SHA}" >> $GITHUB_ENV
- name: Setup
working-directory: parlai/crowdsourcing/
run: |
set -eux
npm install
npm install --save-dev -g eslint
- name: Run ESLint
working-directory: parlai/crowdsourcing/
run: |
set -eux
npx eslint --format unix . | \
sed "s#${GITHUB_WORKSPACE}#.#" | \
tee ${GITHUB_WORKSPACE}/output-annotations.txt
- name: Add annotations
uses: pytorch/add-annotations-github-action@master
with:
check_name: 'jslint'
linter_output_path: 'output-annotations.txt'
commit_sha: ${{ env.HEAD_SHA }}
regex: '^(?<filename>.*?):(?<lineNumber>\d+):(?<columnNumber>\d+): (?<errorDesc>.*) \[(?<errorCode>.*)\]'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}