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
6 changes: 3 additions & 3 deletions scripts/workflow_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
DEPRECATED_ACTIONS = {
"actions/checkout@v2": "actions/checkout@v4",
"actions/checkout@v3": "actions/checkout@v4",
"actions/upload-artifact@v2": "actions/upload-artifact@v6",
"actions/upload-artifact@v3": "actions/upload-artifact@v6",
"actions/upload-artifact@v2": "actions/upload-artifact@v7",
"actions/upload-artifact@v3": "actions/upload-artifact@v7",
"actions/download-artifact@v2": "actions/download-artifact@v7",
"actions/download-artifact@v3": "actions/download-artifact@v7",
}
Expand Down Expand Up @@ -87,7 +87,7 @@ def check_missing_timeout(workflow: dict) -> list[str]:


def check_upload_artifact_major(
workflow: dict, expected_major: int = 6
workflow: dict, expected_major: int = 7
) -> list[tuple[str, str, str]]:
"""Check that actions/upload-artifact uses the expected major version.

Expand Down
5 changes: 5 additions & 0 deletions templates/consumer-repo/.github/workflows/pr-00-gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ jobs:
with:

token: ${{ steps.app_token.outputs.token || github.token }}
persist-credentials: false

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep credentials for path classification fetches

In private consumer repos, this detect checkout is the one immediately used by .github/actions/path-classifier, which runs git fetch origin <base> and then git diff against the fetched base; with persist-credentials: false, checkout no longer leaves the token available for those authenticated git commands, so the fetch/diff failures are swallowed and the classifier returns no changed files. That makes steps.classify.outputs.is-python-code the literal string false, and the later python-ci job condition skips the entire Python CI leg for code PRs while the API diff still lets Gate continue. Keep credentials for this checkout or teach the classifier to fetch with an explicit token/fail closed.

Useful? React with 👍 / 👎.

repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.head.sha || github.sha }}
sparse-checkout: |
Expand Down Expand Up @@ -206,6 +207,7 @@ jobs:
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
Expand Down Expand Up @@ -239,6 +241,7 @@ jobs:
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Detect optional script test suites
Expand Down Expand Up @@ -343,6 +346,7 @@ jobs:
with:
fetch-depth: 0
token: ${{ steps.app_token.outputs.token || github.token }}
persist-credentials: false
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.head.sha || github.sha }}

Expand Down Expand Up @@ -407,6 +411,7 @@ jobs:
with:

token: ${{ steps.app_token.outputs.token || github.token }}
persist-credentials: false
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.head.sha || github.sha }}
sparse-checkout: |
Expand Down
12 changes: 6 additions & 6 deletions tests/test_workflow_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,34 +121,34 @@ class TestCheckUploadArtifactMajor:
"""Tests for check_upload_artifact_major function."""

def test_accepts_expected_major(self) -> None:
"""Test that v6 is accepted."""
"""Test that v7 is accepted."""
workflow = {
"jobs": {"build": {"steps": [{"name": "Upload", "uses": "actions/upload-artifact@v6"}]}}
"jobs": {"build": {"steps": [{"name": "Upload", "uses": "actions/upload-artifact@v7"}]}}
}

issues = check_upload_artifact_major(workflow)
assert issues == []

def test_accepts_expected_major_with_patch(self) -> None:
"""Test that v6.x.y is accepted."""
"""Test that v7.x.y is accepted."""
workflow = {
"jobs": {
"build": {"steps": [{"name": "Upload", "uses": "actions/upload-artifact@v6.1.2"}]}
"build": {"steps": [{"name": "Upload", "uses": "actions/upload-artifact@v7.0.1"}]}
}
}

issues = check_upload_artifact_major(workflow)
assert issues == []

def test_flags_other_major(self) -> None:
"""Test that non-v6 major versions are flagged."""
"""Test that non-v7 major versions are flagged."""
workflow = {
"jobs": {"build": {"steps": [{"name": "Upload", "uses": "actions/upload-artifact@v4"}]}}
}

issues = check_upload_artifact_major(workflow)
assert len(issues) == 1
assert "v6" in issues[0][2]
assert "v7" in issues[0][2]

def test_ignores_other_actions(self) -> None:
"""Test that unrelated actions are ignored."""
Expand Down
Loading