ci: use job summary instead of pr comment
This commit is contained in:
parent
bd75e0a874
commit
806ef46393
10 changed files with 188 additions and 123 deletions
39
.github/actions/lint-error/action.yml
vendored
39
.github/actions/lint-error/action.yml
vendored
|
|
@ -2,10 +2,6 @@ name: "Lint error"
|
||||||
description: "Checks for lint errors and posts a helpful comment"
|
description: "Checks for lint errors and posts a helpful comment"
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
comment-header:
|
|
||||||
description: "The header ID for the comment"
|
|
||||||
required: true
|
|
||||||
|
|
||||||
format-command:
|
format-command:
|
||||||
description: "The command to run to fix lint errors"
|
description: "The command to run to fix lint errors"
|
||||||
required: true
|
required: true
|
||||||
|
|
@ -47,9 +43,40 @@ runs:
|
||||||
if: steps.changes.outputs.diff
|
if: steps.changes.outputs.diff
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ steps.changes.outputs.file }}
|
name: ${{ inputs.format-tool }}-diff
|
||||||
path: ${{ steps.changes.outputs.file }}
|
path: ${{ steps.changes.outputs.file }}
|
||||||
retention-days: 3
|
if-no-files-found: error
|
||||||
|
|
||||||
|
- name: Set summary
|
||||||
|
id: summary
|
||||||
|
if: steps.changes.outputs.diff
|
||||||
|
run: |
|
||||||
|
code_block="\`\`\`"
|
||||||
|
|
||||||
|
summary=$(cat<<EOF
|
||||||
|
❌ \`${{ inputs.format-tool }}\`: It looks like your changes don't match our code style.
|
||||||
|
|
||||||
|
🛠️ Please either run \`${{ inputs.format-command }}\` or apply this patch with \`git apply\`:
|
||||||
|
|
||||||
|
[\`${{ steps.changes.outputs.file }}\`](${{ steps.upload.outputs.artifact-url }})
|
||||||
|
$code_block diff
|
||||||
|
${{ steps.changes.outputs.diff }}
|
||||||
|
$code_block
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
echo "$summary" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
file="ci_summary.md"
|
||||||
|
echo "❌🛠️ \`${{ inputs.format-tool }}\`: Lint errors, fix available." >> $file
|
||||||
|
echo "file=$file" >> $GITHUB_OUTPUT
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Upload CI summary as artifact
|
||||||
|
if: steps.summary.outputs.file
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: summary-${{ inputs.format-tool }}
|
||||||
|
path: ${{ steps.summary.outputs.file }}
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Fail if diff exists
|
- name: Fail if diff exists
|
||||||
|
|
|
||||||
34
.github/actions/run-tests-setup/action.yml
vendored
34
.github/actions/run-tests-setup/action.yml
vendored
|
|
@ -1,34 +0,0 @@
|
||||||
name: "Run tests (setup)"
|
|
||||||
description: "Sets up the PR comment for tests"
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: "composite"
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Get workflow URL
|
|
||||||
id: workflow-url
|
|
||||||
run: |
|
|
||||||
repo_url="${{ github.server_url }}/${{ github.repository }}"
|
|
||||||
echo "url=$repo_url/actions/runs/${{ github.run_id }}" >> $GITHUB_OUTPUT
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Begin PR comment
|
|
||||||
uses: marocchino/sticky-pull-request-comment@v2
|
|
||||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
|
||||||
with:
|
|
||||||
header: tests
|
|
||||||
recreate: true
|
|
||||||
message: |
|
|
||||||
## Test results
|
|
||||||
See [workflow run](${{ steps.workflow-url.outputs.url }}) for test output.
|
|
||||||
|
|
||||||
# Neccesary since the first comment has an annoying comment.
|
|
||||||
- name: Append table header
|
|
||||||
uses: marocchino/sticky-pull-request-comment@v2
|
|
||||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
|
||||||
with:
|
|
||||||
header: tests
|
|
||||||
append: true
|
|
||||||
message: |
|
|
||||||
| Job name | Unit tests | Integration tests |
|
|
||||||
| --- | --- | --- |
|
|
||||||
35
.github/actions/run-tests/action.yml
vendored
35
.github/actions/run-tests/action.yml
vendored
|
|
@ -14,7 +14,13 @@ runs:
|
||||||
id: unittests
|
id: unittests
|
||||||
env:
|
env:
|
||||||
QT_QPA_PLATFORM: offscreen
|
QT_QPA_PLATFORM: offscreen
|
||||||
run: ./build/bin/unittests
|
run: |
|
||||||
|
./build/bin/unittests
|
||||||
|
result=$?
|
||||||
|
|
||||||
|
if [ $result -ne 0 ]; then
|
||||||
|
echo "Unit tests failed with code: $result" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
shell: bash
|
shell: bash
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
|
|
@ -27,7 +33,7 @@ runs:
|
||||||
result=$?
|
result=$?
|
||||||
|
|
||||||
if [ $result -ne 0 ]; then
|
if [ $result -ne 0 ]; then
|
||||||
echo "::warning ::Integration tests failed with code: $result"
|
echo "Integration tests failed with code: $result" >> $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
shell: bash
|
shell: bash
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
@ -45,14 +51,25 @@ runs:
|
||||||
echo "integtests=$integtests" >> $GITHUB_OUTPUT
|
echo "integtests=$integtests" >> $GITHUB_OUTPUT
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Append to PR comment
|
- name: Summary row
|
||||||
uses: marocchino/sticky-pull-request-comment@v2
|
id: row
|
||||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
run: |
|
||||||
|
file="row-${{ inputs.job }}.md"
|
||||||
|
|
||||||
|
row=""
|
||||||
|
row+="| ${{ inputs.job }} "
|
||||||
|
row+="| ${{ steps.results.outputs.unittests }} "
|
||||||
|
row+="| ${{ steps.results.outputs.integtests }} |"
|
||||||
|
echo "$row" > $file
|
||||||
|
|
||||||
|
echo "file=$file" > $GITHUB_OUTPUT
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Save summary row
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
header: tests
|
name: test-result-${{ inputs.job }}
|
||||||
append: true
|
path: ${{ steps.row.outputs.file }}
|
||||||
message: |
|
|
||||||
| ${{ inputs.job }} | ${{ steps.results.outputs.unittests }} | ${{ steps.results.outputs.integtests }} |
|
|
||||||
|
|
||||||
- name: Check test outcome
|
- name: Check test outcome
|
||||||
if: steps.unittests.outcome == 'failure'
|
if: steps.unittests.outcome == 'failure'
|
||||||
|
|
|
||||||
67
.github/actions/test-summary/action.yml
vendored
Normal file
67
.github/actions/test-summary/action.yml
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
name: "Test Summary"
|
||||||
|
description: "Creates a markdown table from test results and uploads a summary file"
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Download test result rows
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
pattern: test-result-*
|
||||||
|
merge-multiple: true
|
||||||
|
path: rows
|
||||||
|
|
||||||
|
- name: Build markdown table
|
||||||
|
id: markdown-table
|
||||||
|
run: |
|
||||||
|
# Builds a markdown table from the row artifacts.
|
||||||
|
|
||||||
|
header=$(cat <<EOF
|
||||||
|
# Test results
|
||||||
|
| Job name | Unit tests | Integration tests |
|
||||||
|
| --- | --- | --- |
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
rows=""
|
||||||
|
for file in rows/*; do
|
||||||
|
rows+=$(cat $file)
|
||||||
|
rows+=$'\n'
|
||||||
|
done
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "markdown<<EOF"
|
||||||
|
echo "$header"
|
||||||
|
echo "$rows"
|
||||||
|
echo "EOF"
|
||||||
|
} >> $GITHUB_OUTPUT
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Set step summary
|
||||||
|
id: summary
|
||||||
|
run: |
|
||||||
|
# Sets the step summary and creates a CI summary file.
|
||||||
|
|
||||||
|
table="${{ steps.markdown-table.outputs.markdown }}"
|
||||||
|
if [ -z "$table" ]; then
|
||||||
|
echo "No test results found" > $GITHUB_STEP_SUMMARY
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "$table" > $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
|
||||||
|
count=$(echo -n "$table" | grep -o "❌" | wc -l || echo 0)
|
||||||
|
if [ $count -gt 0 ]; then
|
||||||
|
file="ci-summary.md"
|
||||||
|
echo "❌🔬 Tests failed: $count" > $file
|
||||||
|
echo "file=$file" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Upload CI summary
|
||||||
|
if: steps.summary.outputs.file
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: summary-tests
|
||||||
|
path: ${{ steps.summary.outputs.file }}
|
||||||
|
if-no-files-found: error
|
||||||
49
.github/workflows/ci.yml
vendored
49
.github/workflows/ci.yml
vendored
|
|
@ -25,11 +25,21 @@ env:
|
||||||
PACKAGE_BUILD: ${{ !github.event.pull_request.draft }}
|
PACKAGE_BUILD: ${{ !github.event.pull_request.draft }}
|
||||||
PACKAGE_UPLOAD: ${{ !github.event.pull_request.draft }}
|
PACKAGE_UPLOAD: ${{ !github.event.pull_request.draft }}
|
||||||
|
|
||||||
permissions:
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
setup:
|
# Quality gate to allow PR merge, used in the branch protection rules.
|
||||||
|
ci-passed:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [lint-cmake, lint-clang, windows, macos, linux, unix]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- run: echo "CI passed" > $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
# Summary of test results, combined from test result artifacts.
|
||||||
|
# Runs even if the tests fail to provide a summary of the failures.
|
||||||
|
test-results:
|
||||||
|
needs: [windows, macos, linux]
|
||||||
|
if: always()
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
|
|
||||||
|
|
@ -37,11 +47,32 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Test setup
|
- name: Test summary
|
||||||
uses: ./.github/actions/run-tests-setup
|
uses: ./.github/actions/test-summary
|
||||||
|
|
||||||
|
lint-cmake:
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
uses: ./.github/workflows/lint-cmake.yml
|
||||||
|
|
||||||
|
lint-clang:
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
uses: ./.github/workflows/lint-clang.yml
|
||||||
|
|
||||||
|
analyse-valgrind:
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
uses: ./.github/workflows/valgrind-analysis.yml
|
||||||
|
|
||||||
|
analyse-codeql:
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
uses: ./.github/workflows/codeql-analysis.yml
|
||||||
|
|
||||||
|
analyse-sonarcloud:
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
uses: ./.github/workflows/sonarcloud-analysis.yml
|
||||||
|
secrets:
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
needs: setup
|
|
||||||
name: ${{ matrix.target.name }}
|
name: ${{ matrix.target.name }}
|
||||||
runs-on: ${{ matrix.target.runs-on }}
|
runs-on: ${{ matrix.target.runs-on }}
|
||||||
container: ${{ matrix.target.container }}
|
container: ${{ matrix.target.container }}
|
||||||
|
|
@ -129,7 +160,6 @@ jobs:
|
||||||
package-version: ${{ env.DESKFLOW_VERSION }}
|
package-version: ${{ env.DESKFLOW_VERSION }}
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
needs: setup
|
|
||||||
name: ${{ matrix.target.name }}
|
name: ${{ matrix.target.name }}
|
||||||
runs-on: ${{ matrix.target.os }}
|
runs-on: ${{ matrix.target.os }}
|
||||||
timeout-minutes: ${{ matrix.target.timeout }}
|
timeout-minutes: ${{ matrix.target.timeout }}
|
||||||
|
|
@ -230,7 +260,7 @@ jobs:
|
||||||
jq-filter: .distro |= map(select(.["runs-on"] | contains("arm64") | not))
|
jq-filter: .distro |= map(select(.["runs-on"] | contains("arm64") | not))
|
||||||
|
|
||||||
linux:
|
linux:
|
||||||
needs: [setup, linux-matrix]
|
needs: linux-matrix
|
||||||
name: linux-${{ matrix.distro.name }}
|
name: linux-${{ matrix.distro.name }}
|
||||||
runs-on: ${{ matrix.distro.runs-on }}
|
runs-on: ${{ matrix.distro.runs-on }}
|
||||||
container: ${{ matrix.distro.container }}
|
container: ${{ matrix.distro.container }}
|
||||||
|
|
@ -294,7 +324,6 @@ jobs:
|
||||||
|
|
||||||
# Technically, "unix" is a misnomer, but we use it here to mean "Unix-like BSD-derived".
|
# Technically, "unix" is a misnomer, but we use it here to mean "Unix-like BSD-derived".
|
||||||
unix:
|
unix:
|
||||||
needs: setup
|
|
||||||
name: unix-${{ matrix.distro.name }}
|
name: unix-${{ matrix.distro.name }}
|
||||||
runs-on: ${{ vars.CI_UNIX_RUNNER || 'ubuntu-24.04' }}
|
runs-on: ${{ vars.CI_UNIX_RUNNER || 'ubuntu-24.04' }}
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
|
|
|
||||||
7
.github/workflows/codeql-analysis.yml
vendored
7
.github/workflows/codeql-analysis.yml
vendored
|
|
@ -2,12 +2,7 @@ name: "CodeQL Analysis"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
pull_request:
|
workflow_call:
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- reopened
|
|
||||||
- synchronize
|
|
||||||
- ready_for_review
|
|
||||||
push:
|
push:
|
||||||
branches: [master]
|
branches: [master]
|
||||||
|
|
||||||
|
|
|
||||||
11
.github/workflows/lint-clang.yml
vendored
11
.github/workflows/lint-clang.yml
vendored
|
|
@ -2,15 +2,7 @@ name: "Lint Clang"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
pull_request:
|
workflow_call:
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- reopened
|
|
||||||
- synchronize
|
|
||||||
- ready_for_review
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint-clang:
|
lint-clang:
|
||||||
|
|
@ -37,4 +29,3 @@ jobs:
|
||||||
with:
|
with:
|
||||||
format-command: ./scripts/lint_clang.py -f
|
format-command: ./scripts/lint_clang.py -f
|
||||||
format-tool: "clang-format"
|
format-tool: "clang-format"
|
||||||
comment-header: "lint-clang"
|
|
||||||
|
|
|
||||||
11
.github/workflows/lint-cmake.yml
vendored
11
.github/workflows/lint-cmake.yml
vendored
|
|
@ -2,15 +2,7 @@ name: "Lint CMake"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
pull_request:
|
workflow_call:
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- reopened
|
|
||||||
- synchronize
|
|
||||||
- ready_for_review
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint-cmake:
|
lint-cmake:
|
||||||
|
|
@ -37,4 +29,3 @@ jobs:
|
||||||
with:
|
with:
|
||||||
format-command: ./scripts/lint_cmake.py -f
|
format-command: ./scripts/lint_cmake.py -f
|
||||||
format-tool: "cmake-format"
|
format-tool: "cmake-format"
|
||||||
comment-header: "lint-cmake"
|
|
||||||
|
|
|
||||||
11
.github/workflows/sonarcloud-analysis.yml
vendored
11
.github/workflows/sonarcloud-analysis.yml
vendored
|
|
@ -2,12 +2,10 @@ name: "SonarCloud Analysis"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
pull_request:
|
workflow_call:
|
||||||
types:
|
secrets:
|
||||||
- opened
|
SONAR_TOKEN:
|
||||||
- reopened
|
required: true
|
||||||
- synchronize
|
|
||||||
- ready_for_review
|
|
||||||
push:
|
push:
|
||||||
branches: [master]
|
branches: [master]
|
||||||
|
|
||||||
|
|
@ -78,7 +76,6 @@ jobs:
|
||||||
QT_QPA_PLATFORM: offscreen
|
QT_QPA_PLATFORM: offscreen
|
||||||
run: cmake --build build --target coverage-unittests
|
run: cmake --build build --target coverage-unittests
|
||||||
|
|
||||||
# Retry integtests coverae as gcovr intermittently fails to parse .gcda files.
|
|
||||||
- name: Integration tests coverage
|
- name: Integration tests coverage
|
||||||
env:
|
env:
|
||||||
QT_QPA_PLATFORM: offscreen
|
QT_QPA_PLATFORM: offscreen
|
||||||
|
|
|
||||||
47
.github/workflows/valgrind-analysis.yml
vendored
47
.github/workflows/valgrind-analysis.yml
vendored
|
|
@ -2,15 +2,7 @@ name: "Valgrind Analysis"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
pull_request:
|
workflow_call:
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- reopened
|
|
||||||
- synchronize
|
|
||||||
- ready_for_review
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
valgrind-analysis:
|
valgrind-analysis:
|
||||||
|
|
@ -58,29 +50,22 @@ jobs:
|
||||||
with:
|
with:
|
||||||
executable: ./build/bin/integtests
|
executable: ./build/bin/integtests
|
||||||
|
|
||||||
- name: Get workflow URL
|
- name: Set job summary
|
||||||
id: workflow-url
|
|
||||||
run: |
|
run: |
|
||||||
repo_url="${{ github.server_url }}/${{ github.repository }}"
|
backticks='```'
|
||||||
echo "url=$repo_url/actions/runs/${{ github.run_id }}" >> $GITHUB_OUTPUT
|
message=$(cat <<EOF
|
||||||
shell: bash
|
## Valgrind summary
|
||||||
|
|
||||||
- name: Append to PR comment
|
### Unit tests
|
||||||
uses: marocchino/sticky-pull-request-comment@v2
|
$backticks
|
||||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
${{ steps.unittests.outputs.summary }}
|
||||||
with:
|
$backticks
|
||||||
recreate: true
|
|
||||||
header: valgrind
|
|
||||||
message: |
|
|
||||||
## Valgrind summary
|
|
||||||
See [workflow run](${{ steps.workflow-url.outputs.url }}) for full `valgrind` output.
|
|
||||||
|
|
||||||
### Unit tests
|
### Integration tests
|
||||||
```
|
$backticks
|
||||||
${{ steps.unittests.outputs.summary }}
|
${{ steps.integtests.outputs.summary }}
|
||||||
```
|
$backticks
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
### Integration tests
|
echo "$message" >> $GITHUB_STEP_SUMMARY
|
||||||
```
|
|
||||||
${{ steps.integtests.outputs.summary }}
|
|
||||||
```
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue