Skip to content

Commit

Permalink
build: ci github action
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaynomics committed Jan 21, 2024
1 parent 7ebd3a8 commit 8f0bff3
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 32 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Tests
on:
pull_request:
push:
branches:
- main
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: [ "3.0", "3.1", "3.2" ]
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler: default
bundler-cache: true

- name: Run tests
run: |
bundle exec rake
linters:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler: default
bundler-cache: true
- name: rubocop check
run: |
bundle exec rubocop
27 changes: 0 additions & 27 deletions .github/workflows/main.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require:
- standard
- rubocop-minitest
- rubocop-rake

inherit_gem:
standard: config/base.yml
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ gem "rake"
gem "minitest"

gem "rubocop"
gem "rubocop-minitest"
gem "rubocop-rake"

gem "standard", require: false

Expand Down
7 changes: 7 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-minitest (0.34.5)
rubocop (>= 1.39, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-performance (1.20.2)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
standard (1.33.0)
Expand Down Expand Up @@ -106,6 +111,8 @@ DEPENDENCIES
minitest
rake
rubocop
rubocop-minitest
rubocop-rake
standard
webmock

Expand Down
2 changes: 1 addition & 1 deletion test/cloudflare/ai/clients/text_generation/test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module TestHelpers

def stub_response_for_successful_completion(response: "Happy song")
stub_request(:post, @url)
.to_return(status: 200, body: {result: {response:}, success: true}.to_json)
.to_return(status: 200, body: {result: {response: response}, success: true}.to_json)
end

def stub_response_for_unsuccessful_completion
Expand Down
4 changes: 2 additions & 2 deletions test/cloudflare/message_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ def test_to_json
private

def system_message_fixture(content: "Hello")
Cloudflare::AI::Message.new(role: "system", content:)
Cloudflare::AI::Message.new(role: "system", content: content)
end

def user_message_fixture(content: "Hello")
Cloudflare::AI::Message.new(role: "user", content:)
Cloudflare::AI::Message.new(role: "user", content: content)
end
end
4 changes: 2 additions & 2 deletions test/cloudflare/result_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ class Cloudflare::AI::ResultTest < Minitest::Test
def test_successful_result
result = Cloudflare::AI::Result.new(successful_response_json)
assert result.success?
assert !result.failure?
refute result.failure?

assert_equal successful_response_json["result"]["response"], result.response
end

def test_unsuccessful_result
result = Cloudflare::AI::Result.new(unsuccessful_response_json)
assert !result.success?
refute result.success?
assert result.failure?

assert_equal unsuccessful_response_json["errors"][0]["code"], result.errors[0]["code"]
Expand Down

0 comments on commit 8f0bff3

Please sign in to comment.