Skip to content

Commit

Permalink
Run sample projects in CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
ncalexan committed May 6, 2022
1 parent ab0a36a commit 3e4bed7
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 17 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,43 @@ jobs:
outputs:
matrix: ${{ steps.setup-matrix.outputs.matrix }}

samples:
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
sample:
- samples/app
- samples/library

steps:
# Checks-out your repository under $GITHUB_WORKSPACE for the job.
- uses: actions/checkout@v2

- name: Setup Rust
run: |
rustup toolchain install stable
rustup target add x86_64-linux-android
rustup target add x86_64-unknown-linux-gnu
rustup target add aarch64-linux-android
- name: Setup Java 11
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: 11
cache: 'gradle'

- name: ${{ matrix.sample }}
run: |
./gradlew -p ${{ matrix.sample }} :assembleDebug --info --warning-mode all
android_unversioned_tests:
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
Expand Down
34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,28 @@ $ ls -al build/local-repo/org/mozilla/rust-android-gradle/org.mozilla.rust-andro
build/local-repo/org/mozilla/rust-android-gradle/org.mozilla.rust-android-gradle.gradle.plugin/0.4.0/org.mozilla.rust-android-gradle.gradle.plugin-0.4.0.pom
```

# Testing Local changes
## Sample projects

The easiest way to get started is to run the sample projects. The sample projects have dependency
substitutions configured so that changes made to `plugin/` are reflected in the sample projects
immediately.

```
$ ./gradlew -p samples/library :assembleDebug
...
$ file samples/library/build/outputs/aar/library-debug.aar
samples/library/build/outputs/aar/library-debug.aar: Zip archive data, at least v1.0 to extract
```

```
$ ./gradlew -p samples/app :assembleDebug
...
$ file samples/app/build/outputs/apk/debug/app-debug.apk
samples/app/build/outputs/apk/debug/app-debug.apk: Zip archive data, at least v?[0] to extract
```

## Testing Local changes

An easy way to locally test changes made in this plugin is to simply add this to your project's `settings.gradle`:

```gradle
Expand Down Expand Up @@ -545,17 +566,6 @@ Publishing artifact build/publish-generated-resources/pom.xml
Activating plugin org.mozilla.rust-android-gradle.rust-android version 0.8.1
```

## Sample projects

To run the sample projects:

```
$ ./gradlew -p samples/library :assembleDebug
...
$ ls -al samples/library/build/outputs/aar/library-debug.aar
-rw-r--r-- 1 nalexander staff 8926315 18 Sep 10:22 samples/library/build/outputs/aar/library-debug.aar
```

## Real projects

To test in a real project, use the local Maven repository in your `build.gradle`, like:
Expand Down
8 changes: 5 additions & 3 deletions samples/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.agp_version = '4.1.0'
ext.agp_version = '7.0.0'
repositories {
google()
maven {
Expand All @@ -17,6 +17,8 @@ apply plugin: 'org.mozilla.rust-android-gradle.rust-android'

android {
compileSdkVersion 27
ndkVersion "23.1.7779620"

defaultConfig {
applicationId "com.nishtahir.androidrust"
minSdkVersion 21
Expand All @@ -31,17 +33,17 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
ndkVersion "20.1.5948944"
}

cargo {
module = "../rust"
targets = ["arm", "x86", "x86_64", "arm64"]
targets = ["x86_64", "arm64"]
libname = "rust"
}

repositories {
google()
mavenCentral()
}

dependencies {
Expand Down
6 changes: 4 additions & 2 deletions samples/library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
buildscript {
ext.agp_version = '7.0.0'
repositories {
google()
maven {
Expand All @@ -16,6 +17,7 @@ apply plugin: 'org.mozilla.rust-android-gradle.rust-android'

android {
compileSdkVersion 27
ndkVersion "23.1.7779620"

defaultConfig {
minSdkVersion 21
Expand All @@ -24,7 +26,6 @@ android {
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
Expand All @@ -36,7 +37,7 @@ android {

cargo {
module = "../rust"
targets = ["arm", "x86", "x86_64", "arm64"]
targets = ["x86_64", "arm64"]
libname = "rust"

features {
Expand All @@ -52,6 +53,7 @@ cargo {

repositories {
google()
mavenCentral()
}

dependencies {
Expand Down

0 comments on commit 3e4bed7

Please sign in to comment.