Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1735: Add Java Linter to the project #2101

Merged
merged 66 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
be81193
added java linter
anandwana001 Nov 10, 2020
aacd296
added exec name
anandwana001 Nov 10, 2020
eff0560
using jar to run command
anandwana001 Nov 10, 2020
9c45bfe
update config file
anandwana001 Nov 10, 2020
09ec7ad
checking on java 10
anandwana001 Nov 10, 2020
6b17885
checking on java 11
anandwana001 Nov 10, 2020
ac0a45c
adding more indentation to check
anandwana001 Nov 10, 2020
7671065
adding property
anandwana001 Nov 10, 2020
cf8c41b
updating property
anandwana001 Nov 10, 2020
96a55f2
fixed path for property
anandwana001 Nov 10, 2020
ae6ceca
update severity to error on custom level
anandwana001 Nov 10, 2020
a1f7c0f
fix java lint errors
anandwana001 Nov 11, 2020
512e234
path reference update
anandwana001 Nov 11, 2020
19bf833
adding all other modules
anandwana001 Nov 11, 2020
ce98803
nit fix
anandwana001 Nov 12, 2020
7d3f0f8
nit fix
anandwana001 Dec 1, 2020
2e9f663
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
anandwana001 Dec 1, 2020
831b258
nit java lint fix
anandwana001 Dec 1, 2020
82fd627
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
anandwana001 Dec 9, 2020
7918330
nit update
anandwana001 Dec 21, 2020
9709143
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
anandwana001 Jan 6, 2021
9e89925
adding pre push
anandwana001 Jan 6, 2021
7a38a17
add license
anandwana001 Jan 6, 2021
221a212
nit fix
anandwana001 Jan 6, 2021
5f7a0a9
comment update
anandwana001 Jan 9, 2021
a349a9d
try without config file
anandwana001 Jan 13, 2021
e6e27e5
separate file for action, non prepush
anandwana001 Jan 13, 2021
c07457c
nit fix
anandwana001 Jan 13, 2021
77b1906
pushing error to see on action
anandwana001 Jan 13, 2021
c11b4cf
fixing script to give error for warn
anandwana001 Jan 13, 2021
29d505b
nit fix
anandwana001 Jan 13, 2021
160e364
fixed putted error
anandwana001 Jan 13, 2021
142f65c
Merge branch 'develop' of https://github.com/oppia/oppia-android into…
anandwana001 Jan 18, 2021
ab86f08
undo changes
anandwana001 Jan 18, 2021
3532b28
shifting main linter to oppia-android-tools
anandwana001 Jan 18, 2021
8f4e0ac
create dir at action
anandwana001 Jan 18, 2021
7ad8a01
checking home path
anandwana001 Jan 18, 2021
6341f28
make actions use scripts
anandwana001 Feb 4, 2021
ec9dcc9
modularize scripts
anandwana001 Feb 5, 2021
e4bb401
trying to get correct path on actions
anandwana001 Feb 5, 2021
a529aca
using $HOME for path
anandwana001 Feb 5, 2021
67e5351
trying giving exe permission to script file
anandwana001 Feb 5, 2021
58816dc
fixing path
anandwana001 Feb 5, 2021
1863036
diff sh/bash
anandwana001 Feb 5, 2021
7ca46b2
diff sh/bash
anandwana001 Feb 5, 2021
992f317
trying sudo
anandwana001 Feb 5, 2021
e714f55
complete path
anandwana001 Feb 5, 2021
16e2dcb
remove header
anandwana001 Feb 5, 2021
d5f5d58
show list
anandwana001 Feb 5, 2021
fb71166
echo list
anandwana001 Feb 5, 2021
151448f
try ls
anandwana001 Feb 5, 2021
2d94da2
try download direct
anandwana001 Feb 5, 2021
77cea50
try sh
anandwana001 Feb 5, 2021
02a7ba9
try github workspace
anandwana001 Feb 5, 2021
3d1f3a7
using complete path
anandwana001 Feb 5, 2021
191fabd
using complete path
anandwana001 Feb 5, 2021
cca2fd4
fix path in lint for actions
anandwana001 Feb 5, 2021
c6c08f4
fix path
anandwana001 Feb 5, 2021
ecd4d06
use home path
anandwana001 Feb 5, 2021
f7a351b
fix for ktlint
anandwana001 Feb 5, 2021
abd4112
nit fix
anandwana001 Feb 5, 2021
854a8b8
removed setup_deps.sh
anandwana001 Feb 9, 2021
65706b6
putting error
anandwana001 Feb 9, 2021
92c12da
fixing script
anandwana001 Feb 9, 2021
9680162
fixing main script
anandwana001 Feb 9, 2021
9599fec
using #!/bin/bash and error removed
anandwana001 Feb 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 35 additions & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ on:
workflow_dispatch:
pull_request:
push:
branches:
branches:
# Push events on develop branch
- develop

