Skip to content

Commit d3c6e3f

Browse files
committed
feat: implement complete Z.ai Ruby SDK v0.1.0
This comprehensive implementation provides a production-ready Ruby SDK for Z.ai AI services, including chat completions, embeddings, images, and files APIs with JWT authentication, streaming support, Rails integration, and extensive documentation with examples.
1 parent 15b41d9 commit d3c6e3f

File tree

82 files changed

+10575
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+10575
-7
lines changed

.github/README.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# GitHub Actions for Z AI SDK Ruby
2+
3+
This repository includes several GitHub Actions workflows to automate the development and release process for your Ruby gem.
4+
5+
## Workflows
6+
7+
### 1. CI Workflow (`.github/workflows/ci.yml`)
8+
- **Triggers**: Push to main/develop branches, pull requests to main
9+
- **Features**:
10+
- Tests on Ruby 2.7, 3.0, 3.1, 3.2
11+
- RuboCop code style checks
12+
- Code coverage analysis
13+
- Gem building and artifact upload
14+
- OpenSpec change detection
15+
16+
### 2. Release Workflow (`.github/workflows/release.yml`)
17+
- **Triggers**: Git tags starting with `v*`
18+
- **Features**:
19+
- Automatic GitHub Release creation
20+
- Changelog generation from git commits
21+
- Gem artifact upload to release
22+
- RubyGems publishing
23+
24+
### 3. OpenSpec Phase Tagging (`.github/workflows/openspec-phases.yml`)
25+
- **Triggers**:
26+
- Changes to `openspec/` directory
27+
- Manual workflow dispatch
28+
- **Features**:
29+
- Automatic detection of completed OpenSpec phases
30+
- Phase-based tagging (e.g., `feature-name-v1.2.3`)
31+
- GitHub release creation for phase completion
32+
- Manual phase tagging option
33+
34+
### 4. Publish Workflow (`.github/workflows/publish.yml`)
35+
- **Triggers**: Manual workflow dispatch or called from other workflows
36+
- **Features**:
37+
- RubyGems version checking
38+
- Safe publishing (skips if version exists)
39+
- GitHub release creation
40+
- Gem building and validation
41+
42+
## Required Secrets
43+
44+
To use these workflows, add the following secrets to your GitHub repository:
45+
46+
1. **GITHUB_TOKEN**: Automatically provided by GitHub Actions
47+
2. **RUBYGEMS_API_KEY**: Your RubyGems API key for publishing gems
48+
49+
## Usage
50+
51+
### Automated Releases
52+
1. Complete your development work
53+
2. Create and push a version tag:
54+
```bash
55+
git tag v1.0.0
56+
git push origin v1.0.0
57+
```
58+
3. The release workflow will automatically:
59+
- Run all tests
60+
- Build the gem
61+
- Create a GitHub release
62+
- Publish to RubyGems
63+
64+
### Phase-based Development with OpenSpec
65+
1. Create OpenSpec changes in the `openspec/changes/` directory
66+
2. Complete all tasks in your change
67+
3. Push to main branch
68+
4. The OpenSpec Phase Tagging workflow will:
69+
- Detect completed changes
70+
- Create phase-specific tags
71+
- Create GitHub releases for each phase
72+
73+
### Manual Phase Tagging
74+
1. Go to Actions tab in GitHub
75+
2. Select "OpenSpec Phase Tagging" workflow
76+
3. Click "Run workflow"
77+
4. Enter phase name and optional version
78+
5. The workflow will create a tag and release for your phase
79+
80+
### Manual Gem Publishing
81+
1. Go to Actions tab in GitHub
82+
2. Select "Publish Gem" workflow
83+
3. Click "Run workflow"
84+
4. The workflow will build and publish your gem if the version doesn't exist
85+
86+
## Tag Naming Convention
87+
88+
- **Version tags**: `v1.2.3` (triggers full release)
89+
- **Phase tags**: `feature-name-v1.2.3` (triggers phase release)
90+
- **Manual tags**: Use workflow dispatch for custom naming
91+
92+
## Integration with OpenSpec
93+
94+
The workflows are designed to work seamlessly with OpenSpec:
95+
96+
1. **Phase Detection**: Automatically detects when all tasks in a change are complete
97+
2. **Change Documentation**: Includes OpenSpec proposal and task information in releases
98+
3. **Archive Integration**: Works with the OpenSpec archive-change skill
99+
100+
## Local Development
101+
102+
To test workflows locally, you can use `act` (GitHub Actions runner):
103+
104+
```bash
105+
# Install act
106+
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
107+
108+
# Run workflow
109+
act -j test
110+
```
111+
112+
## Troubleshooting
113+
114+
- **RubyGems Publishing**: Ensure your `RUBYGEMS_API_KEY` is correct and has publish permissions
115+
- **Tag Conflicts**: Make sure tag names are unique and follow the semver pattern
116+
- **OpenSpec Detection**: Ensure changes are in the correct directory with completed tasks

.github/workflows/ci.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
ruby-version: ['3.2.8', '3.3.0', '3.4.0']
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Ruby ${{ matrix.ruby-version }}
21+
uses: ruby/setup-ruby@v1
22+
with:
23+
ruby-version: ${{ matrix.ruby-version }}
24+
bundler-cache: true
25+
26+
- name: Install dependencies
27+
run: bundle install
28+
29+
- name: Run smoke test
30+
run: ruby smoke_test.rb
31+
32+
- name: Run verification
33+
run: ruby verify_sdk.rb
34+
35+
- name: Run tests
36+
run: bundle exec rake
37+
38+
- name: Run RuboCop
39+
run: bundle exec rubocop
40+
41+
- name: Check code coverage
42+
run: bundle exec rake coverage:check
43+
44+
build:
45+
needs: test
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- name: Set up Ruby
52+
uses: ruby/setup-ruby@v1
53+
with:
54+
ruby-version: '3.2.8'
55+
bundler-cache: true
56+
57+
- name: Build gem
58+
run: gem build *.gemspec
59+
60+
- name: Upload gem artifact
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: gem-package
64+
path: *.gem
65+
retention-days: 30
66+
67+
openspec-check:
68+
runs-on: ubuntu-latest
69+
70+
steps:
71+
- uses: actions/checkout@v4
72+
73+
- name: Check OpenSpec changes
74+
run: |
75+
if [ -d "openspec" ]; then
76+
echo "OpenSpec directory found"
77+
echo "Checking for changes in openspec/ directory..."
78+
79+
# List all OpenSpec changes if they exist
80+
if [ -d "openspec/changes" ]; then
81+
echo "Active changes:"
82+
find openspec/changes -maxdepth 1 -type d -not -path "openspec/changes" | while read change; do
83+
basename "$change"
84+
done
85+
fi
86+
else
87+
echo "No OpenSpec directory found"
88+
fi

0 commit comments

Comments
 (0)