Files
seaweedfs/seaweed-block/.github/workflows/spec-trace.yml
T

71 lines
3.3 KiB
YAML

name: spec trace
# Every PR description carries the spec trace (see the PR template); this
# check fails a PR whose description does not.
#
# pull_request_target: the workflow and the script come from the base branch,
# so a PR cannot change its own check. The PR's code is never checked out or
# run: only its commit is fetched, for the file list. The description is read
# from the event through an environment variable, never interpolated.
on:
pull_request_target:
# edited: the check reads the description and the base.
types: [opened, synchronize, reopened, edited]
permissions:
contents: read
concurrency:
group: spec-trace-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
trace:
name: spec trace
# Same-repository PRs use the project's self-hosted runners, as the test
# workflow does; fork PRs stay on a GitHub-hosted runner, whose shared queue
# can wait for hours. No PR code runs here either way.
runs-on: ${{ github.event.pull_request.head.repo.full_name == github.repository && 'tp04-seaweed-block' || 'ubuntu-latest' }}
timeout-minutes: 5
steps:
- name: Checkout base
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
# github.sha is the tip of the base branch when the event fires; the
# PR's base.sha can predate this workflow's own scripts.
ref: ${{ github.sha }}
fetch-depth: 0
persist-credentials: false
- name: Check spec trace
env:
BASE: ${{ github.event.pull_request.base.sha }}
HEAD: ${{ github.event.pull_request.head.sha }}
PR: ${{ github.event.pull_request.number }}
BODY: ${{ github.event.pull_request.body }}
TITLE: ${{ github.event.pull_request.title }}
run: |
set -euo pipefail
bash .github/scripts/spec-trace-check-test.sh
python3 -B .github/scripts/model-trace-check-test.py
git fetch --no-tags origin "+refs/pull/${PR}/head:refs/remotes/pr/head"
printf '%s' "$BODY" >body.txt
bash .github/scripts/post-merge-review-changed.sh "$BASE" "$HEAD" >changed.bin
# Old and new blobs of each changed non-test Go file, for kind DOCS
# (objects only; nothing from the PR is built or run).
mb=$(git merge-base "$BASE" "$HEAD")
git diff --name-only --no-renames -z "$mb" "$HEAD" -- "*.go" ":(exclude)*_test.go" |
while IFS= read -r -d "" p; do
mkdir -p "blobs/old/$(dirname "$p")" "blobs/new/$(dirname "$p")"
git show "$mb:$p" >"blobs/old/$p" 2>/dev/null || rm -f "blobs/old/$p"
git show "$HEAD:$p" >"blobs/new/$p" 2>/dev/null || rm -f "blobs/new/$p"
done
mkdir -p blobs
# Mapping and validator come from the trusted base checkout above.
bash .github/scripts/spec-trace-check.sh body.txt blobs .github/model-code-trace.tsv <changed.bin
# Internal names stay out of this public repository: added lines,
# commit messages, title and description (no PR code is run).
bash .github/scripts/public-text-check-test.sh
printf '%s' "$TITLE" >title.txt
bash .github/scripts/public-text-check.sh "$mb" "$HEAD" title.txt body.txt