Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .github/actionlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# actionlint knows GitHub's hosted runner labels only. `gpu` is the custom
# label gpu.yml's self-hosted CUDA runner must carry (#38).
self-hosted-runner:
labels:
- gpu
6 changes: 5 additions & 1 deletion .github/scripts/check-crate-metadata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,9 @@ for pkg in $(printf '%s' "$meta" | jq -r '.packages[] | select(.publish == null)
say "FAIL $pkg: ${missing[*]}"; fail=1
fi
done
# The README every crate carries has to work where crates.io renders it,
# from each crate's own directory, so its links are part of the metadata
# (#129). Run whatever the loop above found, so one run reports both.
.github/scripts/check-readme-links.sh || fail=1
[ "$fail" -eq 0 ] || { echo "crate metadata: at least one published crate is missing what crates.io shows (see above)"; exit 1; }
echo "crate metadata: every published crate carries README, repository, homepage, docs.rs link, keywords, categories"
echo "crate metadata: every published crate carries README, repository, homepage, docs.rs link, keywords, categories; README links are absolute"
66 changes: 66 additions & 0 deletions .github/scripts/check-readme-links.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash
# README.md is the README of all nine published crates (`readme.workspace =
# true`), and crates.io resolves a relative link in it against that crate's
# own directory in the repository, not the root: `docs/SPEC.md` on the
# oxidelake-api page became …/blob/HEAD/crates/oxidelake-api/docs/SPEC.md, a
# 404. Every relative link in the 0.2.0 README was one, on every page (#129).
# GitHub renders the same file from the root, where each of them works, so
# nothing there could show it. termlens 0.10.3 and launchbound 2.2.1 fixed
# the same thing the same way.
#
# So no relative link at all, and a link into this repository's main branch
# must name a path that is in this checkout. That half is checked against the
# tree, never over the network, which is slow, flaky, and can answer 200 for
# the wrong reason. A link is every target a renderer follows: an inline
# `](…)`, a reference definition (`[x]: path`), and an HTML `src` or `href`.
#
# Runs from check-crate-metadata.sh (`make crate-metadata`, and CI's
# release-scripts job). Bash 3.2 compatible: macOS runs it too.
set -euo pipefail
cd "$(dirname "$0")/../.."

readme=README.md
repo="https://github.com/vyncint/oxidelake"
[ -f "$readme" ] || { echo "::error::no $readme at the repository root"; exit 1; }

# Every link target, once each. Inline links lose a title and angle brackets;
# a reference definition starts a line (a footnote, `[^1]:`, is not one); HTML
# attributes may use either quote.
links() {
{
grep -oE '\]\([^)]+\)' "$readme" \
| sed -E 's/^\]\([[:space:]]*//; s/\)$//; s/^<//; s/[[:space:]].*$//; s/>$//' || true
grep -E '^ {0,3}\[[^]^][^]]*\]:' "$readme" \
| sed -E 's/^ {0,3}\[[^]]+\]:[[:space:]]*//; s/^<//; s/[[:space:]].*$//; s/>$//' || true
grep -oE "(src|href)=(\"[^\"]*\"|'[^']*')" "$readme" | sed -E 's/^(src|href)=.//; s/.$//' || true
} | sort -u
}

fail=0
checked=0
while IFS= read -r link; do
[ -n "$link" ] || continue
checked=$((checked + 1))
case "$link" in
'#'* | mailto:*) ;;
"$repo/blob/main/"* | "$repo/tree/main/"*)
path=${link#"$repo/blob/main/"}
path=${path#"$repo/tree/main/"}
path=${path%%#*}
if [ ! -e "$path" ]; then
echo "::error file=$readme::$link names $path, which is not in this repository"
fail=1
fi
;;
http://* | https://*) ;;
*)
echo "::error file=$readme::relative link '$link': crates.io resolves it against each crate's directory, where it is a 404; write $repo/blob/main/${link#./}"
fail=1
;;
esac
done < <(links)

# Finding nothing means the extraction broke, not that the README is clean.
[ "$checked" -gt 0 ] || { echo "::error file=$readme::found no links at all; the link extraction is broken"; exit 1; }
[ "$fail" -eq 0 ] || { echo "readme links: a link above is relative or names a path this repository does not have"; exit 1; }
echo "readme links: all $checked absolute, every one into this repository names a path that is here"
58 changes: 58 additions & 0 deletions .github/scripts/crates-io-baseline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bash
# Fails unless crates.io confirms that CRATE is published, so the release's
# cargo-semver-checks job has a baseline to compare against (#130).
#
# .github/scripts/crates-io-baseline.sh oxidelake-core
#
# This used to be a branch in release.yml: HTTP 200 ran the semver check and
# any other answer meant "first release, skip it". A 429 or a 503 therefore
# switched the gate off, silently, minutes before `cargo publish`. Every
# OxideLake crate has been on crates.io since 0.1.0, so there is no first
# release left to skip for, and nothing but a 200 is an answer to act on:
#
# 200 the baseline exists — the semver check runs
# 404 an error: the name is wrong or crates.io is, and either
# way skipping the check is not the remedy
# 429, 5xx, 000 retried (000 is curl's code for no answer at all), then
# an error: a blip is worth a minute, an outage is a re-run
# anything else an error
#
# CRATES_IO_API, BASELINE_ATTEMPTS and BASELINE_PAUSE exist for the stand-in
# server in .github/scripts/test_ci.py.
set -euo pipefail

crate="${1:?usage: crates-io-baseline.sh CRATE}"
api="${CRATES_IO_API:-https://crates.io/api/v1}"
attempts="${BASELINE_ATTEMPTS:-4}"
pause="${BASELINE_PAUSE:-20}"
# crates.io refuses requests without a user agent that names the client.
agent="oxidelake-release (github.com/${GITHUB_REPOSITORY:-vyncint/oxidelake})"

attempt=1
while :; do
# `|| true`: curl exits non-zero when nothing answers, and that case gets
# the same retry as a 503 rather than ending the script under `-e`.
status="$(curl -sS -o /dev/null -w '%{http_code}' -A "$agent" "$api/crates/$crate" || true)"
case "$status" in
200)
echo "$crate is on crates.io (HTTP 200): cargo-semver-checks has a baseline"
exit 0
;;
404)
echo "::error::crates.io answered HTTP 404 for $crate. Every OxideLake crate has been published since 0.1.0, so this is a wrong crate name or a crates.io fault, not a first release; the semver check is not skipped for it."
exit 1
;;
429 | 5?? | 000) ;;
*)
echo "::error::crates.io answered HTTP $status for $crate; only a 200 lets the semver check run, and it is never skipped."
exit 1
;;
esac
if [ "$attempt" -ge "$attempts" ]; then
echo "::error::crates.io answered HTTP $status for $crate on all $attempts attempts. Nothing has been published: re-run this job once crates.io answers."
exit 1
fi
echo "crates.io answered HTTP $status for $crate; retrying in ${pause}s (attempt $attempt of $attempts)"
sleep "$pause"
attempt=$((attempt + 1))
done
Loading
Loading