Skip to content

Commit d67cb70

Browse files
committed
Check format with a rake task
1 parent 75742b8 commit d67cb70

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

.github/workflows/main.yml

+18-1
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,26 @@ jobs:
2424
ruby-version: ${{ matrix.ruby }}
2525
- name: Test
2626
run: bundle exec rake test
27+
28+
check:
29+
name: Check
30+
runs-on: ubuntu-latest
31+
env:
32+
CI: true
33+
steps:
34+
- uses: actions/checkout@master
35+
- uses: ruby/setup-ruby@v1
36+
with:
37+
bundler-cache: true
38+
ruby-version: '3.1'
39+
- name: Check
40+
run: bundle exec rake check
41+
2742
automerge:
2843
name: AutoMerge
29-
needs: ci
44+
needs:
45+
- ci
46+
- check
3047
runs-on: ubuntu-latest
3148
if: github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]'
3249
steps:

Rakefile

+22
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,25 @@ Rake::TestTask.new(:test) do |t|
1010
end
1111

1212
task default: :test
13+
14+
FILEPATHS = %w[
15+
Gemfile
16+
Rakefile
17+
syntax_tree.gemspec
18+
lib/**/*.rb
19+
test/*.rb
20+
].freeze
21+
22+
task :syntax_tree do
23+
$:.unshift File.expand_path("lib", __dir__)
24+
require "syntax_tree"
25+
require "syntax_tree/cli"
26+
end
27+
28+
task check: :syntax_tree do
29+
exit SyntaxTree::CLI.run(["check"] + FILEPATHS)
30+
end
31+
32+
task format: :syntax_tree do
33+
exit SyntaxTree::CLI.run(["write"] + FILEPATHS)
34+
end

0 commit comments

Comments
 (0)