mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	In the past, some API documentation changes were merged with unresolved placeholders like "ZF-..." instead of actual feature level numbers. This commit introduces a GitHub Action that scans the API docs for any occurrence of "ZF-". If found, it will fail the CI check and block the commit from being merged into main. This ensures that all feature level references are properly updated before merging.
		
			
				
	
	
		
			32 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env python3
 | 
						|
import os
 | 
						|
import sys
 | 
						|
from pathlib import Path
 | 
						|
 | 
						|
 | 
						|
def get_build_url_from_environment() -> str:
 | 
						|
    server = os.environ["GITHUB_SERVER_URL"]
 | 
						|
    repo = os.environ["GITHUB_REPOSITORY"]
 | 
						|
    run_id = os.environ["GITHUB_RUN_ID"]
 | 
						|
    return f"{server}/{repo}/actions/runs/{run_id}"
 | 
						|
 | 
						|
 | 
						|
if __name__ == "__main__":
 | 
						|
    branch = os.environ.get("GITHUB_REF", "unknown branch").split("/")[-1]
 | 
						|
    topic = f"{branch} failing"
 | 
						|
    build_url = get_build_url_from_environment()
 | 
						|
    github_actor = os.environ.get("GITHUB_ACTOR", "unknown user")
 | 
						|
 | 
						|
    api_docs_folder = Path("api_docs")
 | 
						|
    api_docs_paths = list(api_docs_folder.glob("*.md"))
 | 
						|
    api_docs_paths.append(Path("zerver/openapi/zulip.yaml"))
 | 
						|
 | 
						|
    for api_docs_path in api_docs_paths:
 | 
						|
        with open(api_docs_path) as file:
 | 
						|
            if "ZF-" in file.read():
 | 
						|
                content = f"[Build]({build_url}) triggered by {github_actor} on branch `{branch}` has failed: Feature level not replaced in '{api_docs_path}'."
 | 
						|
                print(f"fail=true\ntopic={topic}\ncontent={content}")
 | 
						|
                sys.exit(0)
 | 
						|
 | 
						|
    print("fail=false")
 |