Skip to content

Commit 8ac4618

Browse files
committed
Document PR preview retries and test label routing
1 parent ea384d6 commit 8ac4618

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

‎CONTRIBUTING.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ to open pull requests whose branches belong to this repository.
4040
The workflow reacts when the label is added; pushing another commit while the
4141
label remains on the pull request does not publish a new preview. To publish the
4242
new pull request head or retry a failed publication, remove `publish-preview`
43-
and apply it again.
43+
and apply it again. GitHub skips the workflow when the pull request has merge
44+
conflicts. Resolve the conflicts before reapplying the label.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""Regression checks for the preview workflow's event routing configuration."""
2+
3+
import re
4+
from pathlib import Path
5+
6+
WORKFLOW = Path(__file__).resolve().parents[2] / ".github/workflows/pr-preview.yml"
7+
8+
9+
def test_preview_is_triggered_only_by_pull_request_label_events():
10+
workflow = WORKFLOW.read_text(encoding="utf-8")
11+
trigger = re.search(r"^on:\n(.*?)(?=^\S|\Z)", workflow, re.MULTILINE | re.DOTALL)
12+
13+
assert trigger is not None
14+
assert trigger.group(1).split() == ["pull_request:", "types:", "[labeled]"]
15+
16+
17+
def test_preview_context_requires_the_preview_label_and_a_same_repository_pr():
18+
workflow = WORKFLOW.read_text(encoding="utf-8")
19+
condition = re.search(
20+
r"^ context:\n if: >-\n((?: {6}[^\n]+\n)+)", workflow, re.MULTILINE
21+
)
22+
23+
assert condition is not None
24+
assert " ".join(condition.group(1).split()) == (
25+
"github.event.label.name == 'publish-preview' && "
26+
"github.event.pull_request.head.repo.full_name == github.repository"
27+
)

0 commit comments

Comments
 (0)