| 1 | #!/usr/bin/env bash |
| 2 | set -euo pipefail |
| 3 | |
| 4 | # The script is configurable via environment variablesß |
| 5 | FORK_REPO="${FORK_REPO:-kaukabrizvi/boring}" # owner/repo |
| 6 | FORK_BRANCH="${FORK_BRANCH:-symbol-prefixing}" # branch to check |
| 7 | THRESHOLD_DAYS="${THRESHOLD_DAYS:-60}" # ~2 months |
| 8 | |
| 9 | if ! command -v jq >/dev/null 2>&1; then |
| 10 | echo "ERROR: jq is required for the BoringSSL fork freshness check." |
| 11 | exit 2 |
| 12 | fi |
| 13 | |
| 14 | commit_api="https://api.github.com/repos/${FORK_REPO}/commits/${FORK_BRANCH}" |
| 15 | json="$(curl -fsSL "${commit_api}")" |
| 16 | |
| 17 | last_commit_date="$(echo "${json}" | jq -r '.commit.committer.date')" |
| 18 | last_commit_sha="$(echo "${json}" | jq -r '.sha')" |
| 19 | |
| 20 | if [[ -z "${last_commit_date}" || "${last_commit_date}" == "null" ]]; then |
| 21 | echo "ERROR: Could not determine last commit date for ${FORK_REPO}@${FORK_BRANCH} from GitHub API." |
| 22 | exit 2 |
| 23 | fi |
| 24 | |
| 25 | now_epoch="$(date -u +%s)" |
| 26 | commit_epoch="$(date -u -d "${last_commit_date}" +%s)" |
| 27 | age_days="$(( (now_epoch - commit_epoch) / 86400 ))" |
| 28 | |
| 29 | if (( age_days > THRESHOLD_DAYS )); then |
| 30 | cat <<EOF |
| 31 | ERROR: BoringSSL fork branch appears stale. |
| 32 | |
| 33 | Fork: ${FORK_REPO} |
| 34 | Branch: ${FORK_BRANCH} |
| 35 | Last commit: ${last_commit_sha} |
| 36 | Last commit date:${last_commit_date} (~${age_days} days ago) |
| 37 | Threshold: ${THRESHOLD_DAYS} days |
| 38 | |
| 39 | Why this is failing: |
| 40 | s2n-tls currently depends on a forked BoringSSL branch (for symbol prefixing) to avoid |
| 41 | OpenSSL symbol collisions in integration tests. A stale fork risks outdated testing. |
| 42 | |
| 43 | Refresh [email protected]:${FORK_REPO}/tree/${FORK_BRANCH} by syncing it with the upstream repository, |
| 44 | resolving merge conflicts if they appear. This should be done periodically and has not been done in |
| 45 | ~${age_days} days. |
| 46 | EOF |
| 47 | exit 1 |
| 48 | fi |
| 49 | |
| 50 | echo "OK: ${FORK_REPO}@${FORK_BRANCH} last commit ${last_commit_sha} at ${last_commit_date} (~${age_days} days ago) within threshold ${THRESHOLD_DAYS}." |