Skip to content

Add Spotless check format workflow #6121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/check_format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Check Format
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
pull_request:
push:
branches:
- main

jobs:
determine_changed:
name: "Determine changed modules"
runs-on: ubuntu-22.04
if: (github.repository == 'Firebase/firebase-android-sdk' && github.event_name == 'push') || github.event_name == 'pull_request'
outputs:
modules: ${{ steps.changed-modules.outputs.modules }}
steps:
- uses: actions/[email protected]
with:
fetch-depth: 2
submodules: true

- name: Set up JDK 17
uses: actions/[email protected]
with:
java-version: 17
distribution: temurin
cache: gradle

- id: changed-modules
run: |
git diff --name-only HEAD~1 | xargs printf -- '--changed-git-paths %s\n' | xargs ./gradlew writeChangedProjects --output-file-path=modules.json
echo modules=$(cat modules.json) >> $GITHUB_OUTPUT

check_format:
name: "Check Format"
runs-on: ubuntu-22.04
needs:
- determine_changed
strategy:
fail-fast: false
matrix:
module: ${{ fromJSON(needs.determine_changed.outputs.modules) }}

steps:
- uses: actions/[email protected]
with:
fetch-depth: 2
submodules: true

- name: Set up JDK 17
uses: actions/[email protected]
with:
java-version: 17
distribution: temurin
cache: gradle

- name: ${{ matrix.module }} Check Format
run: |
./gradlew ${{matrix.module}}:spotlessCheck

# A job that fails if any job in the check_format matrix fails,
# to be used as a required check for merging.
check_all:
runs-on: ubuntu-22.04
if: always()
name: Check Format (matrix)
needs: check_format
steps:
- name: Check matrix
if: needs.check_format.result != 'success'
run: exit 1
Loading