Skip to content

Improvement: Add gamemode selected for Elite Api displays #12632

Improvement: Add gamemode selected for Elite Api displays

Improvement: Add gamemode selected for Elite Api displays #12632

Workflow file for this run

name: Detekt
on:
pull_request_target:
branches:
- "*"
workflow_dispatch:
permissions:
contents: read
pull-requests: write
jobs:
detekt:
name: Run detekt
runs-on: ubuntu-latest
concurrency:
group: detekt-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
outputs:
sarif_exists: ${{ steps.check_sarif.outputs.exists }}
detekt_failed: ${{ steps.run_detekt.outcome == 'failure' }}
steps:
- name: Checkout PR code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- uses: hannibal002/SkyHanni/.github/actions/setup-normal-workspace@beta
- name: Disable preprocessor
run: |
mkdir -p .gradle
echo skyhanni.multi-version=off > .gradle/private.properties
- name: Run detekt main (w/ typing analysis) w/gradle retry
id: run_detekt
uses: hannibal002/SkyHanni/.github/actions/gradle-retry@beta
continue-on-error: true
with:
gradle-command: detektMain --stacktrace
- name: Check if SARIF file exists
if: always()
id: check_sarif
run: |
if [ -f "build/reports/detekt/main.sarif" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Add label if detekt fails
if: ${{ steps.run_detekt.outcome == 'failure' && steps.check_sarif.outputs.exists == 'true' }}
uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: 'Detekt'
- name: Remove label if detekt passes
if: ${{ steps.run_detekt.outcome != 'failure' }}
uses: actions-ecosystem/action-remove-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: 'Detekt'
- name: Annotate detekt failures
if: ${{ !cancelled() && steps.check_sarif.outputs.exists == 'true' }}
run: |
chmod +x .github/scripts/process_detekt_sarif.sh
./.github/scripts/process_detekt_sarif.sh build/reports/detekt/main.sarif | tee detekt_output.txt
- name: Upload detekt output as artifact
if: ${{ !cancelled() && steps.check_sarif.outputs.exists == 'true' }}
uses: actions/upload-artifact@v4
with:
name: detekt-output
path: detekt_output.txt
detekt_comment:
name: Comment detekt failures on PR
runs-on: ubuntu-latest
concurrency:
group: detekt-comment-${{ github.event.pull_request.number }}
cancel-in-progress: true
needs: detekt
if: ${{
needs.detekt.outputs.sarif_exists == 'true' &&
needs.detekt.outputs.detekt_failed == 'true' &&
github.event.pull_request.draft == false
}}
permissions:
pull-requests: write
steps:
- name: Checkout base repo code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Download detekt output
uses: actions/download-artifact@v4
with:
name: detekt-output
path: .
- name: Process detekt output and create comment
env:
PR_SHA: ${{ github.event.pull_request.head.sha }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: |
kotlinc -script .github/scripts/process-detekt-output.kts
- name: Check for duplicate comment
id: check_duplicate
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const commentBody = fs.readFileSync('detekt_comment.txt', 'utf8');
const m = commentBody.match(/<!--\s*detekt-sarif-hash:(-?\d+)\s*-->/);
if (!m) return false;
const hash = m[1];
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
return comments.some(c => c.body.includes(hash));
- name: Skip comment if duplicate
if: steps.check_duplicate.outputs.result == 'true'
run: echo "Duplicate comment found, skipping..."
- name: Add comment to PR
uses: actions/github-script@v7
if: steps.check_duplicate.outputs.result != 'true'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const commentBody = fs.readFileSync('detekt_comment.txt', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
})
- name: Try to fail
run: exit 1