forked from antmicro/verible-formatter-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
73 lines (70 loc) · 2.62 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
name: 'verible-formatter'
description: 'This action formats Verilog/SystemVerilog code'
author: 'Antmicro'
inputs:
paths:
description: 'Optional array of paths to directories with source code to format'
required: false
default: '.'
github_token:
description: 'GITHUB_TOKEN'
default: ''
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
verible-verilog-format --inplace ${{ inputs.paths }} > /dev/null 2>&1
rm -rf verible
tmp_file=$(mktemp)
git diff >"${tmp_file}"
git stash
export REVIEWDOG_GITHUB_API_TOKEN="${{ inputs.github_token }}"
echo "running reviewdog"
./bin/reviewdog -name="verible-verilog-format" \
-f=diff -f.diff.strip=1 \
-reporter="github-pr-review" \
-filter-mode="diff_context" \
-level="info" \
-diff="$diff_cmd" \
-fail-on-error="false" <"${tmp_file}" || true
echo "done running reviewdog"
cat "${tmp_file}" | wc
if [ -f "$event_file" ]; then
git checkout -
fi
shell: bash