Merge pull request #2 from lloyal-ai/feat/api-expansion #23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Phase 1 Tests (Build from Source) | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| test-vendored-sources: | |
| name: Test on ${{ matrix.os }} (Node ${{ matrix.node }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-14, windows-latest] | |
| node: [18, 20, 22] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| lfs: true | |
| # NO submodules - we're testing vendor/ sources (Phase 1 requirement) | |
| - name: Pull Git LFS files | |
| run: git lfs pull | |
| - name: Setup Node.js ${{ matrix.node }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| cache: 'npm' | |
| - name: Install build dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential cmake | |
| - name: Install build dependencies (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| # Xcode command line tools already installed on GitHub runners | |
| brew install cmake | |
| - name: Install build dependencies (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' | |
| # MSVC already available on GitHub runners | |
| - name: Verify vendor/ sources exist | |
| run: | | |
| node -e "const fs = require('fs'); if (!fs.existsSync('vendor/VERSIONS.json')) throw new Error('vendor/ sources missing! Run npm run update-vendors'); console.log('✓ Vendor sources found');" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build from vendored sources | |
| run: npm install | |
| # This runs the install script which: | |
| # 1. Builds llama.cpp from vendor/llama.cpp | |
| # 2. Sets up headers from vendor/liblloyal | |
| # 3. Builds N-API module with node-gyp | |
| - name: Verify build outputs | |
| run: | | |
| node -e "const fs = require('fs'); const files = fs.readdirSync('build/Release'); console.log('Build outputs:', files); if (!files.some(f => f.endsWith('.node'))) throw new Error('No .node file built!');" | |
| - name: Run API tests (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| $env:PATH = "${{ github.workspace }}\build\Release;$env:PATH" | |
| npm run test:api | |
| timeout-minutes: 5 | |
| - name: Run API tests (Unix) | |
| if: runner.os != 'Windows' | |
| run: npm run test:api | |
| timeout-minutes: 5 | |
| - name: Run E2E tests (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| $env:PATH = "${{ github.workspace }}\build\Release;$env:PATH" | |
| npm run test:e2e | |
| timeout-minutes: 5 | |
| - name: Run E2E tests (Unix) | |
| if: runner.os != 'Windows' | |
| run: npm run test:e2e | |
| timeout-minutes: 5 | |
| # Note: E2E tests include embedding suite which skips gracefully if no embedding model | |
| - name: Display build info | |
| if: always() | |
| run: | | |
| echo "================================" | |
| echo "Build Information" | |
| echo "================================" | |
| echo "OS: ${{ runner.os }}" | |
| echo "Node: ${{ matrix.node }}" | |
| echo "Platform: $(node -p 'process.platform')" | |
| echo "Arch: $(node -p 'process.arch')" | |
| echo "Vendor sources used: YES (Phase 1)" | |
| if [ -f vendor/VERSIONS.json ]; then | |
| echo "Vendored versions:" | |
| cat vendor/VERSIONS.json | |
| fi | |
| shell: bash | |
| - name: Upload build artifacts (failures only) | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-failure-${{ matrix.os }}-node${{ matrix.node }} | |
| path: | | |
| build/ | |
| vendor/llama.cpp/build-*/CMakeCache.txt | |
| vendor/llama.cpp/build-*/CMakeFiles/CMakeError.log | |
| retention-days: 7 | |
| verify-npm-package: | |
| name: Verify npm package contents | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Pack package | |
| run: npm pack | |
| - name: Extract and verify tarball | |
| run: | | |
| tar -tzf lloyal.node-*.tgz > package-contents.txt | |
| echo "📦 Package contents:" | |
| cat package-contents.txt | |
| # Verify vendor/ is included | |
| if ! grep -q "package/vendor/VERSIONS.json" package-contents.txt; then | |
| echo "❌ ERROR: vendor/VERSIONS.json not in package!" | |
| exit 1 | |
| fi | |
| # Verify vendor/liblloyal/include/ is included | |
| if ! grep -q "package/vendor/liblloyal/include" package-contents.txt; then | |
| echo "❌ ERROR: vendor/liblloyal/include/ not in package!" | |
| exit 1 | |
| fi | |
| # Verify vendor/llama.cpp sources are included | |
| if ! grep -q "package/vendor/llama.cpp/src" package-contents.txt; then | |
| echo "❌ ERROR: vendor/llama.cpp/src not in package!" | |
| exit 1 | |
| fi | |
| # Verify build artifacts are NOT included | |
| if grep -q "package/vendor/llama.cpp/build-apple" package-contents.txt; then | |
| echo "❌ ERROR: build-apple/ should not be in package!" | |
| exit 1 | |
| fi | |
| # Note: vendor/liblloyal/tests/ is no longer vendored (only headers needed) | |
| echo "✅ Package contents verified!" | |
| - name: Upload package for inspection | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: npm-package | |
| path: lloyal.node-*.tgz | |
| retention-days: 7 | |
| test-summary: | |
| name: Test Summary | |
| runs-on: ubuntu-latest | |
| needs: [test-vendored-sources, verify-npm-package] | |
| if: always() | |
| steps: | |
| - name: Check test results | |
| run: | | |
| echo "================================" | |
| echo "Phase 1 Test Results" | |
| echo "================================" | |
| echo "✓ Vendor sources tested on Linux, macOS, Windows" | |
| echo "✓ Node.js 18, 20, 22 compatibility verified" | |
| echo "✓ npm package contents verified" | |
| echo "✓ API tests passed (11 tests)" | |
| echo "✓ E2E tests passed (4 text generation + 8 embedding tests)" | |
| echo "" | |
| echo "Phase 1 (Build from Source) Status: ${{ needs.test-vendored-sources.result }}" |