mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 10:22:50 +00:00 
			
		
		
		
	Add GitHub Actions workflow to validate JSON files in the frontend directory (#6152)
* Add GitHub Actions workflow to validate JSON files in the frontend directory * test new github workflow by invalidating script * Revalidate json script to also test workflow * Refactor GitHub Actions workflow to validate JSON files using Python. * test github workflow * Update description in apache-tomcat.json for clarity and consistency. * Consolidate JSON validation workflow: Migrate test-jsons.yml functionality into frontend-cicd.yml, enhancing CI process by validating JSON files in the public directory with Python. * test to see if workflow fails * test to see if workflow passes * testing * testing to see if workflow runs and works * test again * testing to see if it works
This commit is contained in:
		
							
								
								
									
										81
									
								
								.github/workflows/frontend-cicd.yml
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										81
									
								
								.github/workflows/frontend-cicd.yml
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -24,12 +24,87 @@ concurrency:
 | 
			
		||||
  cancel-in-progress: false
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  build:
 | 
			
		||||
    if: github.repository == 'community-scripts/ProxmoxVE'
 | 
			
		||||
  test-json-files:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    defaults:
 | 
			
		||||
      run:
 | 
			
		||||
        working-directory: frontend  # Set default working directory for all run steps
 | 
			
		||||
        working-directory: frontend
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Checkout repository
 | 
			
		||||
        uses: actions/checkout@v4
 | 
			
		||||
 | 
			
		||||
      - name: Setup Python
 | 
			
		||||
        uses: actions/setup-python@v4
 | 
			
		||||
        with:
 | 
			
		||||
          python-version: "3.x"
 | 
			
		||||
 | 
			
		||||
      - name: Test JSON files
 | 
			
		||||
        run: |
 | 
			
		||||
          python3 << 'EOF'
 | 
			
		||||
          import json
 | 
			
		||||
          import glob
 | 
			
		||||
          import os
 | 
			
		||||
          import sys
 | 
			
		||||
 | 
			
		||||
          def test_json_files():
 | 
			
		||||
              # Change to the correct directory
 | 
			
		||||
              json_dir = "public/json"
 | 
			
		||||
              if not os.path.exists(json_dir):
 | 
			
		||||
                  print(f"❌ Directory not found: {json_dir}")
 | 
			
		||||
                  return False
 | 
			
		||||
              
 | 
			
		||||
              # Find all JSON files
 | 
			
		||||
              pattern = os.path.join(json_dir, "*.json")
 | 
			
		||||
              json_files = glob.glob(pattern)
 | 
			
		||||
              
 | 
			
		||||
              if not json_files:
 | 
			
		||||
                  print(f"⚠️  No JSON files found in {json_dir}")
 | 
			
		||||
                  return True
 | 
			
		||||
              
 | 
			
		||||
              print(f"Testing {len(json_files)} JSON files for valid syntax...")
 | 
			
		||||
              
 | 
			
		||||
              invalid_files = []
 | 
			
		||||
              
 | 
			
		||||
              for file_path in json_files:
 | 
			
		||||
                  try:
 | 
			
		||||
                      with open(file_path, 'r', encoding='utf-8') as f:
 | 
			
		||||
                          json.load(f)
 | 
			
		||||
                      print(f"✅ Valid JSON: {file_path}")
 | 
			
		||||
                  except json.JSONDecodeError as e:
 | 
			
		||||
                      print(f"❌ Invalid JSON syntax in: {file_path}")
 | 
			
		||||
                      print(f"   Error: {e}")
 | 
			
		||||
                      invalid_files.append(file_path)
 | 
			
		||||
                  except Exception as e:
 | 
			
		||||
                      print(f"⚠️  Error reading: {file_path}")
 | 
			
		||||
                      print(f"   Error: {e}")
 | 
			
		||||
                      invalid_files.append(file_path)
 | 
			
		||||
              
 | 
			
		||||
              print("\n=== JSON Validation Summary ===")
 | 
			
		||||
              print(f"Total files tested: {len(json_files)}")
 | 
			
		||||
              print(f"Valid files: {len(json_files) - len(invalid_files)}")
 | 
			
		||||
              print(f"Invalid files: {len(invalid_files)}")
 | 
			
		||||
              
 | 
			
		||||
              if invalid_files:
 | 
			
		||||
                  print("\n❌ Found invalid JSON file(s):")
 | 
			
		||||
                  for file_path in invalid_files:
 | 
			
		||||
                      print(f"  - {file_path}")
 | 
			
		||||
                  return False
 | 
			
		||||
              else:
 | 
			
		||||
                  print("\n✅ All JSON files have valid syntax!")
 | 
			
		||||
                  return True
 | 
			
		||||
 | 
			
		||||
          if __name__ == "__main__":
 | 
			
		||||
              success = test_json_files()
 | 
			
		||||
              sys.exit(0 if success else 1)
 | 
			
		||||
          EOF
 | 
			
		||||
  
 | 
			
		||||
  build:
 | 
			
		||||
    if: github.repository == 'community-scripts/ProxmoxVE'
 | 
			
		||||
    needs: test-json-files
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    defaults:
 | 
			
		||||
      run:
 | 
			
		||||
        working-directory: frontend
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Checkout
 | 
			
		||||
        uses: actions/checkout@v4
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user