HastCI RSpec
Distributed test execution for RSpec. Workers pull tests from a central queue, so faster workers automatically run more tests.
Installation
Add to your Gemfile:
group :development, :test do
gem "hastci-rspec"
end
Usage
GitHub Actions
HastCI auto-detects GitHub Actions and configures itself from the environment.
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ci_node_index: [0, 1, 2, 3]
steps:
- uses: actions/checkout@v6
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Run tests
run: bundle exec hastci-rspec
env:
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
HASTCI_API_KEY: ${{ secrets.HASTCI_API_KEY }}
For matrix builds with multiple dimensions (e.g., Ruby versions), use HASTCI_SUBRUN_ID to create separate test queues:
strategy:
matrix:
ruby-version: ["3.2", "3.3", "3.4"]
ci_node_index: [0, 1]
# ...
env:
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
HASTCI_API_KEY: ${{ secrets.HASTCI_API_KEY }}
HASTCI_SUBRUN_ID: ruby-${{ matrix.ruby-version }}
Generic CI
For other CI systems, set the required environment variables:
export HASTCI_API_KEY="your-api-key"
export HASTCI_RUN_KEY="unique-run-identifier" # e.g., build-123-abc
export CI_NODE_INDEX="0" # 0, 1, 2... for each parallel worker
bundle exec hastci-rspec
Configuration
| Variable | Required | Description |
|---|---|---|
HASTCI_API_KEY |
Yes | API key for HastCI |
HASTCI_RUN_KEY |
Generic CI only | Unique identifier for this test run |
CI_NODE_INDEX |
Yes | Worker index (0, 1, 2...) |
HASTCI_WORKER_ID |
No | Custom worker ID (overrides CI_NODE_INDEX) |
HASTCI_SUBRUN_ID |
No | Distinguishes matrix variations (GitHub Actions) |
HASTCI_API_URL |
No | Custom API endpoint |
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/wojtodzio/hastci.
License
The gem is available as open source under the terms of the MIT License.