diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..416d668 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,27 @@ +name: Build + +on: [push] + +jobs: + build: + timeout-minutes: 45 + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Setup java + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Setup Android SDK + uses: android-actions/setup-android@v2 + + - name: Build and test + run: | + export TF_API_KEY=${{ secrets.TF_API_KEY }} + + ./gradlew uploadArchives + cd example/TestApplication + ./gradlew testfairyDebug + shell: bash \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..82f480e --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,91 @@ +name: Publish plugin to testfairy-maven repo as a PR + +on: + push: + tags: + - '*' + +jobs: + publish: + runs-on: ubuntu-latest + + strategy: + fail-fast: true + + steps: + - uses: actions/checkout@v1 + + - name: Setup java + uses: actions/setup-java@v1 + with: + java-version: 1.8 + + - name: Setup Android SDK + uses: android-actions/setup-android@v2 + + - name: Setup Github CLI and login + run: | + sudo apt install -y gh + + echo ${{ secrets.MAVEN_GH_SSH_KEY_BASE64 }} | base64 --decode > ghkey + # sudo chmod 600 ghkey + # eval `ssh-agent -s` + # ssh-add ghkey + echo ${{ secrets.MAVEN_GH_TOKEN }} > maven-token + + gh auth login --with-token < maven-token + + export MAVEN_GH_SSH_KEY=`cat ghkey` + shell: bash + + - name: Check out testfairy-maven + uses: actions/checkout@v2 + with: + repository: testfairy/testfairy-maven + token: ${{ secrets.MAVEN_GH_TOKEN }} + ssh-key: ${{ env.MAVEN_GH_SSH_KEY }} + path: './testfairy-maven' + + - name: Build + run: | + export TF_API_KEY=${{ secrets.TF_API_KEY }} + echo "TF_GRADLE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + export TF_GRADLE_VERSION=${GITHUB_REF#refs/*/} + + ./gradlew uploadArchives + shell: bash + + - name: Upload release artifacts + uses: softprops/action-gh-release@v1 + with: + name: Version ${{ env.TF_GRADLE_VERSION }} + tag_name: ${{ env.TF_GRADLE_VERSION }} + fail_on_unmatched_files: true + prerelease: false + files: | + testfairy-maven/com/testfairy/plugins/gradle/testfairy/${{ env.TF_GRADLE_VERSION }}/testfairy-${{ env.TF_GRADLE_VERSION }}.jar + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish to testfairy-maven + run: | + if [ "$TF_GRADLE_VERSION" == "HEAD" ]; then + echo "Cannot publish HEAD. Please use proper semver in your release." + exit 1 + fi + + git config --global user.email "devtools+maven-publish@testfairy.com" + git config --global user.name "testfairy-maven-publish" + + cd testfairy-maven + + GIT_BRANCH="publish-gradle-$TF_GRADLE_VERSION" + git branch $GIT_BRANCH + git checkout $GIT_BRANCH + git add * + git commit -m "Publishing TestFairy Gradle Plugin $TF_GRADLE_VERSION" + git push -u origin $GIT_BRANCH + + gh pr create --title "Publishing TestFairy Gradle Plugin $TF_GRADLE_VERSION" --body "$TF_GRADLE_VERSION" + shell: bash + diff --git a/.gitignore b/.gitignore index b015251..5611ea6 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ composer.lock /build /captures .externalNativeBuild +repo/com \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 217dc43..0000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: android -sudo: false - -branches: - only: - - master - -jdk: - - openjdk8 - -android: - components: - - android-28 - - build-tools-28.0.3 - -before_script: - # workaround for license agreement: https://github.com/travis-ci/travis-ci/issues/6617 - - mkdir -p "$ANDROID_HOME/licenses" || true - - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55\nd56f5187479451eabf01fb78af6dfcb131a6481e" > "$ANDROID_HOME/licenses/android-sdk-license" - - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license" - -script: - - mkdir ../testfairy-maven - - bash gradlew uploadArchives - - cd example/TestApplication; bash gradlew testfairyDebug - diff --git a/README.md b/README.md index cf78e00..e9c2495 100644 --- a/README.md +++ b/README.md @@ -143,11 +143,21 @@ Changelog Development ---- -* Install Groovy SDK. * Install IntelliJ IDEA. +* Install Groovy SDK if IntelliJ fails importing groovy dependencies. (only affects static analysis) * Open project and setup latest Groovy SDK and Java SDK (1.8) path. * Sync. +To test the plugin after code change, run: + +```bash +export TF_API_KEY=${{ secrets.TF_API_KEY }} + +./gradlew uploadArchives +cd example/TestApplication +./gradlew testfairyDebug +``` + Bugs ---- diff --git a/build.gradle b/build.gradle index bc99ab1..6750f1a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,18 +1,22 @@ apply plugin: 'groovy' dependencies { - compile gradleApi() - compile localGroovy() - compile 'commons-io:commons-io:2.4' - compile 'org.apache.httpcomponents:httpmime:4.2.5' - compile 'org.apache.commons:commons-compress:1.9' - compile 'com.android.tools.build:gradle:3.4.0' + implementation gradleApi() + implementation localGroovy() + implementation 'commons-io:commons-io:2.11.0' + implementation 'org.apache.httpcomponents:httpmime:4.5.13' + implementation 'org.apache.commons:commons-compress:1.21' + implementation 'com.android.tools.build:gradle:3.4.3' } apply plugin: 'maven' group = 'com.testfairy.plugins.gradle' -version = '3.5' + +def pluginVersion = System.getenv('TF_GRADLE_VERSION') +version = (pluginVersion != null && pluginVersion.length() > 0) ? pluginVersion : "HEAD" + +System.out.println("TestFairy Gradle Plugin Version: " + project.version); repositories { mavenCentral() @@ -28,11 +32,19 @@ compileJava { targetCompatibility = 1.6 } + + uploadArchives { repositories { mavenDeployer { -// repository(url: uri('repo')) - repository(url: uri('../testfairy-maven')) + def pluginVersion2 = System.getenv('TF_GRADLE_VERSION') + def version2 = (pluginVersion2 != null && pluginVersion2.length() > 0) ? pluginVersion2 : "HEAD" + def repoUrl = version2.equals("HEAD") ? uri('./repo') : uri('./testfairy-maven') + + System.out.println("Version: " + version2) + System.out.println("Repo: " + repoUrl) + + repository(url: repoUrl) pom.project { name 'TestFairy Uploader Plugin for Gradle' diff --git a/example/TestApplication/app/build.gradle b/example/TestApplication/app/build.gradle index b29fc5a..22f92c0 100644 --- a/example/TestApplication/app/build.gradle +++ b/example/TestApplication/app/build.gradle @@ -32,19 +32,22 @@ buildscript { google() //Enable when testing local plugin - maven { url '../../../../testfairy-maven' } + maven { url ('../../../repo') } + maven { url ('../../../testfairy-maven') } + maven { url ('../../../../repo') } + maven { url ('../../../../testfairy-maven') } //Enable when testing remote release // maven { url 'https://www.testfairy.com/maven' } } dependencies { - classpath 'com.testfairy.plugins.gradle:testfairy:3.+' + classpath 'com.testfairy.plugins.gradle:testfairy:+' } } testfairyConfig { - apiKey "ae6edb30a71f825093216f851a9bf414984cb131" + apiKey System.getenv('TF_API_KEY') testersGroups "myself" notify true video "wifi" diff --git a/example/TestApplication/app/src/androidTest/java/com/example/testapplication/ExampleInstrumentedTest.java b/example/TestApplication/app/src/androidTest/java/com/example/testapplication/ExampleInstrumentedTest.java deleted file mode 100644 index a6e88a0..0000000 --- a/example/TestApplication/app/src/androidTest/java/com/example/testapplication/ExampleInstrumentedTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.example.testapplication; - -import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.*; - -/** - * Instrumentation test, which will execute on an Android device. - * - * @see Testing documentation - */ -@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - @Test - public void useAppContext() throws Exception { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getTargetContext(); - - assertEquals("com.example.testapplication", appContext.getPackageName()); - } -} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 8c0fb64..7454180 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/repo/.keep b/repo/.keep new file mode 100644 index 0000000..e69de29