Skip to content

feat: add uploads gallery with search and copy #2044

feat: add uploads gallery with search and copy

feat: add uploads gallery with search and copy #2044

Workflow file for this run

name: "Ruby on Rails CI"
on: { push: { branches: [main, dev] }, pull_request: { branches: [main, dev] } }
jobs:
rspec:
runs-on: ubuntu-latest
environment: test
strategy:
fail-fast: false
matrix:
include:
- ruby: '3.4.4'
rails: '7.2.2.2'
allowed_failure: false # ✅ required
- ruby: '3.4.4'
rails: '8.0.3'
allowed_failure: false # ✅ required
env:
RAILS_ENV: test
DATABASE_URL: "postgis://rails:password@localhost:5432/rails_test"
ES_HOST: "http://localhost"
ELASTICSEARCH_URL: "http://localhost:9200"
RAILS_VERSION: ${{ matrix.rails }}
services:
postgres:
image: postgis/postgis:latest
ports: ["5432:5432"]
env: { POSTGRES_DB: rails_test, POSTGRES_USER: rails, POSTGRES_PASSWORD: password }
elasticsearch:
image: elasticsearch:7.17.23
ports: ["9200:9200"]
env:
node.name: elasticsearch
cluster.name: better-together-es
discovery.seed_hosts: elasticsearch
discovery.type: single-node
bootstrap.memory_lock: "true"
ES_JAVA_OPTS: "-Xms512m -Xmx512m"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Ruby & gems
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
# Run the automatic bundle-install only on 7.2.
# For 7.2 / 8.0 it just sets up Ruby *and* restores a cache layer
# that we’ll reuse in the later manual install.
bundler-cache: ${{ matrix.rails == '8.0.3' }}
# One cache bucket per Rails version so they don’t clobber each other.
cache-version: rails-${{ matrix.rails }}
# Updating Rails can legitimately blow up on the experimental tracks,
# so we allow that *step* to error out without failing the job.
- name: Update Rails & install gems
if: matrix.rails != '8.0.3'
id: update
run: |
# turn off deployment mode
bundle config set deployment false
# conservative upgrade to the target rails version
bundle update rails --conservative
# install missing gems (writes bin/rspec, etc)
bundle install --jobs 4 --retry 3
continue-on-error: ${{ matrix.allowed_failure }}
- name: Prepare DB schema
if: (matrix.rails == '8.0.3') || steps.update.outcome == 'success'
run: |
rm -f spec/dummy/tmp/pids/server.pid
bundle exec rake -f spec/dummy/Rakefile db:schema:load
continue-on-error: ${{ matrix.allowed_failure }}
- name: Wait for Elasticsearch
if: (matrix.rails == '8.0.3') || steps.update.outcome == 'success'
run: |
echo "Waiting for Elasticsearch to be healthy..."
curl -s "http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s" || (echo "Elasticsearch not healthy" && exit 1)
- name: Run RSpec
if: (matrix.rails == '8.0.3') || steps.update.outcome == 'success'
env:
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
run: |
rm -f spec/dummy/tmp/pids/server.pid
bundle exec rspec
continue-on-error: ${{ matrix.allowed_failure }}
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report-ruby-${{ matrix.ruby }}-rails-${{ matrix.rails }}
path: |
coverage/
- name: Generate coverage badge
if: ${{ github.ref == 'refs/heads/main' && success() }}
continue-on-error: true
run: |
COVERAGE=$(jq -r '.result.covered_percent' coverage/.last_run.json)
COLOR=$(node -e "cov=parseFloat(process.argv[1]);console.log(cov>=90?'green':cov>=75?'orange':'red')" $COVERAGE)
npx badgen-cli --subject coverage --status ${COVERAGE}% --color $COLOR > coverage.svg
- name: Commit badge
if: ${{ github.ref == 'refs/heads/main' && success() }}
continue-on-error: true
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: update coverage badge"
file_pattern: coverage.svg
# ── style & security jobs (unchanged) ───────────────────────────────────────
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with: { bundler-cache: true }
- run: bundle exec rubocop --parallel
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with: { bundler-cache: true }
- run: bundle binstubs bundler-audit --force
- run: bundle exec bundler-audit --update
- run: bundle exec brakeman -q -w2