Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from Travis to GitHub Workflow CI #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

22 changes: 19 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down