Skip to content

Commit

Permalink
added feature to ignore checks fixed #38
Browse files Browse the repository at this point in the history
  • Loading branch information
omkarkhatavkar committed Feb 2, 2023
1 parent 3a56327 commit 4f91e85
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ inputs:
description: "Array of allowed conclusions"
required: false
default: success,skipped
ignore-checks:
description: "Array of ignore checks"
required: false
default: ""
check-name:
description: "A name of a check that has to pass"
required: false
Expand Down Expand Up @@ -65,6 +69,7 @@ runs:
shell: bash
env:
ALLOWED_CONCLUSIONS: ${{ inputs.allowed-conclusions }}
IGNORE_CHECKS: ${{ inputs.ignore-checks }}
CHECK_NAME: ${{ inputs.check-name }}
CHECK_REGEXP: ${{ inputs.check-regexp }}
REF: ${{ inputs.ref }}
Expand Down
2 changes: 2 additions & 0 deletions app/services/github_checks_verifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class GithubChecksVerifier < ApplicationService
config_accessor(:check_regexp) { "" }
config_accessor(:allowed_conclusions) { ["success", "skipped"] }
config_accessor(:verbose) { true }
config_accessor(:ignore_checks){[]}

def call
wait_for_checks
Expand Down Expand Up @@ -47,6 +48,7 @@ def log_checks(checks, msg)

def apply_filters(checks)
checks.reject! { |check| check.name == workflow_name }
checks.reject! { |check| ignore_checks.include?(check.name) }
checks.select! { |check| check.name == check_name } if check_name.present?
log_checks(checks, "Checks after check_name filter:")
apply_regexp_filter(checks)
Expand Down
24 changes: 23 additions & 1 deletion app/spec/services/github_checks_verifier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@
service.send(:apply_filters, checks)
expect(checks.map(&:name)).to all(eq "check_name")
end

it "filters out only ignore_checks" do
checks = [
OpenStruct.new(name: "check_name", status: "queued"),
OpenStruct.new(name: "other_check", status: "queued")
]

service.config.ignore_checks = ["check_name"]
service.send(:apply_filters, checks)
expect(checks.map(&:name)).to all(eq "other_check")
end

it "does not filter by check_name if it's empty" do
checks = [
Expand All @@ -163,7 +174,18 @@

expect(checks.map(&:name)).not_to include("workflow_name")
end


it "does not filter if ignore checks are empty" do
all_checks = [
OpenStruct.new(name: "test1", status: "completed", conclusion: "success"),
OpenStruct.new(name: "test2", status: "completed", conclusion: "skipped")
]
service.config.ignore_checks = []
service.send(:apply_filters, checks)

expect(checks.size).to eq 2
end

it "apply the regexp filter" do
checks = [
OpenStruct.new(name: "test", status: "pending"),
Expand Down
3 changes: 3 additions & 0 deletions entrypoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
wait = ENV["WAIT_INTERVAL"]
workflow_name = ENV["RUNNING_WORKFLOW_NAME"]
api_endpoint = ENV.fetch("API_ENDPOINT", "")
ignore_checks = ENV["IGNORE_CHECKS"]


GithubChecksVerifier.configure do |config|
config.allowed_conclusions = allowed_conclusions.split(",").map(&:strip)
config.ignore_checks = ignore_checks.split(",").map(&:strip)
config.check_name = check_name
config.check_regexp = check_regexp
config.client = Octokit::Client.new(auto_paginate: true)
Expand Down

0 comments on commit 4f91e85

Please sign in to comment.