|
| 1 | +name: Check |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + workflow_call: |
| 6 | + |
| 7 | +concurrency: |
| 8 | + cancel-in-progress: true |
| 9 | + group: check-${{ github.workflow }}-${{ github.head_ref || github.ref }} |
| 10 | + |
| 11 | +env: |
| 12 | + GRADLE_OPTS: "-Dorg.gradle.daemon=true" |
| 13 | + |
| 14 | +jobs: |
| 15 | + lint: |
| 16 | + name: Lint the code |
| 17 | + runs-on: ubuntu-latest |
| 18 | + env: |
| 19 | + GRADLE_OPTS: "-Dorg.gradle.daemon=false" |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v3 |
| 22 | + |
| 23 | + - uses: actions/setup-java@v3 |
| 24 | + with: |
| 25 | + distribution: 'adopt' |
| 26 | + java-version: 11 |
| 27 | + |
| 28 | + - name: Restore Gradle cache |
| 29 | + id: cache-gradle |
| 30 | + uses: actions/cache@v3 |
| 31 | + with: |
| 32 | + path: | |
| 33 | + ~/.gradle/caches |
| 34 | + ~/.gradle/wrapper |
| 35 | + ~/.gradle/yarn |
| 36 | + ~/.gradle/nodejs |
| 37 | + ~/.konan |
| 38 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} |
| 39 | + restore-keys: ${{ runner.os }}-gradle- |
| 40 | + |
| 41 | + - name: Run detekt |
| 42 | + run: ./gradlew detektAll |
| 43 | + |
| 44 | + - name: Make artifact location URIs relative |
| 45 | + if: ${{ always() }} |
| 46 | + continue-on-error: true |
| 47 | + run: | |
| 48 | + ls '${{ github.workspace }}/build/reports/detekt/' |
| 49 | + cp '${{ github.workspace }}/build/reports/detekt/detekt.sarif' '${{ github.workspace }}/detekt.sarif.json' |
| 50 | + echo "$( |
| 51 | + jq --arg github_workspace ${{ github.workspace }} \ |
| 52 | + '. | ( .runs[].results[].locations[].physicalLocation.artifactLocation.uri |= if test($github_workspace) then .[($github_workspace | length | . + 1):] else . end )' \ |
| 53 | + '${{ github.workspace }}/detekt.sarif.json' |
| 54 | + )" > '${{ github.workspace }}/detekt.sarif.json' |
| 55 | +
|
| 56 | + - uses: github/codeql-action/upload-sarif@v2 |
| 57 | + if: ${{ always() }} |
| 58 | + with: |
| 59 | + sarif_file: ${{ github.workspace }}/detekt.sarif.json |
| 60 | + checkout_path: ${{ github.workspace }} |
| 61 | + |
| 62 | + check: |
| 63 | + name: Check on ${{ matrix.os.runner }} |
| 64 | + runs-on: ${{ matrix.os.runner }} |
| 65 | + defaults: |
| 66 | + run: |
| 67 | + shell: ${{ matrix.os.shell }} |
| 68 | + strategy: |
| 69 | + fail-fast: false |
| 70 | + matrix: |
| 71 | + os: |
| 72 | + - runner: macos-latest |
| 73 | + shell: bash |
| 74 | + separator: '/' |
| 75 | + - runner: ubuntu-latest |
| 76 | + shell: bash |
| 77 | + separator: '/' |
| 78 | + - runner: windows-latest |
| 79 | + shell: msys2 {0} |
| 80 | + separator: '\' |
| 81 | + steps: |
| 82 | + - uses: msys2/setup-msys2@v2 |
| 83 | + if: ${{ runner.os == 'Windows' }} |
| 84 | + with: |
| 85 | + release: false |
| 86 | + msystem: MINGW64 |
| 87 | + path-type: inherit |
| 88 | + update: true |
| 89 | + install: >- |
| 90 | + curl |
| 91 | + mingw-w64-x86_64-curl |
| 92 | +
|
| 93 | + - uses: actions/checkout@v3 |
| 94 | + |
| 95 | + - uses: actions/setup-java@v3 |
| 96 | + with: |
| 97 | + distribution: 'adopt' |
| 98 | + java-version: 11 |
| 99 | + |
| 100 | + - name: Restore Gradle cache |
| 101 | + id: cache-gradle |
| 102 | + uses: actions/cache@v3 |
| 103 | + with: |
| 104 | + path: | |
| 105 | + ~/.gradle/caches |
| 106 | + ~/.gradle/wrapper |
| 107 | + ~/.gradle/yarn |
| 108 | + ~/.gradle/nodejs |
| 109 | + ~/.konan |
| 110 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} |
| 111 | + restore-keys: ${{ runner.os }}-gradle- |
| 112 | + |
| 113 | + - name: Gradle Compile |
| 114 | + run: ./gradlew compile assemble --scan |
| 115 | + |
| 116 | + - name: Gradle Check |
| 117 | + run: ./gradlew check -x detekt -x detektAll --scan |
| 118 | + |
| 119 | + - name: Gradle Test Local Publishing |
| 120 | + run: ./gradlew publishToLocal --scan |
| 121 | + |
| 122 | + - uses: actions/upload-artifact@v3 |
| 123 | + if: ${{ always() }} |
| 124 | + with: |
| 125 | + name: reports-${{ runner.os }} |
| 126 | + path: | |
| 127 | + **${{ matrix.os.separator }}build${{ matrix.os.separator }}reports |
0 commit comments