2020-12-20 17:08:29 +01:00
|
|
|
name: Code Quality Checks
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
2022-10-30 00:13:35 +02:00
|
|
|
inputs:
|
|
|
|
clearCaches:
|
|
|
|
description: "Clear workflow caches where possible"
|
|
|
|
required: false
|
|
|
|
type: string
|
2020-12-20 17:08:29 +01:00
|
|
|
pull_request:
|
|
|
|
push:
|
2023-12-12 17:31:48 +01:00
|
|
|
# Ignore merge queue branches on push; avoids merge_group+push concurrency race since ref is same
|
|
|
|
branches-ignore:
|
|
|
|
- 'gh-readonly-queue/**'
|
2023-12-07 17:29:39 +01:00
|
|
|
merge_group:
|
2020-12-20 17:08:29 +01:00
|
|
|
|
2022-04-22 17:30:06 +02:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2020-12-20 17:08:29 +01:00
|
|
|
jobs:
|
2022-02-11 16:43:05 +01:00
|
|
|
lintDebug:
|
|
|
|
name: Lint Debug
|
2022-05-17 19:45:39 +02:00
|
|
|
timeout-minutes: 20
|
2020-12-20 17:08:29 +01:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-09-05 01:37:04 +02:00
|
|
|
- uses: actions/checkout@v4
|
2020-12-20 17:08:29 +01:00
|
|
|
with:
|
|
|
|
fetch-depth: 1
|
|
|
|
|
2022-08-09 18:44:55 +02:00
|
|
|
- name: Configure JDK
|
2023-11-30 00:59:24 +01:00
|
|
|
uses: actions/setup-java@v4
|
2020-12-20 17:08:29 +01:00
|
|
|
with:
|
2022-08-09 18:44:55 +02:00
|
|
|
distribution: "temurin"
|
2024-01-08 03:40:08 +01:00
|
|
|
java-version: "21"
|
2020-12-20 17:08:29 +01:00
|
|
|
|
2022-04-25 18:51:04 +02:00
|
|
|
- name: Setup Gradle
|
|
|
|
uses: gradle/gradle-build-action@v2
|
2022-05-10 20:08:45 +02:00
|
|
|
timeout-minutes: 5
|
2020-12-20 17:08:29 +01:00
|
|
|
with:
|
2022-04-25 18:51:04 +02:00
|
|
|
# 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' }}
|
2022-10-30 00:13:35 +02:00
|
|
|
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
|
2020-12-20 17:08:29 +01:00
|
|
|
|
|
|
|
- name: Warm Gradle Cache
|
|
|
|
# This makes sure we fetch gradle network resources with a retry
|
|
|
|
uses: nick-invision/retry@v2
|
2020-12-20 17:12:33 +01:00
|
|
|
with:
|
|
|
|
timeout_minutes: 10
|
|
|
|
retry_wait_seconds: 60
|
|
|
|
max_attempts: 3
|
2022-04-25 18:51:04 +02:00
|
|
|
command: ./gradlew :AnkiDroid:compilePlayDebugJavaWithJavac compileLint lint-rules:compileTestJava --daemon
|
2020-12-20 17:08:29 +01:00
|
|
|
|
2022-02-11 16:43:05 +01:00
|
|
|
- name: Run Lint Debug
|
2022-04-25 18:51:04 +02:00
|
|
|
uses: gradle/gradle-build-action@v2
|
|
|
|
with:
|
|
|
|
# "lint" is run under the 'Amazon' flavor, so slow in CI
|
|
|
|
# "lintPlayRelease" doesn't test androidTest
|
|
|
|
# "lintPlayDebug" doesn't test the API
|
|
|
|
arguments: lintPlayDebug :api:lintDebug ktLintCheck lint-rules:test --daemon
|
2022-03-14 21:09:16 +01:00
|
|
|
|
2023-02-19 16:42:50 +01:00
|
|
|
- name: Prettify code
|
|
|
|
uses: creyD/prettier_action@v4.3
|
|
|
|
with:
|
|
|
|
prettier_options: --check AnkiDroid/**/*.js
|
|
|
|
dry: True
|