Skip to content
Draft
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
53 changes: 47 additions & 6 deletions .github/workflows/pin-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,58 @@ jobs:
fail-fast: false
matrix:
component: [monero, p2pool, xmrig-proxy, rigforge]
environment: pin-bump
permissions:
contents: write
pull-requests: write
contents: read
issues: write
env:
GH_TOKEN: ${{ github.token }}
COMPONENT: ${{ matrix.component }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
ref: develop
persist-credentials: false
- name: Check the pin-bump App settings
env:
APP_CLIENT_ID: ${{ vars.PIN_BUMP_APP_CLIENT_ID }}
APP_KEY_SET: ${{ secrets.PIN_BUMP_APP_KEY != '' }}
run: |
if [ -z "$APP_CLIENT_ID" ]; then
echo "::error::The pin-bump environment has no PIN_BUMP_APP_CLIENT_ID variable, so this run cannot open its pull request."
exit 1
fi
if [ "$APP_KEY_SET" != true ]; then
echo "::error::The pin-bump environment has no PIN_BUMP_APP_KEY secret, so this run cannot open its pull request."
exit 1
fi
- name: Mint the developer App token for this repository
id: app
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc
with:
client-id: ${{ vars.PIN_BUMP_APP_CLIENT_ID }}
private-key: ${{ secrets.PIN_BUMP_APP_KEY }}
permission-contents: write
permission-pull-requests: write
permission-issues: write
- name: Resolve the newest release and its hash
id: detect
env:
GH_TOKEN: ${{ steps.app.outputs.token }}
run: |
result="$(bash scripts/watch/pin-bump.sh detect "$COMPONENT")"
printf '%s\n' "$result" | tee -a "$GITHUB_OUTPUT"
- name: Push the bump and open its PR
if: steps.detect.outputs.stale == 'true' && inputs.dry_run != true
env:
GH_TOKEN: ${{ steps.app.outputs.token }}
CURRENT: ${{ steps.detect.outputs.current }}
LATEST: ${{ steps.detect.outputs.latest }}
PIN: ${{ steps.detect.outputs.pin }}
BRANCH: ${{ steps.detect.outputs.branch }}
run: |
set -Eeuo pipefail
state="$(gh pr list --state all --head "$BRANCH" --json state \
--jq 'map(.state) | if index("OPEN") then "OPEN" elif length > 0 then .[0] else "none" end')"
state="$(gh pr list --state all --head "$BRANCH" --limit 200 --json state,isCrossRepository \
--jq 'map(select(.isCrossRepository | not) | .state) | if index("OPEN") then "OPEN" elif length > 0 then .[0] else "none" end')"
if [ "$state" != none ]; then
echo "PR for ${COMPONENT} ${LATEST} is ${state}; not opening another"
exit 0
Expand Down Expand Up @@ -84,6 +109,7 @@ jobs:
- name: Close bump PRs this run supersedes
if: inputs.dry_run != true
env:
GH_TOKEN: ${{ steps.app.outputs.token }}
STALE: ${{ steps.detect.outputs.stale }}
BRANCH: ${{ steps.detect.outputs.branch }}
run: |
Expand All @@ -92,7 +118,7 @@ jobs:
if [ "$STALE" = true ]; then
want="$BRANCH"
fi
rows="$(gh pr list --state open --limit 200 --json number,headRefName,author |
rows="$(gh pr list --state open --limit 200 --json number,headRefName,author,isCrossRepository |
bash scripts/watch/pin-bump.sh superseded "$COMPONENT" "$want")"
keep="$(printf '%s\n' "$rows" | awk -F'\t' '$3 == "keep" { print $2; exit }')"
if [ -n "$keep" ]; then
Expand All @@ -105,3 +131,18 @@ jobs:
gh pr close "$number" --comment "$reason"
fi
done <<< "$rows"
- name: Report the failed run on its tracking issue
if: failure()
env:
GH_TOKEN: ${{ steps.app.outputs.token || github.token }}
TITLE: Shipped pin bump run failed for ${{ matrix.component }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -Eeuo pipefail
body="The ${COMPONENT} pin bump failed in [run ${GITHUB_RUN_ID}](${RUN_URL}); its log names the failed step. Close this issue once a run succeeds again."
n="$(bash scripts/watch/find-open-issue.sh "$TITLE")"
if [ -n "$n" ]; then
gh issue comment "$n" --body "$body"
else
gh issue create --title "$TITLE" --label infra --body "$body"
fi
54 changes: 46 additions & 8 deletions .github/workflows/tor-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,52 @@ jobs:
name: Open a PR when Alpine carries a newer tor
runs-on: ubuntu-latest
timeout-minutes: 10
environment: pin-bump
permissions:
contents: write
pull-requests: write
contents: read
issues: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
ref: develop
persist-credentials: false
- name: Check the pin-bump App settings
env:
APP_CLIENT_ID: ${{ vars.PIN_BUMP_APP_CLIENT_ID }}
APP_KEY_SET: ${{ secrets.PIN_BUMP_APP_KEY != '' }}
run: |
if [ -z "$APP_CLIENT_ID" ]; then
echo "::error::The pin-bump environment has no PIN_BUMP_APP_CLIENT_ID variable, so this run cannot open its pull request."
exit 1
fi
if [ "$APP_KEY_SET" != true ]; then
echo "::error::The pin-bump environment has no PIN_BUMP_APP_KEY secret, so this run cannot open its pull request."
exit 1
fi
- name: Mint the developer App token for this repository
id: app
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc
with:
client-id: ${{ vars.PIN_BUMP_APP_CLIENT_ID }}
private-key: ${{ secrets.PIN_BUMP_APP_KEY }}
permission-contents: write
permission-pull-requests: write
permission-issues: write
- name: Detect a newer tor in the Alpine repository
id: detect
run: bash scripts/watch/tor-bump.sh detect >>"$GITHUB_OUTPUT"
- name: Push the bump and open its PR
if: steps.detect.outputs.stale == 'true'
env:
GH_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ steps.app.outputs.token }}
CURRENT: ${{ steps.detect.outputs.current }}
LATEST: ${{ steps.detect.outputs.latest }}
BRANCH: ${{ steps.detect.outputs.branch }}
run: |
set -Eeuo pipefail
branch="bot/tor-${LATEST}"
state="$(gh pr list --state all --head "$branch" --json state \
--jq 'map(.state) | if index("OPEN") then "OPEN" elif length > 0 then .[0] else "none" end')"
state="$(gh pr list --state all --head "$branch" --limit 200 --json state,isCrossRepository \
--jq 'map(select(.isCrossRepository | not) | .state) | if index("OPEN") then "OPEN" elif length > 0 then .[0] else "none" end')"
if [ "$state" = OPEN ]; then
echo "PR for ${LATEST} is already open"
exit 0
Expand Down Expand Up @@ -80,13 +103,13 @@ jobs:

