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:
|
|
|
|
branches:
|
|
|
|
- '**'
|
2020-12-20 17:43:56 +01:00
|
|
|
paths:
|
2020-12-28 18:27:16 +01:00
|
|
|
- '.github/workflows/**'
|
2020-12-20 18:53:16 +01:00
|
|
|
- 'AnkiDroid/**'
|
|
|
|
- 'api/**'
|
|
|
|
- 'lint-rules/**'
|
|
|
|
- 'annotations/**'
|
2020-12-20 17:43:56 +01:00
|
|
|
- '**/*.gradle'
|
2020-12-20 18:53:16 +01:00
|
|
|
- 'gradle/**'
|
2020-12-20 17:08:29 +01:00
|
|
|
push:
|
|
|
|
branches:
|
2022-03-06 20:22:18 +01:00
|
|
|
- main
|
2020-12-20 20:42:28 +01:00
|
|
|
- i18n_sync
|
2021-05-14 16:28:30 +02:00
|
|
|
- dependency-updates
|
2020-12-20 20:42:28 +01:00
|
|
|
- 'release**'
|
2020-12-20 17:43:56 +01:00
|
|
|
paths:
|
2020-12-28 18:27:16 +01:00
|
|
|
- '.github/workflows/**'
|
2020-12-20 18:53:16 +01:00
|
|
|
- 'AnkiDroid/**'
|
|
|
|
- 'api/**'
|
|
|
|
- 'lint-rules/**'
|
|
|
|
- 'annotations/**'
|
2020-12-20 17:43:56 +01:00
|
|
|
- '**/*.gradle'
|
2020-12-20 18:53:16 +01:00
|
|
|
- 'gradle/**'
|
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:
|
2022-03-02 00:17:04 +01:00
|
|
|
- uses: actions/checkout@v3
|
2020-12-20 17:08:29 +01:00
|
|
|
with:
|
|
|
|
fetch-depth: 1
|
|
|
|
|
2022-08-09 18:44:55 +02:00
|
|
|
- name: Configure JDK
|
2022-04-09 01:12:37 +02:00
|
|
|
uses: actions/setup-java@v3
|
2020-12-20 17:08:29 +01:00
|
|
|
with:
|
2022-08-09 18:44:55 +02:00
|
|
|
distribution: "temurin"
|
2023-06-28 18:06:44 +02:00
|
|
|
java-version: "17" # newer libraries require 17 now, force it everywhere
|
2020-12-20 17:08:29 +01:00
|
|
|
|
2023-06-28 18:06:44 +02:00
|
|
|
- name: Verify JDK17
|
|
|
|
# Default JDK varies depending on different runner flavors, make sure we are on 17
|
|
|
|
# Run a check that exits with error unless it is 17 version to future-proof against unexpected upgrades
|
|
|
|
run: java -fullversion 2>&1 | grep '17.0'
|
2020-12-20 17:08:29 +01:00
|
|
|
shell: bash
|
|
|
|
|
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
|