Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 0 additions & 76 deletions .circleci/config.yml

This file was deleted.

103 changes: 0 additions & 103 deletions .circleci/record_coverage

This file was deleted.

1 change: 0 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"mikestead.dotenv",
"ms-vscode.remote-repositories",
"github.remotehub",
"circleci.circleci",
"stylelint.vscode-stylelint",
"christian-kohler.path-intellisense",
"esbenp.prettier-vscode",
Expand Down
38 changes: 38 additions & 0 deletions .github/scripts/build_coverage_comment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -euo pipefail

coverage='unavailable'
if [ -s coverage/.last_run.json ]; then
coverage=$(jq -r 'if .result.line then .result.line else .result.covered_percent end' coverage/.last_run.json)
fi

if [ -z "${coverage}" ] || [ "${coverage}" = 'null' ]; then
coverage='unavailable'
fi

run_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"

if [ "${coverage}" = 'unavailable' ]; then
message=$(
cat <<EOF
### Test coverage
SimpleCov coverage data was unavailable for this run.
Run: ${run_url}
EOF
)
else
message=$(
cat <<EOF
### Test coverage
${coverage}% line coverage reported by SimpleCov.
Run: ${run_url}
EOF
)
fi

{
delimiter="COVERAGE_COMMENT_${RANDOM}_${RANDOM}"
echo "message<<${delimiter}"
echo "${message}"
echo "${delimiter}"
} >> "${GITHUB_OUTPUT}"
49 changes: 49 additions & 0 deletions .github/scripts/post_coverage_comment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -euo pipefail

marker='<!-- simplecov-coverage -->'
body="${marker}"$'\n'"${COVERAGE_MESSAGE:-}"

if [ -z "${COVERAGE_MESSAGE:-}" ]; then
echo 'COVERAGE_MESSAGE is empty; skipping PR comment.'
exit 0
fi

pr_number=$(jq -r '.pull_request.number // empty' "${GITHUB_EVENT_PATH}")
if [ -z "${pr_number}" ]; then
echo 'No pull request number in event payload; skipping PR comment.'
exit 0
fi

owner_repo="${GITHUB_REPOSITORY}"
owner="${owner_repo%%/*}"
repo="${owner_repo#*/}"
api_base="https://api.github.com/repos/${owner}/${repo}/issues"

comments_json=$(curl -sS -f \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H 'Accept: application/vnd.github+json' \
"${api_base}/${pr_number}/comments?per_page=100")

existing_comment_id=$(echo "${comments_json}" | jq -r --arg marker "${marker}" \
'map(select(.user.type == "Bot" and (.body // "" | contains($marker)))) | .[0].id // empty')

payload=$(jq -n --arg body "${body}" '{body: $body}')

if [ -n "${existing_comment_id}" ]; then
curl -sS -f \
-X PATCH \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H 'Accept: application/vnd.github+json' \
"${api_base}/comments/${existing_comment_id}" \
-d "${payload}" > /dev/null
echo "Updated coverage comment ${existing_comment_id} on PR #${pr_number}."
else
curl -sS -f \
-X POST \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H 'Accept: application/vnd.github+json' \
"${api_base}/${pr_number}/comments" \
-d "${payload}" > /dev/null
echo "Created coverage comment on PR #${pr_number}."
fi
Loading