summaryrefslogtreecommitdiffstats
path: root/.github/diag.sh
diff options
context:
space:
mode:
Diffstat (limited to '.github/diag.sh')
-rwxr-xr-x.github/diag.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/.github/diag.sh b/.github/diag.sh
new file mode 100755
index 0000000..d89e7a4
--- /dev/null
+++ b/.github/diag.sh
@@ -0,0 +1,20 @@
+#!/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
+
+SEDFLAGS="-En"
+if sed -u 's/s/s/' </dev/null &>/dev/null; then
+ SEDFLAGS="${SEDFLAGS}u"
+fi
+
+filter() {
+ sed $SEDFLAGS 'p; s/^([^:]*):([^:]*):([^:]*): (warning|error): (.*)$/::\4 file=\1,line=\2,col=\3,title=Compiler \4::\5/p'
+}
+
+exec "$@" > >(filter) 2> >(filter >&2)