How jordanconway/hw-bom works
Project type and purpose
• This is an open-source GitHub Action, implemented in TypeScript/Node.js, that runs on Linux-based GitHub Actions runners and collects hardware details (CPU, GPU, memory, disk, cloud-metadata) from the host and cloud metadata service.
• The README outlines use cases (CI/CD hardware inventory, validation, reports) and target platforms (AWS, Azure, GCE, OpenStack).
File structure
• Top-level artifacts:
• action.yml – declares inputs, outputs, entrypoint.
• src/index.ts & src/main.ts – core logic and CLI wrapper.
• dist/index.js – compiled output invoked at runtime.
• __tests__ & __fixtures__ – unit tests and data fixtures.
• .github/workflows/main.yml – CI building, testing, releasing.
• package.json, tsconfig.json, linting & formatting configs – build and dev toolchain.
• Patterns: simple linear flow (no microservices), modular separation of core logic vs. entrypoint, CI pipeline to publish to npm/GitHub registry.
Extract architecture insights from the README
• Action runs on a GitHub runner VM with sudo.
• Internally executes:
• Calls out to OS commands (lshw, uname, free, df).
• Queries cloud metadata endpoints (AWS IMDS, Azure Instance Metadata Service, GCE, OpenStack).
• Parses results and exposes them as GitHub Action outputs.
Main components and their interactions
a. GitHub Actions Runner
– A Linux VM/container orchestrated by GitHub.
b. Action Entrypoint
– action.yml invokes dist/index.js via Node.js.
c. Node.js Runtime & Action Code
– index.js loads main.ts logic, executes hardware probes.
– Core module orchestrates:
· Metadata fetchers for each cloud provider
· Shell commands (lshw, uname, free, df) with child_process
· Parsers to normalize output
d. External Services & Tools
– Cloud metadata service endpoints (HTTP calls)
– lshw (via sudo), uname, free, df
e. Outputs
– Aggregated JSON/string results mapped to GitHub Action outputs for downstream steps.
f. CI/CD Pipeline (secondary view)
– .github/workflows/main.yml: build → test (__tests__) → lint → release-drafter → git tag → publish.
Architectural patterns & design principles
• Modular separation: metadata fetchers vs. OS command probes vs. output mapper.
• Single responsibility: each module gathers one category of data.
• Graceful error handling: wrappers return fallback messages on failure.
• Build-artifact separation: src/ → dist/ for production code.