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
68 changes: 68 additions & 0 deletions .github/workflows/pr-comment-artifact-url.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# pr-comment-artifact-url.yml
---
name: Comment Artifact URL on PR

on:
workflow_run:
types:
- "completed"
workflows:
- "QA"

jobs:
comment-on-pr:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- name: Get Artifact URL & PR Info
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
WORKFLOW_RUN_EVENT_OBJ: ${{ toJSON(github.event.workflow_run) }}
run: |

PREVIOUS_JOB_ID=$(jq -r '.id' <<< "$WORKFLOW_RUN_EVENT_OBJ")
echo "Previous Job ID: $PREVIOUS_JOB_ID"
echo "PREVIOUS_JOB_ID=$PREVIOUS_JOB_ID" >> "$GITHUB_ENV"

ARTIFACT_URL=$(gh api "/repos/$OWNER/$REPO/actions/artifacts" \
--jq ".artifacts.[] |
select(.workflow_run.id==${PREVIOUS_JOB_ID}) |
select(.expired==false) |
.archive_download_url")

echo "ARTIFACT URL: $ARTIFACT_URL"
echo "ARTIFACT_URL=$ARTIFACT_URL" >> "$GITHUB_ENV"

PR_NUMBER=$(jq -r '.pull_requests[0].number' \
<<< "$WORKFLOW_RUN_EVENT_OBJ")

echo "PR Number: $PR_NUMBER"
echo "PR_NUMBER=$PR_NUMBER" >> "$GITHUB_ENV"

HEAD_SHA=$(jq -r '.pull_requests[0].head.sha' \
<<< "$WORKFLOW_RUN_EVENT_OBJ")

echo "Head sha: $HEAD_SHA"
echo "HEAD_SHA=$HEAD_SHA" >> "$GITHUB_ENV"

- name: Update Comment
env:
JOB_PATH: "${{ github.server_url }}/${{ github.repository }}/actions/\
runs/${{ env.PREVIOUS_JOB_ID }}"
HEAD_SHA: ${{ env.HEAD_SHA }}
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ env.PR_NUMBER }}
body: |-
## Build Preview
You can find files attached to the below linked Workflow Run URL (Logs).

Please note that files only stay for around 90 days!

| Name | Link |
|------|------|
| Commit | ${{ env.HEAD_SHA }} |
| Build Log | ${{ env.JOB_PATH }} |
| APK File (Requires OAuth) | ${{ env. ARTIFACT_URL }} |
77 changes: 36 additions & 41 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,45 @@
name: "QA"

on:
pull_request:
branches: [ master, stable-* ]
pull_request:
branches: [ master, stable-* ]

permissions:
pull-requests: write
contents: read
pull-requests: write
contents: read

