Speed up github actions for apiDumps #159
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Lint and API Checks | |
| on: | |
| pull_request: | |
| branches: [ master ] | |
| concurrency: | |
| group: ci-lint-api-check-${{ github.head_ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| lintAndApiChecks: | |
| runs-on: macos-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '17' | |
| cache: gradle | |
| - name: Format Kotlin | |
| run: ./gradlew formatKotlin | |
| - name: Update API files for changed modules | |
| env: | |
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| run: | | |
| changed_modules="" | |
| dump_all=false | |
| while IFS= read -r changed_file; do | |
| module="${changed_file%%/*}" | |
| if [ -d "$module/api" ]; then | |
| case " $changed_modules " in | |
| *" $module "*) ;; | |
| *) changed_modules="$changed_modules $module" ;; | |
| esac | |
| else | |
| dump_all=true | |
| fi | |
| done < <(git diff --name-only "$BASE_SHA...$HEAD_SHA") | |
| if [ "$dump_all" = true ] || [ -z "$changed_modules" ]; then | |
| changed_modules="" | |
| for api_directory in */api; do | |
| changed_modules="$changed_modules ${api_directory%/api}" | |
| done | |
| fi | |
| api_dump_tasks="" | |
| for module in $changed_modules; do | |
| if [ -d "$module/api/android" ] || find "$module/api" -maxdepth 1 -name '*.api' -print -quit | grep -q .; then | |
| api_dump_tasks="$api_dump_tasks :${module}:androidApiDump" | |
| fi | |
| if [ -d "$module/api/jvm" ]; then | |
| api_dump_tasks="$api_dump_tasks :${module}:jvmApiDump" | |
| fi | |
| done | |
| echo "Running API dump tasks:$api_dump_tasks" | |
| ./gradlew $api_dump_tasks | |
| - run: git status | |
| - uses: stefanzweifel/git-auto-commit-action@v7 |