Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
newhinton authored Apr 28, 2024
2 parents 76a8fe0 + 2b5acf0 commit d755442
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 28 deletions.
38 changes: 17 additions & 21 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,58 @@ name: Android CI

on:
workflow_dispatch:
# schedule:
# - cron: '0 22 * * *' # run at 0:00 GMT+2
push:
tags:
- '*'

jobs:
# hasChanged:
# continue-on-error: true
# name: Verify that changes have occured in the last 24h
# if: ${{ github.event_name == 'schedule' }}
# run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=hasChanged::false"

createArtifacts:
# needs: hasChanged
# if: ${{ needs.hasChanged.outputs.hasChanged != 'false' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Read Go version from project
run: echo "GO_VERSION=$(grep -E "^de\.felixnuesse\.extract\.goVersion=" gradle.properties | cut -d'=' -f2)"
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Set up Go 1.19.8
- name: Set up Go from gradle.properties
uses: actions/setup-go@v4
with:
go-version: 1.19.8
go-version: '${{env.GO_VERSION}}'
id: go
- name: Install NDK
- name: Setup Android SDK/NDK
uses: android-actions/setup-android@v3
- name: Install NDK from gradle.properties
run: |
NDK_VERSION="$(grep -E "^de\.felixnuesse\.extract\.ndkVersion=" gradle.properties | cut -d'=' -f2)"
yes | sudo "${ANDROID_HOME}/tools/bin/sdkmanager" --licenses
sudo "${ANDROID_HOME}/tools/bin/sdkmanager" "ndk;${NDK_VERSION}"
sdkmanager "ndk;${NDK_VERSION}"
- name: Build app
run: ./gradlew assembleOssRelease
- name: Upload APK (arm)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: nightly-armeabi.apk
path: app/build/outputs/apk/oss/debug/roundsync_v*?(-beta)-oss-armeabi-v7a-debug.apk
- name: Upload APK (arm64)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: nightly-arm64.apk
path: app/build/outputs/apk/oss/debug/roundsync_v*?(-beta)-oss-arm64-v8a-debug.apk
- name: Upload APK (x86)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: nightly-x86.apk
path: app/build/outputs/apk/oss/debug/roundsync_v*?(-beta)-oss-x86-debug.apk
- name: Upload APK (arm)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: nightly-x64.apk
path: app/build/outputs/apk/oss/debug/roundsync_v*?(-beta)-oss-x86_64-debug.apk
- name: Upload APK (universal)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: nightly-universal.apk
path: app/build/outputs/apk/oss/debug/roundsync_v*?(-beta)-oss-universal-debug.apk
Expand Down
75 changes: 75 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: "Verify dependency chain"
on:
workflow_dispatch:
push:

jobs:
dependency-change-verification:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.changeDetection.outputs.should-run }}
steps:
- uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
- name: Verify build.gradle changed
id: changeDetection
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
GRADLE='build.gradle'
for file in ${ALL_CHANGED_FILES}; do
if [[ "$file" == *"$GRADLE" ]]; then
echo "$file was changed"
echo "should-run=true" >> $GITHUB_OUTPUT
fi
done
verify-dependencies:
runs-on: ubuntu-latest
needs: dependency-change-verification
if: needs.dependency-change-verification.outputs.changed == 'true'
steps:
- uses: actions/checkout@v4
- name: Read Go version from project
run: echo "GO_VERSION=$(grep -E "^de\.felixnuesse\.extract\.goVersion=" gradle.properties | cut -d'=' -f2)"
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Set up Go from gradle.properties
uses: actions/setup-go@v4
with:
go-version: '${{env.GO_VERSION}}'
id: go
- name: Setup Android SDK/NDK
uses: android-actions/setup-android@v3
- name: Install NDK from gradle.properties
run: |
NDK_VERSION="$(grep -E "^de\.felixnuesse\.extract\.ndkVersion=" gradle.properties | cut -d'=' -f2)"
sdkmanager "ndk;${NDK_VERSION}"
- name: Build app
run: ./gradlew assembleOssDebug

- name: 'Check for non-FOSS libraries'
run: |
# prepare scanapk with apktool.
wget https://github.com/iBotPeaches/Apktool/releases/download/v$apktoolVersion/apktool_$apktoolVersion.jar
# Wrapper for apktool_*.jar
wget https://github.com/iBotPeaches/Apktool/raw/master/scripts/linux/apktool
# clone izzy's repo with the scan tools
git clone https://gitlab.com/IzzyOnDroid/repo.git
# create a directory for Apktool and move the apktool* files there
mkdir -p repo/lib/radar/tool
mv apktool* repo/lib/radar/tool
chmod u+x repo/lib/radar/tool/apktool
mv repo/lib/radar/tool/apktool_$apktoolVersion.jar repo/lib/radar/tool/apktool.jar
repo/bin/scanapk.php app/build/outputs/apk/oss/debug/roundsync_v*-oss-universal-debug.apk
env:
apktoolVersion: "2.9.3"
- name: 'Get Commit Hash'
id: commit
uses: pr-mpt/actions-commit-hash@v1
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
checkLint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
Expand All @@ -21,7 +21,7 @@ jobs:
run: ./gradlew lint -x :rclone:buildAll
- name: Upload Reports
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Lint Reports
path: ~/**/build/reports/
Expand Down
85 changes: 85 additions & 0 deletions .github/workflows/translations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Translations

on:
workflow_dispatch:
pull_request:

