Publish precompiled native gems on tag (x86_64-linux, aarch64-linux, arm64-darwin) #392
Workflow file for this run
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: build | |
| on: pull_request | |
| # The build job only checks out code, restores/saves caches, and runs tests. | |
| # Grant the GITHUB_TOKEN least privilege. | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| ruby-version: ['3.4', '4.0'] | |
| fail-fast: false | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ matrix.ruby-version }} | |
| bundler-cache: true | |
| - name: Detect Ruby patch version for cache path | |
| id: ruby-version | |
| run: echo "patch=$(ruby -e 'puts RUBY_VERSION')" >> "$GITHUB_OUTPUT" | |
| - name: Restore Cargo cache | |
| id: cargo-cache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| tmp/x86_64-linux/candle/${{ steps.ruby-version.outputs.patch }}/target | |
| key: ${{ runner.os }}-cargo-${{ steps.ruby-version.outputs.patch }}-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-${{ steps.ruby-version.outputs.patch }}- | |
| # # Configure AWS credentials for S3 access | |
| # - name: Configure AWS credentials | |
| # uses: aws-actions/configure-aws-credentials@v2 | |
| # with: | |
| # aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| # aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| # aws-region: eu-central-1 | |
| # # Download HuggingFace cache from S3 | |
| # - name: Sync HuggingFace cache from S3 | |
| # run: | | |
| # echo "Downloading HuggingFace cache from S3..." | |
| # aws s3 sync s3://red-candle-hf-cache/cache/ ~/.cache/huggingface/ --quiet | |
| # echo "Cache downloaded successfully" | |
| # echo "Cache size: $(du -sh ~/.cache/huggingface | cut -f1)" | |
| # echo "Models cached: $(ls -d ~/.cache/huggingface/hub/models--* 2>/dev/null | wc -l)" | |
| # # Set offline mode since we have all models | |
| # echo "HF_HUB_OFFLINE=1" >> $GITHUB_ENV | |
| # echo "Offline mode enabled - no HuggingFace API calls will be made" | |
| # - name: Display Memory Usage | |
| # run: free -h | |
| # - name: Display Disk Space Before Test | |
| # run: df -h | |
| - name: Restore HuggingFace model cache | |
| id: hf-cache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: ~/.cache/huggingface/hub | |
| key: ${{ runner.os }}-hf-models-${{ hashFiles('spec/**/*.rb') }} | |
| restore-keys: | | |
| ${{ runner.os }}-hf-models- | |
| - name: Compile native extension | |
| run: bundle exec rake compile | |
| - name: Save Cargo cache | |
| if: always() && steps.cargo-cache.outputs.cache-hit != 'true' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| tmp/x86_64-linux/candle/${{ steps.ruby-version.outputs.patch }}/target | |
| key: ${{ runner.os }}-cargo-${{ steps.ruby-version.outputs.patch }}-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Run unit specs | |
| run: | | |
| bundle exec rspec \ | |
| spec/build_info_spec.rb \ | |
| spec/candle_spec.rb \ | |
| spec/embedding_model_type_spec.rb \ | |
| spec/gazetteer_entity_recognizer_spec.rb \ | |
| spec/generation_config_spec.rb \ | |
| spec/hybrid_ner_spec.rb \ | |
| spec/pattern_entity_recognizer_spec.rb \ | |
| spec/require_spec.rb \ | |
| spec/schema_processor_spec.rb \ | |
| spec/tensor_methods_spec.rb | |
| - name: Run model specs (isolated per file to prevent memory accumulation) | |
| run: | | |
| FAILED=0 | |
| MODEL_SPECS=( | |
| spec/embedding_model_spec.rb | |
| spec/embedding_model_pooling_spec.rb | |
| spec/embedding_model_types_spec.rb | |
| spec/candle_embedding_verification_spec.rb | |
| spec/reranker_spec.rb | |
| spec/reranker_truncation_spec.rb | |
| spec/reranker_max_length_spec.rb | |
| spec/ner_spec.rb | |
| spec/ner_core_functionality_spec.rb | |
| spec/ner_comprehensive_spec.rb | |
| spec/ner_integration_spec.rb | |
| spec/tokenizer_spec.rb | |
| spec/tokenizer_tokens_spec.rb | |
| spec/tokenizer_coverage_spec.rb | |
| spec/vocabulary_adapter_integration_spec.rb | |
| spec/llm_metadata_spec.rb | |
| spec/model_edge_cases_spec.rb | |
| spec/candle_informers_comparison_spec.rb | |
| spec/cache_dir_spec.rb | |
| spec/device_compatibility_spec.rb | |
| ) | |
| for spec in "${MODEL_SPECS[@]}"; do | |
| echo "=== Running $spec ===" | |
| if ! bundle exec rspec "$spec" --tag '~llm'; then | |
| echo "FAILED: $spec" | |
| FAILED=1 | |
| fi | |
| done | |
| exit $FAILED | |
| - name: Save HuggingFace model cache | |
| if: always() && steps.hf-cache.outputs.cache-hit != 'true' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: ~/.cache/huggingface/hub | |
| key: ${{ runner.os }}-hf-models-${{ hashFiles('spec/**/*.rb') }} | |
| # - name: Run specs | |
| # run: | | |
| # # HF_HUB_OFFLINE is already set by S3 sync step | |
| # # This ensures no HuggingFace API calls during tests | |
| # echo "Running specs with HF_HUB_OFFLINE=$HF_HUB_OFFLINE" | |
| # echo "Ruby version: ${{ matrix.ruby-version }}" | |
| # bundle exec rspec | |
| # - name: Display Disk Space After Test | |
| # run: df -h | |
| # - run: bundle exec yard --readme README.md --markup markdown --markup-provider redcarpet |