Skip to content

Commit

Permalink
Merge pull request #215 from bugsnag/v5-app-feature-agp4
Browse files Browse the repository at this point in the history
Add test fixtures that run against AGP 4
  • Loading branch information
fractalwrench authored Jul 7, 2020
2 parents 5a1cdb0 + 74ed993 commit 88a2c6b
Show file tree
Hide file tree
Showing 40 changed files with 169 additions and 51 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ gradle-app.setting
.idea/
local.properties
maze_output/
features/fixtures/rnapp/package-lock.json
package-lock.json
.cxx
15 changes: 11 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ sudo: false
env:
global:
- ANDROID_HOME=/usr/local/android-sdk
- NDK_VERSION=r16b

android:
components:
Expand All @@ -17,12 +16,12 @@ android:
before_install:
- echo y | sdkmanager "platform-tools" >/dev/null
- echo y | sdkmanager "tools" >/dev/null
- echo y | sdkmanager 'cmake;3.6.4111459'
- echo y | sdkmanager 'cmake;3.6.4111459' >/dev/null
- echo y | sdkmanager 'ndk;16.1.4479499' >/dev/null
- gem install bundler
- gem update --system 3.0.6
- bundle install
- ls $ANDROID_HOME
- ./install_ndk.sh

install:
- curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
Expand All @@ -49,4 +48,12 @@ jobs:

# AGP 3.4.0 E2E tests
- name: AGP 3.4.0 E2E tests
script: bundle exec maze-runner -c --verbose
env:
- APP_FIXTURE_DIR=features/fixtures/app_agp340
- RN_FIXTURE_DIR=features/fixtures/rnapp_agp340/android
- NDK_FIXTURE_DIR=features/fixtures/ndkapp_agp340
script: bundle exec maze-runner features/agp3-features features/agp-features -c --verbose

# AGP 4.0.0 E2E tests
- name: AGP 4.0.0 E2E tests
script: bundle exec maze-runner features/agp4-features features/agp-features -c --verbose
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ Scenario: NDK apps send requests

And the request 1 is valid for the Android NDK Mapping API
And the payload field "apiKey" equals "your-api-key-here" for request 1
And the payload field "projectRoot" ends with "features/fixtures/ndkapp/app" for request 1
And the payload field "projectRoot" is not null for request 1
And the payload field "arch" equals "armeabi-v7a" for request 1

And the request 2 is valid for the Android NDK Mapping API
And the payload field "apiKey" equals "your-api-key-here" for request 2
And the payload field "projectRoot" ends with "features/fixtures/ndkapp/app" for request 2
And the payload field "projectRoot" is not null for request 2
And the payload field "arch" equals "x86_64" for request 2

And the request 3 is valid for the Android NDK Mapping API
And the payload field "apiKey" equals "your-api-key-here" for request 3
And the payload field "projectRoot" ends with "features/fixtures/ndkapp/app" for request 3
And the payload field "projectRoot" is not null for request 3
And the payload field "arch" equals "arm64-v8a" for request 3

And the request 4 is valid for the Android NDK Mapping API
And the payload field "apiKey" equals "your-api-key-here" for request 4
And the payload field "projectRoot" ends with "features/fixtures/ndkapp/app" for request 4
And the payload field "projectRoot" is not null for request 4
And the payload field "arch" equals "x86" for request 4

And the request 0 is valid for the Android Mapping API
Expand Down
110 changes: 110 additions & 0 deletions features/agp4-features/ndk_app.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
Feature: Plugin integrated in NDK app

Scenario: NDK apps send requests
When I build the NDK app
Then I should receive 10 requests

And the request 0 is valid for the Android Mapping API
And the payload field "apiKey" equals "your-api-key-here" for request 0

And the request 1 is valid for the Android NDK Mapping API
And the payload field "apiKey" equals "your-api-key-here" for request 1
And the payload field "projectRoot" is not null for request 1
And the payload field "arch" equals "armeabi-v7a" for request 1

And the request 2 is valid for the Android NDK Mapping API
And the payload field "apiKey" equals "your-api-key-here" for request 2
And the payload field "projectRoot" is not null for request 2
And the payload field "arch" equals "armeabi-v7a" for request 2

And the request 3 is valid for the Android NDK Mapping API
And the payload field "apiKey" equals "your-api-key-here" for request 3
And the payload field "projectRoot" is not null for request 3
And the payload field "arch" equals "x86_64" for request 3

And the request 4 is valid for the Android NDK Mapping API
And the payload field "apiKey" equals "your-api-key-here" for request 4
And the payload field "projectRoot" is not null for request 4
And the payload field "arch" equals "x86_64" for request 4

And the request 5 is valid for the Android NDK Mapping API
And the payload field "apiKey" equals "your-api-key-here" for request 5
And the payload field "projectRoot" is not null for request 5
And the payload field "arch" equals "arm64-v8a" for request 5

