Update .gitea/workflows/kibot.yml
This commit is contained in:
@@ -98,34 +98,35 @@ jobs:
|
||||
|
||||
# Look for the layers section in the KiCad PCB file
|
||||
# Format: (layers (0 "F.Cu" signal) (4 "In1.Cu" signal) ...)
|
||||
layers_match = re.search(r'\(layers[^)]*\)', content, re.DOTALL)
|
||||
layers_section = re.search(r'\(layers\s*\n([^)]+)\)', content, re.MULTILINE | re.DOTALL)
|
||||
|
||||
if layers_match:
|
||||
layers_text = layers_match.group(0)
|
||||
# Find all layer definitions
|
||||
if layers_section:
|
||||
layers_text = layers_section.group(0)
|
||||
# Find all layer definitions - match the pattern (number "name" type)
|
||||
layer_matches = re.findall(r'\(\d+\s+"([^"]+)"\s+\w+\)', layers_text)
|
||||
|
||||
# Count copper layers
|
||||
copper_count = 0
|
||||
# Count copper layers - any layer with .Cu suffix
|
||||
copper_layers = []
|
||||
for layer in layer_matches:
|
||||
if '.Cu' in layer:
|
||||
copper_count += 1
|
||||
copper_layers.append(layer)
|
||||
print(f"Found copper layer: {layer}", file=sys.stderr)
|
||||
|
||||
if copper_count > 0:
|
||||
print(copper_count)
|
||||
else:
|
||||
# Fallback: count F.Cu, B.Cu, and In*.Cu layers
|
||||
copper_layers = [l for l in layer_matches if l in ['F.Cu', 'B.Cu'] or (l.startswith('In') and l.endswith('.Cu'))]
|
||||
print(len(copper_layers) if copper_layers else 2)
|
||||
print(len(copper_layers) if copper_layers else 2)
|
||||
else:
|
||||
# Old format fallback
|
||||
copper_layers = re.findall(r'layer\s+"([^"]+)".*?type\s+"?copper"?', content, re.DOTALL)
|
||||
if not copper_layers:
|
||||
copper_layers = re.findall(r'\(layer\s+([FB]\.Cu|In\d+\.Cu)\)', content)
|
||||
# Alternative: look for individual layer definitions
|
||||
all_layers = re.findall(r'\(\d+\s+"([^"]+\.Cu)"\s+\w+\)', content)
|
||||
if not all_layers:
|
||||
# Try another pattern
|
||||
all_layers = re.findall(r'"(F\.Cu|B\.Cu|In\d+\.Cu)"', content)
|
||||
|
||||
total = len(set(copper_layers)) if copper_layers else 2
|
||||
print(total)
|
||||
# Remove duplicates
|
||||
unique_layers = list(set(all_layers))
|
||||
|
||||
for layer in unique_layers:
|
||||
print(f"Found copper layer: {layer}", file=sys.stderr)
|
||||
|
||||
print(len(unique_layers) if unique_layers else 2)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error detecting layers: {e}", file=sys.stderr)
|
||||
@@ -133,15 +134,20 @@ jobs:
|
||||
PYTHON_SCRIPT
|
||||
|
||||
chmod +x /tmp/detect_layers.py
|
||||
LAYERS=$(python3 /tmp/detect_layers.py "$PCB_FILE" 2>/dev/null)
|
||||
if [ -z "$LAYERS" ]; then
|
||||
|
||||
# Run the detection and capture both stdout and stderr
|
||||
LAYERS=$(python3 /tmp/detect_layers.py "$PCB_FILE" 2>&1 | tee /tmp/layer_detection.log | grep -v "Found copper layer" | tail -1)
|
||||
|
||||
# Show debug output
|
||||
grep "Found copper layer" /tmp/layer_detection.log || true
|
||||
|
||||
if [ -z "$LAYERS" ] || [ "$LAYERS" = "0" ]; then
|
||||
LAYERS=2
|
||||
echo "Failed to detect layers, defaulting to 2"
|
||||
fi
|
||||
|
||||
echo "layers=$LAYERS" >> $GITHUB_OUTPUT
|
||||
echo "Auto-detected $LAYERS layer board"
|
||||
|
||||
# Debug: show what was detected
|
||||
python3 /tmp/detect_layers.py "$PCB_FILE" 2>&1 | grep "Found copper layer" || true
|
||||
fi
|
||||
|
||||
- name: Check for KiBot config
|
||||
|
||||
Reference in New Issue
Block a user