concurrency:
group: qa-build-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
group: qa-build-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
qa:
runs-on: ubuntu-latest
steps:
- name: Check if secrets are available
run: echo "::set-output name=ok::${{ secrets.KS_PASS != '' }}"
id: check-secrets
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v3
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
- name: set up JDK 17
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
with:
distribution: "temurin"
java-version: 17
- name: Install NDK and cmake
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
run: |
source ndk.env
/usr/local/lib/android/sdk/tools/bin/sdkmanager "ndk;${NDK_VERSION}" "cmake;${CMAKE_VERSION}"
- name: Build QA
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
env:
KS_PASS: ${{ secrets.KS_PASS }}
KEY_PASS: ${{ secrets.KEY_PASS }}
LOG_USERNAME: ${{ secrets.LOG_USERNAME }}
LOG_PASSWORD: ${{ secrets.LOG_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p $HOME/.gradle
echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > $HOME/.gradle/gradle.properties
sed -i "/qa/,/\}/ s/versionCode .*/versionCode ${{github.event.number}} /" app/build.gradle
sed -i "/qa/,/\}/ s/versionName .*/versionName \"${{github.event.number}}\"/" app/build.gradle
./gradlew assembleQaDebug
$(find /usr/local/lib/android/sdk/build-tools/*/apksigner | sort | tail -n1) sign --ks-pass pass:$KS_PASS --key-pass pass:$KEY_PASS --ks-key-alias key0 --ks scripts/QA_keystore.jks app/build/outputs/apk/qa/debug/qa-debug-*.apk
scripts/uploadArtifact.sh $LOG_USERNAME $LOG_PASSWORD ${{github.event.number}} ${{github.event.number}}
qa:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v3
- name: set up JDK 17
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3
with:
distribution: "temurin"
java-version: 17
- name: Install NDK and cmake
run: |
source ndk.env
/usr/local/lib/android/sdk/tools/bin/sdkmanager "ndk;${NDK_VERSION}" "cmake;${CMAKE_VERSION}"
- name: Build QA
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p $HOME/.gradle
echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > $HOME/.gradle/gradle.properties
sed -i "/qa/,/\}/ s/versionCode .*/versionCode ${{github.event.number}} /" app/build.gradle
sed -i "/qa/,/\}/ s/versionName .*/versionName \"${{github.event.number}}\"/" app/build.gradle
./gradlew assembleQaDebug

- name: Upload Artifact
id: upload
uses: actions/upload-artifact@v3
with:
name: qa-debug-apk
path: "app/build/outputs/apk/qa/debug/qa-debug-*.apk"
if-no-files-found: error
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,4 @@ If you need assistance or want to ask a question about the Android app, you are
## Remarks :scroll:

Google Play and the Google Play logo are trademarks of Google Inc.

5 changes: 4 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ android {
dependencies {
// dependencies for app building
implementation 'androidx.multidex:multidex:2.0.1'
implementation("com.github.nextcloud:android-library:$androidLibraryVersion") {
// implementation("com.github.nextcloud:android-library:$androidLibraryVersion") {
// temporarily using my own version of the nextcloud android-library so automated compile and unit tests
// are able to build the app. should be removed before merging.
implementation("com.github.elv1zz:nextcloud-android-library:$androidLibraryVersion") {
exclude group: 'org.ogce', module: 'xpp3' // unused in Android and brings wrong Junit version
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ public void onPageFinished(WebView view, String url) {
}
}

@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
accountSetupWebviewBinding.loginWebviewProgressBar.setVisibility(View.GONE);
accountSetupWebviewBinding.loginWebview.setVisibility(View.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ package com.owncloud.android.ui
import android.annotation.SuppressLint
import android.net.http.SslCertificate
import android.net.http.SslError
import android.webkit.ClientCertRequest
import android.webkit.SslErrorHandler
import android.webkit.WebResourceRequest
import android.webkit.WebResourceResponse
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.fragment.app.FragmentManager
import com.owncloud.android.authentication.AuthenticatorActivity
import com.owncloud.android.lib.common.network.AdvancedX509KeyManager
import com.owncloud.android.lib.common.network.NetworkUtils
import com.owncloud.android.lib.common.utils.Log_OC
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog
import org.apache.commons.httpclient.HttpStatus
import java.io.ByteArrayInputStream
import java.security.cert.CertificateException
import java.security.cert.CertificateFactory
Expand Down Expand Up @@ -78,4 +83,39 @@ open class NextcloudWebViewClient(val supportFragmentManager: FragmentManager) :
ft.addToBackStack(null)
dialog.show(ft, AuthenticatorActivity.UNTRUSTED_CERT_DIALOG_TAG)
}

/**
* Handle request for a TLS client certificate.
*/
override fun onReceivedClientCertRequest(view: WebView?, request: ClientCertRequest?) {
if (view == null || request == null) {
return
}
AdvancedX509KeyManager(view.context).handleWebViewClientCertRequest(request)
}

/**
* Handle HTTP errors.
*
* We might receive an HTTP status code 400 (bad request), which probably tells us that our certificate
* is not valid (anymore), e.g. because it expired. In that case we forget the selected client certificate,
* so it can be re-selected.
*/
override fun onReceivedHttpError(
view: WebView?,
request: WebResourceRequest?,
errorResponse: WebResourceResponse?
) {
val errorCode = errorResponse?.statusCode ?: return
if (errorCode == HttpStatus.SC_BAD_REQUEST) {
// chosen client certificate alias does not seem to work -> discard it
val failingUrl = request?.url
val context = view?.context
if (failingUrl == null || context == null) {
return
}
Log_OC.w(tag, "WebView failed with error code $errorCode; remove key chain aliases")
AdvancedX509KeyManager(context).removeKeys(failingUrl)
}
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
androidPluginVersion = '8.1.1'
androidPluginVersion = '8.1.2'
appCompatVersion = '1.6.1'
jacoco_version = '0.8.10'
kotlin_version = '1.8.22'
Expand Down