## Here is the proof

Pending: the \`tier4-kvm\` \`tor-heal\` phase must be green at this head before merge, as \`docs/dev/releasing.md\` requires for a Tor pin bump — it is the live proof of Tor's state-file behaviour. Tiers 1 to 3 run from the first push to this branch; a PR opened with the Actions token triggers no \`pull_request\` checks of its own.
Pending: the \`tier4-kvm\` \`tor-heal\` phase must be green at this head before merge, as \`docs/dev/releasing.md\` requires for a Tor pin bump — it is the live proof of Tor's state-file behaviour. Tiers 1 to 3 run as this PR's own checks: the developer App opens it.
EOF
gh pr create --base develop --head "$branch" --label dependencies \
--title "build/tor: bump the Tor pin to ${LATEST}" --body-file pr-body.md
- name: Close bump PRs this run supersedes
env:
GH_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ steps.app.outputs.token }}
STALE: ${{ steps.detect.outputs.stale }}
LATEST: ${{ steps.detect.outputs.latest }}
run: |
Expand All @@ -95,7 +118,7 @@ jobs:
if [ "$STALE" = true ]; then
want="bot/tor-${LATEST}"
fi
rows="$(gh pr list --state open --limit 200 --json number,headRefName,author |
rows="$(gh pr list --state open --limit 200 --json number,headRefName,author,isCrossRepository |
bash scripts/watch/tor-bump.sh superseded "$want")"
keep="$(printf '%s\n' "$rows" | awk -F'\t' '$3 == "keep" { print $2; exit }')"
if [ -n "$keep" ]; then
Expand All @@ -110,3 +133,18 @@ jobs:
gh pr close "$number" --comment "$reason"
fi
done <<< "$rows"
- name: Report the failed run on its tracking issue
if: failure()
env:
GH_TOKEN: ${{ steps.app.outputs.token || github.token }}
TITLE: Tor pin bump run failed
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -Eeuo pipefail
body="The Tor pin bump failed in [run ${GITHUB_RUN_ID}](${RUN_URL}); its log names the failed step. Close this issue once a run succeeds again."
n="$(bash scripts/watch/find-open-issue.sh "$TITLE")"
if [ -n "$n" ]; then
gh issue comment "$n" --body "$body"
else
gh issue create --title "$TITLE" --label infra --body "$body"
fi
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ test-tools: ## Build-tool contracts and CI workflow guards (no live services)
python3 tests/stack/standalone/test_appliance_release_docs.py
bash scripts/watch/tor-bump.sh --self-test
bash scripts/watch/pin-bump.sh --self-test
for w in tor-bump pin-bump; do f=.github/workflows/$$w.yml; grep -Eq '^ environment: pin-bump$$' $$f && grep -Fq 'uses: actions/create-github-app-token@' $$f && ! grep -Fvx ' GH_TOKEN: $${{ steps.app.outputs.token || github.token }}' $$f | grep -Eq 'github\.token|GITHUB_TOKEN' && [ "$$(grep -Fxc ' GH_TOKEN: $${{ steps.app.outputs.token || github.token }}' $$f)" = 1 ] && grep -Eq '^ issues: write$$' $$f && grep -Fq 'permission-pull-requests: write' $$f && grep -Fq 'permission-issues: write' $$f && grep -Fxq ' if: failure()' $$f && awk '/uses: actions\/checkout@/ { k = NR } /name: Check the pin-bump App settings/ { c = NR } /name: Push the bump and open its PR/ { p = NR } END { exit !(k && c && p && k < c && c < p) }' $$f || { echo "$$f: the bump job must run in the pin-bump environment, check the App settings first, write only with the App token and report a failed run" >&2; exit 1; }; done
bash tests/watch/test-find-open-issue.sh
sed -n '/^ shell-block:$$/,/^ shell-fragment:$$/p' .github/workflows/shell.yml | grep -Eq '^ timeout-minutes: 12( |$$)'
sed -n '/^ shell-fragment:$$/,/^ shell:$$/p' .github/workflows/shell.yml | grep -Eq '^ timeout-minutes: 12( |$$)'
Expand Down
4 changes: 2 additions & 2 deletions build/tor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# names the Alpine minor line (3.24) so Dependabot's patch-update policy has a real version to track.
FROM alpine:3.24@sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf

ARG TOR_VERSION=0.4.9.17-r0
RUN apk add --no-cache --upgrade libcrypto3 libssl3 musl musl-utils "tor=${TOR_VERSION}" netcat-openbsd \
ARG TOR_VERSION=0.4.9.18-r0
RUN apk add --no-cache --upgrade libcrypto3 libssl3 musl musl-utils busybox "tor=${TOR_VERSION}" netcat-openbsd \
&& tor --version | grep -F "Tor version ${TOR_VERSION%-r*}."

COPY torrc.template /etc/tor/torrc.template
Expand Down
20 changes: 16 additions & 4 deletions docs/dev/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,22 @@ refuses to go on unless its sha256 equals the digest GitHub publishes for it (Mo
`hashes.txt`, whose signature is not verified), then opens one `dependencies`-labelled PR per upstream
version that moves the version and hash together, so a stale hash never lands. `RIGFORGE_REF` is
resolved from the release tag to its commit. Monero only moves within its pinned minor: a release in
a new minor is reported and never proposed, because that move stays a human decision (#1129). The Actions token
opens these PRs, so they trigger no checks of their own: a maintainer pushes to the branch to start
tiers 1 to 3, and the PR body names the `tier4-e2e` or `tier4-kvm` proof it needs before merge. A newer
release supersedes the open PR for an older one of the same component, and a closed PR is taken as declined.
a new minor is reported and never proposed, because that move stays a human decision (#1129). The developer
App opens these PRs, so tiers 1 to 3 run as their own checks, and the PR body names the `tier4-e2e` or
`tier4-kvm` proof it needs before merge. A newer release supersedes the open PR for an older one of the
same component, and a closed PR is taken as declined.

Both bump workflows, this one and `tor-bump.yml` below, push their branch and open their PR with a
token for the developer App, minted in each run by `actions/create-github-app-token` for this
repository only; the repository setting that lets the Actions token create pull requests stays off
(#4677). They need a one-time setup by the owner: an environment named `pin-bump`, limited to the
`develop` branch, with the variable `PIN_BUMP_APP_CLIENT_ID` (the App's client ID) and the secret `PIN_BUMP_APP_KEY`
(a private key of the App made for this use alone, so it can be revoked without touching its other
keys). Until both are set, each run fails at the settings check and names the missing setting, before
it pushes anything; a run on any other branch never receives the key, so a dry run works only from
`develop`. Every failed run comments on, or opens, an `infra` tracking issue named after the workflow
(per component for the shipped pins), a missing setting or a revoked key included: the report uses
the App token when the run minted one and the Actions token, which may open issues, when it did not.

Advisories are the one thing the watch cannot see: `monerod`, `p2pool` and `xmrig-proxy` install
sha256-verified static binaries with no package metadata, so the Trivy sweep reports no CVEs for
Expand Down
7 changes: 7 additions & 0 deletions scripts/watch/pin-bump-selftest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ self_test() {
"$(superseded p2pool bot/p2pool-v4.19.0 <"$t/prs.json")" $'1\tbot/p2pool-v4.19.0\tkeep\n2\tbot/p2pool-v4.18.9\tclose'
check "superseded with no want closes every own head of the component" "$(superseded p2pool '' <"$t/prs.json" | grep -c close)" 2
check "superseded leaves another component alone" "$(superseded monero bot/monero-v0.18.5.2 <"$t/prs.json")" $'3\tbot/monero-v0.18.5.2\tkeep'
check "superseded treats the developer App's bump PRs as its own" \
"$(printf '[{"number":8,"headRefName":"bot/p2pool-v4.19.0","author":{"login":"app/pithead-developer"}},{"number":9,"headRefName":"bot/p2pool-v4.18.9","author":{"login":"pithead-developer[bot]"}}]' | superseded p2pool bot/p2pool-v4.19.0)" \
$'8\tbot/p2pool-v4.19.0\tkeep\n9\tbot/p2pool-v4.18.9\tclose'
check "superseded skips PRs from forks and a bare login that only looks like the App" \
"$(printf '[{"number":13,"headRefName":"bot/p2pool-v4.19.0","author":{"login":"app/pithead-developer"},"isCrossRepository":true},{"number":14,"headRefName":"bot/p2pool-v4.18.9","author":{"login":"pithead-developer"}}]' | superseded p2pool bot/p2pool-v4.19.0 | wc -l | tr -d ' ')" "0"
check "superseded never touches the developer App's other PRs" \
"$(printf '[{"number":10,"headRefName":"fix/p2pool-pin","author":{"login":"app/pithead-developer"}},{"number":11,"headRefName":"agent/bot/p2pool-v4.19.0","author":{"login":"app/pithead-developer"}},{"number":12,"headRefName":"bot/monero-v0.18.5.4","author":{"login":"app/pithead-developer"}}]' | superseded p2pool '' | wc -l | tr -d ' ')" "0"
check "pr body has the three house sections" "$(pr_body p2pool v4.18.1 v4.19.0 | grep -c '^## ')" 3
check "pr body for p2pool requires the advisory check" "$(pr_body p2pool v4.18.1 v4.19.0 | grep -c 'security advisories for v4.19.0')" 1
check "pr body for monero requires the advisory check" "$(pr_body monero 0.18.4.5 0.18.4.6 | grep -c 'security advisories for 0.18.4.6')" 1
Expand Down
6 changes: 3 additions & 3 deletions scripts/watch/pin-bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ apply_pin() {
superseded() {
local c="$1" want="${2:-}"
jq -r --arg want "$want" --arg prefix "bot/$c-" '
def trusted: ((.author.login // "") | sub("^app/"; "") | sub("\\[bot\\]$"; "")) == "github-actions";
def ours: ((.headRefName // "") | startswith($prefix));
def trusted: (.author.login // "") as $l | ($l | sub("^app/"; "") | sub("\\[bot\\]$"; "")) == "github-actions" or $l == "app/pithead-developer" or $l == "pithead-developer[bot]";
def ours: ((.headRefName // "") | startswith($prefix)) and (.isCrossRepository // false | not);
(map(select(trusted and ours and .headRefName == $want)) | .[0].headRefName // "") as $keep |
map(select(trusted and ours))[] |
[ (.number | tostring), .headRefName, (if .headRefName == $keep then "keep" else "close" end) ] | @tsv'
Expand Down Expand Up @@ -281,7 +281,7 @@ Automated bump of the $c pin to ${latest} only, opened by \`.github/workflows/pi

## Here is the proof

Pending: ${proof}. A PR opened with the Actions token triggers no \`pull_request\` checks of its own, so tiers 1 to 3 run once a maintainer pushes to this branch.${advisory}
Pending: ${proof}. Tiers 1 to 3 run as this PR's own checks: the developer App opens it.${advisory}
EOF
}

Expand Down
11 changes: 9 additions & 2 deletions scripts/watch/tor-bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ apply_pin() {
superseded() {
local want="${1:-}"
jq -r --arg want "$want" '
def trusted: ((.author.login // "") | sub("^app/"; "") | sub("\\[bot\\]$"; "")) == "github-actions";
def ours: ((.headRefName // "") | startswith("bot/tor-"));
def trusted: (.author.login // "") as $l | ($l | sub("^app/"; "") | sub("\\[bot\\]$"; "")) == "github-actions" or $l == "app/pithead-developer" or $l == "pithead-developer[bot]";
def ours: ((.headRefName // "") | startswith("bot/tor-")) and (.isCrossRepository // false | not);
(map(select(trusted and ours and .headRefName == $want)) | .[0].headRefName // "") as $keep |
map(select(trusted and ours))[] |
[ (.number | tostring), .headRefName, (if .headRefName == $keep then "keep" else "close" end) ] | @tsv'
Expand Down Expand Up @@ -143,6 +143,13 @@ self_test() {
"$(superseded bot/tor-0.4.9.18-r1 <"$t/prs.json" | grep -cE '^[4567]')" "0"
check "superseded on an empty list prints nothing" \
"$(printf '[]' | superseded bot/tor-0.4.9.18-r1 | wc -l | tr -d ' ')" "0"
check "superseded treats the developer App's bump PRs as its own" \
"$(printf '[{"number":8,"headRefName":"bot/tor-0.4.9.18-r1","author":{"login":"app/pithead-developer"}},{"number":9,"headRefName":"bot/tor-0.4.9.17-r0","author":{"login":"pithead-developer[bot]"}}]' | superseded bot/tor-0.4.9.18-r1)" \
$'8\tbot/tor-0.4.9.18-r1\tkeep\n9\tbot/tor-0.4.9.17-r0\tclose'
check "superseded skips PRs from forks and a bare login that only looks like the App" \
"$(printf '[{"number":13,"headRefName":"bot/tor-0.4.9.18-r1","author":{"login":"app/pithead-developer"},"isCrossRepository":true},{"number":14,"headRefName":"bot/tor-0.4.9.17-r0","author":{"login":"pithead-developer"}}]' | superseded bot/tor-0.4.9.18-r1 | wc -l | tr -d ' ')" "0"
check "superseded never touches the developer App's other PRs" \
"$(printf '[{"number":10,"headRefName":"fix/tor-egress","author":{"login":"app/pithead-developer"}},{"number":11,"headRefName":"agent/bot/tor-0.4.9.18-r1","author":{"login":"app/pithead-developer"}},{"number":12,"headRefName":"bot/monero-v0.18.5.4","author":{"login":"app/pithead-developer"}}]' | superseded '' | wc -l | tr -d ' ')" "0"
[ "$fail" = 0 ] && echo "tor-bump self-test OK"
return "$fail"
}
Expand Down
Loading