From 38ff7072841864de0a5e7b16f85a5e2965661b5f Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Fri, 28 Jul 2023 13:34:19 +0300 Subject: [PATCH 1/5] fix: Fix failing build on M1 Macs --- model/src/main/proto/deprecation.proto | 2 -- model/src/main/proto/profile.proto | 2 -- 2 files changed, 4 deletions(-) diff --git a/model/src/main/proto/deprecation.proto b/model/src/main/proto/deprecation.proto index 251109f0c23..8e63e84901c 100644 --- a/model/src/main/proto/deprecation.proto +++ b/model/src/main/proto/deprecation.proto @@ -2,8 +2,6 @@ syntax = "proto3"; package model; -import "version.proto"; - option java_package = "org.oppia.android.app.model"; option java_multiple_files = true; diff --git a/model/src/main/proto/profile.proto b/model/src/main/proto/profile.proto index 9d0ccb026ff..aadd1f34881 100644 --- a/model/src/main/proto/profile.proto +++ b/model/src/main/proto/profile.proto @@ -2,8 +2,6 @@ syntax = "proto3"; package model; -import "languages.proto"; - option java_package = "org.oppia.android.app.model"; option java_multiple_files = true; From 688bee51bef9dc0e53d78ea3398b6f89e54ac7b3 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Sat, 29 Jul 2023 18:37:28 +0300 Subject: [PATCH 2/5] feat: Add a bash script to perform all static checks in one batch --- scripts/buildifier_download.sh | 12 +++- scripts/setup.sh | 3 + scripts/static_checks.sh | 110 +++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 scripts/static_checks.sh diff --git a/scripts/buildifier_download.sh b/scripts/buildifier_download.sh index 3632dc1d138..9c2672f2595 100644 --- a/scripts/buildifier_download.sh +++ b/scripts/buildifier_download.sh @@ -3,6 +3,14 @@ # Download buildifier BUILDIFIER="3.4.0" echo Using Buildifier version $BUILDIFIER -curl -sSLO https://github.com/bazelbuild/buildtools/releases/download/$BUILDIFIER/buildifier > buildifier -chmod a+x buildifier +if [[ "$OSTYPE" == "darwin"* ]]; +then + curl -sSLO https://github.com/bazelbuild/buildtools/releases/download/$BUILDIFIER/buildifier.mac > buildifier.mac + chmod a+x buildifier.mac + mv buildifier.mac buildifier +else + curl -sSLO https://github.com/bazelbuild/buildtools/releases/download/$BUILDIFIER/buildifier > buildifier + chmod a+x buildifier +fi + echo Buildifier file downloaded diff --git a/scripts/setup.sh b/scripts/setup.sh index feee46e80ca..8c3ef595e1d 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -28,3 +28,6 @@ bash ../oppia-android/scripts/buf_download.sh # Add protobuf platform for M1 Mac bash ../oppia-android/scripts/buf_m1_mac_setup.sh + +# Download buildifier +bash ../oppia-android/scripts/buildifier_download.sh diff --git a/scripts/static_checks.sh b/scripts/static_checks.sh new file mode 100644 index 00000000000..8a2f1480108 --- /dev/null +++ b/scripts/static_checks.sh @@ -0,0 +1,110 @@ +#!/bin/bash + +# INSTRUCTIONS +# This script will run all script checks locally to make +# sure that all script checks will still pass when run on +# CI +# +# To run this check run the script from the Oppia-android root folder: +# +# bash scripts/static_checks.sh +# + +# LINT CHECKS +# Run Java lint check +bash scripts/checkstyle_lint_check.sh +echo "" + +# Run Kotlin lint check +bash scripts/ktlint_lint_check.sh +echo "" + +# Run protobuf lint checks +bash scripts/buf_lint_check.sh +echo "" + +# Download Buildifier in oppia-andoid-tools folder (pre-requisite for buildifier checks) +echo "********************************" +echo "Downloading buildifier" +echo "********************************" +cd ../oppia-android-tools/ +bash ../oppia-android/scripts/buildifier_download.sh +cd ../oppia-android/ +echo "" + +# Run Bazel Build file lint checks (buildifier checks) +bash scripts/buildifier_lint_check.sh +echo "" + + +# SCRIPT CHECKS +# These checks run on Bazel. Ensure Bazel is installed and configured correctly. + +# Run regex pattern checks +echo "********************************" +echo "Running regex pattern checks" +echo "********************************" +bazel run //scripts:regex_pattern_validation_check -- $(pwd) +echo "" + +# Run XML Syntax check validation +echo "********************************" +echo "Running XML Syntax validation checks" +echo "********************************" +bazel run //scripts:xml_syntax_check -- $(pwd) +echo "" + +# Run Testfile Presence Check +echo "********************************" +echo "Running Testfile presence checks" +echo "********************************" +bazel run //scripts:test_file_check -- $(pwd) +echo "" + +# Run Accessibility label Check +echo "********************************" +echo "Running Accessibility label checks" +echo "********************************" +bazel run //scripts:accessibility_label_check -- $(pwd) scripts/assets/accessibility_label_exemptions.pb app/src/main/AndroidManifest.xml +echo "" + +# Run KDoc Validation Check +echo "********************************" +echo "Running KDoc validation checks" +echo "********************************" +bazel run //scripts:kdoc_validity_check -- $(pwd) scripts/assets/kdoc_validity_exemptions.pb +echo "" + +# Run Todo Check (TODO: Fix here) + +# Run String resource validation check +echo "********************************" +echo "Running resource validation checks" +echo "********************************" +bazel run //scripts:string_resource_validation_check -- $(pwd) +echo "" + + +# THIRD PARTY DEPENDENCY CHECKS +# These are checks for third party dependencies + +# Maven Repin Check +echo "********************************" +echo "Running Maven repin checks" +echo "********************************" +REPIN=1 bazel run @unpinned_maven//:pin +echo "" + +# Maven Dependencies Update Check +echo "********************************" +echo "Running maven dependencies update checks" +echo "********************************" +bazel run //scripts:maven_dependencies_list_check -- $(pwd) third_party/maven_install.json scripts/assets/maven_dependencies.pb +echo "" + +# License Texts Check +echo "********************************" +echo "Running license texts checks" +echo "********************************" +bazel run //scripts:license_texts_check -- $(pwd)/app/src/main/res/values/third_party_dependencies.xml + From e4ede3bb0f362aa9131d0659b079e083a1043ad1 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Sun, 30 Jul 2023 18:22:06 +0300 Subject: [PATCH 3/5] chore: Add explanation for skipped TODO checks --- scripts/static_checks.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/static_checks.sh b/scripts/static_checks.sh index 8a2f1480108..99e88d21ca7 100644 --- a/scripts/static_checks.sh +++ b/scripts/static_checks.sh @@ -75,7 +75,8 @@ echo "********************************" bazel run //scripts:kdoc_validity_check -- $(pwd) scripts/assets/kdoc_validity_exemptions.pb echo "" -# Run Todo Check (TODO: Fix here) +# Todo Check +# Skipped todo checks for local run # Run String resource validation check echo "********************************" From b9543a3c2ee59ae3f773049adc27fa1eef31b326 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Sun, 30 Jul 2023 18:41:37 +0300 Subject: [PATCH 4/5] feat: Add a wiki entry with instructions on how to run static_checks.sh locally --- wiki/Static-Analysis-Checks.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wiki/Static-Analysis-Checks.md b/wiki/Static-Analysis-Checks.md index 75acc335fba..20894ca8aae 100644 --- a/wiki/Static-Analysis-Checks.md +++ b/wiki/Static-Analysis-Checks.md @@ -230,9 +230,10 @@ To fix the failures for this check: resolve the TODO items and then close the is // TODO([#3690](https://github.com/oppia/oppia-android/issues/3690)): Complete static checks Wiki # How to run static checks locally - +There are two ways to run static checks locally. You can either run all checks locally with the command `bash scripts/static_checks.sh` or run individual commands based on the name of the failing check on GitHub CI. To fix failing tests from GitHub CI individually, follow the steps below. - Go to the failing CI check in your GitHub PR. - Scroll to the top of the failing CI check logs, and find the Bazel command that was run for this script. - Alternatively, in Android Studio, go to the `.github` folder and find the [static_checks.yml](https://github.com/oppia/oppia-android/blob/develop/.github/workflows/static_checks.yml) file. Search for the line that corresponds to the name of the job that failed. You can then run the same script on your local terminal. +- You can also go to scripts/static_checks.sh to view the failing check and run it locally. -Note: Before running the script command in your local terminal, make sure you have Bazel installed. To learn how to set up Bazel for Oppia Android, follow these [instructions](https://github.com/oppia/oppia-android/wiki/Oppia-Bazel-Setup-Instructions). +Note: Before running the script command in your local terminal, make sure you have Bazel installed. To learn how to set up Bazel for Oppia Android, follow these [instructions](https://github.com/oppia/oppia-android/wiki/Oppia-Bazel-Setup-Instructions). Also make sure you have oppia-android-tools installed since static checks rely on these tools to be able to perform some of the checks. To install oppia-android-tools, run `bash scripts/setup.sh` in the oppia-android directory. From 995e9ccea795428b3d3c82e35deaa8b2bce23fa4 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Tue, 1 Aug 2023 22:09:05 +0300 Subject: [PATCH 5/5] chore: Added a better description on the wiki --- scripts/static_checks.sh | 5 +---- wiki/Static-Analysis-Checks.md | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/static_checks.sh b/scripts/static_checks.sh index 99e88d21ca7..688e542602e 100644 --- a/scripts/static_checks.sh +++ b/scripts/static_checks.sh @@ -23,7 +23,7 @@ echo "" bash scripts/buf_lint_check.sh echo "" -# Download Buildifier in oppia-andoid-tools folder (pre-requisite for buildifier checks) +# Download Buildifier in oppia-android-tools folder (pre-requisite for buildifier checks) echo "********************************" echo "Downloading buildifier" echo "********************************" @@ -75,9 +75,6 @@ echo "********************************" bazel run //scripts:kdoc_validity_check -- $(pwd) scripts/assets/kdoc_validity_exemptions.pb echo "" -# Todo Check -# Skipped todo checks for local run - # Run String resource validation check echo "********************************" echo "Running resource validation checks" diff --git a/wiki/Static-Analysis-Checks.md b/wiki/Static-Analysis-Checks.md index 20894ca8aae..a3d350fedf9 100644 --- a/wiki/Static-Analysis-Checks.md +++ b/wiki/Static-Analysis-Checks.md @@ -230,7 +230,11 @@ To fix the failures for this check: resolve the TODO items and then close the is // TODO([#3690](https://github.com/oppia/oppia-android/issues/3690)): Complete static checks Wiki # How to run static checks locally -There are two ways to run static checks locally. You can either run all checks locally with the command `bash scripts/static_checks.sh` or run individual commands based on the name of the failing check on GitHub CI. To fix failing tests from GitHub CI individually, follow the steps below. +There are two ways to run static checks locally. You can either run all checks locally with the command `bash scripts/static_checks.sh` or run individual commands based on the name of the failing check on GitHub CI. + +Running `bash scripts/static_checks.sh` should take around 10 minutes for a clean run (after running `bazel clean`) and around 2-5 minutes for subsequent runs. + +To fix failing tests from GitHub CI individually, follow the steps below. - Go to the failing CI check in your GitHub PR. - Scroll to the top of the failing CI check logs, and find the Bazel command that was run for this script. - Alternatively, in Android Studio, go to the `.github` folder and find the [static_checks.yml](https://github.com/oppia/oppia-android/blob/develop/.github/workflows/static_checks.yml) file. Search for the line that corresponds to the name of the job that failed. You can then run the same script on your local terminal.