Switch CI BOM upload from InvenTree (hfsntree) to Astable
Replaces the `inventree_dev` + `inventree_main` jobs with `astable_dev` + `astable_main` calling `POST /api/v1/bom/upload` on the Astable instance. The old hfsntree path is removed — Astable is now the source of truth for BOMs, and owns the supplier-API credentials (Digi-Key / Mouser / etc.) so the CI runner doesn't need them any more. Revision targeting matches the previous convention: - dev branch: uploads to the DRAFT "dev" rev - main branch: uploads to the rev named from commit message, promoted to ACTIVE - MR-to-main: uploads to dev (matches old hfsntree behaviour) Strict mode: any MPN that can't be resolved against an enabled supplier integration aborts the whole upload — no orphan parts get created when a CSV ships with typos. Files uploaded alongside the BOM CSV (each optional, skipped when absent so dev and main share the same template): gerbers, panel gerbers, STEP, schematic PDF, PCB layout PDF, iBOM HTML, BOM xlsx, PCBA + bare-PCB renders, DRC + ERC reports, CPL CSV. Astable attaches each file to the PCBA part, the bare PCB part, or both (per fab-file dispatch table). Files attached to both parts dedupe storage via content-addressed paths. Required CI variables (set group-level on Micromelon/education/hardware/, masked + protected): ASTABLE_URL e.g. https://astable.timhadwen.com ASTABLE_API_TOKEN minted at /manage/api-tokens (ast_…) scripts/upload-bom.sh vendored from the Astable repo (scripts/ci/upload-bom.sh) — the .astable_base before_script curls a copy from this repo's raw URL at job time so the include: project: pattern stays self-contained. Downstream `upload_packages` needs: updated from inventree_main → astable_main.
This commit is contained in:
142
kibot-ci.yml
142
kibot-ci.yml
@@ -310,19 +310,50 @@ generate_panel:
|
||||
fi
|
||||
|
||||
# =============================================================================
|
||||
# Stage: InvenTree
|
||||
# Stage: Astable (replaces the old InvenTree/hfsntree upload path)
|
||||
# =============================================================================
|
||||
.inventree_base:
|
||||
stage: inventree
|
||||
image: python:3.11-slim
|
||||
before_script:
|
||||
- |
|
||||
cd hfsntree
|
||||
pip install -e . --quiet
|
||||
cd $CI_PROJECT_DIR
|
||||
#
|
||||
# Uploads the BOM + every fabrication output to Astable via
|
||||
# POST /api/v1/bom/upload. Astable owns the supplier-API
|
||||
# credentials, so the CI runner doesn't need Digi-Key / Mouser
|
||||
# tokens any more. The upload is strict: any MPN that can't be
|
||||
# resolved against an enabled supplier integration aborts the
|
||||
# upload and writes nothing.
|
||||
#
|
||||
# Revision-targeting follows the existing dev/main convention:
|
||||
# - dev branch: uploads to the part's DRAFT "dev" revision.
|
||||
# - main branch: uploads to the rev named from the commit
|
||||
# message's "VX.Y" token, promoted to ACTIVE.
|
||||
# - MR-to-main: uploads to "dev" (matches old behaviour).
|
||||
#
|
||||
# Required CI variables (set group-level on
|
||||
# Micromelon/education/hardware/, masked + protected):
|
||||
#
|
||||
# ASTABLE_URL e.g. https://astable.timhadwen.com
|
||||
# ASTABLE_API_TOKEN minted at /manage/api-tokens (ast_…)
|
||||
#
|
||||
# The script vendored at scripts/upload-bom.sh in this repo handles
|
||||
# the POST + polling loop. PROJECT_NAME flows through as the
|
||||
# part-ipn — Astable splits on the first hyphen to derive the
|
||||
# PCBA IPN ("<base>A") + bare-PCB IPN ("<base>") + display name.
|
||||
|
||||
inventree_dev:
|
||||
extends: .inventree_base
|
||||
.astable_base:
|
||||
stage: inventree # keep stage name so existing `needs:`
|
||||
# downstream (upload_packages) still match
|
||||
image: curlimages/curl:8.10.1
|
||||
before_script:
|
||||
- apk add --no-cache bash jq
|
||||
# Fetch the upload script from the kicad-ci repo so the yml stays
|
||||
# self-contained (GitLab's `include: project:` only ships the yml
|
||||
# itself, not sibling files in the repo). The ref pins to kicad9
|
||||
# — bump if you move the script.
|
||||
- |
|
||||
curl -fsSL -o /usr/local/bin/upload-bom.sh \
|
||||
"https://gitlab.com/Micromelon/education/hardware/kicad-ci/-/raw/kicad9/scripts/upload-bom.sh"
|
||||
chmod +x /usr/local/bin/upload-bom.sh
|
||||
|
||||
astable_dev:
|
||||
extends: .astable_base
|
||||
rules:
|
||||
- !reference [.dev_rules, rules]
|
||||
needs:
|
||||
@@ -334,21 +365,36 @@ inventree_dev:
|
||||
artifacts: true
|
||||
- job: generate_3d
|
||||
artifacts: true
|
||||
- job: generate_gerbers
|
||||
artifacts: true
|
||||
- job: generate_position
|
||||
artifacts: true
|
||||
- job: generate_panel
|
||||
artifacts: true
|
||||
optional: true
|
||||
script:
|
||||
- |
|
||||
echo "Running InvenTree upload for dev branch (revision: dev)"
|
||||
cd hfsntree
|
||||
python main.py batch $CI_PROJECT_DIR/Fabrication --version-override dev -y
|
||||
FAB="$CI_PROJECT_DIR/Fabrication"
|
||||
SUB="$FAB/${PROJECT_NAME}"
|
||||
VAL="$CI_PROJECT_DIR/Validation"
|
||||
|
||||
inventree_main:
|
||||
extends: .inventree_base
|
||||
# Build args list — each --flag is optional; the script skips
|
||||
# files that aren't present. Dev runs have fewer outputs than
|
||||
# main (no gerbers/panel), so we just pass what exists.
|
||||
ARGS=(
|
||||
--file "$FAB/${PROJECT_NAME}_dev_bom.csv"
|
||||
--part-ipn "$PROJECT_NAME"
|
||||
--branch dev
|
||||
--commit-sha "$CI_COMMIT_SHA"
|
||||
--commit-message "$CI_COMMIT_MESSAGE"
|
||||
)
|
||||
[ -f "$FAB/${PROJECT_NAME}_dev_cpl.csv" ] && ARGS+=(--cpl "$FAB/${PROJECT_NAME}_dev_cpl.csv")
|
||||
[ -f "$FAB/${PROJECT_NAME}_dev.step" ] && ARGS+=(--step "$FAB/${PROJECT_NAME}_dev.step")
|
||||
[ -f "$FAB/${PROJECT_NAME}_dev_schematic.pdf" ] && ARGS+=(--schematic-pdf "$FAB/${PROJECT_NAME}_dev_schematic.pdf")
|
||||
[ -f "$SUB/${PROJECT_NAME}_dev_ibom.html" ] && ARGS+=(--ibom-html "$SUB/${PROJECT_NAME}_dev_ibom.html")
|
||||
[ -f "$SUB/${PROJECT_NAME}_dev_bom.xlsx" ] && ARGS+=(--bom-xlsx "$SUB/${PROJECT_NAME}_dev_bom.xlsx")
|
||||
[ -f "$SUB/PCBA_${PROJECT_NAME}_dev.png" ] && ARGS+=(--pcba-image "$SUB/PCBA_${PROJECT_NAME}_dev.png")
|
||||
[ -f "$SUB/PCB_${PROJECT_NAME}_dev.png" ] && ARGS+=(--pcb-image "$SUB/PCB_${PROJECT_NAME}_dev.png")
|
||||
[ -f "$VAL/${PROJECT_NAME}-erc.html" ] && ARGS+=(--erc-report "$VAL/${PROJECT_NAME}-erc.html")
|
||||
[ -f "$VAL/${PROJECT_NAME}-drc.html" ] && ARGS+=(--drc-report "$VAL/${PROJECT_NAME}-drc.html")
|
||||
|
||||
upload-bom.sh "${ARGS[@]}"
|
||||
|
||||
astable_main:
|
||||
extends: .astable_base
|
||||
rules:
|
||||
- !reference [.main_rules, rules]
|
||||
needs:
|
||||
@@ -374,26 +420,42 @@ inventree_main:
|
||||
expire_in: 1 week
|
||||
script:
|
||||
- |
|
||||
cd hfsntree
|
||||
FAB="$CI_PROJECT_DIR/Fabrication"
|
||||
SUB="$FAB/${PROJECT_NAME}"
|
||||
VAL="$CI_PROJECT_DIR/Validation"
|
||||
|
||||
# MRs targeting main upload to "dev" revision for pre-ordering parts
|
||||
# Actual commits to main upload to the versioned revision
|
||||
# MR-to-main → upload to the dev rev (pre-ordering window).
|
||||
# Actual main pushes → released rev named from the commit
|
||||
# message. The BOM CSV's filename always uses ${VERSION} —
|
||||
# extract_version sets it to "dev" for MRs and the V-token
|
||||
# for direct pushes, so we can read the same path either way.
|
||||
if [[ "$CI_PIPELINE_SOURCE" == "merge_request_event" ]]; then
|
||||
echo "Running InvenTree upload for MR (revision: dev)"
|
||||
python main.py batch $CI_PROJECT_DIR/Fabrication --version-override dev -y
|
||||
BRANCH=dev
|
||||
else
|
||||
echo "Running InvenTree upload for main branch (revision: $VERSION)"
|
||||
python main.py batch $CI_PROJECT_DIR/Fabrication -y
|
||||
|
||||
# Generate Samsung P&P files only on actual release
|
||||
echo "Generating Samsung pick-and-place files..."
|
||||
python main.py samsung $CI_PROJECT_DIR/Fabrication
|
||||
|
||||
# Deactivate old revisions (keep only current release + dev)
|
||||
echo "Deactivating old InvenTree revisions..."
|
||||
python main.py deactivate-old $CI_PROJECT_DIR/Fabrication
|
||||
BRANCH=main
|
||||
fi
|
||||
cd $CI_PROJECT_DIR
|
||||
|
||||
ARGS=(
|
||||
--file "$FAB/${PROJECT_NAME}_${VERSION}_bom.csv"
|
||||
--part-ipn "$PROJECT_NAME"
|
||||
--branch "$BRANCH"
|
||||
--commit-sha "$CI_COMMIT_SHA"
|
||||
--commit-message "$CI_COMMIT_MESSAGE"
|
||||
)
|
||||
[ -f "$FAB/${PROJECT_NAME}_${VERSION}_cpl.csv" ] && ARGS+=(--cpl "$FAB/${PROJECT_NAME}_${VERSION}_cpl.csv")
|
||||
[ -f "$FAB/${PROJECT_NAME}_${VERSION}_JLC.zip" ] && ARGS+=(--gerbers "$FAB/${PROJECT_NAME}_${VERSION}_JLC.zip")
|
||||
[ -f "$FAB/${PROJECT_NAME}_panel_${VERSION}_JLC.zip" ] && ARGS+=(--panel-gerbers "$FAB/${PROJECT_NAME}_panel_${VERSION}_JLC.zip")
|
||||
[ -f "$FAB/${PROJECT_NAME}_${VERSION}.step" ] && ARGS+=(--step "$FAB/${PROJECT_NAME}_${VERSION}.step")
|
||||
[ -f "$FAB/${PROJECT_NAME}_${VERSION}_schematic.pdf" ] && ARGS+=(--schematic-pdf "$FAB/${PROJECT_NAME}_${VERSION}_schematic.pdf")
|
||||
[ -f "$SUB/${PROJECT_NAME}_${VERSION}_PCB.pdf" ] && ARGS+=(--pcb-pdf "$SUB/${PROJECT_NAME}_${VERSION}_PCB.pdf")
|
||||
[ -f "$SUB/${PROJECT_NAME}_${VERSION}_ibom.html" ] && ARGS+=(--ibom-html "$SUB/${PROJECT_NAME}_${VERSION}_ibom.html")
|
||||
[ -f "$SUB/${PROJECT_NAME}_${VERSION}_bom.xlsx" ] && ARGS+=(--bom-xlsx "$SUB/${PROJECT_NAME}_${VERSION}_bom.xlsx")
|
||||
[ -f "$SUB/PCBA_${PROJECT_NAME}_${VERSION}.png" ] && ARGS+=(--pcba-image "$SUB/PCBA_${PROJECT_NAME}_${VERSION}.png")
|
||||
[ -f "$SUB/PCB_${PROJECT_NAME}_${VERSION}.png" ] && ARGS+=(--pcb-image "$SUB/PCB_${PROJECT_NAME}_${VERSION}.png")
|
||||
[ -f "$VAL/${PROJECT_NAME}-erc.html" ] && ARGS+=(--erc-report "$VAL/${PROJECT_NAME}-erc.html")
|
||||
[ -f "$VAL/${PROJECT_NAME}-drc.html" ] && ARGS+=(--drc-report "$VAL/${PROJECT_NAME}-drc.html")
|
||||
|
||||
upload-bom.sh "${ARGS[@]}"
|
||||
|
||||
# =============================================================================
|
||||
# Stage: Release
|
||||
@@ -407,7 +469,7 @@ upload_packages:
|
||||
needs:
|
||||
- job: extract_version
|
||||
artifacts: true
|
||||
- job: inventree_main
|
||||
- job: astable_main
|
||||
artifacts: true
|
||||
script:
|
||||
- apt-get update && apt-get -y install zip
|
||||
|
||||
Reference in New Issue
Block a user