File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,4 +40,5 @@ to open pull requests whose branches belong to this repository.
4040The workflow reacts when the label is added; pushing another commit while the
4141label remains on the pull request does not publish a new preview. To publish the
4242new 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.
Original file line number Diff line number Diff line change 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+ )
You can’t perform that action at this time.
0 commit comments