And the request 6 is valid for the Android NDK Mapping API
And the payload field "apiKey" equals "your-api-key-here" for request 6
And the payload field "projectRoot" is not null for request 6
And the payload field "arch" equals "arm64-v8a" for request 6

And the request 7 is valid for the Android NDK Mapping API
And the payload field "apiKey" equals "your-api-key-here" for request 7
And the payload field "projectRoot" is not null for request 7
And the payload field "arch" equals "x86" for request 7

And the request 8 is valid for the Android NDK Mapping API
And the payload field "apiKey" equals "your-api-key-here" for request 8
And the payload field "projectRoot" is not null for request 8
And the payload field "arch" equals "x86" for request 8

And the request 9 is valid for the Build API
And the payload field "appVersion" equals "1.0" for request 9
And the payload field "apiKey" equals "your-api-key-here" for request 9
And the payload field "builderName" is not null for request 9
And the payload field "buildTool" equals "gradle-android" for request 9
And the payload field "appVersionCode" equals "1" for request 9

Scenario: Custom projectRoot is added to payload
When I set environment variable "PROJECT_ROOT" to "/repos/custom/my-app"
When I build the NDK app
Then I should receive 10 requests

And the request 0 is valid for the Android Mapping API

And the request 1 is valid for the Android NDK Mapping API
And the payload field "projectRoot" equals "/repos/custom/my-app" for request 1

And the request 2 is valid for the Android NDK Mapping API
And the payload field "projectRoot" equals "/repos/custom/my-app" for request 2

And the request 3 is valid for the Android NDK Mapping API
And the payload field "projectRoot" equals "/repos/custom/my-app" for request 3

And the request 4 is valid for the Android NDK Mapping API
And the payload field "projectRoot" equals "/repos/custom/my-app" for request 4

And the request 5 is valid for the Android NDK Mapping API
And the payload field "projectRoot" equals "/repos/custom/my-app" for request 5

And the request 6 is valid for the Android NDK Mapping API
And the payload field "projectRoot" equals "/repos/custom/my-app" for request 6

And the request 7 is valid for the Android NDK Mapping API
And the payload field "projectRoot" equals "/repos/custom/my-app" for request 7

And the request 8 is valid for the Android NDK Mapping API
And the payload field "projectRoot" equals "/repos/custom/my-app" for request 8

And the request 9 is valid for the Build API

# Sets a non-existent objdump location for x86 and arm64-v8a, delivery should proceed as normal for other files
Scenario: Custom objdump location
When I set environment variable "OBJDUMP_LOCATION" to "/fake/objdump"
When I build the NDK app
Then I should receive 6 requests

And the request 0 is valid for the Android Mapping API

And the request 1 is valid for the Android NDK Mapping API
And the payload field "arch" equals "armeabi-v7a" for request 1

And the request 2 is valid for the Android NDK Mapping API
And the payload field "arch" equals "armeabi-v7a" for request 2

And the request 3 is valid for the Android NDK Mapping API
And the payload field "arch" equals "x86_64" for request 3

And the request 4 is valid for the Android NDK Mapping API
And the payload field "arch" equals "x86_64" for request 4

And the request 5 is valid for the Build API
2 changes: 1 addition & 1 deletion features/fixtures/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.android.tools.build:gradle:4.0.0'
}
}

Expand Down
Binary file modified features/fixtures/app/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 1 addition & 0 deletions features/fixtures/ndkapp/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 29
ndkVersion "16.1.4479499"

