Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 7 additions & 9 deletions .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ jobs:
echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc
shell: bash

- name: Binary files 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: |
bash /home/runner/work/oppia-android/oppia-android/scripts/binary_files_check.sh

- 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.
Expand Down Expand Up @@ -209,15 +216,6 @@ jobs:
run: |
bazel run //scripts:string_resource_validation_check -- $(pwd)

- name: Binary files 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: |
bash /home/runner/work/oppia-android/oppia-android/scripts/pre-commit.sh
echo "No binary files found in commit"
echo "BINARY FILES CHECK PASSED"

# 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).
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.oppia.android.app.walkthrough

class DummyWalkthrough
Binary file added app/src/main/res/drawable/cute-otter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/dev flavor apk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/otter2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/otter_cartoon.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions app/src/main/res/layout/activity_otter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

</LinearLayout>
Empty file.
Empty file.
Empty file.
Binary file added scripts/assets/bread.mp4
Binary file not shown.
Binary file added scripts/assets/mockversion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions scripts/assets/newtext.textproto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
exempted_activity: "app/src/main/java/org/oppia/android/app/devoptions/forcenetworktype/testing/ForceNetworkTypeTestActivity"
exempted_activity: "app/src/main/java/org/oppia/android/app/devoptions/markchapterscompleted/testing/MarkChaptersCompletedTestActivity"
exempted_activity: "app/src/main/java/org/oppia/android/app/devoptions/markstoriescompleted/testing/MarkStoriesCompletedTestActivity"
exempted_activity: "app/src/main/java/org/oppia/android/app/devoptions/marktopicscompleted/testing/MarkTopicsCompletedTestActivity"
exempted_activity: "app/src/main/java/org/oppia/android/app/devoptions/vieweventlogs/testing/ViewEventLogsTestActivity"
exempted_activity: "app/src/main/java/org/oppia/android/app/devoptions/testing/DeveloperOptionsTestActivity"
exempted_activity: "app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedActivity"
exempted_activity: "app/src/main/java/org/oppia/android/app/player/state/testing/StateFragmentTestActivity"
Empty file added scripts/assets/proto.mp4
Empty file.
21 changes: 21 additions & 0 deletions scripts/binary_files_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

source scripts/formatting.sh

check_binary_files() {
base_commit=$(git merge-base origin/develop HEAD)
binary_files=$(git diff --numstat "$base_commit"...HEAD | awk '$1 == "-" && $2 == "-" { print $3 }')
binary_files_count=$(echo "$binary_files" | grep -c . || true)

if [[ "$binary_files_count" -gt 0 ]]; then
echo "Detected $binary_files_count binary file(s):"
echo "$binary_files"
echo_error "\nBINARY FILES CHECK FAILED\n"
exit 1
else
echo "No binary files detected in the commit"
echo_success "\nBINARY FILES CHECK PASSED\n"
fi
}

check_binary_files
12 changes: 6 additions & 6 deletions scripts/formatting.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
#!/bin/bash

#Defines color codes for output formatting
# Defines color codes for output formatting

# Red color for error messages
RED='\033[0;31m'

# Green color for success messages
GREEN='\033[0;32m'

# Yellow color for warnings messages
# Yellow color for warning messages
YELLOW='\033[0;33m'

# No color, used to reset the color after each message
# No color, resets color after message
NC='\033[0m'

# Function to print an error message in red
function echo_error() {
echo -e "${RED}$1${NC}"
printf "${RED}%b${NC}\n" "$1"
}

# Function to print a success message in green
function echo_success() {
echo -e "${GREEN}$1${NC}"
printf "${GREEN}%b${NC}\n" "$1"
}

# Function to print a warning message in yellow
function echo_warning() {
echo -e "${YELLOW}$1${NC}"
printf "${YELLOW}%b${NC}\n" "$1"
}
34 changes: 1 addition & 33 deletions scripts/pre-commit.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,35 +1,3 @@
#!/bin/bash

# Pre-commit hook to check for binary files.

# Find the common ancestor between develop and the current branch
base_commit=$(git merge-base 'origin/develop' HEAD)

# Get the list of staged changes (files ready to be committed)
staged_files=$(git diff --cached --name-only)

# Get the list of changed files compared to the base commit
changed_files=$(git diff --name-only "$base_commit" HEAD)

# Combine both lists of files, ensuring no duplicates
all_files=$(echo -e "$staged_files\n$changed_files" | sort -u)

function checkForBinaries() {
binaryFilesCount=0

# Iterate over all files (both staged and changed)
for file in $all_files; do
if [ -f "$file" ] && file --mime "$file" | grep -q 'binary'; then
((binaryFilesCount++))
printf "\n\033[33m%s\033[0m" "$file"
fi
done

if [[ "${binaryFilesCount}" -gt 0 ]]; then
printf "\n\nPlease remove the %d detected binary file(s)." "$binaryFilesCount"
printf "\nBINARY FILES CHECK FAILED"
exit 1
fi
}

checkForBinaries
bash scripts/binary_files_check.sh
Empty file added wiki/Dummy.md
Empty file.
Empty file added wiki/Dummy.txt
Empty file.
Empty file added wiki/DummyWiki.kt
Empty file.
2 changes: 2 additions & 0 deletions wiki/res/values/DummyLayout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>
Loading