forked from chipsalliance/verible-linter-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
87 lines (86 loc) · 3.2 KB
/
action.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
name: 'verible-linter'
description: 'This action lints Verilog/SystemVerilog code'
author: 'Antmicro'
inputs:
config_file:
description: 'Relative path to configuration file'
required: true
extra_args:
description: 'Extra arguments for verible-linter'
required: false
paths:
description: 'Optional array of paths to directories with source code to check'
required: false
default: '.'
exclude_paths:
description: 'Exclude these paths after finding all target files'
required: false
log_file:
description: 'Name for a log file'
required: false
default: 'verible-verilog-lint.log'
github_token:
description: 'GITHUB_TOKEN'
default: ''
reviewdog_reporter:
description: '-reporter option to reviewdog'
default: 'github-pr-review'
runs:
using: 'composite'
steps:
- run: sudo apt update
shell: bash
- run: sudo apt install -y python3 wget python3-click golang-go
shell: bash
- run: mkdir verible && wget -qO- https://github.com/google/verible/releases/download/v0.0-1213-g9e5c085/verible-v0.0-1213-g9e5c085-Ubuntu-20.04-focal-x86_64.tar.gz | tar -zxvf - -C verible --strip-components=1
shell: bash
- run: for i in $PWD/verible/bin/*; do sudo ln -s $i /bin/$(basename $i); done
shell: bash
- name: Install reviewdog
run: |
git clone https://github.com/reviewdog/reviewdog
cd reviewdog
git checkout 72c205e138df049330f2a668c33782cda55d61f6
git apply ${{ github.action_path }}/reviewdog.patch
mkdir ../bin
go build all
GOBIN=`pwd`/../bin go install ./cmd/reviewdog
cd ..
rm -rf reviewdog
./bin/reviewdog --version
shell: bash
- run: |
event_file=event.json
diff_cmd="git diff FECH_HEAD"
if [ -f "$event_file" ]; then
pr_branch=$(cat event.json | \
python3 -c "import sys, json; print(json.load(sys.stdin)['pull_request']['head']['ref'])")
base_branch=$(cat event.json | \
python3 -c "import sys, json; print(json.load(sys.stdin)['pull_request']['base']['ref'])")
git fetch origin $pr_branch
git checkout $pr_branch
echo "the PR branch is $pr_branch"
echo "the base branch is $base_branch"
diff_cmd="git diff $base_branch $pr_branch"
export OVERRIDE_GITHUB_EVENT_PATH=`pwd`/event.json
fi
touch "${{ inputs.log_file }}"
export REVIEWDOG_GITHUB_API_TOKEN="${{ inputs.github_token }}"
${{ github.action_path }}/action.py \
--conf-file "${{ inputs.config_file }}" \
--extra-opts "${{ inputs.extra_args }}" \
--exclude-paths "${{ inputs.exclude_paths }}" \
--log-file "${{ inputs.log_file }}" \
"${{ inputs.paths }}" || exitcode=$?
echo "Running reviewdog"
cat "${{ inputs.log_file }}" |
./bin/reviewdog -efm="%f:%l:%c: %m" \
-reporter="${{ inputs.reviewdog_reporter }}" \
-fail-on-error="false" \
-name="verible-verilog-lint" \
-diff="$diff_cmd" || cat "${{ inputs.log_file }}"
if [ -f "$event_file" ]; then
git checkout -
fi
exit $exitcode
shell: bash