Repository navigation
ci: add PR status labels #971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yaythomas
wants to merge
1
commit into
main
Choose a base branch
from
ci/pr-status-labels
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+72
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import re | ||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| import pytest | ||
| import yaml | ||
|
|
||
| WORKFLOW_PATH = Path(__file__).parents[2] / "workflows" / "pr-status-labels.yml" | ||
| TEST_PARSER_PATH = Path(__file__).parents[2] / "workflows" / "test-parser.yml" | ||
|
|
||
|
|
||
| @pytest.fixture(name="workflow") | ||
| def workflow_fixture() -> dict[Any, Any]: | ||
| return yaml.safe_load(WORKFLOW_PATH.read_text()) | ||
|
|
||
|
|
||
| def test_runs_on_events_that_change_status(workflow: dict[Any, Any]) -> None: | ||
| # PyYAML reads the bare key `on` as the boolean True. | ||
| assert workflow[True] == { | ||
| "pull_request_target": { | ||
| "types": ["opened", "reopened", "ready_for_review", "synchronize"] | ||
| } | ||
| } | ||
|
|
||
|
|
||
| def test_calls_shared_workflow_pinned_to_commit(workflow: dict[Any, Any]) -> None: | ||
| uses = workflow["jobs"]["pr-status-labels"]["uses"] | ||
|
|
||
| assert re.fullmatch( | ||
| r"aws/aws-durable-execution-ci/\.github/workflows/pr-status-labels\.yml" | ||
| r"@[0-9a-f]{40}", | ||
| uses, | ||
| ) | ||
|
|
||
|
|
||
| def test_grants_only_label_permissions(workflow: dict[Any, Any]) -> None: | ||
| assert workflow["permissions"] == {} | ||
| assert workflow["jobs"]["pr-status-labels"]["permissions"] == { | ||
| "contents": "read", | ||
| "pull-requests": "write", | ||
| } | ||
|
|
||
|
|
||
| def test_passes_no_secrets(workflow: dict[Any, Any]) -> None: | ||
| # pull_request_target runs for fork pull requests with the base | ||
| # repository's token, so the job gets no secrets. | ||
| assert "secrets" not in workflow["jobs"]["pr-status-labels"] | ||
|
|
||
|
|
||
| def test_workflow_triggers_script_tests() -> None: | ||
| parser = yaml.safe_load(TEST_PARSER_PATH.read_text()) | ||
| path = ".github/workflows/pr-status-labels.yml" | ||
|
|
||
| assert path in parser[True]["pull_request"]["paths"] | ||
| assert path in parser[True]["push"]["paths"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| name: PR Status Labels | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: [opened, reopened, ready_for_review, synchronize] | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| pr-status-labels: | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| uses: aws/aws-durable-execution-ci/.github/workflows/pr-status-labels.yml@c28fdc7df300996309e282ee6bfe54658ba53351 # v0.7.0 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.