Skip to content

Commit

Permalink
Wip
Browse files Browse the repository at this point in the history
  • Loading branch information
safafa committed Jan 25, 2024
1 parent 819e3a5 commit 62237ee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
26 changes: 21 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ jobs:
test:
name: Test failing spec detector
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ci_node_total: [3]
ci_node_index: [0, 1, 2]

steps:
- uses: actions/checkout@v3
Expand All @@ -19,20 +24,22 @@ jobs:
with:
ruby-version: 2.7.2
bundler-cache: true
- name: Lint files
run: bundle exec rake rubocop
- name: Run tests
env:
RAILS_ENV: test
CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
run: bundle exec rake spec
- name: Upload Failures
uses: actions/upload-artifact@v3
with:
name: Failures
path: failures_log_*.yml
path: spec/failing_spec_detector/failures
- name: Upload Exceptions
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v2
with:
name: Exceptions
path: exceptions_log_*.yml
path: spec/failing_spec_detector/exceptions

print_log:
name: Test print logs task
Expand All @@ -50,10 +57,19 @@ jobs:
uses: actions/download-artifact@v3
with:
name: Failures
path: spec/failing_spec_detector/failures
- name: Download Exceptions
uses: actions/download-artifact@v3
with:
name: Exceptions
path: spec/failing_spec_detector/exceptions
- name: Run print_log task
run: bundle exec rake failing_specs_detector:print_log
- name: File Reader
id: read_file
uses: andstor/[email protected]
with:
path: "failing_specs_detector_log.txt"
- name: File contents
run: echo "${ steps.read_file.outputs.contents }"

12 changes: 8 additions & 4 deletions lib/failing_spec_detector/combiner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@ class Combiner
def initialize(exceptions, failures)
@exceptions = exceptions
@failures = failures
@filename = 'failing_specs_detector_log.txt'
end

def combine
puts "Failing specs detector:\n\n\n"
File.write(@filename, "Failing spec detector:\n\n\n")
return if @exceptions.empty?

@exceptions.uniq.each do |exception|
puts "#{exception}:\n\n"
File.write(@filename, "#{exception}:\n\n", mode: 'a')
related_examples = @failures.select { |failure| failure.exception == exception }
next if related_examples.empty?

related_examples.each do |failure|
puts "#{failure.backtrace}:\n"
File.write(@filename, "#{failure.backtrace}:\n", mode: 'a')
end
puts "\n\n\n"
File.write(@filename, "\n\n\n", mode: 'a')
end
File.write(@filename, '----------------------------------------------------------------', mode: 'a')
end
end
end

0 comments on commit 62237ee

Please sign in to comment.