# This workflow has the following jobs:
# linters: Kotlin and Protobuf Linting
# linters: Kotlin, Protobuf and Java Linting
anandwana001 marked this conversation as resolved.
Show resolved Hide resolved
# robolectric_tests: Robolectric tests for all modules except the app module
# app_tests: Non-flaky Robolectric tests for the app module
jobs:
Expand All @@ -25,40 +25,55 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up JDK 1.11
uses: actions/setup-java@v1
with:
java-version: 1.11
BenHenning marked this conversation as resolved.
Show resolved Hide resolved

- name: Download Ktlint
run: |
KTLINT="0.37.0"
echo Using Ktlint $KTLINT
curl -sSLO https://github.com/pinterest/ktlint/releases/download/$KTLINT/ktlint
chmod a+x ktlint
- name: Download buf
run: |

- name: Download buf
run: |
BUFVERSION="v0.15.0"
echo Using Bufbuild version $BUFVERSION
curl -sSL https://github.com/bufbuild/buf/releases/download/$BUFVERSION/buf-$(uname -s)-$(uname -m) > buf
chmod a+x buf


- name: Download Checkstyle
run: |
CHECKSTYLE="8.37"
echo Using Checkstyle version $CHECKSTYLE
curl -sSLO https://github.com/checkstyle/checkstyle/releases/download/checkstyle-$CHECKSTYLE/checkstyle-$CHECKSTYLE-all.jar
chmod a+x checkstyle-$CHECKSTYLE-all.jar

- name: Kotlin lint check
run: ./ktlint --android domain/src/**/*.kt utility/src/**/*.kt data/src/**/*.kt app/src/**/*.kt testing/src/**/*.kt && echo "Lint completed successfully"

- name: Protobuf lint check
run: ./buf check lint --input=model/src/main/proto --input-config buf.yaml && echo "Protobuf lint check completed successfully"


- name: Protobuf lint check
run: ./buf check lint --input=model/src/main/proto --input-config buf.yaml && echo "Protobuf lint check completed successfully"

- name: Java lint check
run: java -jar checkstyle-8.37-all.jar -c=checkstyle.xml app/src/**/*.java && echo "Lint completed successfully"
anandwana001 marked this conversation as resolved.
Show resolved Hide resolved

robolectric_tests:
name: Robolectric Tests (Non-App Modules)
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04]
os: [ubuntu-18.04]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
id: cache
with:
path: ~/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-jars-{{ checksum "build.gradle" }}

- name: Set up JDK 1.9
uses: actions/setup-java@v1
with:
Expand All @@ -67,11 +82,11 @@ jobs:
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: ./gradlew --full-stacktrace androidDependencies

- name: Build App
# We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58
run: sudo ./gradlew --full-stacktrace assembleDebug

- name: Utility tests
# We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58
run: sudo ./gradlew --full-stacktrace :utility:testDebugUnitTest
Expand All @@ -81,7 +96,7 @@ jobs:
with:
name: utility reports
path: utility/build/reports

