summaryrefslogtreecommitdiffstats
path: root/.github/diag.sh
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-05-17 15:13:11 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-05-17 17:46:16 -0400
commit23e048793401900c8d1768b4ffb0fc4ff623ef3e (patch)
tree7734fbdaae685feadda1d1448b3d6bca0d9aa512 /.github/diag.sh
parent5b46712d892bebbb280f971675e9b598903d11cf (diff)
downloadbfs-23e048793401900c8d1768b4ffb0fc4ff623ef3e.tar.xz
ci: Surface compiler warnings/errors as GitHub actions messages
Diffstat (limited to '.github/diag.sh')
-rwxr-xr-x.github/diag.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/.github/diag.sh b/.github/diag.sh
new file mode 100755
index 0000000..942487a
--- /dev/null
+++ b/.github/diag.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+# Copyright © Tavian Barnes <tavianator@tavianator.com>
+# SPDX-License-Identifier: 0BSD
+
+# Convert compiler diagnostics to GitHub Actions messages
+# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message
+
+set -eu
+
+filter() {
+ sed -E 's/^(([^:]*):([^:]*):([^:]*): (warning|error): (.*))$/::\5 file=\2,line=\3,col=\4,title=Compiler \5::\6\
+\1/'
+}
+
+"$@" 2> >(filter >&2) | filter