Merged main into kicad9

This commit is contained in:
Tim Hadwen
2025-08-31 17:40:03 +10:00
41 changed files with 2162 additions and 584 deletions

View File

@@ -82,38 +82,45 @@ image:
fi
echo ${dir_arr[i-1]}
echo ${sch_arr[i-1]}
USER_FILE="$CI_PROJECT_DIR/.gitlab/configs/blank.kibot.yaml"
if [ -f "${dir_arr[i-1]}/kibot.yaml" ]; then
USER_FILE="${dir_arr[i-1]}/kibot.yaml"
fi
cp $USER_FILE $CI_PROJECT_DIR/.gitlab/configs/user.kibot.yaml
python3 $CI_PROJECT_DIR/.gitlab/.scripts/orig.py ${dir_arr[i-1]}
kibot -e ${dir_arr[i-1]}/${sch_arr[i-1]} -c $CI_PROJECT_DIR/.gitlab/default.kibot.yaml -d $CI_PROJECT_DIR/Fabrication/${dir_arr[i-1]} -s $SUFFIX
for CONF in $KIBOT_CONF
do
kibot -e ${dir_arr[i-1]}/${sch_arr[i-1]} -c $CI_PROJECT_DIR/.gitlab/configs/$CONF.kibot.yaml -d $CI_PROJECT_DIR/Fabrication/${dir_arr[i-1]} $VARIANTS
done
mv $CI_PROJECT_DIR/Fabrication/${dir_arr[i-1]}/*.zip Fabrication/ 2> /dev/null || true
done
- cd $CI_PROJECT_DIR
panel:
pre_panel:
- cd $CI_PROJECT_DIR
- mkdir panels
- 'SEARCH="_panel.json"'
- !reference [.commands, get_dirs]
- |
mkdir panels
cd $CI_PROJECT_DIR
for d in $DIRS
do
echo "found panel"
echo $d
echo "found panel: $d"
JSON=$(find $d/*_panel.json)
FILE=$(basename "${JSON}")
NAME=$(echo "${FILE%.json}")
PCB=$(find $d/*.kicad_pcb)
echo "mkdring"
mkdir -p panels/$NAME
echo "panelising"
python3 .gitlab/.scripts/pre_panel.py $PCB $JSON
kikit panelize -p $JSON $PCB panels/$NAME/$NAME.kicad_pcb
cp .gitlab/micromelon_default/micromelon_default.kicad_sch panels/$NAME/$NAME.kicad_sch
cp .gitlab/templates/micromelon_default/micromelon_default.kicad_sch panels/$NAME/$NAME.kicad_sch
cp $d/fp-lib-table panels/$NAME/
python3 .gitlab/.scripts/post_panel.py panels/$NAME/$NAME.kicad_pro $PCB
done
- cd panels || true
- !reference [.commands, kibot]
- cd panels
post_panel:
- mv panels/* . || true
- rm -rf panels/ || true
neo:
- 'SEARCH=".kicad_pro"'
@@ -132,10 +139,6 @@ image:
- client=$(echo $CI_PROJECT_PATH | cut -d'/' -f3 | sed -r 's/\<./\U&/g')
- proj=$(echo $CI_PROJECT_NAME | tr -d '0123456789' | tr '-' ' ' | sed -r 's/\<./\U&/g')
- desc_suffix=$(echo $client $proj)
- cd $CI_PROJECT_DIR/.gitlab/.scripts/ki-ntree/
- apt remove libcurl4 -y
- apt update && apt install curl pip -y && pip install --break-system-packages poetry
- poetry install
- url="https://gitlab.com/api/v4/projects/${DIGI_API_PRJ_ID}/packages/generic/digikey_api/0/token_storage.json"
- |
if [[ -z "$KINTREE_DIGI_TOKEN" ]]; then
@@ -146,37 +149,43 @@ image:
- cat token_storage.json
- cd $CI_PROJECT_DIR/Fabrication
- 'SEARCH="bom.csv"'
- !reference [.commands, strip_tag]
- !reference [.commands, parse_commit]
- !reference [.commands, get_files]
- cd $CI_PROJECT_DIR/.gitlab/.scripts/ki-ntree/
- cd $CI_PROJECT_DIR
- FAIL=0
- |
for f in $FILES
do
echo $f
name=$(echo $f | cut -c3- | cut -d'-' -f1)A
fab_path=$CI_PROJECT_DIR/Fabrication/$(dirname $f | cut -c3-)
name_n_rev=$(echo $f | cut -c3- | rev | cut -d'/' -f1 | cut -c9- | rev)
pcb_im=$fab_path/PCB_$name_n_rev.png
pcba_im=$fab_path/PCBA_$name_n_rev.png
pcb_attach=$(echo "['$fab_path/${name_n_rev}_PCB.pdf', '$CI_PROJECT_DIR/Fabrication/${name_n_rev}_JLC.zip']")
pcba_attach=$(echo "['$fab_path/${name_n_rev}_schematic.pdf', '$fab_path/${name_n_rev}_bom.csv', '$fab_path/${name_n_rev}-neo-pos_top.csv', '$fab_path/${name_n_rev}-neo-pos_bot.csv', '$fab_path/${name_n_rev}_ibom.html']")
full_name=$(echo $f | cut -c3- | rev | cut -d'/' -f1 | cut -c9- | rev)
echo "name: $full_name"
name_n_rev=$(echo $full_name | cut -d'_' -f1,2)
assembly_rev=$(echo $full_name | cut -d'_' -f2)
name=$(echo $full_name | cut -d'-' -f1)A$(echo ${full_name//$assembly_rev/.} | cut -d'.' -f2)
pcb_rev=$(echo ${assembly_rev} | cut -d'_' -f1,2 | cut -d'.' -f1,2)
pcb_im=${fab_path}/PCB_${name_n_rev}.png
pcba_im=${fab_path}/PCBA_${name_n_rev}.png
pcb_attach=$(echo "['${fab_path}/${name_n_rev}_PCB.pdf', '$CI_PROJECT_DIR/Fabrication/${name_n_rev}_JLC.zip']")
pcba_attach=$(echo "['${fab_path}/${full_name}_schematic.pdf', '${fab_path}/${full_name}_bom.csv', '${fab_path}/${full_name}-neo-pos_top.csv', '${fab_path}/${full_name}-neo-pos_bot.csv', '${fab_path}/${full_name}_ibom.html']")
DRY="--dry"
DRY="--dry assemblies"
if [[ $CI_COMMIT_BRANCH == "main" ]]; then
DRY=""
fi
poetry run python -m kintree_cli $DRY -p $CI_PROJECT_DIR/Fabrication/$f --assembly "{'ipn': '$name', 'rev': '$TAG', 'image': ['$pcb_im', '$pcba_im'], 'desc': '$desc_suffix', 'attachments': [$pcb_attach, $pcba_attach]}" --settings $KINTREE_SETT --digi_token token_storage.json || FAIL=1
echo "Revs: $pcb_rev, $assembly_rev"
python -m kintree.kintree_cli $DRY -b $CI_PROJECT_DIR/Fabrication/$f -a "{'ipn': '$name', 'rev': ['$pcb_rev', '$assembly_rev'], 'image': ['$pcb_im', '$pcba_im'], 'desc': '$desc_suffix', 'attachments': [$pcb_attach, $pcba_attach]}" --settings $KINTREE_SETT --digi_token token_storage.json || FAIL=1
done
# - cp token_storage.json /tmp
- |
cat /tmp/token_storage.json
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file /tmp/token_storage.json $url
cd $CI_PROJECT_DIR
cat token_storage.json
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file token_storage.json $url
- exit $FAIL
# USE PRIVATE-TOKEN to upload from gitlab-ci
git_tag:
- !reference [.commands, strip_tag]
- !reference [.commands, parse_commit]
- |
if [[ $GITLAB_CI == 'true' && $CI_COMMIT_BRANCH == "main" ]]; then
echo "running git tag"
@@ -228,97 +237,131 @@ image:
done
fi
strip_tag:
- TAG=$(echo ${CI_COMMIT_MESSAGE} | tr -d \\n)
parse_commit:
- |
initials () {
echo "$(echo $1 | cut -d' ' -f1 | cut -c1-1)$(echo $1 | cut -d' ' -f2 | cut -c1-1)"
}
output_mech:
str=$CI_COMMIT_MESSAGE
REV=$(echo "$str" | sed -n '1 p')
DWN=$(initials "$(echo "$str" | sed -n '3 p' | cut -d' ' -f1,2)")
CHK=''
APP=''
while IFS= read -r line; do
if [[ $line == Rev* ]]; then
CHK=$(initials "$(echo $line | cut -d' ' -f2,3)")
fi
if [[ $line == App* ]]; then
APP=$(initials "$(echo $line | cut -d' ' -f2,3)")
fi
done <<<"$str"
export DWN
export CHK
export APP
- !reference [.commands, parse_tag]
parse_tag:
- TAG=$(echo "$CI_COMMIT_MESSAGE" | sed -n '1 p')
- echo $TAG
outputs_mech:
stage: gen_mech
when: always
artifacts:
when: always
paths:
- Fabrication/**/*
variables:
SUFF_MECH: erc,drc step pcb_render pcba_render
script:
- !reference [.commands, git_tag]
- SUFFIX=$SUFF_MECH
- !reference [.commands, kibot]
outputs_dev:
rules:
- !reference [.dev_rules, rules]
stage: gen_fab
artifacts:
when: always
name: "$CI_PROJECT_TITLE-$CI_COMMIT_SHORT_SHA"
paths:
- Fabrication/**/*
expire_in: 1 week
variables:
SUFF_SCH: drc sch
SUFF_PCB: erc,update_xml,set_text_variables print_pcb
script:
before_script:
- !reference [.commands, git_tag]
- SUFFIX=$SUFF_SCH
- !reference [.commands, kibot]
- SUFFIX=$SUFF_PCB
script:
- VARIANTS="$VARIANTS_MECH"
- KIBOT_CONF="mech"
- !reference [.commands, kibot]
outputs_all:
outputs_dev:
extends: outputs_mech
rules:
- !reference [.dev_rules, rules]
stage: gen_fab
script:
# SCH
- VARIANTS="$VARIANTS_SCH"
- KIBOT_CONF="sch"
- !reference [.commands, kibot]
# PCB
- VARIANTS="$VARIANTS_PCB"
- KIBOT_CONF="pcb_dev"
- !reference [.commands, kibot]
outputs_main:
extends: outputs_dev
rules:
- !reference [.main_rules, rules]
variables:
SUFF_SCH: drc sch
SUFF_PCB: erc,update_xml,set_text_variables pcb
SUFF_PANEL: erc,update_xml,set_text_variables pcb_panel
script:
- !reference [.commands, git_tag]
- SUFFIX=$SUFF_SCH
# SCH
- VARIANTS="$VARIANTS_SCH"
- KIBOT_CONF="sch"
- !reference [.commands, kibot]
- SUFFIX=$SUFF_PCB
# PCB
- VARIANTS="$VARIANTS_PCB"
- KIBOT_CONF="pcb_main"
- !reference [.commands, kibot]
# Panels
- !reference [.commands, pre_panel]
- KIBOT_CONF="panel"
- !reference [.commands, kibot]
- !reference [.commands, post_panel]
# Pos
- VARIANTS="$VARIANTS_SCH"
- KIBOT_CONF="pos"
- !reference [.commands, kibot]
- SUFFIX=$SUFF_PANEL
- !reference [.commands, panel]
- !reference [.commands, neo]
- ls Fabrication/
inventree_job_dev:
image:
name: ghcr.io/andrew-collins/ki-ntree:cli
entrypoint: [""]
stage: inventree
rules:
- !reference [.dev_rules, rules]
needs:
- job: output_mech
- job: outputs_mech
artifacts: true
- job: outputs_dev
artifacts: true
rules:
- !reference [.dev_rules, rules]
script:
- !reference [.commands, boms]
inventree_job:
inventree_job_main:
image:
name: ghcr.io/andrew-collins/ki-ntree:cli
entrypoint: [""]
stage: inventree
needs:
- job: output_mech
artifacts: true
- job: outputs_all
artifacts: true
rules:
- !reference [.main_rules, rules]
needs:
- job: outputs_mech
artifacts: true
- job: outputs_main
artifacts: true
script:
- !reference [.commands, boms]
upload_job:
stage: upload
needs:
- job: inventree_job
- job: outputs_all
- job: inventree_job_main
- job: outputs_main
artifacts: true
rules:
- if: $CI_COMMIT_TAG
when: never # Do not run this job when a tag is created manually
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when commits are pushed or merged to the default branch
script:
- !reference [.commands, strip_tag]
- !reference [.commands, parse_commit]
- apt remove libcurl4 -y
- apt-get update && apt-get -y install zip curl
- |
@@ -353,7 +396,7 @@ release_job:
when: never # Do not run this job when a tag is created manually
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when commits are pushed or merged to the default branch
script:
- !reference [.commands, strip_tag]
- !reference [.commands, parse_tag]
- apk add jq curl
- |
echo "running release_job for $TAG"