Parse errors from Bedrock properly #240
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: CI | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| paths: | |
| - 'lib/**' | |
| - 'spec/**' | |
| - 'Gemfile' | |
| - 'Rakefile' | |
| - 'ruby_llm.gemspec' | |
| - '.github/workflows/cicd.yml' | |
| pull_request: | |
| branches: [ "main" ] | |
| paths: | |
| - 'lib/**' | |
| - 'spec/**' | |
| - 'Gemfile' | |
| - 'Rakefile' | |
| - 'ruby_llm.gemspec' | |
| - '.github/workflows/cicd.yml' | |
| workflow_call: | |
| # Define default permissions for this workflow | |
| permissions: | |
| contents: read | |
| packages: write # Needed for publishing to GitHub Packages | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| ruby-version: ['3.1', '3.2', '3.3', '3.4'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ matrix.ruby-version }} | |
| bundler-cache: true | |
| - name: Install dependencies | |
| run: bundle install | |
| - name: Check code format | |
| run: bundle exec rubocop | |
| - name: Run tests | |
| run: bundle exec rspec | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| with: | |
| files: ./coverage/coverage.xml | |
| fail_ci_if_error: false | |
| publish: | |
| name: Build + Publish | |
| needs: test | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.3' | |
| bundler-cache: true | |
| - name: Check if version has changed | |
| id: check_version | |
| run: | | |
| VERSION=$(ruby -r ./lib/ruby_llm/version.rb -e "puts RubyLLM::VERSION") | |
| echo "Current version: $VERSION" | |
| # Fetch all versions including prereleases | |
| ALL_VERSIONS=$(gem list ruby_llm -r --prerelease | grep -oE '[0-9a-zA-Z\.\-]+') | |
| echo "Available versions: $ALL_VERSIONS" | |
| # Check if current version is among published versions | |
| if echo "$ALL_VERSIONS" | grep -Fxq "$VERSION"; then | |
| echo "Version $VERSION already published, skipping publish" | |
| echo "version_changed=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Version $VERSION is new" | |
| echo "version_changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Test with real APIs before publishing | |
| if: steps.check_version.outputs.version_changed == 'true' | |
| run: | | |
| echo "Removing all VCR cassettes to test against real APIs..." | |
| rm -rf spec/fixtures/vcr_cassettes | |
| echo "Running tests with real API calls..." | |
| env -u CI bundle exec rspec | |
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
| DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }} | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| - name: Publish to GPR | |
| if: steps.check_version.outputs.version_changed == 'true' | |
| run: | | |
| mkdir -p $HOME/.gem | |
| touch $HOME/.gem/credentials | |
| chmod 0600 $HOME/.gem/credentials | |
| printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials | |
| gem build *.gemspec | |
| output=$(gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem 2>&1) || { | |
| echo "$output" | |
| if echo "$output" | grep -q "already been pushed"; then | |
| echo "Version already exists, skipping" | |
| exit 0 | |
| else | |
| exit 1 | |
| fi | |
| } | |
| env: | |
| GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}" | |
| OWNER: ${{ github.repository_owner }} | |
| - name: Publish to RubyGems | |
| if: steps.check_version.outputs.version_changed == 'true' | |
| run: | | |
| mkdir -p $HOME/.gem | |
| touch $HOME/.gem/credentials | |
| chmod 0600 $HOME/.gem/credentials | |
| printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials | |
| gem build *.gemspec | |
| output=$(gem push *.gem 2>&1) || { | |
| echo "$output" | |
| if echo "$output" | grep -q "Repushing of gem versions is not allowed"; then | |
| echo "Version already exists, skipping" | |
| exit 0 | |
| else | |
| exit 1 | |
| fi | |
| } | |
| env: | |
| GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}" |