Skip to content

Commit 9c2f16f

Browse files
authored
Get wrangle results displayed well (enough) (#1)
Creates markdown with the tool results and displays that as a summary of the run.
1 parent 4597299 commit 9c2f16f

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

.github/workflows/check_source.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
id: scan
2828
run: ./run.sh osv zizmor
2929
- name: Display results
30-
run: find ./
30+
run: cat ./metadata/summary.md >> $GITHUB_STEP_SUMMARY
3131
- name: Upload SARIFs
3232
if: ${{ false }} # We're still a private repo so we can't enable code scanning. :(
3333
uses: github/codeql-action/upload-sarif@v3

run.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,38 @@ set -e
44
# Pass tools to run as arguments.
55
# e.g. run.sh foo bar
66

7+
mkdir ./metadata
8+
SUMMARY_FILE=./metadata/summary.md
9+
echo "# Wrangle results" >> $SUMMARY_FILE
10+
echo "| Tool | Status | Results |" >> $SUMMARY_FILE
11+
echo "| ---- | ------ | ------- |" >> $SUMMARY_FILE
712
WRANGLE_EXIT_STATUS=0
813
for tool in $@;
914
do
1015
echo "Running $tool..."
1116
mkdir -p ./metadata/$tool
1217
mkdir -p ./dist/$tool
18+
TOOL_STATUS="Success"
1319
docker run \
1420
--quiet \
1521
--mount type=bind,source=./dist/$tool,target=/dist \
1622
--mount type=bind,source=./metadata/$tool,target=/metadata \
1723
--mount type=bind,source=./,target=/src,readonly \
1824
-v /var/run/docker.sock:/var/run/docker.sock \
19-
ghcr.io/tomhennen/wrangle/$tool:main || (echo "$tool failed" && WRANGLE_EXIT_STATUS=1)
20-
echo "$tool done"
25+
ghcr.io/tomhennen/wrangle/$tool:main | tee ./metadata/$tool/output.txt || WRANGLE_EXIT_STATUS=1; TOOL_STATUS="Failed"
26+
echo "$tool $TOOL_STATUS"
27+
echo "| $tool | $TOOL_STATUS | [Details](#$tool-details) |" >> $SUMMARY_FILE
2128
done
29+
30+
echo "" >> $SUMMARY_FILE
31+
32+
# Add in the details
33+
for tool in $@;
34+
do
35+
echo "## $tool Details" >> $SUMMARY_FILE
36+
printf "\n\n<pre><code>" >> $SUMMARY_FILE
37+
cat ./metadata/$tool/output.txt >> $SUMMARY_FILE
38+
printf "</code></pre>\n" >> $SUMMARY_FILE
39+
done
40+
echo "Done with all tools. Exiting with $WRANGLE_EXIT_STATUS"
2241
exit $WRANGLE_EXIT_STATUS

tools/osv/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ WRANGLE_EXIT_STATUS=0
77

88
# Run a scan over all of source and ignore errors, because OSV likes to fail
99
# too often. :) (Maybe it generates an error code when it finds problems?)
10-
/osv-scanner --format sarif --output /metadata/osv.sarif -r /src || (echo "osv failure when generating sarif" && WRANGLE_EXIT_STATUS=1)
10+
/osv-scanner --format sarif --output /metadata/osv.sarif -r /src || echo "osv failure when generating sarif"; WRANGLE_EXIT_STATUS=1
1111
# Run it again for the markdown. (if only we could output in multiple formats from one run...)
12-
/osv-scanner --format markdown --output /metadata/osv.md -r /src || (echo`"osv failure when generating markdown" && WRANGLE_EXIT_STATUS=1)
12+
/osv-scanner --format markdown --output /metadata/osv.md -r /src || echo "osv failure when generating markdown"; WRANGLE_EXIT_STATUS=1
1313
cat /metadata/osv.md
1414
exit $WRANGLE_EXIT_STATUS

tools/zizmor/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ echo "zizmor"
55
WRANGLE_EXIT_STATUS=0
66
NO_COLOR=1
77
echo "zizmor sarif"
8-
/usr/local/cargo/bin/zizmor --format sarif -o `find /src/.github/workflows -name "*.yml"` > /metadata/zizmor.sarif || (echo "zizmor failure when generating sarif" && WRANGLE_EXIT_STATUS=1)
8+
/usr/local/cargo/bin/zizmor --format sarif -o `find /src/.github/workflows -name "*.yml"` > /metadata/zizmor.sarif || echo "zizmor failure when generating sarif"; WRANGLE_EXIT_STATUS=1
99
# Run it again for the plain output. (if only we could output in multiple formats from one run...)
1010
echo "zizmor plain"
11-
/usr/local/cargo/bin/zizmor --format plain -o `find /src/.github/workflows -name "*.yml"` > /metadata/zizmor.txt || (echo "zizmor failure when generating text" && WRANGLE_EXIT_STATUS=1)
11+
/usr/local/cargo/bin/zizmor --format plain -o `find /src/.github/workflows -name "*.yml"` > /metadata/zizmor.txt || echo "zizmor failure when generating text"; WRANGLE_EXIT_STATUS=1
1212
cat /metadata/zizmor.txt
1313
exit $WRANGLE_EXIT_STATUS

0 commit comments

Comments
 (0)