changed workflos
Some checks failed
KiBot PCB Generation with Multi-layer Support / generate (push) Failing after 21s
KiBot PCB Generation with Multi-layer Support / deploy (push) Has been skipped

This commit is contained in:
2025-09-08 14:58:48 +07:00
parent a5e5a3b96d
commit 3701681161
3 changed files with 498 additions and 90 deletions

241
.gitea/workflows/kibot.yml Normal file
View File

@@ -0,0 +1,241 @@
name: "KiBot PCB Generation with Multi-layer Support"
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
paths:
- 'kicad/c64psu/*.kicad_sch'
- 'kicad/c64psu/*.kicad_pcb'
- 'kicad/c64psu/*.kicad_pro'
- '.gitea/workflows/kibot_quick_start.yml'
- 'kibot.yaml'
pull_request:
paths:
- 'kicad/c64psu/*.kicad_sch'
- 'kicad/c64psu/*.kicad_pcb'
- 'kicad/c64psu/*.kicad_pro'
- '.gitea/workflows/kibot_quick_start.yml'
- 'kibot.yaml'
repository_dispatch:
types: [run_qs]
workflow_dispatch:
inputs:
board_layers:
description: 'Number of PCB layers (auto-detect if not specified)'
required: false
default: 'auto'
type: choice
options:
- auto
- 2
- 4
- 6
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
generate:
runs-on: kicad-kibot-runner
steps:
- uses: actions/checkout@v3
with:
# So we can run a diff between last 2 changes
fetch-depth: '0'
- name: Detect layer count
id: layers
working-directory: kicad/c64psu
run: |
if [ "${{ github.event.inputs.board_layers }}" != "" ] && [ "${{ github.event.inputs.board_layers }}" != "auto" ]; then
echo "layers=${{ github.event.inputs.board_layers }}" >> $GITHUB_OUTPUT
echo "Using manually specified ${{ github.event.inputs.board_layers }} layer configuration"
else
# Auto-detect layers from PCB file
LAYERS=$(python3 -c "
import re
import sys
import glob
try:
pcb_files = glob.glob('*.kicad_pcb')
if not pcb_files:
print(2)
sys.exit(0)
with open(pcb_files[0], 'r') as f:
content = f.read()
# Find all copper layers
copper_layers = re.findall(r'\(layer\s+\"([^\"]+)\".*?\(type\s+\"?copper\"?\)', content, re.DOTALL)
# Count inner layers (In1.Cu, In2.Cu, etc)
inner_layers = [l for l in copper_layers if 'In' in l and '.Cu' in l]
total = 2 + len(inner_layers) # F.Cu + B.Cu + inner layers
print(total)
except Exception as e:
print(f'Error: {e}', file=sys.stderr)
print(2) # Default to 2 layers
")
echo "layers=$LAYERS" >> $GITHUB_OUTPUT
echo "Auto-detected $LAYERS layer board"
fi
- name: Check for KiBot config
id: config_check
run: |
if [ -f "kibot.yaml" ]; then
echo "found=true" >> $GITHUB_OUTPUT
echo "Using custom kibot.yaml configuration"
elif [ -f "kicad/c64psu/kibot.yaml" ]; then
echo "found=true" >> $GITHUB_OUTPUT
echo "config_path=kicad/c64psu/kibot.yaml" >> $GITHUB_OUTPUT
echo "Using project-specific kibot.yaml configuration"
else
echo "found=false" >> $GITHUB_OUTPUT
echo "Using --quick-start mode (no custom config found)"
fi
- name: Run ERC
working-directory: kicad/c64psu
run: |
if [ "${{ steps.config_check.outputs.found }}" == "true" ]; then
CONFIG_PATH="${{ steps.config_check.outputs.config_path }}"
[ -z "$CONFIG_PATH" ] && CONFIG_PATH="../../kibot.yaml"
[ -f *.kicad_sch ] && kibot -c "$CONFIG_PATH" -s run_erc -v || true
fi
continue-on-error: true
- name: Run DRC
working-directory: kicad/c64psu
run: |
if [ "${{ steps.config_check.outputs.found }}" == "true" ]; then
CONFIG_PATH="${{ steps.config_check.outputs.config_path }}"
[ -z "$CONFIG_PATH" ] && CONFIG_PATH="../../kibot.yaml"
[ -f *.kicad_pcb ] && kibot -c "$CONFIG_PATH" -s run_drc -v || true
fi
continue-on-error: true
- name: Generate outputs with custom config
if: steps.config_check.outputs.found == 'true'
working-directory: kicad/c64psu
run: |
echo "Generating outputs for ${{ steps.layers.outputs.layers }} layer board"
CONFIG_PATH="${{ steps.config_check.outputs.config_path }}"
[ -z "$CONFIG_PATH" ] && CONFIG_PATH="../../kibot.yaml"
# Run KiBot with the configuration
kibot -c "$CONFIG_PATH" -d Fabrication -v
# Move outputs to match the original structure
mkdir -p ../../Generated
if [ -d "Fabrication" ]; then
cp -r Fabrication/* ../../Generated/
fi
- name: Quick Start fallback
if: steps.config_check.outputs.found == 'false'
working-directory: kicad/c64psu
run: |
echo "Running KiBot in quick-start mode"
kibot --quick-start
# Move outputs to expected location
if [ -d "Generated" ]; then
mv Generated ../../
fi
- name: Add layer information to outputs
run: |
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 path: ${{ steps.find_project.outputs.project_dir }}" >> Generated/board_info.txt
echo "Generated on: $(date)" >> Generated/board_info.txt
echo "Commit: ${{ github.sha }}" >> Generated/board_info.txt
- name: Fix file permissions
run: |
chmod -R a+rw Generated || true
- name: Retrieve results - All outputs
uses: actions/upload-artifact@v3
with:
name: Automatic_outputs
path: Generated
- name: Retrieve results - Gerbers
if: steps.config_check.outputs.found == 'true'
uses: actions/upload-artifact@v3
with:
name: Gerbers-${{ steps.layers.outputs.layers }}layer
path: Generated/Gerbers
- name: Retrieve results - Assembly
if: steps.config_check.outputs.found == 'true'
uses: actions/upload-artifact@v3
with:
name: Assembly-${{ steps.layers.outputs.layers }}layer
path: Generated/Assembly
- name: Retrieve results - 3D Model
if: steps.config_check.outputs.found == 'true'
uses: actions/upload-artifact@v3
with:
name: 3D-Model
path: Generated/3D
- name: Retrieve results - Fabrication Package
if: steps.config_check.outputs.found == 'true'
uses: actions/upload-artifact@v3
with:
name: Fabrication-Package-${{ steps.layers.outputs.layers }}layer
path: Generated/*.zip
# This step is to upload the results to another repo (web pages)
deploy:
runs-on: kicad-kibot-runner
needs: generate
steps:
- uses: actions/checkout@v4
- name: Retrieve results
uses: actions/download-artifact@v3
with:
name: Automatic_outputs
path: Generated
- name: Disable Jekyll
# Jekyll will filter the KiRi folders
run: |
touch Generated/.nojekyll
- name: Push to docu branch
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
# Set up git identity
git config --global user.email "${{ gitea.actor }}@noreply.localhost"
git config --global user.name "${{ gitea.actor }}"
# Get the repository URL and add authentication
REPO_URL=$(git config --get remote.origin.url)
AUTHED_URL=${REPO_URL/https:\/\//https:\/\/${GITEA_TOKEN}@}
# Clone the docu branch into a separate folder
git clone --depth 1 --branch docu "$AUTHED_URL" docu-branch || \
git clone --depth 1 "$AUTHED_URL" docu-branch
cd docu-branch
git checkout -B docu
# Clean old contents and copy new files
rm -rf ./*
cp -r ../Generated/* ./
# Commit and push if there are changes
git add .
if ! git diff --cached --quiet; then
git commit -m "chore: update deployed documentation for ${{ needs.generate.outputs.layers }}-layer board"
git push --force "$AUTHED_URL" docu
else
echo "No changes to deploy"
fi

View File

@@ -1,90 +0,0 @@
name: "Variants demo using --quick-start"
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
paths:
- 'kicad/c64psu/*.kicad_sch'
- 'kicad/c64psu/*.kicad_pcb'
- '.gitea/workflows/kibot_quick_start.yml'
pull_request:
paths:
- 'kicad/c64psu/*.kicad_sch'
- 'kicad/c64psu/*.kicad_pcb'
- '.gitea/workflows/kibot_quick_start.yml'
repository_dispatch:
types: [run_qs]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
quick-start:
runs-on: kicad-kibot-runner
steps:
- uses: actions/checkout@v3
with:
# So we can run a diff between last 2 changes
fetch-depth: '0'
- name: Quick Start
run: |
kibot --quick-start
- name: Retrieve results
uses: actions/upload-artifact@v3
with:
name: Automatic_outputs
path: Generated
# This step is to upload the results to another repo (web pages)
deploy:
runs-on: kicad-kibot-runner
needs: quick-start
steps:
- uses: actions/checkout@v4
- name: Retrieve results
uses: actions/download-artifact@v3
with:
name: Automatic_outputs
path: Generated
- name: Disable Jekyll
# Jekyll will filter the KiRi folders
run: |
touch Generated/.nojekyll
- name: Push to docu branch
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
# Set up git identity
git config --global user.email "${{ gitea.actor }}@noreply.localhost"
git config --global user.name "${{ gitea.actor }}"
# Get the repository URL and add authentication
REPO_URL=$(git config --get remote.origin.url)
AUTHED_URL=${REPO_URL/https:\/\//https:\/\/${GITEA_TOKEN}@}
# Clone the docu branch into a separate folder
git clone --depth 1 --branch docu "$AUTHED_URL" docu-branch || \
git clone --depth 1 "$AUTHED_URL" docu-branch
cd docu-branch
git checkout -B docu
# Clean old contents and copy new files
rm -rf ./*
cp -r ../Generated/* ./
# Commit and push if there are changes
git add .
if ! git diff --cached --quiet; then
git commit -m "chore: update deployed documentation"
git push --force "$AUTHED_URL" docu
else
echo "No changes to deploy"
fi