.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-integration: false
- name: ubuntu-latest
run-integration: true
- name: windows-latest
run-integration: 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-integration }}
run: "./gradlew check --no-daemon"
- name: Run unit and integration tests
if: ${{ matrix.os.run-integration }}
uses: paambaati/codeclimate-action@v2.7.4
env:
GITHUB_SHA: "${{ github.event.pull_request.head.sha }}"
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"
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: "xvfb-run --auto-servernum ./gradlew check integrationTest codeCoverageReport --no-daemon"
coverageLocations: ${{github.workspace}}/build/reports/jacoco/codeCoverageReport/codeCoverageReport.xml:jacoco
- name: Configure AWS credentials
if: ${{ matrix.os.run-integration }}
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Upload screenshoots
if: ${{ matrix.os.run-integration }}
run: |
aws s3 sync ${{github.workspace}}/app/captures s3://insulator-screenshots/${{ github.event.pull_request.head.sha }}/${{ matrix.os.name }}
- name: Comment on PR
if: ${{ matrix.os.run-integration }}
uses: mshick/add-pr-comment@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }}
with:
message: |
**Screenshoots 📷**
http://insulator-screenshots.s3-website-eu-west-1.amazonaws.com/${{ github.event.pull_request.head.sha }}
allow-repeats: false
- name: Test build update4j config
if: ${{ matrix.os.run-integration }}
run: |
./gradlew getDependencySources
./gradlew :app:mergeLocalLibs
python3 scripts/build.py