.github/workflows/ci.yml
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
persist-credentials: false
fetch-depth: 0
- name: Use current branch
run: git checkout ${{ github.head_ref }}
- name: Download ktlint
run: "curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.39.0/ktlint && chmod a+x ktlint && mv ktlint .."
- name: Run ktlint
run: "../ktlint -F"
- name: Check for changes
run: |
if [[ $(git status -s) ]]; then
echo "Fixing PR lint"
git diff
git config --local user.email "autolint@lint.local"
git config --local user.name "Auto Lint"
git commit -m "Fix PR lint" -a
git push https://${{ secrets.GITHUBTOKEN }}@github.com/andrewinci/insulator.git
exit 1
else
echo "Nothing to change"
exit 0
fi
build-and-test:
needs: linting
runs-on: ${{ matrix.os.name }}
strategy:
matrix:
os:
- name: macos-latest
run-coverage: false
- name: ubuntu-latest
run-coverage: true
- name: windows-latest
run-coverage: false
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Java JDK
uses: actions/setup-java@v1.4.3
with:
java-version: 14
java-package: jdk
- name: Cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Build and run tests
if: ${{ !matrix.os.run-coverage }}
run: "./gradlew check --no-daemon"
- name: Run unit tests and upload coverage
if: ${{ matrix.os.run-coverage }}
uses: paambaati/codeclimate-action@v3.0.0
env:
DISPLAY: ":99.0"
_JAVA_OPTIONS: "-Djava.awt.headless=true -Dtestfx.robot=glass -Dtestfx.headless=true -Dprism.order=sw -Dprism.text=t2k -Dtestfx.setup.timeout=2500 -Dheadless.geometry=1920x1080-64"
GITHUB_SHA: "${{ github.event.pull_request.head.sha }}"
CC_TEST_REPORTER_ID: ${{secrets.codecovToken}}
JACOCO_SOURCE_PATH: |
${{github.workspace}}/app/src/main/kotlin \
${{github.workspace}}/bootstrap/src/main/kotlin \
${{github.workspace}}/lib/configuration/src/main/kotlin \
${{github.workspace}}/lib/helper/src/main/kotlin \
${{github.workspace}}/lib/jsonhelper/src/main/kotlin \
${{github.workspace}}/lib/kafka/src/main/kotlin \
${{github.workspace}}/lib/update/src/main/kotlin
with:
coverageCommand: ./gradlew clean check integrationTest codeCoverageReport --no-daemon
coverageLocations: ${{github.workspace}}/build/reports/jacoco/codeCoverageReport/codeCoverageReport.xml:jacoco
- name: Test build update4j config
if: ${{ matrix.os.run-coverage }}
run: |
./gradlew getDependencySources && \
./gradlew :app:mergeLocalLibs && \
python3 scripts/build.py