Skip to content

Commit 3e4bed7

Browse files
committed
Run sample projects in CI.
1 parent ab0a36a commit 3e4bed7

File tree

4 files changed

+68
-17
lines changed

4 files changed

+68
-17
lines changed

.github/workflows/check.yml

+37
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,43 @@ jobs:
3030
outputs:
3131
matrix: ${{ steps.setup-matrix.outputs.matrix }}
3232

33+
samples:
34+
# The type of runner that the job will run on
35+
runs-on: ${{ matrix.os }}
36+
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
os:
41+
- ubuntu-latest
42+
- macos-latest
43+
- windows-latest
44+
sample:
45+
- samples/app
46+
- samples/library
47+
48+
steps:
49+
# Checks-out your repository under $GITHUB_WORKSPACE for the job.
50+
- uses: actions/checkout@v2
51+
52+
- name: Setup Rust
53+
run: |
54+
rustup toolchain install stable
55+
rustup target add x86_64-linux-android
56+
rustup target add x86_64-unknown-linux-gnu
57+
rustup target add aarch64-linux-android
58+
59+
- name: Setup Java 11
60+
uses: actions/setup-java@v2
61+
with:
62+
distribution: 'temurin'
63+
java-version: 11
64+
cache: 'gradle'
65+
66+
- name: ${{ matrix.sample }}
67+
run: |
68+
./gradlew -p ${{ matrix.sample }} :assembleDebug --info --warning-mode all
69+
3370
android_unversioned_tests:
3471
# The type of runner that the job will run on
3572
runs-on: ${{ matrix.os }}

README.md

+22-12
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,28 @@ $ ls -al build/local-repo/org/mozilla/rust-android-gradle/org.mozilla.rust-andro
496496
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
497497
```
498498

499-
# Testing Local changes
499+
## Sample projects
500+
501+
The easiest way to get started is to run the sample projects. The sample projects have dependency
502+
substitutions configured so that changes made to `plugin/` are reflected in the sample projects
503+
immediately.
504+
505+
```
506+
$ ./gradlew -p samples/library :assembleDebug
507+
...
508+
$ file samples/library/build/outputs/aar/library-debug.aar
509+
samples/library/build/outputs/aar/library-debug.aar: Zip archive data, at least v1.0 to extract
510+
```
511+
512+
```
513+
$ ./gradlew -p samples/app :assembleDebug
514+
...
515+
$ file samples/app/build/outputs/apk/debug/app-debug.apk
516+
samples/app/build/outputs/apk/debug/app-debug.apk: Zip archive data, at least v?[0] to extract
517+
```
518+
519+
## Testing Local changes
520+
500521
An easy way to locally test changes made in this plugin is to simply add this to your project's `settings.gradle`:
501522

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

548-
## Sample projects
549-
550-
To run the sample projects:
551-
552-
```
553-
$ ./gradlew -p samples/library :assembleDebug
554-
...
555-
$ ls -al samples/library/build/outputs/aar/library-debug.aar
556-
-rw-r--r-- 1 nalexander staff 8926315 18 Sep 10:22 samples/library/build/outputs/aar/library-debug.aar
557-
```
558-
559569
## Real projects
560570

561571
To test in a real project, use the local Maven repository in your `build.gradle`, like:

samples/app/build.gradle

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.agp_version = '4.1.0'
2+
ext.agp_version = '7.0.0'
33
repositories {
44
google()
55
maven {
@@ -17,6 +17,8 @@ apply plugin: 'org.mozilla.rust-android-gradle.rust-android'
1717

1818
android {
1919
compileSdkVersion 27
20+
ndkVersion "23.1.7779620"
21+
2022
defaultConfig {
2123
applicationId "com.nishtahir.androidrust"
2224
minSdkVersion 21
@@ -31,17 +33,17 @@ android {
3133
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
3234
}
3335
}
34-
ndkVersion "20.1.5948944"
3536
}
3637

3738
cargo {
3839
module = "../rust"
39-
targets = ["arm", "x86", "x86_64", "arm64"]
40+
targets = ["x86_64", "arm64"]
4041
libname = "rust"
4142
}
4243

4344
repositories {
4445
google()
46+
mavenCentral()
4547
}
4648

4749
dependencies {

samples/library/build.gradle

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
buildscript {
2+
ext.agp_version = '7.0.0'
23
repositories {
34
google()
45
maven {
@@ -16,6 +17,7 @@ apply plugin: 'org.mozilla.rust-android-gradle.rust-android'
1617

1718
android {
1819
compileSdkVersion 27
20+
ndkVersion "23.1.7779620"
1921

2022
defaultConfig {
2123
minSdkVersion 21
@@ -24,7 +26,6 @@ android {
2426
versionName "1.0"
2527

2628
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
27-
2829
}
2930
buildTypes {
3031
release {
@@ -36,7 +37,7 @@ android {
3637

3738
cargo {
3839
module = "../rust"
39-
targets = ["arm", "x86", "x86_64", "arm64"]
40+
targets = ["x86_64", "arm64"]
4041
libname = "rust"
4142

4243
features {
@@ -52,6 +53,7 @@ cargo {
5253

5354
repositories {
5455
google()
56+
mavenCentral()
5557
}
5658

5759
dependencies {

0 commit comments

Comments
 (0)