Skip to content

Commit

Permalink
Run i18n_specs in a separate job
Browse files Browse the repository at this point in the history
  • Loading branch information
binarygit committed Jul 11, 2024
1 parent 77c4000 commit 15ff5e5
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 4 deletions.
89 changes: 88 additions & 1 deletion .github/workflows/system-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,94 @@ jobs:
- name: Run tests
id: run_tests
run: bundle exec rspec spec/system
run: bundle exec rspec spec/system/

- uses: actions/upload-artifact@v3
with:
name: coverage_system_${{ matrix.rails }}_ruby_${{ matrix.ruby }}
path: coverage/.resultset.json

- uses: actions/upload-artifact@v3
if: always() && steps.run_tests.outcome == 'failure'
with:
name: rspec_failed_screenshots_rails_${{ matrix.rails }}_ruby_${{ matrix.ruby }}
path: ./spec/dummy/tmp/screenshots

i18n_tests:
strategy:
matrix:
ruby:
- '3.3.0'
rails:
- '8.0'
runs-on: ubuntu-latest

env:
RAILS_VERSION: ${{matrix.rails}}
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.rails }}_ruby_${{ matrix.ruby }}.gemfile

services:
postgres:
image: postgres:10.8
ports: ["5432:5432"]
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v3

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
# bundler-cache: true
bundler: default
ruby-version: ${{ matrix.ruby }}

- uses: actions/cache@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-test-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-test-gems-${{ hashFiles('**/Gemfile.lock') }}
- name: Bundle install
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
bin/rails db:create
bin/rails db:migrate
- name: Get yarn cache directory path
id: test-yarn-cache-dir-path
run: echo "name=dir::$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: test-yarn-cache
with:
path: ${{ steps.test-yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-test-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-test-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Yarn install the dummy app
run: |
cd spec/dummy
yarn
- name: Yarn install
run: yarn

- name: Build assets
env:
RAILS_ENV: production
NODE_ENV: production
run: |
yarn build:js
yarn build:css
yarn build:custom-js
- name: Run tests
id: run_tests
run: bundle exec rspec spec/system/i18n_spec.rb

- uses: actions/upload-artifact@v3
with:
Expand Down
9 changes: 6 additions & 3 deletions spec/system/i18n_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
let(:unused_keys) { i18n.unused_keys }
let(:inconsistent_interpolations) { i18n.inconsistent_interpolations }

it 'does not have missing keys' do
# Using i18n tags in these tests, so we can exclude them
# when running system_tests in CI and run only these tests in
# a separate job.
it "does not have missing keys", i18n: true do
expect(missing_keys).to be_empty,
"Missing #{missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them"
end
Expand All @@ -18,15 +21,15 @@
# "#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them"
# end

it 'files are normalized' do
it "files are normalized", i18n: true do
non_normalized = i18n.non_normalized_paths
error_message = "The following files need to be normalized:\n" \
"#{non_normalized.map { |path| " #{path}" }.join("\n")}\n" \
"Please run `i18n-tasks normalize' to fix"
expect(non_normalized).to be_empty, error_message
end

it 'does not have inconsistent interpolations' do
it "does not have inconsistent interpolations", i18n: true do
error_message = "#{inconsistent_interpolations.leaves.count} i18n keys have inconsistent interpolations.\n" \
"Run `i18n-tasks check-consistent-interpolations' to show them"
expect(inconsistent_interpolations).to be_empty, error_message
Expand Down

0 comments on commit 15ff5e5

Please sign in to comment.