File tree Expand file tree Collapse file tree 4 files changed +108
-1
lines changed Expand file tree Collapse file tree 4 files changed +108
-1
lines changed Original file line number Diff line number Diff line change 1+ #  Configuration for Release Drafter: https://github.com/toolmantim/release-drafter
12_extends : .github 
3+ 
4+ #  Override the template to include default tool versions
5+ template : | 
6+   <!-- Optional: add a release summary here --> 
7+    
8+   ## Default Tool Versions 
9+    
10+   This release uses the following default versions: 
11+   - **clang-format**: `$CLANG_FORMAT_VERSION` 
12+   - **clang-tidy**: `$CLANG_TIDY_VERSION` 
13+    
14+   Users can override these versions by specifying a different version in their hook configuration. 
15+    
16+   $CHANGES 
17+ 
18+   **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION 
Original file line number Diff line number Diff line change 88
99jobs :
1010  draft-release :
11-     uses : cpp-linter/.github/.github/workflows/release-drafter.yml@main 
11+     permissions :
12+       #  write permission is required to create a github release
13+       contents : write 
14+       #  write permission is required for autolabeler
15+       #  otherwise, read permission is required at least
16+       pull-requests : write 
17+     runs-on : ubuntu-latest 
18+     steps :
19+       - name : Checkout repository 
20+         uses : actions/checkout@v4 
21+         
22+       - name : Set up Python 
23+         uses : actions/setup-python@v5 
24+         with :
25+           python-version : " 3.12" 
26+           
27+       - name : Install dependencies 
28+         run : | 
29+           python -m pip install --upgrade pip 
30+           python -m pip install -e . 
31+            
32+        - name : Extract default tool versions 
33+         id : versions 
34+         run : | 
35+           CLANG_FORMAT_VERSION=$(python -c "from cpp_linter_hooks.util import DEFAULT_CLANG_FORMAT_VERSION; print(DEFAULT_CLANG_FORMAT_VERSION)") 
36+           CLANG_TIDY_VERSION=$(python -c "from cpp_linter_hooks.util import DEFAULT_CLANG_TIDY_VERSION; print(DEFAULT_CLANG_TIDY_VERSION)") 
37+           echo "CLANG_FORMAT_VERSION=$CLANG_FORMAT_VERSION" >> $GITHUB_OUTPUT 
38+           echo "CLANG_TIDY_VERSION=$CLANG_TIDY_VERSION" >> $GITHUB_OUTPUT 
39+           echo "Default clang-format version: $CLANG_FORMAT_VERSION" 
40+           echo "Default clang-tidy version: $CLANG_TIDY_VERSION" 
41+          
42+        #  Draft your next Release notes as Pull Requests are merged into the default branch
43+       - uses : release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5  # v6
44+         with :
45+           commitish : ' main' 
46+         env :
47+           GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} 
48+           CLANG_FORMAT_VERSION : ${{ steps.versions.outputs.CLANG_FORMAT_VERSION }} 
49+           CLANG_TIDY_VERSION : ${{ steps.versions.outputs.CLANG_TIDY_VERSION }} 
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3 
2+ """Script to extract default clang-format and clang-tidy versions from pyproject.toml.""" 
3+ 
4+ import  sys 
5+ from  pathlib  import  Path 
6+ 
7+ # Add the project root to Python path 
8+ project_root  =  Path (__file__ ).parent .parent 
9+ sys .path .insert (0 , str (project_root ))
10+ 
11+ from  cpp_linter_hooks .util  import  DEFAULT_CLANG_FORMAT_VERSION , DEFAULT_CLANG_TIDY_VERSION 
12+ 
13+ def  main ():
14+     """Print the default tool versions.""" 
15+     print (f"Default clang-format version: { DEFAULT_CLANG_FORMAT_VERSION }  " )
16+     print (f"Default clang-tidy version: { DEFAULT_CLANG_TIDY_VERSION }  " )
17+     
18+     # Also output in a format suitable for GitHub Actions 
19+     print (f"CLANG_FORMAT_VERSION={ DEFAULT_CLANG_FORMAT_VERSION }  " )
20+     print (f"CLANG_TIDY_VERSION={ DEFAULT_CLANG_TIDY_VERSION }  " )
21+ 
22+ if  __name__  ==  "__main__" :
23+     main ()
Original file line number Diff line number Diff line change @@ -262,6 +262,35 @@ def test_version_lists_not_empty():
262262    assert  all (isinstance (v , str ) for  v  in  CLANG_TIDY_VERSIONS )
263263
264264
265+ @pytest .mark .benchmark  
266+ def  test_get_default_versions_script ():
267+     """Test that the get_default_versions script works correctly.""" 
268+     import  subprocess 
269+     import  sys 
270+     from  pathlib  import  Path 
271+     
272+     script_path  =  Path (__file__ ).parent .parent  /  "scripts"  /  "get_default_versions.py" 
273+     assert  script_path .exists (), "get_default_versions.py script should exist" 
274+     
275+     result  =  subprocess .run (
276+         [sys .executable , str (script_path )], 
277+         capture_output = True , 
278+         text = True 
279+     )
280+     
281+     assert  result .returncode  ==  0 , f"Script failed with: { result .stderr }  " 
282+     output_lines  =  result .stdout .strip ().split ('\n ' )
283+     
284+     # Should have 4 lines of output 
285+     assert  len (output_lines ) >=  4 
286+     
287+     # Check that it contains expected format 
288+     assert  any (line .startswith ("Default clang-format version:" ) for  line  in  output_lines )
289+     assert  any (line .startswith ("Default clang-tidy version:" ) for  line  in  output_lines )
290+     assert  any (line .startswith ("CLANG_FORMAT_VERSION=" ) for  line  in  output_lines )
291+     assert  any (line .startswith ("CLANG_TIDY_VERSION=" ) for  line  in  output_lines )
292+ 
293+ 
265294@pytest .mark .benchmark  
266295def  test_resolve_install_with_none_default_version ():
267296    """Test _resolve_install when DEFAULT versions are None.""" 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments