Skip to content

Commit 856457a

Browse files
authored
Add Spotless check format workflow (#6121)
1 parent fd33b50 commit 856457a

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

.github/workflows/check_format.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Check Format
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
4+
cancel-in-progress: true
5+
on:
6+
pull_request:
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
determine_changed:
13+
name: "Determine changed modules"
14+
runs-on: ubuntu-22.04
15+
if: (github.repository == 'Firebase/firebase-android-sdk' && github.event_name == 'push') || github.event_name == 'pull_request'
16+
outputs:
17+
modules: ${{ steps.changed-modules.outputs.modules }}
18+
steps:
19+
- uses: actions/[email protected]
20+
with:
21+
fetch-depth: 2
22+
submodules: true
23+
24+
- name: Set up JDK 17
25+
uses: actions/[email protected]
26+
with:
27+
java-version: 17
28+
distribution: temurin
29+
cache: gradle
30+
31+
- id: changed-modules
32+
run: |
33+
git diff --name-only HEAD~1 | xargs printf -- '--changed-git-paths %s\n' | xargs ./gradlew writeChangedProjects --output-file-path=modules.json
34+
echo modules=$(cat modules.json) >> $GITHUB_OUTPUT
35+
36+
check_format:
37+
name: "Check Format"
38+
runs-on: ubuntu-22.04
39+
needs:
40+
- determine_changed
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
module: ${{ fromJSON(needs.determine_changed.outputs.modules) }}
45+
46+
steps:
47+
- uses: actions/[email protected]
48+
with:
49+
fetch-depth: 2
50+
submodules: true
51+
52+
- name: Set up JDK 17
53+
uses: actions/[email protected]
54+
with:
55+
java-version: 17
56+
distribution: temurin
57+
cache: gradle
58+
59+
- name: ${{ matrix.module }} Check Format
60+
run: |
61+
./gradlew ${{matrix.module}}:spotlessCheck
62+
63+
# A job that fails if any job in the check_format matrix fails,
64+
# to be used as a required check for merging.
65+
check_all:
66+
runs-on: ubuntu-22.04
67+
if: always()
68+
name: Check Format (matrix)
69+
needs: check_format
70+
steps:
71+
- name: Check matrix
72+
if: needs.check_format.result != 'success'
73+
run: exit 1

0 commit comments

Comments
 (0)