|
| 1 | +name: AIBomGen-cli Integration Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + integration: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Checkout code |
| 14 | + uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Set up Go 1.25.x |
| 17 | + uses: actions/setup-go@v5 |
| 18 | + with: |
| 19 | + go-version: '1.25.x' |
| 20 | + check-latest: true |
| 21 | + cache: true |
| 22 | + cache-dependency-path: | |
| 23 | + **/go.sum |
| 24 | + **/go.work.sum |
| 25 | +
|
| 26 | + - name: Download dependencies |
| 27 | + run: go mod download |
| 28 | + |
| 29 | + - name: Run generator against repo-10 |
| 30 | + run: | |
| 31 | + rm -rf dist |
| 32 | + go run . generate \ |
| 33 | + --input ./testdata/repo-10 \ |
| 34 | + --output dist/integration/aibom.json \ |
| 35 | + --log-level debug |
| 36 | +
|
| 37 | + - name: Verify generated AIBOM files |
| 38 | + run: | |
| 39 | + set -euo pipefail |
| 40 | + if [ ! -d dist/integration ]; then |
| 41 | + echo "dist/integration directory not found" |
| 42 | + exit 1 |
| 43 | + fi |
| 44 | + mapfile -t bom_files < <(find dist/integration -maxdepth 1 -type f -name '*_aibom.json' -print) |
| 45 | + if [ "${#bom_files[@]}" -eq 0 ]; then |
| 46 | + echo "No AIBOM files generated" |
| 47 | + exit 1 |
| 48 | + fi |
| 49 | + for file in "${bom_files[@]}"; do |
| 50 | + if [ ! -s "$file" ]; then |
| 51 | + echo "Generated file $file is empty" |
| 52 | + exit 1 |
| 53 | + fi |
| 54 | + python - "$file" <<'PY' |
| 55 | + import json, pathlib, sys |
| 56 | + path = pathlib.Path(sys.argv[1]) |
| 57 | + try: |
| 58 | + with path.open() as fh: |
| 59 | + json.load(fh) |
| 60 | + except json.JSONDecodeError as exc: |
| 61 | + raise SystemExit(f"Invalid JSON in {path}: {exc}") |
| 62 | + PY |
| 63 | + done |
| 64 | + |
| 65 | + - name: Upload AIBOM artifacts |
| 66 | + uses: actions/upload-artifact@v4 |
| 67 | + with: |
| 68 | + name: aibom-integration |
| 69 | + path: dist/integration/*.json |
| 70 | + if-no-files-found: error |
0 commit comments