Skip to content

Bump uri from 0.13.1 to 1.0.2 #1754

Bump uri from 0.13.1 to 1.0.2

Bump uri from 0.13.1 to 1.0.2 #1754

Workflow file for this run

name: Rails API
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
pull-requests: write
checks: write
env:
RAILS_ENV: test
POSTGRES_HOST: ${{ secrets.DB_HOST }}
POSTGRES_PORT: ${{ secrets.DB_PORT }}
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
POSTGRES_DATABASE: ${{ secrets.POSTGRES_DB }}
AUTH_SECRET: ${{ secrets.DEVISE_JWT_SECRET_KEY }}
BUNDLE_GEMFILE: ${{ github.workspace }}/Gemfile
CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }}
CLERK_PUBLISHABLE_KEY: ${{ secrets.CLERK_PUBLISHABLE_KEY }}
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{ secrets.CLERK_PUBLISHABLE_KEY }}
CLERK_WEBHOOK_SECRET: ${{ secrets.CLERK_WEBHOOK_SECRET }}
RUBY_VERSION: 3.3.5
REDIS_URL: ${{ secrets.REDIS_URL }}
ACTION_CABLE_URL: ${{ secrets.ACTION_CABLE_URL }}
ACTION_CABLE_ALLOWED_ORIGINS: ${{ secrets.ACTION_CABLE_ALLOWED_ORIGINS }}
RAILS_HOSTS: ${{ secrets.RAILS_HOSTS }}
RAILS_API_DEFAULT_HOST: ${{ secrets.RAILS_API_DEFAULT_HOST }}
CORS_ALLOWED_ORIGINS: ${{ secrets.CORS_ALLOWED_ORIGINS }}
jobs:
parallel-tests:
runs-on: ubuntu-latest
strategy:
matrix:
group: [1, 2, 3, 4]
max-parallel: 4
name: RSpec parallel group ${{ matrix.group }}/4
services:
postgres:
image: postgres:16.3
env:
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: "${{ secrets.POSTGRES_PASSWORD }}"
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- name: Install dependencies
run: bundle check || bundle install
- name: "Runtime cache: restore"
uses: actions/cache/restore@v4
id: cache-restore
with:
key: runtime-cache-all
path: tmp/parallel_runtime_rspec.log
- name: Setup database
run: |
bundle exec rake parallel:create
bundle exec rake parallel:migrate
bundle exec rake parallel:prepare
- name: Run Rspec Tests
run: |
mkdir -p tmp/parallel_runtime_rspec
rm -f tmp/parallel_runtime_rspec.log
if [ -f "tmp/parallel_runtime_rspec.log" ]; then
bundle exec parallel_rspec -n 4 --group-by runtime --only-group ${{ matrix.group }} --verbose
else
bundle exec parallel_rspec -n 4 --group-by filesize --only-group ${{ matrix.group }} --verbose
fi
env:
AUTH_SECRET: ${{ secrets.AUTH_SECRET}}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
RECORD_RUNTIME: "true"
- name: "Runtime cache: store chunk"
if: always() && steps.cache-restore.outputs.cache-hit != 'true' # Only save if cache was not hit
uses: actions/cache/save@v4
with:
key: runtime-cache-${{ matrix.group }}
path: tmp/parallel_runtime_rspec
- name: "Runtime cache: clear chunk"
if: always()
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete runtime-cache-${{ matrix.group }} --confirm || true
mkdir -p tmp/parallel_runtime_rspec
if [ -f "tmp/parallel_runtime_rspec.log" ]; then
mv tmp/parallel_runtime_rspec.log tmp/parallel_runtime_rspec/${{ matrix.group }}.log
fi
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: always()
with:
report_paths: './test-results/rspec/results.xml'
include_passed: true
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
if: ${{ !cancelled() }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: 'coverage/.resultset.json,coverage/index.html,coverage/lcov.info'
flags: rspec
name: codecov-umbrella
verbose: true
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
directory: test-results
files: '**/*.xml'
flags: rspec
token: ${{ secrets.CODECOV_TOKEN }}
- name: List coverage directory
run: ls -la coverage
store-runtime:
runs-on: ubuntu-latest
needs: parallel-tests
steps:
- name: "Runtime cache: load chunk 1"
uses: actions/cache/restore@v4
with:
key: runtime-cache-1
path: tmp/parallel_runtime_rspec
- name: "Runtime cache: load chunk 2"
uses: actions/cache/restore@v4
with:
key: runtime-cache-2
path: tmp/parallel_runtime_rspec
- name: "Runtime cache: load chunk 3"
uses: actions/cache/restore@v4
with:
key: runtime-cache-3
path: tmp/parallel_runtime_rspec
- name: "Runtime cache: load chunk 4"
uses: actions/cache/restore@v4
with:
key: runtime-cache-4
path: tmp/parallel_runtime_rspec
- name: "Runtime cache: combine chunks"
run: |
mkdir -p tmp
if [ ! -f "tmp/parallel_runtime_rspec/1.log" ] || [ ! -f "tmp/parallel_runtime_rspec/2.log" ] || [ ! -f "tmp/parallel_runtime_rspec/3.log" ] || [ ! -f "tmp/parallel_runtime_rspec/4.log" ]; then
echo "Error: Missing runtime logs"
exit 1
fi
cat tmp/parallel_runtime_rspec/* > tmp/parallel_runtime_rspec.log
cat tmp/parallel_runtime_rspec.log
- name: "Runtime cache: clear"
env:
GH_TOKEN: ${{ github.token }}
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete runtime-cache-all --confirm
continue-on-error: true
- name: "Runtime cache: store"
uses: actions/cache/save@v4
with:
key: runtime-cache-all
path: tmp/parallel_runtime_rspec.log
audit:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- name: Install dependencies
run: bundle check || bundle install
- name: Run Ruby Audit
run: bundle exec ruby-audit check
rubocop:
runs-on: ubuntu-latest
env:
BUNDLE_ONLY: rubocop
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- name: Install dependencies
run: bundle check || bundle install
- name: Run RuboCop with Reviewdog
if: github.event_name == 'pull_request'
uses: reviewdog/action-rubocop@v2
with:
rubocop_version: gemfile
rubocop_extensions: rubocop-rails:gemfile rubocop-rspec:gemfile rubocop-performance:gemfile rubocop-rspec:gemfile rubocop-github:gemfile
only_changed: true
github_token: ${{ github.token }}
reporter: github-pr-review # Default is github-pr-check
skip_install: true
use_bundler: true
rubocop_flags: --force-exclusion