New build (9) #40
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Android CI | |
permissions: | |
checks: write | |
pull-requests: write | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
test: | |
name: Run Unit Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set current date as env variable | |
run: echo "date_today=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
- name: Set repository name as env variable | |
run: echo "repository_name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV | |
- name: Setup JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' # See 'Supported distributions' for available options | |
java-version: '17' | |
cache: 'gradle' | |
- name: Change wrapper permissions | |
run: chmod +x ./gradlew | |
- name: Run gradle tests (littlefuzzy) | |
run: ./gradlew :littlefuzzy:test | |
- name: Run gradle tests (confermeifyoucan) | |
run: ./gradlew :convertmeifyoucan:test | |
- name: Run gradle tests (ratiogenerator) | |
run: ./gradlew :ratiogenerator:test | |
- name: Publish Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
if: always() | |
with: | |
files: | | |
littlefuzzy/build/test-results/**/*.xml | |
convertmeifyoucan/build/test-results/**/*.xml | |
ratiogenerator/build/test-results/**/*.xml | |
- name: Set badge color | |
if: always() | |
shell: bash | |
run: | | |
case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in | |
success) | |
echo "BADGE_COLOR=31c653" >> $GITHUB_ENV | |
;; | |
failure) | |
echo "BADGE_COLOR=800000" >> $GITHUB_ENV | |
;; | |
neutral) | |
echo "BADGE_COLOR=696969" >> $GITHUB_ENV | |
;; | |
esac | |
- name: Create badge | |
uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1 | |
if: always() | |
with: | |
label: Tests | |
status: '${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests }} tests, ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.runs }} runs: ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}' | |
color: ${{ env.BADGE_COLOR }} | |
path: badge.svg | |
- name: Upload badge to Gist | |
# Upload only for master branch | |
if: > | |
github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'master' || | |
github.event_name != 'workflow_run' && github.ref == 'refs/heads/master' | |
uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d | |
with: | |
token: ${{ secrets.GIST_TOKEN }} | |
gistURL: https://gist.githubusercontent.com/mikolasan/761a1d92d370f0b7a4f63cbc231d27bf | |
file: badge.svg |