defaultConfig {
applicationId "com.bugsnag.android.ndkapp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import com.bugsnag.android.Bugsnag;
import com.example.Bar;

public class MainActivity extends Activity {

Expand All @@ -20,6 +22,7 @@ protected void onCreate(Bundle savedInstanceState) {
TextView view = new TextView(this);
view.setText(stringFromJNI());
setContentView(view);
Log.v("Bugsnag", new Bar().doSomething());
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example;

public class Bar {
public String doSomething() {
return "Hello World";
}
}
2 changes: 1 addition & 1 deletion features/fixtures/ndkapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath "com.bugsnag:bugsnag-android-gradle-plugin:${project.plugin_version}"
}
}
Expand Down
1 change: 1 addition & 0 deletions features/fixtures/ndkapp/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
plugin_version=9000.0.0-test
Binary file modified features/fixtures/ndkapp/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 1 addition & 0 deletions features/fixtures/rnapp/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def enableProguardInReleaseBuilds = true

android {
compileSdkVersion 28
ndkVersion "16.1.4479499"

defaultConfig {
applicationId "com.bugsnag.android.rnapp"
Expand Down
2 changes: 1 addition & 1 deletion features/fixtures/rnapp/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath "com.bugsnag:bugsnag-android-gradle-plugin:${project.plugin_version}"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 1 addition & 1 deletion features/fixtures/rnapp/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

android.useDeprecatedNdk=true
android.useAndroidX=true
plugin_version=9000.0.0-test
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions features/scripts/build_ndk_app.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# Build test app
cd features/fixtures/ndkapp
./gradlew :app:clean :app:build -x lint \
--stacktrace --refresh-dependencies
cd $NDK_FIXTURE_DIR
echo "Test fixture used: $NDK_FIXTURE_DIR"
./gradlew :app:clean :app:assemble -x lint --stacktrace
5 changes: 3 additions & 2 deletions features/scripts/build_project_module.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ function resetGitConfig {

trap resetGitConfig EXIT

cd features/fixtures/app
./gradlew :module:clean :module:build -x lint --stacktrace
cd $APP_FIXTURE_DIR
echo "Test fixture used: $APP_FIXTURE_DIR"
./gradlew :module:clean :module:assemble -x lint --stacktrace
5 changes: 3 additions & 2 deletions features/scripts/build_react_native_app.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash

cd features/fixtures/rnapp/android
cd $RN_FIXTURE_DIR
echo "Test fixture used: $RN_FIXTURE_DIR"
npm install
./gradlew :app:clean :app:build -x lint --stacktrace
./gradlew :app:clean :app:assemble -x lint --stacktrace
3 changes: 2 additions & 1 deletion features/scripts/bundle_one_flavor.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash

cd features/fixtures/app
cd $APP_FIXTURE_DIR
echo "Test fixture used: $APP_FIXTURE_DIR"
./gradlew :module:clean :module:bundleFoo -x lint --stacktrace
3 changes: 2 additions & 1 deletion features/scripts/bundle_project_module.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ function resetGitConfig {

trap resetGitConfig EXIT

cd features/fixtures/app
cd $APP_FIXTURE_DIR
echo "Test fixture used: $APP_FIXTURE_DIR"
./gradlew :module:clean :module:bundle -x lint --stacktrace
2 changes: 1 addition & 1 deletion features/scripts/install_gradle_plugin.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

./gradlew clean build install -x groovyDoc -x codenarcMain -x codenarcTest -x test -PlocalVersion=9000.0.0-test
./gradlew build install -x groovyDoc -x codenarcMain -x codenarcTest -x test -PlocalVersion=9000.0.0-test
5 changes: 3 additions & 2 deletions features/scripts/upload_variant_mapping.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ if [ -z "$VARIANT_OUTPUT_NAME" ]; then
exit 1
fi

cd features/fixtures/app
./gradlew :module:clean :module:build -x lint uploadBugsnag${VARIANT_OUTPUT_NAME}Mapping --stacktrace
cd $APP_FIXTURE_DIR
echo "Test fixture used: $APP_FIXTURE_DIR"
./gradlew :module:clean :module:assemble -x lint uploadBugsnag${VARIANT_OUTPUT_NAME}Mapping --stacktrace
6 changes: 0 additions & 6 deletions features/steps/gradle_plugin_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
When I set environment variable "MODULE_CONFIG" to "#{module_config}"
When I set environment variable "BUGSNAG_CONFIG" to "#{bugsnag_config}"
And I run the script "features/scripts/build_project_module.sh" synchronously
And I wait for 1 second
}
end

Expand All @@ -13,7 +12,6 @@
When I set environment variable "MODULE_CONFIG" to "#{module_config}"
When I set environment variable "BUGSNAG_CONFIG" to "#{bugsnag_config}"
And I run the script "features/scripts/upload_variant_mapping.sh" synchronously
And I wait for 1 second
}
end

Expand All @@ -22,7 +20,6 @@
When I set environment variable "MODULE_CONFIG" to "#{module_config}"
When I set environment variable "BUGSNAG_CONFIG" to "#{bugsnag_config}"
And I run the script "features/scripts/bundle_project_module.sh" synchronously
And I wait for 1 second
}
end

Expand All @@ -32,21 +29,18 @@
When I set environment variable "MODULE_CONFIG" to "#{module_config}"
When I set environment variable "BUGSNAG_CONFIG" to "#{bugsnag_config}"
And I run the script "features/scripts/bundle_one_flavor.sh" synchronously
And I wait for 1 second
}
end

When("I build the React Native app") do
steps %Q{
And I run the script "features/scripts/build_react_native_app.sh" synchronously
And I wait for 1 second
}
end

When("I build the NDK app") do
steps %Q{
And I run the script "features/scripts/build_ndk_app.sh" synchronously
And I wait for 1 second
}
end

Expand Down
5 changes: 5 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Configure app environment

# Set which test fixture should be used
ENV["APP_FIXTURE_DIR"] ||= "features/fixtures/app"
ENV["NDK_FIXTURE_DIR"] ||= "features/fixtures/ndkapp"
ENV["RN_FIXTURE_DIR"] ||= "features/fixtures/rnapp/android"

run_required_commands([
["./features/scripts/clear_local_maven_repo.sh"],
["./features/scripts/install_gradle_plugin.sh"],
Expand Down
Loading

0 comments on commit 88a2c6b

Please sign in to comment.