From 6b3e36c64c116ab2e04feca129cc2a20086c160f Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Thu, 18 Jun 2026 20:21:51 +0300 Subject: [PATCH 1/8] feat: support Windows runner by using platform-specific Python command and venv activate path - Use variable (python on Windows, python3 on Linux/macOS) - Use for correct venv activation path (venv/Scripts/activate on Windows, venv/bin/activate on Linux/macOS) - Keep DEB_PYTHON_INSTALL_LAYOUT Linux-specific The action now works on all three GitHub-hosted runner OSes: ubuntu-latest, macos-latest, and windows-latest. --- action.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/action.yml b/action.yml index 5fa3bce..0018a52 100644 --- a/action.yml +++ b/action.yml @@ -43,17 +43,25 @@ runs: - name: Install dependencies and run commit-check shell: bash run: | - if [[ "$RUNNER_OS" == "Linux" ]]; then - # https://github.com/pypa/setuptools/issues/3269 - export DEB_PYTHON_INSTALL_LAYOUT=deb + # Platform-specific settings + if [[ "$RUNNER_OS" == "Windows" ]]; then + PYTHON_CMD="python" + VENV_ACTIVATE="venv/Scripts/activate" + else + if [[ "$RUNNER_OS" == "Linux" ]]; then + # https://github.com/pypa/setuptools/issues/3269 + export DEB_PYTHON_INSTALL_LAYOUT=deb + fi + PYTHON_CMD="python3" + VENV_ACTIVATE="venv/bin/activate" fi # Set up virtual environment - python3 -m venv venv - source venv/bin/activate + $PYTHON_CMD -m venv venv + source "$VENV_ACTIVATE" # Download artifact - python3 -m pip download -r "$GITHUB_ACTION_PATH/requirements.txt" + $PYTHON_CMD -m pip download -r "$GITHUB_ACTION_PATH/requirements.txt" # Verify artifact attestations if ! gh attestation verify commit_check-*.whl -R commit-check/commit-check; then @@ -62,9 +70,9 @@ runs: fi # Install artifact - python3 -m pip install commit_check-*.whl pygithub-*.whl + $PYTHON_CMD -m pip install commit_check-*.whl pygithub-*.whl - python3 "$GITHUB_ACTION_PATH/main.py" + $PYTHON_CMD "$GITHUB_ACTION_PATH/main.py" env: MESSAGE: ${{ inputs.message }} BRANCH: ${{ inputs.branch }} From cb06023fb0e260b25bceb03088f1abf4a12b953e Mon Sep 17 00:00:00 2001 From: Xianpeng Shen Date: Thu, 18 Jun 2026 20:23:23 +0300 Subject: [PATCH 2/8] chore: Update subject_max_length to 100 Increase maximum subject length for commit messages. --- commit-check.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commit-check.toml b/commit-check.toml index 5eec90c..dc3b366 100644 --- a/commit-check.toml +++ b/commit-check.toml @@ -3,7 +3,7 @@ conventional_commits = true subject_capitalized = false subject_imperative = true -subject_max_length = 80 +subject_max_length = 100 subject_min_length = 5 allow_commit_types = ["feat", "fix", "docs", "style", "refactor", "test", "chore", "ci"] allow_merge_commits = true From 87165924d1081d39755102deb96f7eb20b93eb5f Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Thu, 18 Jun 2026 21:04:14 +0300 Subject: [PATCH 3/8] ci: add Windows runner to self-test matrix Run the self-test workflow on both ubuntu-latest and windows-latest to validate Windows compatibility. PR comments are only posted from the ubuntu job to avoid duplicates. --- .github/workflows/commit-check.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index f62c734..a1dbc89 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -8,8 +8,11 @@ on: jobs: commit-check: - runs-on: ubuntu-latest - permissions: # use permissions because of use pr-comments + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} + permissions: contents: read pull-requests: write steps: @@ -23,5 +26,6 @@ jobs: author-name: true author-email: true job-summary: true - pr-comments: ${{ github.event_name == 'pull_request' }} + # Only post PR comments from the ubuntu job to avoid duplicates + pr-comments: ${{ github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' }} pr-title: true From 338036b9473b61ab959cb10759548c355ea4a226 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Thu, 18 Jun 2026 21:06:53 +0300 Subject: [PATCH 4/8] fix: specify utf-8 encoding in all open() calls for Windows compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Windows, Python's default encoding is cp1252, which doesn't support Unicode characters like the ❌ emoji used in result messages. This caused UnicodeEncodeError when: 1. Reading GitHub event JSON files with UTF-8 content (get_pr_title, is_fork_pr, get_pr_number) 2. Writing job summary with emoji characters (add_job_summary) 3. Reading/writing result.txt with potential Unicode content Fixed all 7 open() calls to explicitly use encoding='utf-8'. --- main.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index b61241e..d8e58c2 100755 --- a/main.py +++ b/main.py @@ -72,7 +72,7 @@ def get_pr_title() -> str | None: if not event_path: return None try: - with open(event_path, "r") as f: + with open(event_path, "r", encoding="utf-8") as f: event = json.load(f) return event.get("pull_request", {}).get("title") except Exception as e: @@ -247,7 +247,7 @@ def run_commit_check() -> int: exit_code = 0 emitted_failure_output = False - with open("result.txt", "w") as result_file: + with open("result.txt", "w", encoding="utf-8") as result_file: # ---- 1. PR title check ------------------------------------------------ if PR_TITLE_ENABLED and is_pr_event(): pr_title = get_pr_title() @@ -286,7 +286,7 @@ def run_commit_check() -> int: def read_result_file() -> str | None: """Reads the result.txt file and removes ANSI color codes.""" if os.path.getsize("result.txt") > 0: - with open("result.txt", "r") as result_file: + with open("result.txt", "r", encoding="utf-8") as result_file: result_text = re.sub( r"\x1B\[[0-9;]*[a-zA-Z]", "", result_file.read() ) # Remove ANSI colors @@ -308,7 +308,7 @@ def add_job_summary() -> int: result_text = read_result_file() - with open(GITHUB_STEP_SUMMARY, "a") as summary_file: + with open(GITHUB_STEP_SUMMARY, "a", encoding="utf-8") as summary_file: summary_file.write(build_result_body(result_text)) return 0 if result_text is None else 1 @@ -320,7 +320,7 @@ def is_fork_pr() -> bool: if not event_path: return False try: - with open(event_path, "r") as f: + with open(event_path, "r", encoding="utf-8") as f: event = json.load(f) pr = event.get("pull_request", {}) head_full_name = pr.get("head", {}).get("repo", {}).get("full_name", "") @@ -357,7 +357,7 @@ def get_pr_number() -> int: event_path = os.getenv("GITHUB_EVENT_PATH") if event_path: try: - with open(event_path, "r") as f: + with open(event_path, "r", encoding="utf-8") as f: event = json.load(f) number = event.get("number") or (event.get("pull_request", {}) or {}).get( "number" @@ -389,7 +389,7 @@ def add_pr_comments() -> int: ) print(f"::warning::{msg}") if JOB_SUMMARY_ENABLED: - with open(GITHUB_STEP_SUMMARY, "a") as f: + with open(GITHUB_STEP_SUMMARY, "a", encoding="utf-8") as f: f.write( "\n---\n" "### \u2139\ufe0f PR Comment Skipped\n\n" From d352cb882eeca1411774462ab67b1ba7ed06c1dd Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Thu, 18 Jun 2026 21:08:30 +0300 Subject: [PATCH 5/8] fix: add encoding=utf-8 to subprocess.run in run_check_command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When text=True, subprocess.run uses the system default encoding (cp1252 on Windows) to encode stdin input. If commit messages contain Unicode characters outside cp1252 (e.g. ❌), the encoding fails with UnicodeEncodeError. The other two subprocess.run calls already had encoding='utf-8'. --- main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/main.py b/main.py index d8e58c2..9bb2187 100755 --- a/main.py +++ b/main.py @@ -165,6 +165,7 @@ def run_check_command( stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, + encoding="utf-8", check=False, ) if result.stdout: From a310be41cbbd116243996a3f945286979b7c9f45 Mon Sep 17 00:00:00 2001 From: Xianpeng Shen Date: Sun, 21 Jun 2026 18:04:56 +0300 Subject: [PATCH 6/8] ci: add macos-latest to self-test matrix and document cross-platform runner support Back the macOS support claim by running the self-test workflow on macos-latest in addition to ubuntu-latest and windows-latest, and add a README note that the action runs on Linux, macOS, and Windows runners. --- .github/workflows/commit-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index a1dbc89..4ef0eb3 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -10,7 +10,7 @@ jobs: commit-check: strategy: matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} permissions: contents: read From 9d72a58bccdae2290a6c39396276416bd9f5830b Mon Sep 17 00:00:00 2001 From: Xianpeng Shen Date: Sun, 21 Jun 2026 18:05:49 +0300 Subject: [PATCH 7/8] docs: note Linux, macOS, and Windows runner support in README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index ddfa6a6..e40ea44 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,9 @@ jobs: pr-comments: ${{ github.event_name == 'pull_request' }} ``` +> [!NOTE] +> This action runs on Linux, macOS, and Windows runners (`ubuntu-latest`, `macos-latest`, `windows-latest`). + ## Used By

From e7ed4b25d2a08d1a419718574635fbc5b90df235 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sun, 21 Jun 2026 15:39:54 +0000 Subject: [PATCH 8/8] docs: update cross-platform runner support note --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e40ea44..cbde04e 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ jobs: ``` > [!NOTE] -> This action runs on Linux, macOS, and Windows runners (`ubuntu-latest`, `macos-latest`, `windows-latest`). +> This action supports running on Linux, macOS, and Windows (`ubuntu-latest`, `macos-latest`, `windows-latest`). ## Used By