- name: Domain tests
# We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58
run: sudo ./gradlew --full-stacktrace :domain:testDebugUnitTest
Expand All @@ -101,26 +116,26 @@ jobs:
with:
name: testing reports
path: testing/build/reports

app_tests:
name: Robolectric Tests - App Module (Non-Flaky)
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04]
steps:
steps:
- uses: actions/checkout@v2

- uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-jars-{{ checksum "build.gradle" }}

- name: Set up JDK 1.9
uses: actions/setup-java@v1
with:
java-version: 1.9

- name: Robolectric tests - App Module
# We require 'sudo' to avoid an error of the existing android sdk. See https://github.com/actions/starter-workflows/issues/58
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static void setBackgroundDrawable(@NonNull View view, @ColorInt int color
background.setColor(0xff000000 | colorRgb);
}

/** Used to set a top rounded-rect background drawable with a data-bound color. */
@BindingAdapter("app:topRoundedRectDrawableWithColor")
public static void setTopBackgroundDrawable(@NonNull View view, @ColorInt int colorRgb) {
view.setBackgroundResource(R.drawable.top_rounded_rect_background);
Expand All @@ -29,6 +30,7 @@ public static void setTopBackgroundDrawable(@NonNull View view, @ColorInt int co
background.setColor(0xff000000 | colorRgb);
}

/** Used to set a bottom rounded-rect background drawable with a data-bound color. */
@BindingAdapter("app:bottomRoundedRectDrawableWithColor")
public static void setBottomBackgroundDrawable(@NonNull View view, @ColorInt int colorRgb) {
view.setBackgroundResource(R.drawable.bottom_rounded_rect_background);
Expand All @@ -37,6 +39,7 @@ public static void setBottomBackgroundDrawable(@NonNull View view, @ColorInt int
background.setColor(0xff000000 | colorRgb);
}

/** Used to set a rectangular background drawable with a data-bound color. */
@BindingAdapter("app:rectangleDrawableWithColor")
public static void setRectangleBackgroundDrawable(@NonNull View view, @ColorInt int colorRgb) {
view.setBackgroundResource(R.drawable.rectangle_background);
Expand All @@ -45,6 +48,7 @@ public static void setRectangleBackgroundDrawable(@NonNull View view, @ColorInt
background.setColor(0xff000000 | colorRgb);
}

/** Used to set a resource background to a button. */
@BindingAdapter("android:button")
public static void setBackgroundResource(@NonNull Button button, @DrawableRes int resource) {
button.setBackgroundResource(resource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/** Holds all custom binding adapters that bind to [EditText]. */
public final class EditTextBindingAdapters {

/** Binding adapter for setting a [TextWatcher] as a change listener for an [EditText] */
/** Binding adapter for setting a [TextWatcher] as a change listener for an [EditText]. */
@BindingAdapter("app:textChangedListener")
public static void bindTextWatcher(@NonNull EditText editText, TextWatcher textWatcher) {
editText.addTextChangedListener(textWatcher);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void setImageDrawable(

/**
* Binds the specified [LessonThumbnailGraphic] as the source for the [ImageView].
*
* <p/>
* The view should be specified to have no width/height (when sized in a constraint layout), and
* use centerCrop for the image to appear correctly.
*/
Expand All @@ -58,42 +58,61 @@ public static void setImageDrawable(
switch (thumbnailGraphic) {
case BAKER:
drawableResourceId = R.drawable.lesson_thumbnail_graphic_baker;
break;
anandwana001 marked this conversation as resolved.
Show resolved Hide resolved
case CHILD_WITH_BOOK:
drawableResourceId = R.drawable.lesson_thumbnail_graphic_child_with_book;
break;
case CHILD_WITH_CUPCAKES:
drawableResourceId = R.drawable.lesson_thumbnail_graphic_child_with_cupcakes;
break;
case CHILD_WITH_FRACTIONS_HOMEWORK:
drawableResourceId = R.drawable.lesson_thumbnail_graphic_child_with_fractions_homework;
break;
case DUCK_AND_CHICKEN:
drawableResourceId = R.drawable.lesson_thumbnail_graphic_duck_and_chicken;
break;
case PERSON_WITH_PIE_CHART:
drawableResourceId = R.drawable.lesson_thumbnail_graphic_person_with_pie_chart;
break;
case IDENTIFYING_THE_PARTS_OF_A_FRACTION:
drawableResourceId = R.drawable.topic_fractions_01;
break;
case WRITING_FRACTIONS:
drawableResourceId = R.drawable.topic_fractions_02;
break;
case EQUIVALENT_FRACTIONS:
drawableResourceId = R.drawable.topic_fractions_03;
break;
case MIXED_NUMBERS_AND_IMPROPER_FRACTIONS:
drawableResourceId = R.drawable.topic_fractions_04;
break;
case COMPARING_FRACTIONS:
drawableResourceId = R.drawable.topic_fractions_05;
break;
case ADDING_AND_SUBTRACTING_FRACTIONS:
drawableResourceId = R.drawable.topic_fractions_06;
break;
case MULTIPLYING_FRACTIONS:
drawableResourceId = R.drawable.topic_fractions_07;
break;
case DIVIDING_FRACTIONS:
drawableResourceId = R.drawable.topic_fractions_08;
break;
case DERIVE_A_RATIO:
drawableResourceId = R.drawable.topic_ratios_01;
break;
case WHAT_IS_A_FRACTION:
drawableResourceId = R.drawable.topic_fractions_01;
break;
case FRACTION_OF_A_GROUP:
drawableResourceId = R.drawable.topic_fractions_02;
break;
case ADDING_FRACTIONS:
drawableResourceId = R.drawable.topic_fractions_03;
break;
case MIXED_NUMBERS:
drawableResourceId = R.drawable.topic_fractions_04;
break;
default:
drawableResourceId = R.drawable.topic_fractions_01;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import androidx.annotation.NonNull;
import androidx.annotation.PluralsRes;
import androidx.databinding.BindingAdapter;
import org.oppia.android.R;
import org.oppia.android.util.system.OppiaDateTimeFormatter;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import org.oppia.android.R;
import org.oppia.android.util.system.OppiaDateTimeFormatter;

/** Holds all custom binding adapters that bind to [TextView]. */
public final class TextViewBindingAdapters {
Expand All @@ -29,6 +29,7 @@ public static void setProfileDataText(@NonNull TextView textView, long timestamp
));
}

/** Binds last used with relative timestamp. */
@BindingAdapter("profile:lastVisited")
public static void setProfileLastVisitedText(@NonNull TextView textView, long timestamp) {
String profileLastUsed = textView.getContext().getString(R.string.profile_last_used);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public static void setLayoutHeight(@NonNull View view, float height) {
view.setLayoutParams(layoutParams);
}

/**
* BindingAdapter to set Rotation Animation and Rotation Angle.
*/
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
@BindingAdapter(
value = {
"app:isRotationAnimationClockwise",
Expand Down
4 changes: 3 additions & 1 deletion app/src/test/java/DataBinderMapperImpl.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package androidx.databinding;

// TODO(#1683): Remove when android_local_test works with data-binding.
/**
* Generated code necessary to run tests with Bazel.
*
* <p/>
* Typically, this code is generated by Bazel and included in the srcs list when running tests.
* However, the `enable_data_binding` flag somehow affects this process. For now, this file must be
* included in the srcs list of any Bazel test in app module.
*/
public final class DataBinderMapperImpl extends MergedDataBinderMapper {

DataBinderMapperImpl() {
addMapper(new org.oppia.android.app.test.DataBinderMapperImpl());
}
Expand Down
Loading