Skip to content

Commit

Permalink
Migrate to github actions (#105)
Browse files Browse the repository at this point in the history
* Fix javadoc generation failure when java={11~12}

* Fix build failure in windows caused by encoding

error info: error: unmappable character for encoding Cp1252.
windows seems try to detect character encoding when scan non-ascii
characters, but an incorrect encoding is determined.

We explicitly set compile/compileTest/javadoc encoding to utf-8 to avoid
this.

Note: A one-shot config good enough is not found currently.

* Migrate to github actions

also remove travis-ci config.
  • Loading branch information
owarai committed Nov 16, 2020
1 parent 640c55d commit 4dbe8c5
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 21 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
name: "CodeQL"

on:
push:
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: '0 10 * * 5'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['java']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# Override default version of java (8) as described in https://github.com/github/codeql-action/issues/97
- name: Setup Java JDK
uses: actions/setup-java@v1
with:
java-version: 11

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# env GRADLE_OPTS="-Dorg.gradle.daemon=false -Dorg.gradle.workers.max=3 -Xmx768m" ./gradlew --parallel --build-cache downloadDependencies testClasses

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
12 changes: 12 additions & 0 deletions .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# add a new dedicated workflow. run once.
# see: https://github.com/gradle/wrapper-validation-action
name: "Validate Gradle Wrapper"
on: [push, pull_request]

jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1
45 changes: 45 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Unit Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
unit-test:
name: Unit Test
runs-on: ${{ matrix.os }}

strategy:
matrix:
# ref: https://www.oracle.com/java/technologies/java-se-support-roadmap.html
java-version: [ "8", "11", "15" ]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java-version }}
# cache Gradle package to speed up future runs after a successful run.
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ matrix.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ matrix.os }}-gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# gradle build process include test phase.
- name: Build with Gradle
run: ./gradlew build
# store the built packages as part of the workflow run.
# Allow us to download these artifacts and import to project to help local test.
# with matrix, Each job overwrites what was previously uploaded, but it's fine for us.
- uses: actions/upload-artifact@v2
with:
name: Package
path: build/libs
retention-days: 7
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

14 changes: 13 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ java {
}

tasks {
compileJava.configure {
options.encoding = "UTF-8"
}
compileTestJava.configure {
options.encoding = "UTF-8"
}
javadoc.configure {
options.encoding = "UTF-8"
}
jar {
manifest {
attributes(
Expand All @@ -30,8 +39,11 @@ tasks {
}
}
javadoc {
// see: https://github.com/gradle/gradle/pull/8321
if (JavaVersion.current().isJava9Compatible) {
(options as CoreJavadocOptions).addBooleanOption("-no-module-directories", true)
if (JavaVersion.current().isJava11Compatible && !JavaVersion.current().isJava12Compatible) {
(options as CoreJavadocOptions).addBooleanOption("-no-module-directories", true)
}
(options as CoreJavadocOptions).addBooleanOption("html5", true)
}
}
Expand Down

0 comments on commit 4dbe8c5

Please sign in to comment.