ktlint 1.0 support #792
Workflow file for this run
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: Build and check | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
jobs: | |
build-jvm-matrix: | |
runs-on: ubuntu-latest | |
steps: # https://michaelheap.com/dynamic-matrix-generation-github-actions/ | |
- id: set-matrix | |
run: echo "::set-output name=version_matrix::$(curl https://endoflife.date/api/java.json | jq -c '[.[] | select(.eol > (now | strftime("%Y-%m-%d"))) | .cycle]' | sed 's/ //g')" | |
- name: verify-matrix | |
run: echo "The selected java versions are ${{ steps.set-matrix.outputs.version_matrix }}" | |
outputs: | |
version_matrix: ${{ steps.set-matrix.outputs.version_matrix }} | |
build: | |
needs: build-jvm-matrix | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
java_version: ${{ fromJson(needs.build-jvm-matrix.outputs.version_matrix) }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: configure windows pagefile | |
if: ${{ matrix.os == 'windows-latest' }} | |
uses: al-cheb/[email protected] | |
with: | |
minimum-size: 8GB | |
maximum-size: 8GB | |
disk-root: "D:" | |
- name: set up JDK | |
uses: actions/setup-java@v2 | |
with: | |
java-version: ${{ matrix.java_version }} | |
distribution: 'zulu' | |
- name: Restore Gradle caches | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.gradle/caches/modules-2 | |
~/.gradle/caches/files-2.1 | |
~/.gradle/caches/metadata-2.96 | |
key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('**/gradle.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle-cache- | |
# Inspired by https://github.com/actions/cache/issues/432#issuecomment-740376179 | |
- name: Restore TestKit cache | |
uses: actions/cache@v2 | |
with: | |
path: | | |
plugin/.gradle-test-kit/caches/modules-2 | |
plugin/.gradle-test-kit/caches/files-2.1 | |
plugin/.gradle-test-kit/caches/metadata-2.96 | |
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }}-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }}- | |
${{ runner.os }}-gradle-wrapper- | |
- name: Restore Gradle wrapper | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }} | |
restore-keys: | | |
${{ runner.os }}-gradle-wrapper- | |
- name: Build plugin | |
run: ./plugin/gradlew -p ./plugin assemble ensureDependenciesAreInlined test --no-daemon | |
- name: Upload test results | |
uses: actions/upload-artifact@v2 | |
if: failure() | |
with: | |
name: test-results-${{ runner.os }} | |
path: plugin/build/reports/tests/test/ | |
- name: Upload Memory Dump | |
uses: actions/upload-artifact@v2 | |
if: failure() | |
with: | |
name: memory-dump-${{ runner.os }} | |
path: | | |
hs_err_pid* | |
replay_pid* | |
plugin/hs_err_pid* | |
plugin/replay_pid* | |
- name: Check plugin codestyle | |
run: ./plugin/gradlew -p ./plugin ktlintCheck --no-daemon | |
check_bashisms: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v2 | |
- name: set up JDK 1.8 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: 8 | |
distribution: 'zulu' | |
- name: Install checkbashisms | |
run: sudo apt-get install -qq devscripts | |
- name: Restore Gradle caches | |
uses: actions/cache@v2 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('**/gradle.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle-cache- | |
- name: Restore Gradle wrapper | |
uses: actions/cache@v2 | |
with: | |
path: ~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }} | |
restore-keys: | | |
${{ runner.os }}-gradle-wrapper- | |
- name: Check git bashisms | |
run: ./gradlew addKtlintCheckGitPreCommitHook --no-daemon && checkbashisms .git/hooks/pre-commit | |
check_samples: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
needs: build | |
steps: | |
- uses: actions/checkout@v2 | |
- name: set up JDK 1.8 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: 8 | |
distribution: 'zulu' | |
- name: Restore Gradle caches | |
uses: actions/cache@v2 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('**/gradle.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle-cache- | |
- name: Restore Gradle wrapper | |
uses: actions/cache@v2 | |
with: | |
path: ~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }} | |
restore-keys: | | |
${{ runner.os }}-gradle-wrapper- | |
- name: Check ktlint-plugin on samples | |
run: ./gradlew ktlintCheck --no-daemon |