mirror of
https://github.com/GTNewHorizons/GTNH-Actions-Workflows.git
synced 2026-10-16 12:27:28 +02:00
Show test results on PRs (#73)
This commit is contained in:
@@ -31,6 +31,11 @@ on:
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
disable-test-comment:
|
||||
description: 'Do not create or update the PR test-results comment'
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
horizonqa:
|
||||
description: 'Run Horizon-QA in CI mode during runServer'
|
||||
required: false
|
||||
@@ -54,6 +59,7 @@ on:
|
||||
|
||||
env:
|
||||
ARTIFACT_RETENTION_DAYS: ${{ github.event.repository.private && 5 || 30 }}
|
||||
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
@@ -153,13 +159,43 @@ jobs:
|
||||
id: build_mod
|
||||
run: xvfb-run --server-args="-screen 0 1366x768x24" ./gradlew --build-cache --info --stacktrace build
|
||||
|
||||
- name: Summarize test results
|
||||
id: test_results
|
||||
if: ${{ !cancelled() && steps.build_mod.conclusion != 'skipped' }}
|
||||
continue-on-error: true
|
||||
run: python3 .gtnh-workflows/scripts/test_results.py render
|
||||
|
||||
- name: Attach test report
|
||||
id: test_report
|
||||
if: ${{ !cancelled() && steps.test_results.outputs.report != '' }}
|
||||
uses: actions/upload-artifact@v7
|
||||
continue-on-error: true
|
||||
with:
|
||||
path: ${{ steps.test_results.outputs.report }}
|
||||
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
|
||||
archive: false
|
||||
|
||||
- name: Publish test results
|
||||
if: ${{ !cancelled() && steps.test_results.outputs.report != '' }}
|
||||
continue-on-error: true
|
||||
run: python3 .gtnh-workflows/scripts/test_results.py publish
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# Fork PRs get a read-only token: job summary only, no status or comment
|
||||
CAN_PUBLISH: ${{ !github.event.pull_request || github.event.pull_request.head.repo.full_name == github.repository }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
REPORT_URL: ${{ steps.test_report.outputs.artifact-url }}
|
||||
DISABLE_COMMENT: ${{ inputs.disable-test-comment }}
|
||||
|
||||
- name: Attach gradle reports
|
||||
if: failure() && steps.build_mod.conclusion == 'failure'
|
||||
uses: actions/upload-artifact@v7
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: ${{ github.repository_id }}-reports
|
||||
path: build/reports/
|
||||
path: |
|
||||
**/build/reports/
|
||||
**/build/test-results/**/*.xml
|
||||
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
|
||||
|
||||
- name: Attempt to make a PR fixing spotless errors
|
||||
@@ -169,27 +205,14 @@ jobs:
|
||||
github.event_name == 'pull_request' &&
|
||||
github.event.pull_request.head.repo.full_name == github.repository }}
|
||||
run: |
|
||||
git reset --hard
|
||||
git checkout "${PR_BRANCH}"
|
||||
./gradlew --build-cache --info --stacktrace spotlessApply || exit 1
|
||||
git diff --exit-code && exit 1
|
||||
git config user.name "GitHub GTNH Actions"
|
||||
git config user.email "<>"
|
||||
git switch -c "${FIXED_BRANCH}"
|
||||
git commit -am "spotlessApply"
|
||||
git push --force-with-lease origin "${FIXED_BRANCH}"
|
||||
gh pr create \
|
||||
--head "${FIXED_BRANCH}" \
|
||||
--base "${PR_BRANCH}" \
|
||||
--title "Spotless apply for branch ${PR_BRANCH} for #${{ github.event.pull_request.number }}" \
|
||||
--body "Automatic spotless apply to fix formatting errors, applies to PR #${{ github.event.pull_request.number }}" \
|
||||
2>&1 | tee pr-message.log || true
|
||||
gh pr comment "${PR_BRANCH}" -F pr-message.log || true
|
||||
shell: bash # ensures set -eo pipefail
|
||||
chmod +x .gtnh-workflows/scripts/spotless_fix_pr
|
||||
.gtnh-workflows/scripts/spotless_fix_pr
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PR_BRANCH: ${{ github.head_ref }}
|
||||
FIXED_BRANCH: ${{ github.head_ref }}-spotless-fixes
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
|
||||
- name: Run server for up to ${{ inputs.timeout }} seconds
|
||||
id: run_server
|
||||
|
||||
Reference in New Issue
Block a user