Skip to content

Commit

Permalink
Merge branch 'ankidroid:main' into aviWorkaroundFeature
Browse files Browse the repository at this point in the history
  • Loading branch information
henriqueccmac committed May 27, 2024
1 parent 6b11c31 commit 01c0953
Show file tree
Hide file tree
Showing 893 changed files with 16,935 additions and 8,285 deletions.
10 changes: 9 additions & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@ blank_issues_enabled: true
contact_links:
- name: Anki Forums
url: https://forums.ankiweb.net/
about: If your issue also occurs in Anki Desktop, please report it in the forums
about: If your issue also occurs in Anki Desktop, please report it in the forums

- name: Questions/Support
url: https://forums.ankiweb.net/c/ankidroid/help/16
about: If you have a question or need support, please post on the user forum.

- name: Feature Requests/Suggestions
url: https://forums.ankiweb.net/c/ankidroid/suggestions/23
about: Please post suggestions and feature requests on the user forum.
20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/conflict.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:

jobs:
scan_conflicts:
# Do not run the scheduled jobs on forks
if: (github.event_name == 'schedule' && github.repository == 'ankidroid/Anki-Android') || (github.event_name != 'schedule')
permissions:
contents: read
pull-requests: write
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,11 @@ jobs:
command: ./gradlew :AnkiDroid:compilePlayDebugJavaWithJavac compileLint lint-rules:compileTestJava --daemon

