Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content
Draft
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
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
- release/*
- release-*

permissions:
contents: read

jobs:
build:
name: Build
Expand Down Expand Up @@ -37,6 +40,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Rust Tool Chain setup
uses: dtolnay/rust-toolchain@7e38f4b43b4db5c8dd498af069a4f6196df1d067 # v1
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
- release-*

permissions:
actions: read
contents: read
pull-requests: write

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Rust Tool Chain setup
uses: dtolnay/rust-toolchain@7e38f4b43b4db5c8dd498af069a4f6196df1d067 # v1
Expand All @@ -40,6 +42,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Rust Tool Chain setup
uses: dtolnay/rust-toolchain@7e38f4b43b4db5c8dd498af069a4f6196df1d067 # v1
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/perf-baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Set Python to PATH
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/perf-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ on:
workflow_dispatch:

permissions:
actions: read
contents: read
pull-requests: write

Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ on:
- release-*
workflow_dispatch:

permissions:
contents: read

jobs:
tests:
# Very generic tests, we don't verify whether the envs are discovered correctly or not.
Expand Down Expand Up @@ -43,6 +46,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Set Python to PATH
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
Expand Down Expand Up @@ -257,6 +262,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

# region Setup Poetry
- name: Set Python 3.x to PATH
Expand Down Expand Up @@ -423,6 +430,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

# Homebrew
- name: Homebrew Python
Expand Down Expand Up @@ -486,6 +495,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Rust Tool Chain setup
uses: dtolnay/rust-toolchain@7e38f4b43b4db5c8dd498af069a4f6196df1d067 # v1
Expand Down
31 changes: 31 additions & 0 deletions scripts/tests/test_quality_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,37 @@ def test_comment_steps_are_fork_safe_and_non_gating(self) -> None:
),
)

def test_workflow_tokens_have_only_required_permissions(self) -> None:
for workflow, expected in (
("build.yml", {"contents": "read"}),
("pr-check.yml", {"contents": "read"}),
("coverage.yml", {"contents": "read", "pull-requests": "write"}),
("perf-tests.yml", {"contents": "read", "pull-requests": "write"}),
):
with self.subTest(workflow=workflow):
text = (ROOT / ".github" / "workflows" / workflow).read_text(encoding="utf-8")
match = re.search(
r"(?m)^permissions:\n((?: [a-z-]+: [a-z]+\n)+)", text
)
self.assertIsNotNone(match)
assert match is not None
self.assertEqual(
dict(re.findall(r"(?m)^ ([a-z-]+): ([a-z]+)$", match.group(1))),
expected,
)

def test_checkout_tokens_are_not_persisted_after_fetch(self) -> None:
for workflow in ("build.yml", "lint.yml", "perf-baseline.yml", "pr-check.yml"):
text = (ROOT / ".github" / "workflows" / workflow).read_text(encoding="utf-8")
checkouts = [
step for step in re.split(r"(?m)^ - name: ", text)[1:]
if re.search(r"(?m)^ uses: actions/checkout@", step)
]
with self.subTest(workflow=workflow):
self.assertTrue(checkouts)
for checkout in checkouts:
self.assertRegex(checkout, r"(?m)^ persist-credentials: false$")

def test_coverage_proof_and_source_reports_are_required_and_uploaded(self) -> None:
for workflow in ("coverage.yml", "coverage-baseline.yml", "coverage-macos.yml"):
with self.subTest(workflow=workflow):
Expand Down
Loading