Files
goodwe-addon/.gitea/workflows/checks.yml
T
2026-09-01 03:18:19 +02:00

108 lines
3.8 KiB
YAML

# CI-02 PROBE WORKFLOW - THROWAWAY. This branch is deleted after the run.
#
# It replaces the real gate with a set of one-bit steps, because this Gitea
# 404s its Actions log endpoints and the ONLY machine-readable channel out of a
# job is /api/v1/repos/.../actions/runs/<id>/jobs, which carries a per-STEP
# conclusion. So each question this ticket has to answer is asked as its own
# step, and the answer is read as that step's success or failure.
#
# There is deliberately NO `concurrency:` block: the point of pushes B and C is
# to find out whether a still-WAITING run is cancelled by the next push even
# when the workflow asks for no concurrency at all. If it is, the cancellation
# is the server's and no edit to this file can prevent it.
name: checks
on:
pull_request:
branches: [release/1.0, master]
workflow_dispatch:
jobs:
unit:
runs-on: [self-hosted, goodwe-rig]
timeout-minutes: 20
env:
WS: /home/homelab/ci/ci02probe-${{ github.run_number }}
PRNUM: ${{ github.event.pull_request.number }}
PRHEAD: ${{ github.event.pull_request.head.sha }}
BASEREF: ${{ github.base_ref }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
URL: ${{ github.server_url }}/${{ github.repository }}.git
steps:
- name: P00 an empty clone to ask the server questions from
run: |
set -eu
rm -rf "$WS" && mkdir -p "$WS" && cd "$WS"
git init -q .
git remote add origin "$(echo "$URL" | sed "s#://#://x-access-token:${TOKEN}@#")"
echo "GITHUB_REF=$GITHUB_REF"
echo "GITHUB_SHA=$GITHUB_SHA"
echo "PRNUM=$PRNUM PRHEAD=$PRHEAD BASEREF=$BASEREF"
- name: P01 GITHUB_REF is refs-pull-N-head (the bare head)
if: always()
run: |
set -eu
test "$GITHUB_REF" = "refs/pull/$PRNUM/head"
- name: P02 GITHUB_REF is refs-pull-N-merge (merged content)
if: always()
run: |
set -eu
test "$GITHUB_REF" = "refs/pull/$PRNUM/merge"
- name: P03 GITHUB_SHA equals the PR head sha
if: always()
run: |
set -eu
test "$GITHUB_SHA" = "$PRHEAD"
- name: P04 the first half of the shipped fallback fetches at all
if: always()
run: |
set -eu
cd "$WS"
git fetch -q --depth 1 origin "$GITHUB_REF"
- name: P05 ...and what it lands on IS the bare PR head
if: always()
run: |
set -eu
cd "$WS"
git fetch -q --depth 1 origin "$GITHUB_REF"
test "$(git rev-parse FETCH_HEAD)" = "$PRHEAD"
- name: P06 refs-pull-N-merge exists on the server for an OPEN pr
if: always()
run: |
set -eu
cd "$WS"
git fetch -q --depth 1 origin "refs/pull/$PRNUM/merge"
- name: P07 a real merge of this head into the base tip applies cleanly
if: always()
run: |
set -eu
cd "$WS"
git fetch -q origin "+refs/heads/$BASEREF:refs/remotes/origin/base"
git fetch -q origin "+refs/pull/$PRNUM/head:refs/remotes/origin/pr"
git checkout -qf refs/remotes/origin/base
git -c user.email=ci@local -c user.name=ci merge --no-edit --no-ff refs/remotes/origin/pr
- name: P08 the base tip is already an ancestor of the head
if: always()
run: |
set -eu
cd "$WS"
git fetch -q origin "+refs/heads/$BASEREF:refs/remotes/origin/base"
git fetch -q origin "+refs/pull/$PRNUM/head:refs/remotes/origin/pr"
git merge-base --is-ancestor refs/remotes/origin/base refs/remotes/origin/pr
- name: P09 hold the single runner slot so the next push has to wait
if: always()
run: sleep 150
- name: P99 clean up
if: always()
run: rm -rf "$WS" || true