Code Quality Checks #20465
Workflow file for this run
This file contains 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: Code Quality Checks | |
on: | |
workflow_dispatch: | |
inputs: | |
clearCaches: | |
description: "Clear workflow caches where possible" | |
required: false | |
type: string | |
pull_request: | |
push: | |
# Ignore merge queue branches on push; avoids merge_group+push concurrency race since ref is same | |
branches-ignore: | |
- 'gh-readonly-queue/**' | |
merge_group: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
lintDebug: | |
name: Lint Debug | |
timeout-minutes: 20 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Configure JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: "temurin" | |
java-version: "21" | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
timeout-minutes: 5 | |
with: | |
# Only write to the cache for builds on the 'main' branches, stops branches evicting main cache | |
# Builds on other branches will only read from main branch cache writes | |
# Comment this and the with: above out for performance testing on a branch | |
cache-read-only: ${{ github.ref != 'refs/heads/main' }} | |
gradle-home-cache-cleanup: true | |
- name: Clear Caches Optionally | |
if: "${{ github.event.inputs.clearCaches != '' }}" | |
shell: bash | |
run: | | |
du -sk ~/.gradle | |
rm -fr ~/.gradle | |
du -sk ~/.gradle || echo ~/.gradle is gone | |
- name: Warm Gradle Cache | |
# This makes sure we fetch gradle network resources with a retry | |
uses: nick-invision/retry@v3 | |
with: | |
timeout_minutes: 10 | |
retry_wait_seconds: 60 | |
max_attempts: 3 | |
command: ./gradlew :AnkiDroid:compilePlayDebugJavaWithJavac compileLint lint-rules:compileTestJava --daemon | |
- name: Run Lint Debug | |
# "lint" is run under the 'Amazon' flavor, so slow in CI | |
# "lintPlayRelease" doesn't test androidTest | |
# "lintPlayDebug" doesn't test the API | |
# "lintVitalFullRelease": if `main` resources are only used in `androidTest` (#15741) | |
run: ./gradlew lintPlayDebug :api:lintDebug ktLintCheck lintVitalFullRelease lint-rules:test --daemon | |
# Handled under the pre-commit hook: ./gradlew installGitHook | |
# To run manually, run the following inside folder: Anki-Android | |
# npm install --location=global prettier | |
# prettier --check AnkiDroid/**/*.js | |
- name: Prettify code | |
uses: creyD/[email protected] | |
with: | |
prettier_options: --check AnkiDroid/**/*.js | |
dry: True |