Skip to content

Commit 73007de

Browse files
committed
chore: fix tests
1 parent e83f3d3 commit 73007de

14 files changed

Lines changed: 955 additions & 512 deletions

.github/workflows/ci.yml

Lines changed: 14 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
name: CI/CD Pipeline
1+
name: CI
22

33
on:
44
push:
5-
branches: [ master, main, develop ]
5+
branches: [ master, main ]
66
pull_request:
7-
branches: [ master, main, develop ]
8-
release:
9-
types: [ published ]
7+
branches: [ master, main ]
108

119
env:
12-
RUBY_VERSION: '2.6.0'
10+
STREAM_API_KEY: ${{ vars.STREAM_API_KEY }}
11+
STREAM_API_SECRET: ${{ secrets.STREAM_API_SECRET }}
1312

1413
jobs:
1514
test:
1615
name: Test Suite
1716
runs-on: ubuntu-latest
18-
19-
strategy:
20-
matrix:
21-
ruby-version: ['2.6.0', '2.7.0', '3.0.0', '3.1.0', '3.2.0']
17+
environment: ci
2218

2319
steps:
2420
- name: Checkout code
@@ -27,179 +23,21 @@ jobs:
2723
- name: Set up Ruby
2824
uses: ruby/setup-ruby@v1
2925
with:
30-
ruby-version: ${{ matrix.ruby-version }}
26+
ruby-version: '3.1.0'
3127
bundler-cache: true
3228

3329
- name: Install dependencies
34-
run: |
35-
gem install bundler
36-
bundle install --jobs 4 --retry 3
30+
run: bundle install --jobs 4 --retry 3
3731

38-
- name: Run unit tests
39-
run: make test-unit
32+
- name: Run tests
33+
run: make test
4034

