summaryrefslogtreecommitdiffstats
path: root/.github/diag.sh
blob: fe78be8963a82b89f4d87956c8023635c6847bff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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/'
}

exec "$@" > >(filter) 2> >(filter >&2)