split jobs #28
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: Pull Request | |
on: | |
pull_request: | |
branches: [ "main" ] | |
concurrency: | |
group: build-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
detekt-review: | |
name: Detekt review | |
runs-on: ubuntu-latest | |
outputs: | |
detekt-logs: ${{ steps.detekt-pr-check.outputs.detekt-logs }} | |
steps: | |
- name: checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 1 | |
ref: ${{ github.head_ref }} | |
- name: detekt-pr-check | |
id: detekt-pr-check | |
uses: alaegin/Detekt-Action@v1.23.6 | |
with: | |
reviewdog_reporter: github-pr-check | |
github_token: ${{ secrets.github_token }} | |
detekt_config: internal/detekt-config.yml | |
# Capture the standard output and standard error as detekt-logs output | |
env: | |
DETEKT_LOGS: ${{ steps.detekt-pr-check.outputs.stdout }}${{ steps.detekt-pr-check.outputs.stderr }} | |
run: | | |
echo "::set-output name=detekt-logs::$DETEKT_LOGS" | |
detekt-evaluate: | |
name: Evaluate Detekt Logs | |
runs-on: ubuntu-latest | |
needs: [detekt-review] | |
steps: | |
- name: Check Detekt Logs | |
id: check-detekt-logs | |
run: | | |
detekt_logs="${{ needs.detekt-review.outputs.detekt-logs }}" | |
if grep -qE "(Analysis failed|conclusion=failure)" <(echo "$detekt_logs"); then | |
echo "Detekt analysis failed" >&2 | |
exit 1 | |
else | |
echo "Detekt analysis succeeded" | |
echo "Last 100 chars of Detekt logs:" | |
echo "$detekt_logs" | tail -c 100 | |
fi | |
check: | |
name: Build and test | |
needs: [detekt-evaluate] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4.1.0 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3.13.0 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: gradle | |
- name: Change permissions | |
run: chmod +x ./gradlew | |
- name: Build with Gradle | |
run: ./gradlew build | |
- name: Test with Gradle | |
run: ./gradlew test |