Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kilianc committed May 15, 2024
1 parent c80a620 commit 1a277c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/pull.sh
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
Expand Down
12 changes: 9 additions & 3 deletions scripts/push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 1a277c0

Please sign in to comment.