From e17b27eadd8f0d2dacfd3bc576e0450b13e00189 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 6 Jun 2022 15:37:14 +0200 Subject: [PATCH 1/2] Switch from Travis to GitHub Workflow CI --- .github/workflows/ci.yml | 92 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 15 ------- 2 files changed, 92 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7d1c76a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,92 @@ +name: CI + +env: + GRADLE_VERSION: 7.4.2 + +on: [push, pull_request] + +jobs: + build: + name: Build jbosh + + runs-on: ubuntu-20.04 + strategy: + matrix: + java: + - 11 + - 15 + env: + PRIMARY_JAVA_VERSION: 11 + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + + # Caches + - name: Cache Maven + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: maven-${{ hashFiles('**/build.gradle') }} + restore-keys: | + maven- + - name: Cache Gradle + uses: actions/cache@v2 + with: + path: ~/.gradle/caches + key: gradle-caches-${{ hashFiles('**/build.gradle') }} + restore-keys: + gradle-caches + - name: Cache Gradle Binary + uses: actions/cache@v2 + with: + path: | + ~/gradle-bin-${GRADLE_VERSION}/ + key: gradle-bin-${GRADLE_VERSION} + - name: Cache Android SDK + uses: actions/cache@v2 + with: + path: | + ~/.android/sdk + key: android-${{ hashFiles('build.gradle') }} + restore-keys: | + android- + + # Pre-reqs + - name: Grab gradle wrapper + run: | + wget https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-all.zip + unzip gradle-${GRADLE_VERSION}-all.zip + echo "PATH_TO_GRADLE=./gradle-${GRADLE_VERSION}/bin/gradle" >> $GITHUB_ENV + - name: Install Android SDK Manager + uses: android-actions/setup-android@v2 + - name: Install Android SDK + run: | + sdkmanager "platforms;android-9" + + # Testing + - name: Gradle Check + run: ${PATH_TO_GRADLE} check --stacktrace + + # Test local publish + - name: Gradle publish + run: ${PATH_TO_GRADLE} publishToMavenLocal --stacktrace + + # Javadoc + - name: Javadoc + if: ${{ matrix.java == env.PRIMARY_JAVA_VERSION }} + run: ${PATH_TO_GRADLE} javadoc --stacktrace + + # Upload build artifacts + - name: Upload build artifacts + uses: actions/upload-artifact@v2 + with: + name: smack-java-${{ matrix.java }} + path: | + build/libs/*.jar + !**/*-test-fixtures.jar + !**/*-tests.jar diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8e0f17e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: android -android: - components: - - android-9 -jdk: - - oraclejdk8 - -before_install: - - export GRADLE_VERSION=5.4.1 - - wget https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-all.zip - - unzip -q gradle-${GRADLE_VERSION}-all.zip - - export PATH="$(pwd)/gradle-${GRADLE_VERSION}/bin:$PATH" - -install: gradle assemble -script: gradle check From a8ecfd0984a593d8f0bd71e2331e29e9f77b2907 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 6 Jun 2022 15:41:56 +0200 Subject: [PATCH 2/2] [gradle] Sync getGitCommit() with Smack --- build.gradle | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index e10830b..1dda9b3 100644 --- a/build.gradle +++ b/build.gradle @@ -160,13 +160,29 @@ task compileAndroid(type: JavaCompile) { test { dependsOn compileAndroid } def getGitCommit() { - def dotGit = new File("$projectDir/.git") + def projectDirFile = new File("$projectDir") + def dotGit = new File(projectDirFile, ".git") if (!dotGit.isDirectory()) return 'non-git build' - def cmd = 'git describe --tags --dirty=+' - def proc = cmd.execute() + def cmd = 'git describe --always --tags --dirty=+' + def proc = cmd.execute(null, projectDirFile) + proc.waitForOrKill(10 * 1000) + def gitCommit = proc.text.trim() assert !gitCommit.isEmpty() + + def srCmd = 'git symbolic-ref --short HEAD' + def srProc = srCmd.execute(null, projectDirFile) + srProc.waitForOrKill(10 * 1000) + if (srProc.exitValue() == 0) { + // Only add the information if the git command was + // successful. There may be no symbolic reference for HEAD if + // e.g. in detached mode. + def symbolicReference = srProc.text.trim() + assert !symbolicReference.isEmpty() + gitCommit += "-$symbolicReference" + } + gitCommit }