Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/github-shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
issues: read
steps:
- uses: $/.github/actions/check-github-config
with:
Expand Down
10 changes: 10 additions & 0 deletions test/test_github_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import unittest
from pathlib import Path

import yaml

BASELINE_ROOT = Path(__file__).parent.parent
SPEC = importlib.util.spec_from_file_location(
"check_github_config", BASELINE_ROOT / ".github" / "actions" / "check-github-config" / "check.py"
Expand Down Expand Up @@ -43,6 +45,14 @@ def test_loads_repository_config(self):
"Pull requests that update a dependency file",
)

def test_shared_workflow_grants_permissions_for_repository_and_label_checks(self):
with open(BASELINE_ROOT / ".github" / "workflows" / "github-shared.yml") as workflow_file:
workflow = yaml.safe_load(workflow_file)

permissions = workflow["jobs"]["github-config-check"]["permissions"]

self.assertEqual(permissions, {"contents": "read", "issues": "read"})

def test_rejects_invalid_repository_config(self):
with tempfile.NamedTemporaryFile(mode="w", suffix=".yml") as config:
config.write("config:\n invalid-field: false\n")
Expand Down