mirror of
https://github.com/fankes/moshi.git
synced 2025-10-18 23:49:21 +08:00
Switch to Github Actions for CI
This commit is contained in:
52
.github/workflows/build.yml
vendored
Normal file
52
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
name: CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
java-version:
|
||||
- 1.8
|
||||
- 9
|
||||
- 10
|
||||
- 11
|
||||
- 12
|
||||
- 13
|
||||
- 14
|
||||
- 15-ea
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
|
||||
- name: Generate cache key
|
||||
run: ./.github/workflows/checksum.sh checksum.txt
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.gradle/caches
|
||||
key: ${{ runner.os }}-gradle-${{ matrix.java-version }}-${{ hashFiles('checksum.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-${{ matrix.java-version }}-
|
||||
|
||||
- name: Configure JDK
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: ${{ matrix.java-version }}
|
||||
|
||||
- name: Test
|
||||
run: ./gradlew build check
|
||||
|
||||
- name: Publish (default branch only)
|
||||
if: github.ref == 'refs/heads/master' && matrix.java-version == '1.7'
|
||||
run: ./gradlew uploadArchives
|
||||
env:
|
||||
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
|
||||
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
|
24
.github/workflows/checksum.sh
vendored
Executable file
24
.github/workflows/checksum.sh
vendored
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
RESULT_FILE=$1
|
||||
|
||||
if [[ -f ${RESULT_FILE} ]]; then
|
||||
rm ${RESULT_FILE}
|
||||
fi
|
||||
touch ${RESULT_FILE}
|
||||
|
||||
checksum_file() {
|
||||
echo $(openssl md5 $1 | awk '{print $2}')
|
||||
}
|
||||
|
||||
FILES=()
|
||||
while read -r -d ''; do
|
||||
FILES+=("$REPLY")
|
||||
done < <(find . -type f \( -name "build.gradle*" -o -name "settings.gradle*" -o -name "gradle-wrapper.properties" \) -print0)
|
||||
|
||||
# Loop through files and append MD5 to result file
|
||||
for FILE in ${FILES[@]}; do
|
||||
echo $(checksum_file ${FILE}) >> ${RESULT_FILE}
|
||||
done
|
||||
# Now sort the file so that it is idempotent.
|
||||
sort ${RESULT_FILE} -o ${RESULT_FILE}
|
31
.travis.yml
31
.travis.yml
@@ -1,31 +0,0 @@
|
||||
language: java
|
||||
|
||||
jdk:
|
||||
- openjdk8
|
||||
|
||||
script:
|
||||
- ./gradlew build check
|
||||
|
||||
after_success:
|
||||
- .buildscript/deploy_snapshot.sh
|
||||
|
||||
env:
|
||||
global:
|
||||
- secure: "TM2N/yo3azbA7+J6WG0W1RmK4vvS7b4JzvJP8NcXpoZCQw2Je1nQqmKS3F/04/DEUf8+SKVh2thKEeUxLN8knCO0OQLxeKIFj9PLvtgHnV8beB+pPxUdpEvMlB6ISeDsOZ098zoax28zfMwR7+uMeGe2VbtTSpwtqt4jkWx3ooA="
|
||||
- secure: "A5flBI/PCmmxuHjqG73CIXqHYg8X1GWloA3jv0zrhCAuK5m3nAvt7JY2qom22ttEY9JI32dlArxhusrKib18gKNgZbxzoN5PydkG6T0uuGZw+uZM6jPiTlvkC0F4ikL6lg1dBap4BoakDMwAPfb11UpETamBGKOWdopLqw6T6w0="
|
||||
|
||||
branches:
|
||||
except:
|
||||
- gh-pages
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
before_cache:
|
||||
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
|
||||
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.gradle/caches/
|
||||
- $HOME/.gradle/wrapper/
|
@@ -688,7 +688,7 @@ class KotlinJsonAdapterTest {
|
||||
var a = 5
|
||||
}
|
||||
|
||||
@Test fun objectExpressionsNotSupported() {
|
||||
@Test fun anonymousClassesNotSupported() {
|
||||
val expression = object : Any() {
|
||||
var a = 5
|
||||
}
|
||||
@@ -697,9 +697,16 @@ class KotlinJsonAdapterTest {
|
||||
moshi.adapter(expression.javaClass)
|
||||
fail()
|
||||
} catch (e: IllegalArgumentException) {
|
||||
// anonymous/local classes are slightly different in bytecode across JVM versions
|
||||
val javaVersion = System.getProperty("java.version")
|
||||
val type = if (javaVersion.startsWith("1.8")) {
|
||||
"local class or object expression"
|
||||
} else {
|
||||
"anonymous class"
|
||||
}
|
||||
assertThat(e).hasMessage(
|
||||
"Cannot serialize local class or object expression " +
|
||||
"com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest\$objectExpressionsNotSupported" +
|
||||
"Cannot serialize $type " +
|
||||
"com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest\$anonymousClassesNotSupported" +
|
||||
"\$expression$1"
|
||||
)
|
||||
}
|
||||
|
@@ -53,7 +53,9 @@ public final class CircularAdaptersTest {
|
||||
JsonAdapter<Team> teamAdapter = moshi.adapter(Team.class);
|
||||
|
||||
Team team =
|
||||
new Team("Alice", new Project("King", new Team("Charlie", new Project("Delivery", null))));
|
||||
new Team(
|
||||
"Alice",
|
||||
new Project("King", new Team("Charlie", new Project("Delivery", (Team[]) null))));
|
||||
assertThat(teamAdapter.toJson(team))
|
||||
.isEqualTo(
|
||||
"{\"lead\":\"Alice\",\"projects\":[{\"name\":"
|
||||
|
Reference in New Issue
Block a user