4135
- name: Run integration tests
4236
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')
43-
env:
44-
STREAM_API_KEY: ${{ secrets.STREAM_API_KEY }}
45-
STREAM_API_SECRET: ${{ secrets.STREAM_API_SECRET }}
46-
STREAM_APP_ID: ${{ secrets.STREAM_APP_ID }}
47-
run: make test-integration
48-
49-
- name: Run code formatting check
50-
run: make format-check
51-
52-
- name: Run linting
53-
run: make lint
54-
55-
- name: Run security audit
56-
run: make security
57-
continue-on-error: true
58-
59-
integration-tests:
60-
name: Integration Tests
61-
runs-on: ubuntu-latest
62-
if: github.event_name == 'pull_request' || (github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'))
63-
64-
steps:
65-
- name: Checkout code
66-
uses: actions/checkout@v4
67-
68-
- name: Set up Ruby
69-
uses: ruby/setup-ruby@v1
70-
with:
71-
ruby-version: ${{ env.RUBY_VERSION }}
72-
bundler-cache: true
73-
74-
- name: Install dependencies
75-
run: |
76-
gem install bundler
77-
bundle install --jobs 4 --retry 3
78-
79-
- name: Run integration tests
80-
env:
81-
STREAM_API_KEY: ${{ secrets.STREAM_API_KEY }}
82-
STREAM_API_SECRET: ${{ secrets.STREAM_API_SECRET }}
83-
STREAM_APP_ID: ${{ secrets.STREAM_APP_ID }}
8437
run: make test-integration
85-
86-
release:
87-
name: Release
88-
runs-on: ubuntu-latest
89-
needs: [test, integration-tests]
90-
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')
91-
92-
steps:
93-
- name: Checkout code
94-
uses: actions/checkout@v4
95-
with:
96-
fetch-depth: 0
97-
98-
- name: Set up Ruby
99-
uses: ruby/setup-ruby@v1
100-
with:
101-
ruby-version: ${{ env.RUBY_VERSION }}
102-
bundler-cache: true
103-
104-
- name: Install dependencies
105-
run: |
106-
gem install bundler
107-
bundle install --jobs 4 --retry 3
108-
109-
- name: Check for major release
110-
id: check-major
111-
run: |
112-
if git log --oneline -1 | grep -q "major"; then
113-
echo "release_type=major" >> $GITHUB_OUTPUT
114-
echo "should_release=true" >> $GITHUB_OUTPUT
115-
else
116-
echo "should_release=false" >> $GITHUB_OUTPUT
117-
fi
118-
119-
- name: Check for minor release
120-
id: check-minor
121-
run: |
122-
if git log --oneline -1 | grep -q "minor"; then
123-
echo "release_type=minor" >> $GITHUB_OUTPUT
124-
echo "should_release=true" >> $GITHUB_OUTPUT
125-
else
126-
echo "should_release=false" >> $GITHUB_OUTPUT
127-
fi
128-
129-
- name: Check for patch release
130-
id: check-patch
131-
run: |
132-
if git log --oneline -1 | grep -q "patch"; then
133-
echo "release_type=patch" >> $GITHUB_OUTPUT
134-
echo "should_release=true" >> $GITHUB_OUTPUT
135-
else
136-
echo "should_release=false" >> $GITHUB_OUTPUT
137-
fi
138-
139-
- name: Determine release type
140-
id: release-type
141-
run: |
142-
if [ "${{ steps.check-major.outputs.should_release }}" = "true" ]; then
143-
echo "release_type=major" >> $GITHUB_OUTPUT
144-
echo "should_release=true" >> $GITHUB_OUTPUT
145-
elif [ "${{ steps.check-minor.outputs.should_release }}" = "true" ]; then
146-
echo "release_type=minor" >> $GITHUB_OUTPUT
147-
echo "should_release=true" >> $GITHUB_OUTPUT
148-
elif [ "${{ steps.check-patch.outputs.should_release }}" = "true" ]; then
149-
echo "release_type=patch" >> $GITHUB_OUTPUT
150-
echo "should_release=true" >> $GITHUB_OUTPUT
151-
else
152-
echo "should_release=false" >> $GITHUB_OUTPUT
153-
fi
154-
155-
- name: Release gem
156-
if: steps.release-type.outputs.should_release == 'true'
157-
env:
158-
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
159-
run: |
160-
echo "Releasing ${{ steps.release-type.outputs.release_type }} version..."
161-
make release-${{ steps.release-type.outputs.release_type }}
162-
163-
- name: Create GitHub Release
164-
if: steps.release-type.outputs.should_release == 'true'
165-
uses: actions/create-release@v1
166-
env:
167-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
168-
with:
169-
tag_name: v${{ steps.release-type.outputs.release_type }}
170-
release_name: Release ${{ steps.release-type.outputs.release_type }}
171-
body: |
172-
This is an automated ${{ steps.release-type.outputs.release_type }} release.
173-
174-
Changes in this release:
175-
- See commit history for details
176-
draft: false
177-
prerelease: false
178-
179-
security-scan:
180-
name: Security Scan
181-
runs-on: ubuntu-latest
182-
if: github.event_name == 'pull_request'
183-
184-
steps:
185-
- name: Checkout code
186-
uses: actions/checkout@v4
18738

188-
- name: Set up Ruby
189-
uses: ruby/setup-ruby@v1
190-
with:
191-
ruby-version: ${{ env.RUBY_VERSION }}
192-
bundler-cache: true
193-
194-
- name: Install dependencies
39+
- name: Run code quality checks
19540
run: |
196-
gem install bundler
197-
bundle install --jobs 4 --retry 3
198-
199-
- name: Run security audit
200-
run: make security
201-
202-
- name: Run CodeQL Analysis
203-
uses: github/codeql-action/analyze@v2
204-
with:
205-
languages: ruby
41+
make format-check
42+
make lint
43+
make security

.github/workflows/release.yml

Lines changed: 18 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,157 +1,42 @@
1-
name: Automated Release
1+
name: Release
22

33
on:
44
push:
5-
branches: [ master, main ]
6-
paths-ignore:
7-
- 'README.md'
8-
- 'docs/**'
9-
- '*.md'
10-
11-
env:
12-
RUBY_VERSION: '2.6.0'
5+
branches: [ master ]
6+
tags: [ 'v*' ]
137

148
jobs:
159
release:
16-
name: Automated Release
10+
name: Release
1711
runs-on: ubuntu-latest
18-
if: github.event_name == 'push'
1912

2013
steps:
2114
- name: Checkout code
2215
uses: actions/checkout@v4
2316
with:
2417
fetch-depth: 0
25-
token: ${{ secrets.GITHUB_TOKEN }}
2618

2719
- name: Set up Ruby
2820
uses: ruby/setup-ruby@v1
2921
with:
30-
ruby-version: ${{ env.RUBY_VERSION }}
22+
ruby-version: '2.6.0'
3123
bundler-cache: true
3224

3325
- name: Install dependencies
34-
run: |
35-
gem install bundler
36-
bundle install --jobs 4 --retry 3
37-
38-
- name: Configure Git
39-
run: |
40-
git config --local user.email "action@github.com"
41-
git config --local user.name "GitHub Action"
42-
43-
- name: Check for major release trigger
44-
id: check-major
45-
run: |
46-
if git log --oneline -1 | grep -qi "major"; then
47-
echo "trigger=major" >> $GITHUB_OUTPUT
48-
echo "should_release=true" >> $GITHUB_OUTPUT
49-
else
50-
echo "should_release=false" >> $GITHUB_OUTPUT
51-
fi
52-
53-
- name: Check for minor release trigger
54-
id: check-minor
55-
run: |
56-
if git log --oneline -1 | grep -qi "minor"; then
57-
echo "trigger=minor" >> $GITHUB_OUTPUT
58-
echo "should_release=true" >> $GITHUB_OUTPUT
59-
else
60-
echo "should_release=false" >> $GITHUB_OUTPUT
61-
fi
62-
63-
- name: Check for patch release trigger
64-
id: check-patch
65-
run: |
66-
if git log --oneline -1 | grep -qi "patch"; then
67-
echo "trigger=patch" >> $GITHUB_OUTPUT
68-
echo "should_release=true" >> $GITHUB_OUTPUT
69-
else
70-
echo "should_release=false" >> $GITHUB_OUTPUT
71-
fi
72-
73-
- name: Determine release trigger
74-
id: release-trigger
75-
run: |
76-
if [ "${{ steps.check-major.outputs.should_release }}" = "true" ]; then
77-
echo "trigger=major" >> $GITHUB_OUTPUT
78-
echo "should_release=true" >> $GITHUB_OUTPUT
79-
elif [ "${{ steps.check-minor.outputs.should_release }}" = "true" ]; then
80-
echo "trigger=minor" >> $GITHUB_OUTPUT
81-
echo "should_release=true" >> $GITHUB_OUTPUT
82-
elif [ "${{ steps.check-patch.outputs.should_release }}" = "true" ]; then
83-
echo "trigger=patch" >> $GITHUB_OUTPUT
84-
echo "should_release=true" >> $GITHUB_OUTPUT
85-
else
86-
echo "should_release=false" >> $GITHUB_OUTPUT
87-
fi
26+
run: bundle install --jobs 4 --retry 3
8827

89-
- name: Run tests before release
90-
if: steps.release-trigger.outputs.should_release == 'true'
91-
run: make test-unit
92-
93-
- name: Release gem
94-
if: steps.release-trigger.outputs.should_release == 'true'
28+
- name: Build and release gem
9529
env:
9630
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
9731
run: |
98-
echo "Releasing ${{ steps.release-trigger.outputs.trigger }} version..."
99-
make release-${{ steps.release-trigger.outputs.trigger }}
100-
101-
- name: Get version
102-
if: steps.release-trigger.outputs.should_release == 'true'
103-
id: get-version
104-
run: |
105-
VERSION=$(ruby -e "require_relative 'lib/getstream_ruby/version'; puts GetStreamRuby::VERSION")
106-
echo "version=$VERSION" >> $GITHUB_OUTPUT
107-
echo "Released version: $VERSION"
108-
109-
- name: Create GitHub Release
110-
if: steps.release-trigger.outputs.should_release == 'true'
111-
uses: actions/create-release@v1
112-
env:
113-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114-
with:
115-
tag_name: v${{ steps.get-version.outputs.version }}
116-
release_name: Release v${{ steps.get-version.outputs.version }}
117-
body: |
118-
## Release v${{ steps.get-version.outputs.version }}
119-
120-
This is an automated ${{ steps.release-trigger.outputs.trigger }} release triggered by commit message.
121-
122-
### Changes
123-
- See commit history for detailed changes
124-
125-
### Installation
126-
```bash
127-
gem install getstream-ruby -v ${{ steps.get-version.outputs.version }}
128-
```
129-
130-
### Usage
131-
```ruby
132-
require 'getstream_ruby'
133-
134-
# Configure the client
135-
GetStreamRuby.configure do |config|
136-
config.api_key = 'your_api_key'
137-
config.api_secret = 'your_api_secret'
138-
config.app_id = 'your_app_id'
139-
end
140-
141-
# Use the client
142-
client = GetStreamRuby.client
143-
```
144-
draft: false
145-
prerelease: false
146-
147-
- name: Comment on PR
148-
if: github.event_name == 'pull_request' && steps.release-trigger.outputs.should_release == 'true'
149-
uses: actions/github-script@v6
150-
with:
151-
script: |
152-
github.rest.issues.createComment({
153-
issue_number: context.issue.number,
154-
owner: context.repo.owner,
155-
repo: context.repo.repo,
156-
body: '🚀 **Automated Release Triggered!**\n\nA ${{ steps.release-trigger.outputs.trigger }} release has been triggered by the commit message and will be published shortly.'
157-
})
32+
# Extract version from tag if it's a tag push
33+
if [[ $GITHUB_REF == refs/tags/* ]]; then
34+
VERSION=${GITHUB_REF#refs/tags/v}
35+
echo "Releasing version $VERSION"
36+
# Update version in version.rb if needed
37+
# Then build and release
38+
bundle exec rake build
39+
bundle exec rake release
40+
else
41+
echo "Not a tag push, skipping release"
42+
fi

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.6.0

0 commit comments

Comments
 (0)