Skip to content

Commit f3554c8

Browse files
authored
Merge pull request #2466 from DARMA-tasking/2465-integrate-comment-on-pr-action-into-bake-ci
#2465: Integrate compilation and test logs into bake pipeline
2 parents d292522 + c121ffc commit f3554c8

File tree

5 files changed

+107
-153
lines changed

5 files changed

+107
-153
lines changed

.github/workflows/build-docker-images.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ jobs:
7373

7474
- name: Build
7575
uses: docker/bake-action@v6
76+
id: build-image
7677
with:
7778
source: .
7879
targets: ${{ matrix.target }}
@@ -85,7 +86,6 @@ jobs:
8586
GIT_BRANCH: ${{ github.head_ref || github.ref_name }}
8687

8788
- name: Retrieve build artifacts
88-
if: ${{ matrix.target == 'vt-build-amd64-ubuntu-22-04-gcc-11-cpp' }}
8989
run: |
9090
# We rely on the persistence of data on cache mounts with identical IDs and builders.
9191
# This allows us to copy build artifacts from the "bake" step and use the Codecov action within the GitHub environment.
@@ -99,6 +99,34 @@ jobs:
9999
100100
docker buildx build --builder ${{ steps.setup-buildx.outputs.name }} -f tmp_dockerfile --output type=local,dest=build .
101101
102+
- name: Generate comment
103+
if: github.event_name == 'pull_request'
104+
id: generate_comment
105+
run: |
106+
comment_content=$(
107+
./scripts/generate_comment_body.sh \
108+
"build/vt/compilation_errors_warnings.out" \
109+
"build/vt/cmake-output.log" \
110+
"${{ matrix.target }}" \
111+
"${{ steps.build-image.outcome }}"
112+
)
113+
114+
echo "comment_content<<EOF" >>"$GITHUB_OUTPUT"
115+
echo "$comment_content" >>"$GITHUB_OUTPUT"
116+
echo "EOF" >>"$GITHUB_OUTPUT"
117+
env:
118+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119+
120+
- uses: DARMA-tasking/comment-on-pr@master
121+
if: github.event_name == 'pull_request'
122+
with:
123+
repo_owner: ${{ github.event.repository.owner.login }}
124+
repo_name: ${{ github.event.repository.name }}
125+
pr_number: ${{ github.event.pull_request.number }}
126+
comment_title: ${{ matrix.target }}
127+
comment_content: ${{ steps.generate_comment.outputs.comment_content }}
128+
github_token: ${{ secrets.GITHUB_TOKEN }}
129+
102130
- name: Upload coverage
103131
if: ${{ matrix.target == 'vt-build-amd64-ubuntu-22-04-gcc-11-cpp' }}
104132
uses: codecov/codecov-action@v5

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# *vt* => virtual transport
22

