Skip to content

Commit

Permalink
deploy gplay artifact on success as own QA flavor
Browse files Browse the repository at this point in the history
Signed-off-by: tobiasKaminsky <[email protected]>
  • Loading branch information
tobiasKaminsky committed May 17, 2019
1 parent d16d297 commit 1776557
Show file tree
Hide file tree
Showing 22 changed files with 2,785 additions and 4 deletions.
32 changes: 31 additions & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ steps:
- ./gradlew combinedTestReport
- curl -o codecov.sh https://codecov.io/bash
- bash ./codecov.sh -t fc506ba4-33c3-43e4-a760-aada38c24fd5

- scripts/uploadArtifact.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
- name: notify
image: drillster/drone-email
host: $EMAIL_HOST
Expand Down Expand Up @@ -160,3 +160,33 @@ trigger:
event:
- push
- pull_request
---
kind: pipeline
name: qa

steps:
- name: qa
image: nextcloudci/android:android-44
privileged: true
environment:
LOG_USERNAME:
from_secret: LOG_USERNAME
LOG_PASSWORD:
from_secret: LOG_PASSWORD
GIT_USERNAME:
from_secret: GIT_USERNAME
GIT_TOKEN:
from_secret: GIT_TOKEN
KS_PASS:
from_secret: KS_PASS
KEY_PASS:
from_secret: KEY_PASS
commands:
- sed -i "/qa/,/\}/ s/versionCode .*/versionCode $DRONE_BUILD_NUMBER/" build.gradle
- sed -i "/qa/,/\}/ s/versionName .*/versionName \"$DRONE_BUILD_NUMBER\"/" build.gradle
- ./gradlew assembleQaDebug
- /opt/android-sdk-linux/build-tools/*/apksigner sign --ks-pass pass:$KS_PASS --key-pass pass:$KEY_PASS --ks-key-alias key0 --ks scripts/QA_keystore.jks build/outputs/apk/qa/debug/qa-debug-*.apk
- scripts/uploadArtifact.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
trigger:
event:
- pull_request
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ android {
versionCode 20190515
versionName "20190515"
}

qa {
applicationId "com.nextcloud.android.qa"
dimension "default"
versionCode 1
versionName "1"
}
}
}

Expand Down Expand Up @@ -254,6 +261,7 @@ dependencies {
genericImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
gplayImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
qaImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
Expand Down
35 changes: 35 additions & 0 deletions drawable_resources/logo_qa.svg
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 scripts/QA_keystore.jks
Binary file not shown.
6 changes: 3 additions & 3 deletions scripts/analysis/analysis-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ else
echo "New findbugs results at https://www.kaminsky.me/nc-dev/$repository-findbugs/$6.html"
curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$6.html --upload-file build/reports/spotbugs/spotbugs.html

# delete all old comments
oldComments=$(curl 2>/dev/null -u $1:$2 -X GET https://api.github.com/repos/nextcloud/android/issues/$7/comments | jq '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) ' | grep true | tr -d "\"" | cut -f1 -d"|")
# delete all old comments, starting with Codacy
oldComments=$(curl 2>/dev/null -u $1:$2 -X GET https://api.github.com/repos/nextcloud/android/issues/$7/comments | jq '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) + "|" + (.body | test("<h1>Codacy.*") | tostring)' | grep "true|true" | tr -d "\"" | cut -f1 -d"|")

echo $oldComments | while read comment ; do
curl 2>/dev/null -u $1:$2 -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
done

# check library, only if base branch is master
baseBranch=$(scripts/analysis/getBranchBase.sh $1 $2 $7 | tr -d "\"")
if [ $baseBranch = "master" -a $(grep "android-library:master" build.gradle -c) -ne 3 ]; then
if [ $baseBranch = "master" -a $(grep "android-library:master" build.gradle -c) -ne 4 ]; then
checkLibraryMessage="<h1>Android-library is not set to master branch in build.gradle</h1>"
checkLibrary=1
elif [ $baseBranch != "master" -a $baseBranch = $stableBranch -a $(grep "android-library:.*SNAPSHOT" build.gradle -c) -ne 0 ]; then
Expand Down
37 changes: 37 additions & 0 deletions scripts/uploadArtifact.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

#1: LOG_USERNAME
#2: LOG_PASSWORD
#3: DRONE_BUILD_NUMBER
#4: DRONE_PULL_REQUEST
#5: GIT_USERNAME
#6: GIT_TOKEN

DAV_URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-artifacts/
PUBLIC_URL=https://www.kaminsky.me/nc-dev/android-artifacts
USER=$1
PASS=$2
BUILD=$3
PR=$4
GIT_USERNAME=$5
GIT_TOKEN=$6

if ! test -e build/outputs/apk/qa/debug/qa-debug-*.apk ; then
exit 1
fi
echo "Uploaded artifact to $DAV_URL/$BUILD.apk"

# delete all old comments, starting with "APK file:"
oldComments=$(curl 2>/dev/null -u $GIT_USERNAME:$GIT_TOKEN -X GET https://api.github.com/repos/nextcloud/android/issues/$PR/comments | jq '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) + "|" + (.body | test("APK file:.*") | tostring)' | grep "true|true" | tr -d "\"" | cut -f1 -d"|")

echo $oldComments | while read comment ; do
curl 2>/dev/null -u $GIT_USERNAME:$GIT_TOKEN -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
done

apt-get -y install qrencode

qrencode -o $PR.png "$PUBLIC_URL/$BUILD.apk"

curl -u $USER:$PASS -X PUT $DAV_URL/$BUILD.apk --upload-file build/outputs/apk/qa/debug/qa-debug-*.apk
curl -u $USER:$PASS -X PUT $DAV_URL/$BUILD.png --upload-file $PR.png
curl -u $GIT_USERNAME:$GIT_TOKEN -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments -d "{ \"body\" : \"APK file: $PUBLIC_URL/$BUILD.apk <br/><br/> ![qrcode]($PUBLIC_URL/$BUILD.png) \" }"
35 changes: 35 additions & 0 deletions src/qa/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"project_info": {
"project_number": "",
"project_id": ""
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "",
"android_client_info": {
"package_name": "com.nextcloud.android.beta"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": ""
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 1
}
}
}
],
"configuration_version": "1"
}
Binary file added src/qa/ic_launcher-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions src/qa/java/com/nextcloud/client/di/VariantComponentsModule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Nextcloud Android client application
*
* @author Chris Narkiewicz
* Copyright (C) 2919 Chris Narkiewicz <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.nextcloud.client.di;

import dagger.Module;

@Module
abstract class VariantComponentsModule {
}
58 changes: 58 additions & 0 deletions src/qa/java/com/owncloud/android/utils/PushUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Nextcloud Android client application
*
* @author Mario Danic
* @author Chris Narkiewicz Copyright (C) 2017 Mario Danic Copyright (C) 2019 Chris Narkiewicz
* <p>
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
* Public License as published by the Free Software Foundation, either version 3 of the License, or at your option) any
* later version.
* <p>
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
* <p>
* You should have received a copy of the GNU Affero General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/

package com.owncloud.android.utils;

import android.content.Context;

import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.preferences.AppPreferencesImpl;
import com.owncloud.android.MainApp;
import com.owncloud.android.datamodel.SignatureVerification;

import java.security.Key;

public final class PushUtils {
public static final String KEY_PUSH = "push";

private PushUtils() {
}

public static void pushRegistrationToServer(
final UserAccountManager accountManager,
final String pushToken) {
// do nothing
}

public static void reinitKeys(final UserAccountManager accountManager) {
Context context = MainApp.getAppContext();
AppPreferencesImpl.fromContext(context).setKeysReInitEnabled();
}

public static Key readKeyFromFile(boolean readPublicKey) {
return null;
}

public static SignatureVerification verifySignature(
final Context context,
final UserAccountManager accountManager,
final byte[] signatureBytes, final byte[] subjectBytes
) {
return null;
}
}
20 changes: 20 additions & 0 deletions src/qa/java/com/owncloud/android/utils/SecurityUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Nextcloud Android client application
*
* @author Mario Danic Copyright (C) 2018 Mario Danic
* <p>
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
* Public License as published by the Free Software Foundation, either version 3 of the License, or at your option) any
* later version.
* <p>
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
* <p>
* You should have received a copy of the GNU Affero General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.owncloud.android.utils;

public class SecurityUtils {
}
Loading

0 comments on commit 1776557

Please sign in to comment.