forked from openconfig/featureprofiles
-
Notifications
You must be signed in to change notification settings - Fork 1
109 lines (104 loc) · 3.23 KB
/
pull_request.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
name: Pull Request
on: [pull_request]
jobs:
check_style:
name: Check style against CONTRIBUTING.md
runs-on: ubuntu-latest
steps:
- name: Setup Perl
uses: perl-actions/install-with-cpanm@v1
with:
install: |
Net::IP
- name: Checkout code
uses: actions/checkout@v3
- name: IP Addresses Assignment
run: |
find . -name \*.go -exec ./tools/check_ip_addresses.pl \{} +
- name: Allowed File Types
run: ./tools/allowed_file_types.sh
- name: Enum
run: |
fail=0
if find . -name \*.go -exec egrep -n '\.Union.*?\([0-9]+\)' \{} +
then
echo "Please do not use numerical constants in a union." >&2
echo "See CONTRIBUTING.md#enum" >&2
fail=1
fi
if find . -name \*.go -exec egrep -n '_Union\([0-9]+\)' \{} +
then
echo "Please do not use numerical constants in a union." >&2
echo "See CONTRIBUTING.md#enum" >&2
fail=1
fi
exit "${fail}"
- name: Default NetworkInstance
run: |
if find . -name \*.go -exec egrep -n '"default"' \{} +
then
echo "Default network instance name should be uppercase." >&2
echo "See CONTRIBUTING.md#default-network-instance" >&2
exit 1
fi
static_analysis:
name: Static Analysis
runs-on: ubuntu-latest
steps:
- name: Install go
uses: actions/setup-go@v2
with:
go-version: '1.19'
- name: Checkout code
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/.cache/staticcheck
key: ${{ github.job }}-${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ github.job }}-${{ runner.os }}-go-build-
- name: Go vet
run: GOGC=30 go vet ./...
- name: Gofmt
run: |
# gofmt always returns true, so we use grep '^' which returns
# true on non-empty output, but will otherwise passthrough all
# output lines.
if gofmt -d -s . | grep '^'; then
exit 1
fi
- name: Get goimports
run: go install golang.org/x/tools/cmd/goimports@latest
- name: Goimports
run: |
# goimports always returns true, so we use grep '^' which returns
# true on non-empty output, but will otherwise passthrough all
# output lines.
#
# goimports does not support "gofmt -s" so both goimports and gofmt are
# required.
if goimports -d . | grep '^'; then
exit 1
fi
- name: Get revive
run: go install github.com/mgechev/revive@latest
- name: Run revive
run: revive ./...
- name: Get staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest
- name: Run staticcheck
run: GOGC=30 staticcheck ./...
otg_changes:
name: OTG Changes Required
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check if OTG changes required
uses: actions/github-script@v6
with:
script: |
const script = require('./.github/workflows/required_otg_changes_check.js')
await script({github, context, core})