3-
[![CI](https://github.com/DARMA-tasking/vt/actions/workflows/build-docker-images.yml/badge.svg)](https://github.com/DARMA-tasking/vt/actions/workflows/build-docker-images.yml)
3+
[![CI](https://github.com/DARMA-tasking/vt/actions/workflows/build-docker-images.yml/badge.svg?branch=develop)](https://github.com/DARMA-tasking/vt/actions/workflows/build-docker-images.yml?query=branch%3Adevelop)
44
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/e21fba68df8947ecb9a9c51b5e159e56)](https://www.codacy.com/gh/DARMA-tasking/vt?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=DARMA-tasking/vt&amp;utm_campaign=Badge_Grade)
55
[![codecov](https://codecov.io/gh/DARMA-tasking/vt/branch/develop/graph/badge.svg)](https://codecov.io/gh/DARMA-tasking/vt)
66
[![License](https://img.shields.io/badge/License-BSD%203--Clause-orange.svg)](https://opensource.org/licenses/BSD-3-Clause)

ci/build_cpp.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,6 @@ then
205205
GENERATOR=$(cmake -L . | grep USED_CMAKE_GENERATOR:STRING | cut -d"=" -f2)
206206
OUTPUT="$VT_BUILD"/compilation_errors_warnings.out
207207
OUTPUT_TMP="$OUTPUT".tmp
208-
209-
# Because of the problem with new lines in Azure pipelines, all of them will be
210-
# converted to this unique delimiter
211-
DELIMITER="-=-=-=-"
212-
213208
WARNS_ERRS=""
214209

215210
# Unfortunately Ninja doesn't output compilation warnings and errors to stderr
@@ -233,8 +228,6 @@ then
233228
WARNS_ERRS=$(cat "$OUTPUT_TMP")
234229
fi
235230

236-
# Convert new lines and redirect to an output file
237-
WARNS_ERRS=${WARNS_ERRS//$'\n'/$DELIMITER}
238231
echo "$WARNS_ERRS" > "$OUTPUT"
239232
else
240233
time cmake --build . ${dashj} --target "${target}"

scripts/generate_comment_body.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
3+
# -----------------------------------------------------------------------------
4+
# generate_comment_body.sh
5+
#
6+
# Purpose:
7+
# Produce a markdown-formatted body for a GitHub PR comment that summarises
8+
# compilation warnings/errors and failed CTest results for a single matrix
9+
# target.
10+
#
11+
# Expected positional arguments:
12+
# $1 compilation_errors_warnings.out – file with compiler output
13+
# $2 cmake-output.log – file with CTest output
14+
# $3 bake_target – matrix target name (e.g. vt-build-…)
15+
# $4 job_status – “success”, “failure”, “cancelled”, …
16+
#
17+
# Environment variables (read-only) – provided by GitHub Actions:
18+
# GITHUB_REPOSITORY, GITHUB_RUN_ID, GITHUB_RUN_ATTEMPT, GITHUB_SHA
19+
#
20+
# Output:
21+
# The assembled markdown comment is printed to STDOUT.
22+
# -----------------------------------------------------------------------------
23+
24+
set -euo pipefail
25+
26+
compilation_errors_warnings_out="$1"
27+
cmake_output_log="$2"
28+
bake_target="$3"
29+
job_status="$4"
30+
31+
newline=$'\n'
32+
max_comment_size=2000
33+
34+
[[ "$job_status" == "success" || "$job_status" == "failure" ]] && succeeded=1 || succeeded=0
35+
36+
if [[ -f "$compilation_errors_warnings_out" && -s "$compilation_errors_warnings_out" ]]; then
37+
warnings_errors=$(<"$compilation_errors_warnings_out")
38+
else
39+
warnings_errors=""
40+
fi
41+
42+
tests_failures=""
43+
if [[ -f "$cmake_output_log" && -s "$cmake_output_log" ]]; then
44+
tests_failures=$(sed -n '/The following tests FAILED:/,$p' "$cmake_output_log")
45+
tests_failures=${tests_failures//$'\t'/ }
46+
fi
47+
48+
if (( succeeded )); then
49+
[[ -z "$warnings_errors" ]] && warnings_errors='Compilation – successful'
50+
[[ -z "$tests_failures" ]] && tests_failures='Testing – passed'
51+
else
52+
[[ -z "$warnings_errors" && -z "$tests_failures" ]] && \
53+
warnings_errors='Build failed for unknown reason. Check build logs'
54+
fi
55+
56+
val="${warnings_errors}${newline}${newline}${tests_failures}"
57+
if (( ${#val} > max_comment_size )); then
58+
val="${val:0:max_comment_size}${newline}${newline} ==> And there is more. Read log. <=="
59+
fi
60+
61+
build_link=$(gh api "repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/attempts/${GITHUB_RUN_ATTEMPT}/jobs" |
62+
jq -r --arg target "$bake_target" '.jobs | map(select(.name | contains($target))) | .[0].html_url')
63+
64+
commit_date=$(date -u -d "$(gh api "repos/${GITHUB_REPOSITORY}/commits/${GITHUB_SHA}" --jq '.commit.committer.date')" '+%Y-%m-%d %H:%M:%S %Z')
65+
66+
comment_body=$(cat <<EOF
67+
Build for $GITHUB_SHA ($commit_date)
68+
69+
\`\`\`
70+
$val
71+
\`\`\`
72+
73+
[View job log]($build_link)
74+
EOF
75+
)
76+
77+
printf '%s\n' "$comment_body"

scripts/report_logs_in_comment.sh

Lines changed: 0 additions & 144 deletions
This file was deleted.

0 commit comments

Comments
 (0)