Repository navigation
50 lines (45 loc) · 1.82 KB
/
Copy pathcheck-spotless.yml
File metadata and controls
50 lines (45 loc) · 1.82 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
# Check for code formatting and license header errors using Spotless
#
# Description:
# Runs Spotless check for pull requests to ensure code formatting consistency,
# proper import ordering, and license headers.
# Fails the build if any violations are found.
#
# Deliberately has no `paths` filter: `mvn spotless:check` runs across every
# Maven module, so filtering by path would skip the job for changes it still
# validates. A module missing from such a filter (e.g. otel-plugin) can merge
# unformatted code and then break this check on unrelated pull requests.
#
# Triggers:
# - pull_request: every PR targeting main
# - push: main, to catch any formatting drift that lands
# - workflow_dispatch: manual run
name: Spotless
on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main
permissions:
contents: read
jobs:
spotless-check:
# CodeBuild-hosted runner in the Java testing account (Lambda compute,
# corretto21 image with Maven preinstalled). The label must match the
# CodeBuild project name exactly. Fork PRs stay on GitHub-hosted runners so
# untrusted fork code never executes inside the testing account.
runs-on: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && 'ubuntu-latest' || format('codebuild-github-actions-runner-{0}-{1}', github.run_id, github.run_attempt) }}
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up JDK 17
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
java-version: '17'
distribution: 'corretto'
cache: maven
- name: Run Spotless check
run: mvn -B -q spotless:check --file pom.xml