jobs:
string-change-verification:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.changeDetection.outputs.should-run }}
files: ${{ steps.changeDetection.outputs.files }}
steps:
- uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
- name: Verify build.gradle changed
id: changeDetection
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
SEARCH='strings.xml'
CHANGEDFILES=''
for file in ${ALL_CHANGED_FILES}; do
if [[ "$file" == *"$SEARCH" ]]; then
echo "$file was changed"
CHANGEDFILES="${CHANGEDFILES} $file"
echo "should-run=true" >> $GITHUB_OUTPUT
fi
done
echo "files=$CHANGEDFILES" >> $GITHUB_OUTPUT
checkTranslations:
runs-on: ubuntu-latest
needs: string-change-verification
if: needs.string-change-verification.outputs.changed == 'true'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Prepare Profanity Check
id: prep
run: |
sudo apt-get install -y xmlstarlet
pip3 install alt-profanity-check
chmod +x ./scripts/checkProfanity.py
chmod +x ./scripts/generateFilelist.sh
FILE_LIST="${{needs.string-change-verification.outputs.files}}"
SIZE=$(echo "$FILE_LIST" | awk '{print NF}')
if [ "$SIZE" -ne 1 ]; then
echo "Only pass the amount of commits and one translation file! You passed: $SIZE"
exit 1
fi
TRANSLATIONS=$(./scripts/generateFilelist.sh ${{ github.event.pull_request.commits }} ${{needs.string-change-verification.outputs.files}})
echo "TRANSLATIONS=$TRANSLATIONS" >> $GITHUB_OUTPUT
shell: sh
- uses: fabasoad/translation-action@main
id: google-translate
with:
provider: google
lang: auto-en
source: ${{ steps.prep.outputs.TRANSLATIONS }}
- name: Print the result
run: |
echo "Translations are: '${{ steps.google-translate.outputs.text }}'"
echo "${{ steps.google-translate.outputs.text }}" | sed 's/ ; /\n/g' > translated_texts.txt
./scripts/checkProfanity.py translated_texts.txt
shell: sh
- name: Upload Raw Translations
uses: actions/upload-artifact@v4
with:
name: Translations
path: |
changed_texts.txt
translated_texts.txt
suspicious_texts.txt
- name: Fail if there are suspected profanities
run: |
if [ -s "suspicious_texts.txt" ]; then
echo "We found suspicious translations. Please check!"
exit 1
fi
shell: sh

7 changes: 3 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ android {
minSdkVersion 23
compileSdk 34
targetSdkVersion 34
versionCode 370 // last digit is reserved for ABI, only ever end on 0!
versionName '2.5.2'
versionCode 380 // last digit is reserved for ABI, only ever end on 0!
versionName '2.5.3'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "java.lang.String", "CLI", System.getenv('RCX_BUILD_CLI') ? System.getenv('RCX_BUILD_CLI') : "\"c03129b6-b09f-9cb4-8fcd-7f143b8f94ef\""
buildConfigField "java.lang.String", "VCP_AUTHORITY", "\"" + applicationId + ".vcp\"";
Expand Down Expand Up @@ -168,7 +168,7 @@ dependencies {

implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'androidx.datastore:datastore-preferences:1.0.0'
implementation 'androidx.datastore:datastore-preferences:1.1.0'

implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")

Expand Down Expand Up @@ -207,5 +207,4 @@ dependencies {

//Updates
implementation 'com.github.Sharkaboi:AppUpdateChecker:v1.0.5'
implementation("com.google.android.play:app-update-ktx:2.1.0")
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class UpdateWorker (private var mContext: Context, workerParams: WorkerParameter

private var checkForUpdates = preferenceManager.getBoolean(mContext.getString(R.string.pref_key_app_updates), false)
private val ignoredVersion = preferenceManager.getString(mContext.getString(R.string.pref_key_app_update_dismiss_current_update), "")
private val lastFoundVersion = preferenceManager.getString(mContext.getString(R.string.pref_key_app_updates_found_update_for_version), "")?:""
private val lastFoundVersion = preferenceManager.getString(mContext.getString(R.string.pref_key_app_updates_found_update_for_version), BuildConfig.VERSION_NAME)?:BuildConfig.VERSION_NAME


override fun doWork(): Result {
Expand Down
17 changes: 17 additions & 0 deletions scripts/checkProfanity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/python

from profanity_check import predict, predict_prob
import sys


file = open("suspicious_texts.txt", "a")
source = open(sys.argv[1], "r")
lines = source.readlines()
for line in lines:
print("Checking: "+str(line.rstrip()))
prediction = predict_prob([line.rstrip()])
if prediction[0] > 0.5:
file.write(str(prediction[0]) + " - " + str(line.rstrip())+"\n")
print("Offending line: "+str(line.rstrip()))

file.close()
14 changes: 14 additions & 0 deletions scripts/generateFilelist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

if [ "$#" -ne 2 ]; then
echo "Only pass the amount of commits and one translation file!"
exit 1
fi

DIFF=$(git diff -U0 HEAD~$1 ${@:2} | grep -E "^\+" | grep -v +++ | cut -c 2- | sed 's/^[ \t]*\(.*$\)/\1/')
echo "<xml>$DIFF</xml>" | xmlstarlet sel -t -m '//string' -v . -n > changed_texts.txt
TRANSLATIONS=$(cat changed_texts.txt)
TRANSLATIONS="${TRANSLATIONS//'%'/' ; '}"
TRANSLATIONS="${TRANSLATIONS//$'\n'/' ; '}"
TRANSLATIONS="${TRANSLATIONS//$'\r'/' ; '}"
echo $TRANSLATIONS

0 comments on commit d755442

Please sign in to comment.