-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
10 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
set -xeo pipefail | ||
|
||
cd go-cover | ||
git fetch origin | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,37 +5,43 @@ set -xeo pipefail | |
cd "${INPUTS_PATH}" | ||
|
||
# generate coverage files | ||
|
||
go tool cover -html=cover.out -o "${GITHUB_WORKSPACE}/go-cover/${REVISION}.html" | ||
go tool cover -func=cover.out -o "${GITHUB_WORKSPACE}/go-cover/${REVISION}.txt" | ||
cp cover.out "${GITHUB_WORKSPACE}/go-cover/${REVISION}.out" | ||
|
||
# generate incremental coverage files | ||
|
||
echo "mode: set" > incremental.out | ||
# grep exits with 1 if no lines are found, so we need to ignore that | ||
grep -F -v -x -f "${GITHUB_WORKSPACE}/go-cover/main.out" cover.out >> incremental.out || true | ||
cat incremental.out | ||
go tool cover -html=incremental.out -o "${GITHUB_WORKSPACE}/go-cover/${REVISION}-inc.html" | ||
go tool cover -func=incremental.out -o "${GITHUB_WORKSPACE}/go-cover/${REVISION}-inc.txt" | ||
cp incremental.out "${GITHUB_WORKSPACE}/go-cover/${REVISION}-inc.out" | ||
|
||
cd "${GITHUB_WORKSPACE}/go-cover" | ||
|
||
# beautify html | ||
|
||
for file in "${REVISION}.html" "${REVISION}-inc.html"; do | ||
ex -sc '%s/<style>/<style>@import url("nord.css");/' -c 'x' "${file}" | ||
ex -sc '%s/<\/script>/<\/script><script src="ln.js"><\/script>/' -c 'x' "${file}" | ||
done | ||
|
||
# if we are on the main branch, copy files to main.* | ||
# if [ "${REF_NAME}" = "main" ]; then | ||
|
||
if [ "${REF_NAME}" = "main" ]; then | ||
cp "${REVISION}.html" main.html | ||
cp "${REVISION}.txt" main.txt | ||
cp "${REVISION}.out" main.out | ||
# fi | ||
fi | ||
|
||
# copy assets | ||
|
||
cp "${GITHUB_ACTION_PATH}"/assets/* . | ||
|
||
# push to branch | ||
|
||
git add . | ||
git config user.email "[email protected]" | ||
git config user.name "go-coverage-action" | ||
|