Skip to content

Commit

Permalink
Write a passing spellr at the end of everything
Browse files Browse the repository at this point in the history
  • Loading branch information
robotdana committed Jul 18, 2022
1 parent ec211a6 commit ee9a012
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,11 @@ jobs:
PGPASSWORD: postgres
PGHOST: localhost
run: ./ci/bin/build-and-test
spellr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
- run: gem install spellr; spellr
23 changes: 14 additions & 9 deletions template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ def apply_template!
template "rubocop.yml.tt", ".rubocop.yml"
run_rubocop_autocorrections

copy_file ".spellr.yml"
copy_file ".spellr_wordlists/english.txt"
# TODO: add the @app_name to the wordlist then clean it

apply "variants/frontend-audit-app/template.rb"
apply "variants/frontend-base/js-lint/fixes.rb"

Expand All @@ -156,6 +152,13 @@ def apply_template!
# we deliberately place this after the initial git commit because it
# contains a lot of changes and adds its own git commit
apply "variants/devise/template.rb" if $config.apply_variant_devise?

copy_file ".spellr.yml"
FileUtils.mkdir_p ".spellr_wordlists"
wordlist = run_with_clean_bundler_env "bundle exec spellr --wordlist", capture: true
File.write('.spellr_wordlists/english.txt', wordlist)
git add: '.spellr_wordlists'
git commit: "-m 'Add Spellr wordlist'"
end
end

Expand Down Expand Up @@ -250,16 +253,18 @@ def preexisting_git_repo?
@preexisting_git_repo == true
end

def run_with_clean_bundler_env(cmd)
success = if defined?(Bundler)
Bundler.with_unbundled_env { run(cmd) }
def run_with_clean_bundler_env(cmd, **options)
result = if defined?(Bundler)
Bundler.with_unbundled_env { run(cmd, **options) }
else
run(cmd)
run(cmd, **options)
end
unless success
unless result
puts "Command failed, exiting: #{cmd}"
exit(1)
end

result
end

def run_rubocop_autocorrections
Expand Down

0 comments on commit ee9a012

Please sign in to comment.