simplified workflow
This commit is contained in:
@@ -1,38 +1,34 @@
|
|||||||
name: "KiBot PCB Generation with Multi-layer Support"
|
name: "KiBot PCB Generation"
|
||||||
|
|
||||||
# Controls when the action will run. Triggers the workflow on push or pull request
|
# Controls when the action will run
|
||||||
# events but only for the master branch
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
- '**/*.kicad_sch'
|
- '**/*.kicad_sch'
|
||||||
- '**/*.kicad_pcb'
|
- '**/*.kicad_pcb'
|
||||||
- '**/*.kicad_pro'
|
- '**/*.kicad_pro'
|
||||||
- '**/*.kibot.yaml'
|
- 'kibot.yaml'
|
||||||
- '**/kibot.yaml'
|
|
||||||
- '.gitea/workflows/*.yml'
|
- '.gitea/workflows/*.yml'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- '**/*.kicad_sch'
|
- '**/*.kicad_sch'
|
||||||
- '**/*.kicad_pcb'
|
- '**/*.kicad_pcb'
|
||||||
- '**/*.kicad_pro'
|
- '**/*.kicad_pro'
|
||||||
- '**/*.kibot.yaml'
|
- 'kibot.yaml'
|
||||||
- '**/kibot.yaml'
|
|
||||||
- '.gitea/workflows/*.yml'
|
- '.gitea/workflows/*.yml'
|
||||||
repository_dispatch:
|
repository_dispatch:
|
||||||
types: [run_qs]
|
types: [run_qs]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
board_layers:
|
board_layers:
|
||||||
description: 'Number of PCB layers (auto-detect if not specified)'
|
description: 'Number of PCB layers'
|
||||||
required: false
|
required: false
|
||||||
default: 'auto'
|
default: '2'
|
||||||
type: choice
|
type: choice
|
||||||
options:
|
options:
|
||||||
- auto
|
- '2'
|
||||||
- 2
|
- '4'
|
||||||
- 4
|
- '6'
|
||||||
- 6
|
|
||||||
|
|
||||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||||
jobs:
|
jobs:
|
||||||
@@ -77,128 +73,38 @@ jobs:
|
|||||||
echo "All PCB files found:"
|
echo "All PCB files found:"
|
||||||
echo "$PCB_FILES"
|
echo "$PCB_FILES"
|
||||||
|
|
||||||
- name: Detect layer count
|
- name: Set layer count
|
||||||
id: layers
|
id: layers
|
||||||
run: |
|
run: |
|
||||||
PCB_FILE="${{ steps.find_project.outputs.pcb_file }}"
|
# Use workflow input or default to 2 layers
|
||||||
if [ "${{ github.event.inputs.board_layers }}" != "" ] && [ "${{ github.event.inputs.board_layers }}" != "auto" ]; then
|
LAYERS="${{ github.event.inputs.board_layers }}"
|
||||||
echo "layers=${{ github.event.inputs.board_layers }}" >> $GITHUB_OUTPUT
|
if [ -z "$LAYERS" ]; then
|
||||||
echo "Using manually specified ${{ github.event.inputs.board_layers }} layer configuration"
|
LAYERS="2"
|
||||||
else
|
|
||||||
# Create Python script to detect layers
|
|
||||||
cat > /tmp/detect_layers.py << 'PYTHON_SCRIPT'
|
|
||||||
#!/usr/bin/env python3
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
|
|
||||||
try:
|
|
||||||
pcb_file = sys.argv[1]
|
|
||||||
with open(pcb_file, 'r') as f:
|
|
||||||
content = f.read()
|
|
||||||
|
|
||||||
# Look for the layers section in the KiCad PCB file
|
|
||||||
# Format: (layers (0 "F.Cu" signal) (4 "In1.Cu" signal) ...)
|
|
||||||
layers_section = re.search(r'\(layers\s*\n([^)]+)\)', content, re.MULTILINE | re.DOTALL)
|
|
||||||
|
|
||||||
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 - any layer with .Cu suffix
|
|
||||||
copper_layers = []
|
|
||||||
for layer in layer_matches:
|
|
||||||
if '.Cu' in layer:
|
|
||||||
copper_layers.append(layer)
|
|
||||||
print(f"Found copper layer: {layer}", file=sys.stderr)
|
|
||||||
|
|
||||||
print(len(copper_layers) if copper_layers else 2)
|
|
||||||
else:
|
|
||||||
# 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)
|
|
||||||
|
|
||||||
# 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)
|
|
||||||
print(2) # Default to 2 layers
|
|
||||||
PYTHON_SCRIPT
|
|
||||||
|
|
||||||
chmod +x /tmp/detect_layers.py
|
|
||||||
|
|
||||||
# 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"
|
|
||||||
fi
|
fi
|
||||||
|
echo "layers=$LAYERS" >> $GITHUB_OUTPUT
|
||||||
|
echo "Using $LAYERS layer configuration"
|
||||||
|
|
||||||
- name: Check for KiBot config
|
- name: Check for KiBot config
|
||||||
id: config_check
|
id: config_check
|
||||||
run: |
|
run: |
|
||||||
PROJECT_DIR="${{ steps.find_project.outputs.project_dir }}"
|
# Check if kibot.yaml exists in repository root
|
||||||
|
if [ -f "kibot.yaml" ]; then
|
||||||
# Search for kibot config in multiple locations
|
|
||||||
if [ -f "$PROJECT_DIR/kibot.yaml" ]; then
|
|
||||||
echo "found=true" >> $GITHUB_OUTPUT
|
echo "found=true" >> $GITHUB_OUTPUT
|
||||||
echo "config_path=$PROJECT_DIR/kibot.yaml" >> $GITHUB_OUTPUT
|
echo "Using kibot.yaml configuration from repository root"
|
||||||
echo "Using project-specific kibot.yaml"
|
|
||||||
elif [ -f "$PROJECT_DIR/../kibot.yaml" ]; then
|
|
||||||
echo "found=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "config_path=$PROJECT_DIR/../kibot.yaml" >> $GITHUB_OUTPUT
|
|
||||||
echo "Using parent directory kibot.yaml"
|
|
||||||
elif [ -f "kibot.yaml" ]; then
|
|
||||||
echo "found=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "config_path=kibot.yaml" >> $GITHUB_OUTPUT
|
|
||||||
echo "Using root kibot.yaml"
|
|
||||||
elif [ -f ".kibot/config.yaml" ]; then
|
|
||||||
echo "found=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "config_path=.kibot/config.yaml" >> $GITHUB_OUTPUT
|
|
||||||
echo "Using .kibot/config.yaml"
|
|
||||||
else
|
else
|
||||||
echo "found=false" >> $GITHUB_OUTPUT
|
echo "found=false" >> $GITHUB_OUTPUT
|
||||||
echo "Using --quick-start mode (no custom config found)"
|
echo "No kibot.yaml found in repository root - will use --quick-start mode"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Run ERC
|
- name: Run ERC
|
||||||
if: steps.config_check.outputs.found == 'true'
|
if: steps.config_check.outputs.found == 'true'
|
||||||
run: |
|
run: |
|
||||||
cd "${{ steps.find_project.outputs.project_dir }}"
|
cd "${{ steps.find_project.outputs.project_dir }}"
|
||||||
CONFIG_PATH="${{ steps.config_check.outputs.config_path }}"
|
|
||||||
|
|
||||||
# Convert to absolute path if needed
|
|
||||||
if [[ "$CONFIG_PATH" != /* ]]; then
|
|
||||||
CONFIG_PATH="$(pwd)/$CONFIG_PATH"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Normalize the path
|
|
||||||
CONFIG_PATH=$(readlink -f "$CONFIG_PATH" 2>/dev/null || realpath "$CONFIG_PATH" 2>/dev/null || echo "$CONFIG_PATH")
|
|
||||||
|
|
||||||
if [ ! -f "$CONFIG_PATH" ]; then
|
|
||||||
echo "Warning: Config file not found at $CONFIG_PATH"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "${{ steps.find_project.outputs.sch_file }}" ]; then
|
if [ -n "${{ steps.find_project.outputs.sch_file }}" ]; then
|
||||||
echo "Running ERC with config: $CONFIG_PATH"
|
echo "Running ERC on schematic files..."
|
||||||
kibot -c "$CONFIG_PATH" -s run_erc -v || true
|
# Use absolute path to config file in repo root
|
||||||
|
kibot -c "${GITHUB_WORKSPACE}/kibot.yaml" -s run_erc -v || true
|
||||||
else
|
else
|
||||||
echo "No schematic files found, skipping ERC"
|
echo "No schematic files found, skipping ERC"
|
||||||
fi
|
fi
|
||||||
@@ -208,57 +114,29 @@ jobs:
|
|||||||
if: steps.config_check.outputs.found == 'true'
|
if: steps.config_check.outputs.found == 'true'
|
||||||
run: |
|
run: |
|
||||||
cd "${{ steps.find_project.outputs.project_dir }}"
|
cd "${{ steps.find_project.outputs.project_dir }}"
|
||||||
CONFIG_PATH="${{ steps.config_check.outputs.config_path }}"
|
|
||||||
|
|
||||||
# Convert to absolute path if needed
|
echo "Running DRC on PCB..."
|
||||||
if [[ "$CONFIG_PATH" != /* ]]; then
|
# Use absolute path to config file in repo root
|
||||||
CONFIG_PATH="$(pwd)/$CONFIG_PATH"
|
kibot -c "${GITHUB_WORKSPACE}/kibot.yaml" -s run_drc -v || true
|
||||||
fi
|
|
||||||
|
|
||||||
# Normalize the path
|
|
||||||
CONFIG_PATH=$(readlink -f "$CONFIG_PATH" 2>/dev/null || realpath "$CONFIG_PATH" 2>/dev/null || echo "$CONFIG_PATH")
|
|
||||||
|
|
||||||
if [ ! -f "$CONFIG_PATH" ]; then
|
|
||||||
echo "Warning: Config file not found at $CONFIG_PATH"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Running DRC with config: $CONFIG_PATH"
|
|
||||||
kibot -c "$CONFIG_PATH" -s run_drc -v || true
|
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Generate outputs with custom config
|
- name: Generate outputs with custom config
|
||||||
if: steps.config_check.outputs.found == 'true'
|
if: steps.config_check.outputs.found == 'true'
|
||||||
run: |
|
run: |
|
||||||
cd "${{ steps.find_project.outputs.project_dir }}"
|
cd "${{ steps.find_project.outputs.project_dir }}"
|
||||||
CONFIG_PATH="${{ steps.config_check.outputs.config_path }}"
|
|
||||||
|
|
||||||
# Convert to absolute path if needed
|
|
||||||
if [[ "$CONFIG_PATH" != /* ]]; then
|
|
||||||
CONFIG_PATH="$(pwd)/$CONFIG_PATH"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Normalize the path
|
|
||||||
CONFIG_PATH=$(readlink -f "$CONFIG_PATH" 2>/dev/null || realpath "$CONFIG_PATH" 2>/dev/null || echo "$CONFIG_PATH")
|
|
||||||
|
|
||||||
if [ ! -f "$CONFIG_PATH" ]; then
|
|
||||||
echo "Error: Config file not found at $CONFIG_PATH"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Generating outputs for ${{ steps.layers.outputs.layers }} layer board"
|
echo "Generating outputs for ${{ steps.layers.outputs.layers }} layer board"
|
||||||
echo "Project: ${{ steps.find_project.outputs.project_name }}"
|
echo "Project: ${{ steps.find_project.outputs.project_name }}"
|
||||||
echo "Using config: $CONFIG_PATH"
|
echo "Using config: ${GITHUB_WORKSPACE}/kibot.yaml"
|
||||||
|
|
||||||
# Run KiBot with the configuration
|
# Run KiBot with the configuration from repo root
|
||||||
kibot -c "$CONFIG_PATH" -d Fabrication -v
|
kibot -c "${GITHUB_WORKSPACE}/kibot.yaml" -d Fabrication -v
|
||||||
|
|
||||||
# Move outputs to root Generated folder
|
# Move outputs to root Generated folder
|
||||||
mkdir -p ../Generated
|
mkdir -p "${GITHUB_WORKSPACE}/Generated"
|
||||||
if [ -d "Fabrication" ]; then
|
if [ -d "Fabrication" ]; then
|
||||||
cp -r Fabrication/* ../Generated/
|
cp -r Fabrication/* "${GITHUB_WORKSPACE}/Generated/"
|
||||||
fi
|
fi
|
||||||
cd ..
|
|
||||||
|
|
||||||
- name: Quick Start fallback
|
- name: Quick Start fallback
|
||||||
if: steps.config_check.outputs.found == 'false'
|
if: steps.config_check.outputs.found == 'false'
|
||||||
@@ -268,15 +146,12 @@ jobs:
|
|||||||
kibot --quick-start
|
kibot --quick-start
|
||||||
|
|
||||||
# Move outputs to root Generated folder
|
# Move outputs to root Generated folder
|
||||||
|
mkdir -p "${GITHUB_WORKSPACE}/Generated"
|
||||||
if [ -d "Generated" ]; then
|
if [ -d "Generated" ]; then
|
||||||
mv Generated ../
|
cp -r Generated/* "${GITHUB_WORKSPACE}/Generated/"
|
||||||
else
|
|
||||||
mkdir -p ../Generated
|
|
||||||
echo "No Generated folder found after quick-start"
|
|
||||||
fi
|
fi
|
||||||
cd ..
|
|
||||||
|
|
||||||
- name: Add layer information to outputs
|
- name: Add board information to outputs
|
||||||
run: |
|
run: |
|
||||||
echo "Board configuration: ${{ steps.layers.outputs.layers }} layers" > Generated/board_info.txt
|
echo "Board configuration: ${{ steps.layers.outputs.layers }} layers" > Generated/board_info.txt
|
||||||
echo "Project: ${{ steps.find_project.outputs.project_name }}" >> Generated/board_info.txt
|
echo "Project: ${{ steps.find_project.outputs.project_name }}" >> Generated/board_info.txt
|
||||||
@@ -322,7 +197,7 @@ jobs:
|
|||||||
name: Fabrication-Package-${{ steps.layers.outputs.layers }}layer
|
name: Fabrication-Package-${{ steps.layers.outputs.layers }}layer
|
||||||
path: Generated/*.zip
|
path: Generated/*.zip
|
||||||
|
|
||||||
# This step is to upload the results to another repo (web pages)
|
# Deploy to documentation branch
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: kicad-kibot-runner
|
runs-on: kicad-kibot-runner
|
||||||
needs: generate
|
needs: generate
|
||||||
@@ -367,7 +242,7 @@ jobs:
|
|||||||
# Commit and push if there are changes
|
# Commit and push if there are changes
|
||||||
git add .
|
git add .
|
||||||
if ! git diff --cached --quiet; then
|
if ! git diff --cached --quiet; then
|
||||||
git commit -m "chore: update deployed documentation for ${{ needs.generate.outputs.layers }}-layer board"
|
git commit -m "chore: update deployed documentation"
|
||||||
git push --force "$AUTHED_URL" docu
|
git push --force "$AUTHED_URL" docu
|
||||||
else
|
else
|
||||||
echo "No changes to deploy"
|
echo "No changes to deploy"
|
||||||
|
|||||||
Reference in New Issue
Block a user