Skip to content

Commit

Permalink
Merge pull request #6178 from LitterSun/github_actions
Browse files Browse the repository at this point in the history
Migrate CI checks from CircleCI to GitHub actions
  • Loading branch information
hoisie committed Feb 2, 2021
2 parents 0f67c0a + 9332280 commit fd5e44e
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/check_java_formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Check Java formatting

on:
push:
branches: [ master ]

pull_request:
branches: [ master ]

jobs:
check_java_formatting:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up JDK 11.0.8
uses: actions/setup-java@v1
with:
java-version: 11.0.8

- name: Download google-java-format 1.9
run: |
curl -L -o $HOME/google-java-format.jar https://github.com/google/google-java-format/releases/download/google-java-format-1.9/google-java-format-1.9-all-deps.jar
curl -L -o $HOME/google-java-format-diff.py https://raw.githubusercontent.com/google/google-java-format/google-java-format-1.9/scripts/google-java-format-diff.py
- name: Check Java formatting
run: |
diff=$(git diff -U0 $(git merge-base HEAD origin/master) | python $HOME/google-java-format-diff.py --google-java-format-jar=$HOME/google-java-format.jar -p1)
if [[ $diff ]]; then
echo "Please run google-java-format on the changes in this pull request"
git diff -U0 $(git merge-base HEAD origin/master) | python $HOME/google-java-format-diff.py --google-java-format-jar=$HOME/google-java-format.jar -p1
exit 1
fi
94 changes: 94 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Tests

on:
push:
branches: [ master ]

pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/cache@v2
with:
path: |
~/.gradle
~/.m2
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK 11.0.8
uses: actions/setup-java@v1
with:
java-version: 11.0.8

- name: Build
run: SKIP_JAVADOC=true ./gradlew clean assemble testClasses --parallel --stacktrace

tests:
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
api-versions: ['16,17,18', '19,21,22', '23,24,25', '26,27,28', '29,20']

steps:
- uses: actions/checkout@v2

- uses: actions/cache@v2
with:
path: |
~/.gradle
~/.m2
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK 11.0.8
uses: actions/setup-java@v1
with:
java-version: 11.0.8

- name: Run tests
run: |
./gradlew test --info --stacktrace --continue \
--parallel \
-Drobolectric.enabledSdks=${{ matrix.api-versions }} \
-Drobolectric.alwaysIncludeVariantMarkersInTestName=true \
-Dorg.gradle.workers.max=2
- name: Upload Test Results
uses: actions/upload-artifact@v2
if: always()
with:
name: test_results_${{ matrix.api-versions }}
path: '**/build/test-results/**/TEST-*.xml'

publish_test_results:
needs: tests
if: always()
runs-on: ubuntu-latest

steps:
- name: Download All Test Results
uses: actions/download-artifact@v2
with:
path: artifacts

- name: Display structure of downloaded files
run: ls -R
working-directory: artifacts

- name: Publish All Test Results
uses: EnricoMi/publish-unit-test-result-action@v1.7
if: always()
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: 'artifacts/**/TEST-*.xml'

0 comments on commit fd5e44e

Please sign in to comment.