-
Notifications
You must be signed in to change notification settings - Fork 229
137 lines (136 loc) · 4.73 KB
/
pre-commit.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
name: Pre-commit
on:
pull_request:
push:
branches:
- master
schedule:
- cron: '0 * * * *' # Hourly
workflow_dispatch:
jobs:
get_date:
name: ":clock: Get Date"
runs-on: ubuntu-latest
steps:
- name: Get current date
id: date
run: echo "::set-output name=ymd::$(date +'%Y-%m-%d')"
outputs:
ymd: ${{ steps.date.outputs.ymd }}
format:
runs-on: ubuntu-latest
needs:
- get_date
steps:
- uses: actions/checkout@v3
- name: google-java-format cache
uses: actions/cache@v3
with:
path: "~/.cache/google-java-format"
key: google-java-format-${{ hashFiles('tools/fix_java_format.sh') }}
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: Java Formatting
run: tools/fix_java_format.sh --check
json_template:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install dependencies
run: python -m pip install pytest
- name: JSON Templates
run: cd tests && pytest
checkstyle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkstyle cache
uses: actions/cache@v3
with:
path: "~/.cache/checkstyle"
key: checkstyle-${{ hashFiles('tools/run_checkstyle.sh') }}
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: Checkstyle
run: tools/run_checkstyle.sh
bazel_build_test_and_pmd:
needs:
- get_date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Bazelisk cache
uses: actions/cache@v3
with:
path: "~/.cache/bazelisk"
key: ${{runner.os}}-bazelisk-${{ hashFiles('.bazelversion') }}
- name: Bazel cache
uses: actions/cache@v3
with:
path: "~/.cache/bazel"
key: ${{runner.os}}-bazel-${{ hashFiles('.bazelversion', 'WORKSPACE', 'maven_install.json') }}-test-${{ needs.get_date.outputs.ymd }}
restore-keys: |
${{runner.os}}-bazel-${{ hashFiles('.bazelversion', 'WORKSPACE', 'maven_install.json') }}-test-
${{runner.os}}-bazel-${{ hashFiles('.bazelversion', 'WORKSPACE', 'maven_install.json') }}-
${{runner.os}}-bazel-
- name: Bazel build and test
run: |
bazel test --test_output=errors --test_tag_filters=-pmd_test --build_tag_filters=-pmd_test -- //...
bazel test --test_output=errors --test_tag_filters=pmd_test -- //...
- name: Build JAR
run: |
mkdir workspace
bazel build //projects/allinone:allinone_main_deploy.jar
cp bazel-bin/projects/allinone/allinone_main_deploy.jar workspace/allinone.jar
- name: Save JAR
uses: actions/upload-artifact@v3
with:
name: allinone_jar
path: workspace/allinone.jar
code_cov:
needs:
- format
- json_template
- get_date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Bazelisk cache
uses: actions/cache@v3
with:
path: "~/.cache/bazelisk"
key: ${{runner.os}}-bazelisk-${{ hashFiles('.bazelversion') }}
- name: Bazel cache
uses: actions/cache@v3
with:
path: "~/.cache/bazel"
key: ${{runner.os}}-bazel-${{ hashFiles('.bazelversion', 'WORKSPACE', 'maven_install.json') }}-junit-${{ needs.get_date.outputs.ymd }}
restore-keys: |
${{runner.os}}-bazel-${{ hashFiles('.bazelversion', 'WORKSPACE', 'maven_install.json') }}-junit-
${{runner.os}}-bazel-${{ hashFiles('.bazelversion', 'WORKSPACE', 'maven_install.json') }}-
${{runner.os}}-bazel-
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: Bazel Junit Tests and Coverage
run: |
bazel coverage //projects/... \
--instrumentation_filter="-//projects/batfish/src/main/java/org/batfish/representation/juniper/parboiled,-//projects/batfish/src/main/java/org/batfish/vendor/check_point_management/parsing/parboiled,-//projects/batfish-common-protocol:specifier_common,-//projects/batfish/src/main/antlr4[/:],-//projects/.*/src/test[/:]" \
--test_tag_filters=-pmd_test \
--combined_report=lcov \
--instrument_test_targets=false
- name: Generate report
uses: codecov/codecov-action@v3
with:
files: bazel-out/_coverage/_coverage_report.dat
fail_ci_if_error: true
verbose: true