Skip to content

Fix #6190: Add tests for ApplicationLifecycleLogger #17617

Fix #6190: Add tests for ApplicationLifecycleLogger

Fix #6190: Add tests for ApplicationLifecycleLogger #17617

Workflow file for this run

# Contains jobs corresponding to static checks (such as syntax correctness & prohibited patterns).
name: Static Checks
on:
workflow_dispatch:
pull_request:
push:
branches:
- develop
merge_group:
branches:
- develop
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.merge_group.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
check_codeowners:
name: Check CODEOWNERS & Repository files
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- uses: mszostok/codeowners-validator@v0.7.4
with:
checks: "duppatterns,files,syntax"
experimental_checks: "notowned"
check_base_branch:
name: Check base branch
runs-on: ubuntu-24.04
if: github.event_name == 'pull_request' || github.event_name == 'merge_group'
steps:
- name: "Branch is not based on develop or release branch"
if: ${{ github.base_ref != 'develop' && !startsWith(github.base_ref, 'release-') }}
run: |
echo "Current base branch: $BASE_BRANCH"
echo "Note: this check is expected to fail for chained PRs so that they can't accidentally be merged. PRs should only ever be merged directly into develop or a release branch."
exit 1
env:
BASE_BRANCH: ${{ github.base_ref }}
- name: "Branch verified as based on develop/release branch"
if: ${{ github.base_ref == 'develop' || startsWith(github.base_ref, 'release-') }}
run: |
echo "Branch is correctly branched off of valid base branch to merge PRs into: $BASE_BRANCH"
env:
BASE_BRANCH: ${{ github.base_ref }}
linters:
name: Lint Tests
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Create oppia android tools directory
run: mkdir -p $HOME/oppia-android-tools
- name: Download Checkstyle
run: |
cd $HOME/oppia-android-tools
bash /home/runner/work/oppia-android/oppia-android/scripts/checkstyle_download.sh
- name: Download Ktlint
run: |
cd $HOME/oppia-android-tools
bash /home/runner/work/oppia-android/oppia-android/scripts/ktlint_download.sh
- name: Download Buf
run: |
cd $HOME/oppia-android-tools
bash /home/runner/work/oppia-android/oppia-android/scripts/buf_download.sh
- name: Download Buildifier
run: |
cd $HOME/oppia-android-tools
bash /home/runner/work/oppia-android/oppia-android/scripts/buildifier_download.sh
- name: Java lint check
run: |
bash /home/runner/work/oppia-android/oppia-android/scripts/checkstyle_lint_check.sh $HOME
- name: Kotlin lint check
run: |
bash /home/runner/work/oppia-android/oppia-android/scripts/ktlint_lint_check.sh $HOME
- name: Protobuf lint check
run: |
bash /home/runner/work/oppia-android/oppia-android/scripts/buf_lint_check.sh $HOME
- name: Bazel lint check
run: |
bash /home/runner/work/oppia-android/oppia-android/scripts/buildifier_lint_check.sh $HOME
script_checks:
name: Script Checks
runs-on: ubuntu-24.04
env:
CACHE_DIRECTORY: ~/.bazel_cache
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Bazel
uses: bazel-contrib/setup-bazel@0.19.0
with:
bazelisk-cache: true
- uses: actions/cache@v5
id: scripts_cache
with:
path: ${{ env.CACHE_DIRECTORY }}
key: ${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-scripts-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-scripts-
${{ runner.os }}-${{ env.CACHE_DIRECTORY }}-bazel-
# This check is needed to ensure that Bazel's unbounded cache growth doesn't result in a
# situation where the cache never updates (e.g. due to exceeding GitHub's cache size limit)
# thereby only ever using the last successful cache version. This solution will result in a
# few slower CI actions around the time cache is detected to be too large, but it should
# incrementally improve thereafter.
- name: Ensure cache size
env:
BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }}
run: |
# See https://stackoverflow.com/a/27485157 for reference.
EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}"
CACHE_SIZE_MB=$(du -smc $EXPANDED_BAZEL_CACHE_PATH | grep total | cut -f1)
echo "Total size of Bazel cache (rounded up to MBs): $CACHE_SIZE_MB"
# Use a 4.5GB threshold since actions/cache compresses the results, and Bazel caches seem
# to only increase by a few hundred megabytes across changes for unrelated branches. This
# is also a reasonable upper-bound (local tests as of 2021-03-31 suggest that a full build
# of the codebase (e.g. //...) from scratch only requires a ~2.1GB uncompressed/~900MB
# compressed cache).
if [[ "$CACHE_SIZE_MB" -gt 4500 ]]; then
echo "Cache exceeds cut-off; resetting it (will result in a slow build)"
rm -rf $EXPANDED_BAZEL_CACHE_PATH
fi
- name: Configure Bazel to use a local cache
env:
BAZEL_CACHE_DIR: ${{ env.CACHE_DIRECTORY }}
run: |
EXPANDED_BAZEL_CACHE_PATH="${BAZEL_CACHE_DIR/#\~/$HOME}"
echo "Using $EXPANDED_BAZEL_CACHE_PATH as Bazel's cache path"
echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc
shell: bash
- name: Regex Patterns Validation Check
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
run: |
bazel run //scripts:regex_pattern_validation_check -- $(pwd)
- name: XML Syntax Validation Check
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
run: |
bazel run //scripts:xml_syntax_check -- $(pwd)
- name: TextView Style Validation Check
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
run: |
bazel run //scripts:check_textview_styles -- $(pwd)
- name: Android Lint Check
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
run: |
bazel run //scripts:android_lint_check -- $(pwd) --mode=full
- name: Lint Check Catalog Consistency
# Verifies that LintCheckCatalog is in sync with the linter's actual check list.
# This always runs regardless of other changes to catch drift after lint upgrades.
if: ${{ !cancelled() }}
run: |
bazel run //scripts:android_lint_check -- $(pwd) --mode=check-script-consistency
- name: Testfile Presence Check
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
run: |
bazel run //scripts:test_file_check -- $(pwd)
- name: Accessibility label Check
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
run: |
bazel run //scripts:accessibility_label_check -- $(pwd) scripts/assets/accessibility_label_exemptions.pb app/src/main/AndroidManifest.xml
- name: KDoc Validation Check
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
run: |
bazel run //scripts:kdoc_validity_check -- $(pwd) scripts/assets/kdoc_validity_exemptions.pb
- name: Todo Check
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
bazel run //scripts:todo_open_check -- $(pwd) scripts/assets/todo_open_exemptions.pb
- name: String Resource Validation Check
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
run: |
bazel run //scripts:string_resource_validation_check -- $(pwd)
- name: Binary File Check
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
run: |
bazel run //scripts:binary_file_check -- $(pwd) scripts/assets/binary_file_exemptions.pb
# Note that caching is intentionally not enabled for this check since licenses should always be
# verified without any potential influence from earlier builds (i.e. always from a clean build to
# ensure the results exactly match the current state of the repository).
third_party_dependencies_check:
name: Maven Dependencies Checks
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Set up Bazel
uses: bazel-contrib/setup-bazel@0.19.0
with:
bazelisk-cache: true
- name: Maven Repin Check
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
run: |
REPIN=1 bazel run @unpinned_maven//:pin
- name: Maven Dependencies Update Check
# The expression if: ${{ !cancelled() }} runs a job or step regardless of its success or failure while responding to cancellations,
# serving as a cancellation-compliant alternative to if: ${{ always() }} in concurrent workflows.
if: ${{ !cancelled() }}
run: |
bazel run //scripts:maven_dependencies_list_check -- $(pwd) third_party/maven_install.json scripts/assets/maven_dependencies.pb
check_changelog_limit:
name: Check changelog character limit
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Check 500-character limit for changelog files
run: |
FAILED=false
for file in config/changelogs/[0-9]*.md; do
if [[ ! -f "$file" ]]; then continue; fi
char_count=$(python3 -c "print(len(open('$file').read().rstrip()))")
if [[ "$char_count" -gt 500 ]]; then
echo "::error file=$file::Changelog '$file' exceeds the 500-character Play Console limit (${char_count}/500 chars). Shorten it before merging."
FAILED=true
else
echo "✓ $file: ${char_count}/500 characters"
fi
done
if [[ "$FAILED" == "true" ]]; then exit 1; fi