diff --git a/.github/workflows/auto-label.yml b/.github/workflows/auto-label.yml index 8570cfe7e..4b0ed17d0 100644 --- a/.github/workflows/auto-label.yml +++ b/.github/workflows/auto-label.yml @@ -2,6 +2,8 @@ name: Auto Label on: pull_request: types: [opened, reopened, synchronized] +permissions: + pull-requests: write jobs: label: runs-on: ubuntu-latest diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 9abb9b837..f1e9c3bdb 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -4,6 +4,7 @@ on: types: [opened, reopened, synchronize, edited] permissions: issues: write + pull-requests: write jobs: validate: runs-on: ubuntu-latest @@ -17,7 +18,7 @@ jobs: if (pr.title.length < 10) { issues.push('❌ PR title too short (minimum 10 characters)'); } - if (!/^(feat|fix|docs|style|refactor|test|chore|perf|ci|build|revert)(\(.+\))?:/.test(pr.title)) { + if (!/^(?:[\p{Emoji}\u200d\s\W]+)?(feat|fix|docs|style|refactor|test|chore|perf|ci|build|revert)(\(.+\))?[:\]\s]/iu.test(pr.title)) { issues.push('⚠️ PR title should follow conventional commits format'); } diff --git a/tests/testing/test_video_utils.py b/tests/testing/test_video_utils.py index 06febc2b3..e6079c800 100644 --- a/tests/testing/test_video_utils.py +++ b/tests/testing/test_video_utils.py @@ -105,6 +105,38 @@ def test_non_string(self): """Test with non-string value""" assert is_valid_video_id(12345678901) is False + def test_exact_length_with_whitespace(self): + """Test 11-character string with whitespace""" + assert is_valid_video_id("auJzb1D fag") is False + assert is_valid_video_id("auJzb\tD-fag") is False + assert is_valid_video_id("auJzb\nD-fag") is False + + def test_exact_length_with_special_chars(self): + """Test 11-character string with invalid special characters""" + assert is_valid_video_id("auJzb1D*fag") is False + assert is_valid_video_id("auJzb1D@fag") is False + assert is_valid_video_id("auJzb1D.fag") is False + assert is_valid_video_id("auJzb1D/fag") is False + + def test_boundary_lengths(self): + """Test lengths exactly at the boundaries""" + assert is_valid_video_id("1234567890") is False # 10 chars + assert is_valid_video_id("123456789012") is False # 12 chars + assert is_valid_video_id("12345678901") is True # 11 chars (all numbers) + assert is_valid_video_id("-----------") is True # 11 chars (all hyphens) + assert is_valid_video_id("___________") is True # 11 chars (all underscores) + + def test_leading_trailing_whitespace(self): + """Test valid IDs with leading or trailing whitespace""" + assert is_valid_video_id(" auJzb1D-fag") is False + assert is_valid_video_id("auJzb1D-fag ") is False + assert is_valid_video_id("\tauJzb1D-fag\n") is False + + def test_url_instead_of_id(self): + """Test full URLs (should fail as it expects only the ID)""" + assert is_valid_video_id("https://www.youtube.com/watch?v=auJzb1D-fag") is False + assert is_valid_video_id("youtube.com/watch?v=auJzb1D") is False + class TestNormalizeVideoUrl: """Tests for normalize_video_url function"""