Repository navigation
88 lines (78 loc) · 3.02 KB
/
Copy pathjava-checkstyle.yml
File metadata and controls
88 lines (78 loc) · 3.02 KB
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
# Copyright 2021 Collate
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Java Checkstyle
on:
merge_group:
# Trigger analysis when pushing in master or pull requests, and when creating
# a pull request.
push:
branches:
- main
- "0.[0-9]+.[0-9]+"
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- "openmetadata-ui/src/main/resources/ui/playwright/doc-generator/**"
- "openmetadata-ui/src/main/resources/ui/playwright/docs/**"
permissions:
contents: read
concurrency:
group: java-checkstyle-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
jobs:
java-checkstyle:
runs-on: ubuntu-latest
env:
FAILURE_HELP: |
**The Java checkstyle failed.**
Please run `mvn spotless:apply` in the root of your repository and commit the changes to this PR.
You can also use [pre-commit](https://pre-commit.com/) to automate the Java code formatting.
You can install the pre-commit hooks with `make install_test precommit_install`.
steps:
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'merge_group' && github.sha || github.event.pull_request.head.sha }}
persist-credentials: false
# Restore-only: spotless and google-java-format come from the ~/.m2 the
# unit-test jobs save on main. This job never saves, so PR runs add no
# PR-scoped copy to the shared cache budget.
- name: Restore Maven dependencies
uses: actions/cache/restore@v6
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
- name: Run checkstyle
run: mvn spotless:apply
- name: Save checkstyle outcome
id: git
continue-on-error: true
run: |
git diff-files --quiet
- name: Java checkstyle failed
if: steps.git.outcome != 'success'
run: |
{
echo "$FAILURE_HELP"
echo
echo "Files \`mvn spotless:apply\` reformatted:"
echo
git diff --name-only | sed 's/^/- /'
} >> "$GITHUB_STEP_SUMMARY"
echo "::error title=Java checkstyle failed::Run 'mvn spotless:apply' in the repository root and commit the changes. The job summary lists the files."
exit 1