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 #85: Update test and project config #86

Merged
merged 10 commits into from
Dec 21, 2023
Merged
35 changes: 18 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ on:
- master
- release/*
pull_request:
schedule:
- cron: '11 6 3 * *'

jobs:
buildJob:
name: Build
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'zulu'
Expand All @@ -29,14 +27,14 @@ jobs:

lintJob:
name: Lint
runs-on: macos-latest
runs-on: ubuntu-latest
needs: [buildJob]
steps:
- name: Checkout the repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'zulu'
Expand All @@ -46,22 +44,22 @@ jobs:

- name: Upload lint results artifact
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: lint-results-debug
path: library/build/reports/lint-results-debug.html
retention-days: 5

unitTestJob:
name: Unit Test
runs-on: macos-latest
runs-on: ubuntu-latest
needs: [buildJob]
steps:
- name: Checkout the repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'zulu'
Expand All @@ -71,7 +69,7 @@ jobs:

- name: Upload unit test results artifact
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: unit-test-results-debug
path: library/build/reports/tests/testDebugUnitTest/
Expand All @@ -83,10 +81,10 @@ jobs:
needs: [buildJob]
steps:
- name: Checkout the repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'zulu'
Expand All @@ -95,11 +93,14 @@ jobs:
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
script: ./gradlew library:connectedAndroidTest
script: >
./gradlew library:connectedAndroidTest
-Ptest.sslPinning.baseUrl=${{ secrets.SSL_PINNING_TEST_BASE_URL }}
-Ptest.sslPinning.appName=${{ secrets.SSL_PINNING_TEST_APP_NAME }}

- name: Upload instrumentation test results artifact
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: instrumentation-test-results-debug
path: library/build/reports/androidTests/connected/
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md

# jEnv
.java-version
55 changes: 0 additions & 55 deletions build.gradle

This file was deleted.

31 changes: 31 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2018 Wultra s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
*/

buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath("com.android.tools.build:gradle:${Constants.BuildScript.androidPluginVersion}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Constants.BuildScript.kotlinVersion}")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:${Constants.BuildScript.dokkaVersion}")
}
}

tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
1 change: 1 addition & 0 deletions buildSrc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
32 changes: 32 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2023 Wultra s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
*/

plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
google()
}

val androidPluginVersion: String by System.getProperties()
val kotlinVersion: String by System.getProperties()

dependencies {
implementation("com.android.tools.build", "gradle", androidPluginVersion)
implementation(kotlin("gradle-plugin", kotlinVersion))
}
19 changes: 19 additions & 0 deletions buildSrc/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Copyright 2023 Wultra s.r.o.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.
#

systemProp.kotlinVersion=1.8.20
systemProp.androidPluginVersion=7.4.2
systemProp.dokkaVersion=1.8.10
44 changes: 44 additions & 0 deletions buildSrc/src/main/kotlin/Constants.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2023 Wultra s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
*/

import org.gradle.api.JavaVersion

object Constants {
object BuildScript {
// These have to be defined in buildSrc/gradle.properties
// It's the only way to make them available in buildSrc/build.gradle.kts.kts
val androidPluginVersion: String by System.getProperties()
val kotlinVersion: String by System.getProperties()
val dokkaVersion: String by System.getProperties()
}

object Java {
val sourceCompatibility = JavaVersion.VERSION_1_8
val targetCompatibility = JavaVersion.VERSION_1_8
const val kotlinJvmTarget = "1.8"
}

object Android {
const val compileSdkVersion = 33
const val targetSdkVersion = 33
const val minSdkVersion = 19
const val buildToolsVersion = "33.0.2"
}

object Dependencies {
const val powerAuthSdkVersion = "1.8.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2023 Wultra s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
*/

package com.wultra.gradle.sslpinning

import com.android.build.gradle.BaseExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.getByType

/**
* Plugin for handling server configurations for instrumentation tests.
*/
class WultraSslPinningTestPlugin : Plugin<Project> {

override fun apply(target: Project) {
target.loadPropertiesFromGradleProps()
target.addInstrumentationArgumentsToDefaultConfig()
}

private val instrumentationArgumentKeys = setOf("test.sslPinning.baseUrl", "test.sslPinning.appName")
private val instrumentationArguments = mutableMapOf<String, String>()

private fun Project.loadPropertiesFromGradleProps() {
for (key in instrumentationArgumentKeys) {
project.properties[key]?.let {
instrumentationArguments[key] = it.toString()
}
}
}

private fun Project.addInstrumentationArgumentsToDefaultConfig() {
project.extensions.getByType<BaseExtension>().let {
it.defaultConfig {
for (entry in instrumentationArguments) {
this.testInstrumentationRunnerArguments[entry.key] = entry.value
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
implementation-class=com.wultra.gradle.sslpinning.WultraSslPinningTestPlugin
Loading