- name: Run Lint Debug
uses: gradle/gradle-build-action@v3
with:
# "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)
arguments: lintPlayDebug :api:lintDebug ktLintCheck lintVitalFullRelease lint-rules:test --daemon
# "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

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/milestone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ github.event.pull_request.number }},
milestone: 52
milestone: 59
});
// graphql query to get referenced issues to merged pull request
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
milestone: 52
milestone: 59
});
}
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Hello 👋, this issue has been opened for more than 3 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like _still searching for solutions_ and if you found one, please open a pull request! You have 7 days until this gets closed automatically'
stale-pr-message: 'Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically'
exempt-issue-labels: 'Keep Open'
exempt-issue-labels: 'Keep Open,Anki Ecosystem Compatibility,Accepted'
exempt-pr-labels: 'Keep Open'
close-issue-reason: 'not_planned'
days-before-issue-stale: 90
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync_translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
("0" + now.getUTCHours()).slice(-2) + ":" +
("0" + now.getUTCMinutes()).slice(-2);
try {
github.rest.pulls.create({
await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "Updated strings from Crowdin " + formattedDate,
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/tests_emulator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
name: Android Emulator Test
runs-on: ubuntu-latest
timeout-minutes: 75
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -180,6 +182,6 @@ jobs:
name: ${{ matrix.api-level }}-${{ matrix.arch }}-${{matrix.target}}-${{matrix.first-boot-delay}}-${{matrix.iteration}}-adb_video
path: video.webm

- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
verbose: true
146 changes: 120 additions & 26 deletions .github/workflows/tests_unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,27 @@ on:
workflow_dispatch:
inputs:
clearCaches:
description: "Clear workflow caches where possible"
description: "Clear workflow caches where possible, empty means false"
required: false
type: string
iterations:
description: "Number of iterations on each chosen operating system. Default 1. Max 85."
required: true
default: 1
type: number
operatingSystems:
description: "Which operating systems to run tests on"
required: true
type: choice
# If you alter system names in default + options here, also alter osArray below to match
default: '["windows-latest", "macos-14", "ubuntu-latest"]'
options:
- '["windows-latest", "macos-14", "ubuntu-latest"]'
- '["windows-latest"]'
- '["macos-14"]'
- '["ubuntu-latest"]'
schedule:
- cron: "42 0 * * *"
pull_request:
push:
# Ignore merge queue branches on push; avoids merge_group+push concurrency race since ref is same
Expand All @@ -15,27 +33,90 @@ on:
merge_group:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# if a workflow is run against the same ref, only one at a time...
# ...but allow different triggers to run concurrent (push, manual flake run, scheduled flake run...)
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
# We want to generate our matrix dynamically
# Initial job generates the matrix as a JSON, and following job will use deserialize and use the result
matrix_prep:
# Do not run the scheduled jobs on forks
if: (github.event_name == 'schedule' && github.repository == 'ankidroid/Anki-Android') || (github.event_name != 'schedule')
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.build-matrix.outputs.result }}
steps:
- id: build-matrix
uses: actions/github-script@v7
with:
script: |
// by default, we will include all 3 platforms we test on
// "latest" would be easy everywhere, but "macos-14" doesn't always happen if you choose "latest"
// and we want macos-14 because it has Apple Silicon and is faster
// if you alter this, also alter it above in the workflow_dispatch options list
let osArray = ["ubuntu-latest", "macos-14", "windows-latest"]
// by default, we will run one iteration on each selected system
let iterationArray = [1]
// workflow dispatch will be a drop-down of different options
if (context.eventName === "workflow_dispatch") {
const inputs = ${{ toJSON(inputs) }}
osArray = JSON.parse(inputs['operatingSystems'])
console.log('inputs is: ' + JSON.stringify(inputs))
console.log('osArray is: ' + osArray)
const iterationInput = inputs.iterations
console.log('iterations input is: ' + iterationInput)
// this will expand for example with input 5 => [1, 2, 3, 4, 5]
iterationArray = []
for (let i = 1; i <= iterationInput; i++) {
iterationArray.push(i);
}
console.log('iterationArray is: ' + iterationArray)
}
// If we are running on a schedule it's our periodic passive scan for flakes
// Goal is to run enough iterations on all systems that we have confidence there are no flakes
if (context.eventName === "schedule") {
const iterationCount = 15
for (let i = 1; i <= iterationCount; i++) {
iterationArray.push(i);
}
}
let includeArray = [];
for(const os of osArray) {
// we do this work to define 'name' so we don't need to update branch protection rules
// if the os changes, the name is used in the expanded workflow run name, which is then
// used as a "required check" on branch protection merge rules, this keeps it stable
// even if "macos-14" changes to "macos-15" in the future so we just change the list here
// but don't have to go into organization settings / protection rules etc etc
includeArray.push({"os": os, "name": os.split('-')[0]});
}
return {
"os": osArray,
"include": includeArray,
"iteration": iterationArray
}
- name: Debug Output
run: echo "${{ steps.build-matrix.outputs.result }}"

# This uses the matrix generated from the matrix-prep stage
# it will run unit tests on whatever OS combinations are desired
unit:
name: JUnit Tests (${{ matrix.name }})
timeout-minutes: 40
name: JUnit Tests (${{ matrix.name }} run ${{ matrix.iteration }})
# Do not run the scheduled jobs on forks
if: (github.event_name == 'schedule' && github.repository == 'ankidroid/Anki-Android') || (github.event_name != 'schedule')
needs: matrix_prep
timeout-minutes: 30
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
strategy:
fail-fast: false
matrix:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
# macOS 14 is in beta and runs on Apple Silicon [M1]
os: [ubuntu-latest, macos-14, windows-latest]
# define 'name' so we don't need to update branch protection rules if the os changes
include:
- os: ubuntu-latest
name: ubuntu
- os: macos-14
name: macos
- os: windows-latest
name: windows
matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}}
runs-on: ${{ matrix.os }}
#env:
# CODACY_TOKEN: ${{ secrets.CODACY_TOKEN }}
Expand Down Expand Up @@ -66,10 +147,9 @@ jobs:
# 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
# All runners have cache pollution issues, disable all caches
# https://github.com/gradle/actions/issues/47
cache-disabled: true
# gradle-home-cache-cleanup is temporarily disabled to investigate cache pollution issues
# Requested in: https://github.com/gradle/actions/issues/167#issuecomment-2052352341
# gradle-home-cache-cleanup: true

- name: Clear Caches Optionally
if: "${{ github.event.inputs.clearCaches != '' }}"
Expand All @@ -88,16 +168,30 @@ jobs:
command: ./gradlew robolectricSdkDownload --daemon

- name: Run Unit Tests
uses: gradle/gradle-build-action@v3
run: ./gradlew jacocoUnitTestReport --daemon

- name: Store Logcat as Artifact
# cancelled() handles test timeouts
# remove when test timeouts cause a failure()
if: failure() || cancelled()
uses: actions/upload-artifact@v4
with:
arguments: jacocoUnitTestReport --daemon
name: logcat-${{ matrix.name }}-${{ matrix.iteration }}
# look for the `<system-out>` element in the XML files in `test-results`
# The folder contains far too much data:
# * .bin files
# * XML rather than TXT
# * Files are mostly JaCoCo issues logged to stderr (#16180)
# * All tests are logged, rather than just failures
# despite this, it's a great start
# look to see if there's a dependency we can use, arther than improving this
path: |
**/build/test-results/
- name: Stop Gradle
if: contains(matrix.os, 'windows')
uses: gradle/gradle-build-action@v3
with:
arguments: --stop
run: ./gradlew --stop

- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
verbose: true
11 changes: 5 additions & 6 deletions AnkiDroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ android {
applicationId "com.ichi2.anki"
buildConfigField "Boolean", "CI", (System.getenv("CI") == "true").toString()
buildConfigField "String", "ACRA_URL", '"https://ankidroid.org/acra/report"'
buildConfigField "String", "BACKEND_VERSION", "\"${libs.versions.ankidroidBackend}\""
buildConfigField "String", "BACKEND_VERSION", "\"${libs.versions.ankiBackend.get()}\""
buildConfigField "Boolean", "ENABLE_LEAK_CANARY", "false"
buildConfigField "Boolean", "ALLOW_UNSAFE_MIGRATION", "false"
buildConfigField "String", "GIT_COMMIT_HASH", "\"${gitCommitHash()}\""
Expand Down Expand Up @@ -74,8 +74,8 @@ android {
//
// This ensures the correct ordering between the various types of releases (dev < alpha < beta < release) which is
// needed for upgrades to be offered correctly.
versionCode=21800107
versionName="2.18alpha7"
versionCode=21900103
versionName="2.19alpha3"
minSdk 23 // also in testlib/build.gradle.kts
// After #13695: change .tests_emulator.yml
targetSdk 33 // also in [api|testlib]/build.gradle.kts and ../robolectricDownloader.gradle
Expand Down Expand Up @@ -306,7 +306,7 @@ dependencies {
compileOnly libs.auto.service.annotations
annotationProcessor libs.auto.service

implementation libs.androidx.activity.ktx
implementation libs.androidx.activity
implementation libs.androidx.annotation
implementation libs.androidx.appcompat
implementation libs.androidx.browser
Expand Down Expand Up @@ -352,8 +352,6 @@ dependencies {
implementation libs.acra.dialog
implementation libs.acra.http

implementation libs.materialDialogs.core
implementation libs.materialDialogs.input
implementation libs.commons.compress
implementation libs.commons.collections4 // SetUniqueList
implementation libs.commons.io // FileUtils.contentEquals
Expand Down Expand Up @@ -404,6 +402,7 @@ dependencies {
testImplementation(libs.androidx.espresso.contrib) {
exclude module: "protobuf-lite"
}
testImplementation libs.androidx.work.testing

androidTestImplementation project(':testlib')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class DeckPickerTest : InstrumentedTest() {

// For tablet. If it is not a tablet, then test will be ignored.
assumeTrue(isTablet)
closeGetStartedScreenIfExists()
closeBackupCollectionDialogIfExists()
val testString = System.currentTimeMillis().toString() + ""
createDeckWithCard(testString)

Expand All @@ -101,8 +103,8 @@ class DeckPickerTest : InstrumentedTest() {
// Create a new deck
onView(withId(R.id.fab_main)).perform(click())
onView(withId(R.id.add_deck_action)).perform(click())
onView(withId(R.id.action_edit)).perform(typeText("TestDeck$testString"))
onView(withId(com.afollestad.materialdialogs.R.id.md_button_positive)).perform(click())
onView(withId(R.id.dialog_text_input)).perform(typeText("TestDeck$testString"))
onView(withText(R.string.dialog_ok)).perform(click())

// The deck is currently empty, so if we tap on it, it becomes the selected deck but doesn't enter
onView(withId(R.id.files)).perform(
Expand All @@ -114,7 +116,7 @@ class DeckPickerTest : InstrumentedTest() {

// Create a card belonging to the new deck, using Basic type (guaranteed to exist)
onView(withId(R.id.fab_main)).perform(click())
onView(withId(R.id.add_note_label)).perform(click())
onView(withId(R.id.fab_main)).perform(click())

// Close the keyboard, it auto-focuses and obscures enough of the screen
// on some devices that espresso complains about global visibility being <90%
Expand All @@ -128,5 +130,6 @@ class DeckPickerTest : InstrumentedTest() {

// Go back to Deck Picker
pressBack()
pressBack()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ class NoteEditorTabOrderTest : NoteEditorTest() {
}

private fun ensureCollectionLoaded() {
CollectionHelper.instance.getColUnsafe(targetContext)
CollectionManager.getColUnsafe()
}
}
Loading

0 comments on commit 01c0953

Please sign in to comment.