Skip to content

Commit

Permalink
Fix some issues with github actions CI (#2724)
Browse files Browse the repository at this point in the history
Adds [turbo_tests](https://github.com/serpapi/turbo_tests) but doesn't
use them on github actions yet
  • Loading branch information
sethherr authored Mar 8, 2025
1 parent a89a0bd commit f6bfaf1
Show file tree
Hide file tree
Showing 17 changed files with 220 additions and 194 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
TRANSLATION_BRANCH: main
RETRY_FLAKY: true
steps:
- name: Get CPU cores
id: cpu-info
run: echo "cpu-cores=$(nproc)" >> $GITHUB_OUTPUT
# install system dependencies
- name: Install system dependencies
run: |
Expand Down Expand Up @@ -85,13 +88,14 @@ jobs:
- name: Set up database
run: bin/rails db:create db:schema:load:primary db:schema:load:analytics db:migrate db:seed
- name: Sync translations (only on main by default)
run: bin/check_translations
run: bin/check_translations ${{ secrets.TRANSLATION_IO_API_KEY }}
# Install JS dependencies
- name: build assets
run: bin/rails assets:precompile --trace
# Run tests
- name: Run tests
run: bundle exec rspec
# TODO: switch to using turbo_tests, need to do parallel prepare, etc
- name: publish code coverage
uses: paambaati/[email protected]

Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ group :development, :test do
gem "dotenv-rails"
gem "factory_bot_rails"
gem "foreman"
gem "parallel_tests"
gem "turbo_tests" # parallel tests
gem "pry-byebug"
gem "pry-rails"
gem "rspec"
Expand All @@ -158,6 +158,7 @@ group :test do
gem "rspec-sidekiq"
gem "simplecov", require: false
gem "simplecov_json_formatter", require: false # Fix json error
gem "rspec-github", require: false
gem "vcr" # Stub external HTTP requests
gem "webmock" # mocking for VCR
gem "rspec-retry", require: false # Retry flaky test failures on CI
Expand Down
10 changes: 8 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ GEM
bigdecimal (>= 3.0)
pagy (9.3.3)
parallel (1.26.3)
parallel_tests (4.9.0)
parallel_tests (4.10.1)
parallel
paranoia (3.0.1)
activerecord (>= 6, < 8.1)
Expand Down Expand Up @@ -639,6 +639,8 @@ GEM
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-github (3.0.0)
rspec-core (~> 3.0)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
Expand Down Expand Up @@ -763,6 +765,9 @@ GEM
turbo-rails (2.0.11)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
turbo_tests (2.2.4)
parallel_tests (>= 3.3.0, < 5)
rspec (>= 3.10)
twilio-ruby (5.40.4)
faraday (>= 0.9, < 2.0)
jwt (>= 1.5, <= 2.5)
Expand Down Expand Up @@ -878,7 +883,6 @@ DEPENDENCIES
observer
oj
pagy
parallel_tests
paranoia
pg
pg_search
Expand All @@ -901,6 +905,7 @@ DEPENDENCIES
responders
rqrcode (= 0.10.1)
rspec
rspec-github
rspec-rails
rspec-retry
rspec-sidekiq
Expand All @@ -923,6 +928,7 @@ DEPENDENCIES
thor
translation
turbo-rails
turbo_tests
twilio-ruby
twitter
vcr
Expand Down
6 changes: 3 additions & 3 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ We use [RSpec](https://github.com/rspec/rspec) and
CREATE EXTENSION fuzzystrmatch;
```

We use [`parallel_tests`](https://github.com/grosser/parallel_tests/) to run the test suite in parallel. By default, this will spawn one process per CPU in your computer.
We use [`turbo_tests`](https://github.com/serpapi/turbo_tests) to run the test suite in parallel. By default, this will spawn one process per CPU in your computer.

- Run all the tests in parallel with `bin/rake parallel:spec`
- Run all the tests in parallel with `bundle exec turbo_tests`

- Run `bin/rake parallel:prepare` to synchronize the test db schema after migrations (rather than `db:test:prepare`).

- Run specific files or test directories with `bin/parallel_rspec <FILES_OR_FOLDERS>`
- Run specific files or test directories with `bundle exec turbo_tests <FILES_OR_FOLDERS>`

- Run Guard with parallelism `bin/guard -G Guardfile_parallel`

Expand Down
4 changes: 4 additions & 0 deletions bin/check_translations
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env bash

if [ -n "$1" ]; then
export TRANSLATION_IO_API_KEY="$1"
fi

set -e

CYAN="\033[0;36m"
Expand Down
29 changes: 0 additions & 29 deletions bin/parallel_rspec

This file was deleted.

2 changes: 1 addition & 1 deletion config/locales/.translation_io
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
timestamp: 1740269298
timestamp: 1741390285
7 changes: 1 addition & 6 deletions config/locales/translation.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3345,7 +3345,6 @@ es:
users_new:
welcome_index: 'El mejor registro de bicicletas: Sencillo, seguro y gratuito.'
meta_titles:
about:
bikes_index:
bikes_new:
bikes_new_stolen:
Expand All @@ -3356,7 +3355,6 @@ es:
info_about:
info_serials:
info_spokecard:
info_stolen_bikes:
info_where:
landing_pages_ambassadors_current:
landing_pages_ambassadors_how_to:
Expand All @@ -3370,17 +3368,13 @@ es:
landing_pages_for_law_enforcement:
landing_pages_for_schools:
landing_pages_show:
links:
manufacturers_index:
news_index:
payments_create:
payments_new:
sessions_create:
sessions_new:
stolen_howworks:
stolen_index:
stolen_merging:
tech:
users_accept_terms:
users_accept_vendor_terms:
users_confirm:
Expand All @@ -3389,6 +3383,7 @@ es:
users_request_password_reset:
welcome_goodbye:
welcome_index:
my_account_show: Sus bicicletas
money:
currencies:
en:
Expand Down
7 changes: 1 addition & 6 deletions config/locales/translation.it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3361,7 +3361,6 @@ it:
users_new:
welcome_index:
meta_titles:
about:
bikes_index:
bikes_new:
bikes_new_stolen:
Expand All @@ -3372,7 +3371,6 @@ it:
info_about:
info_serials:
info_spokecard:
info_stolen_bikes:
info_where:
landing_pages_ambassadors_current:
landing_pages_ambassadors_how_to:
Expand All @@ -3386,17 +3384,13 @@ it:
landing_pages_for_law_enforcement:
landing_pages_for_schools:
landing_pages_show:
links:
manufacturers_index:
news_index:
payments_create:
payments_new:
sessions_create:
sessions_new:
stolen_howworks:
stolen_index:
stolen_merging:
tech:
users_accept_terms:
users_accept_vendor_terms:
users_confirm:
Expand All @@ -3405,6 +3399,7 @@ it:
users_request_password_reset:
welcome_goodbye:
welcome_index:
my_account_show:
money:
currencies:
en: USD
Expand Down
7 changes: 1 addition & 6 deletions config/locales/translation.nb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4341,7 +4341,6 @@ nb:
users_new: Registrer deg for Bike Index
welcome_index: 'Det beste sykkelregisteret: Enkelt, sikkert og gratis.'
meta_titles:
about: FAQ
bikes_index: Søkeresultater
bikes_new: Registrer en sykkel!
bikes_new_stolen: Registrer en stjålet sykkel
Expand All @@ -4352,7 +4351,6 @@ nb:
info_about: Bike Index - Sykkelregistrering som fungerer
info_serials: Serienummer på sykkel
info_spokecard: Spoke-kort - Bike Index
info_stolen_bikes: Reagerer på tyveri
info_where: Bike Index-partnere
landing_pages_ambassadors_current: Sykkelindeksambassadører
landing_pages_ambassadors_how_to: Bli en Bike Index-ambassadør
Expand All @@ -4367,17 +4365,13 @@ nb:
landing_pages_for_law_enforcement: Sykkelindeks for rettshåndhevelse
landing_pages_for_schools: Sykkelindeks for skoler
landing_pages_show: "%{organization} Sykkelregistrering"
links: lenker
manufacturers_index: Sykkelprodusenter
news_index: Sykkelindeksnyheter
payments_create: Takk for støtten!
payments_new: Støtt sykkelindeks!
sessions_create: Logg Inn
sessions_new: Logg Inn
stolen_howworks: Hvordan det fungerer
stolen_index: Sykkelregister
stolen_merging: Stjålet sykkelregister
tech: Teknologi for å bekjempe sykkeltyveri
users_accept_terms: Vilkår for bruk - Bike Index
users_accept_vendor_terms: Organisasjonsvilkår - Bike Index
users_confirm: Bekreft e-posten din - Bike Index
Expand All @@ -4386,6 +4380,7 @@ nb:
users_request_password_reset: Tilbakestill passord - Bike Index
welcome_goodbye: Logget ut
welcome_index: Bike Index - Sykkelregistrering som fungerer
my_account_show: Syklene dine
money:
currencies:
en: USD
Expand Down
7 changes: 1 addition & 6 deletions config/locales/translation.nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4116,7 +4116,6 @@ nl:
welcome_index: 'Het beste fietsregister: eenvoudig, veilig en gratis.'
my_accounts_show: Uw fietsen op Bike Index
meta_titles:
about: FAQ
bikes_index: Zoekresultaten
bikes_new: Registreer een fiets!
bikes_new_stolen: Registreer een gestolen fiets
Expand All @@ -4127,7 +4126,6 @@ nl:
info_about: Bike Index - de fietsregistratie die werkt
info_serials: Framenummers van de fiets
info_spokecard: Gesproken kaarten - Bike Index
info_stolen_bikes: Reageren op diefstal
info_where: Bike Index-partners
landing_pages_ambassadors_current: Bike Index Ambassadors
landing_pages_ambassadors_how_to: Word een ambassadeur van de fietsindex
Expand All @@ -4142,17 +4140,13 @@ nl:
landing_pages_for_law_enforcement: Fietsindex voor wetshandhaving
landing_pages_for_schools: Fietsindex voor scholen
landing_pages_show: "%{organization} Fietsregistratie"
links: Links
manufacturers_index: Fietsfabrikanten
news_index: Bike Index nieuws
payments_create: Bedankt voor je steun!
payments_new: Steun de Index!
sessions_create: Log in
sessions_new: Log in
stolen_howworks: Hoe het werkt
stolen_index: Fietsregister
stolen_merging: Gestolen fietsregister
tech: Technologie voor het bestrijden van fietsdiefstal
users_accept_terms: Gebruiksvoorwaarden - Bike Index
users_accept_vendor_terms: Organisatievoorwaarden - Bike Index
users_confirm: Bevestig uw e-mail - Fietsindex
Expand All @@ -4161,6 +4155,7 @@ nl:
users_request_password_reset: Wachtwoord opnieuw instellen - Fietsindex
welcome_goodbye: Uitgelogd
welcome_index: Bike Index - Fietsregistratie die werkt
my_account_show: Je fietsen
organized:
ambassador_dashboards:
getting_started:
Expand Down
6 changes: 6 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
RSpec.configure do |config|
# Use the GitHub Annotations formatter for CI
if ENV["GITHUB_ACTIONS"] == "true"
require "rspec/github"
config.add_formatter RSpec::Github::Formatter
end

# Use color in STDOUT
config.color = true

Expand Down
Loading

0 comments on commit f6bfaf1

Please sign in to comment.