Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
codezninja authored Aug 12, 2022
2 parents 8e0c618 + e255823 commit 6a601c2
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 18 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/wait-for-check-without-token.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Wait for check name
on:
push:
workflow_dispatch:

jobs:
wait-without-token:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Wait without token
uses: ./
with:
ref: ${{ github.sha }}
wait-interval: 10 # seconds
running-workflow-name: wait-without-token
check-name: wait-on-me

- name: Success
run: echo 'Success!'
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

gem "octokit", "~> 4.20"
gem "octokit", "~> 4.25"
gem "activesupport", "~> 6.1.1"

group :test, :development do
Expand Down
26 changes: 12 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,20 @@ GEM
byebug (11.1.3)
concurrent-ruby (1.1.7)
diff-lcs (1.4.4)
faraday (1.3.0)
faraday-net_http (~> 1.0)
multipart-post (>= 1.2, < 3)
ruby2_keywords
faraday-net_http (1.0.1)
faraday (2.3.0)
faraday-net_http (~> 2.0)
ruby2_keywords (>= 0.0.4)
faraday-net_http (2.0.3)
i18n (1.8.7)
concurrent-ruby (~> 1.0)
minitest (5.14.3)
multipart-post (2.1.1)
octokit (4.20.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
octokit (4.25.0)
faraday (>= 1, < 3)
sawyer (~> 0.9)
parallel (1.20.1)
parser (3.0.2.0)
ast (~> 2.4.1)
public_suffix (4.0.6)
public_suffix (4.0.7)
rainbow (3.0.0)
regexp_parser (2.1.1)
rexml (3.2.5)
Expand Down Expand Up @@ -60,10 +58,10 @@ GEM
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.2)
sawyer (0.8.2)
ruby2_keywords (0.0.5)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
faraday (>= 0.17.3, < 3)
standard (1.1.7)
rubocop (= 1.18.4)
rubocop-performance (= 1.11.4)
Expand All @@ -79,7 +77,7 @@ PLATFORMS
DEPENDENCIES
activesupport (~> 6.1.1)
byebug
octokit (~> 4.20)
octokit (~> 4.25)
rspec
standard

Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ jobs:
allowed-conclusions: success,skipped,cancelled
...
```

### Using check-regexp
Similar to the `check-name` parameter, this filters the checks to be waited but using a Regular Expression (aka regexp) to match the check name (jobs.<job_id>.name)

Expand Down Expand Up @@ -275,6 +274,12 @@ jobs:
### Verbose (optional, default: true)
If true, it prints some logs to help understanding the process (checks found, filtered, conclussions, etc.)

## Auto-pagination

Since we are using Octokit for using GitHub API, we are subject to their limitations. One of them is the pagination max size: if we have more than 100 workflows running, the auto-pagination won't help.
More about Octokit auto-pagination can be found [here](https://octokit.github.io/octokit.rb/file.README.html#Pagination:~:text=get.data-,Auto%20Pagination,-For%20smallish%20resource)
The solution would be to fetch all pages to gather all running workflows if they're more than 100, but it's still no implemented.

## Tests

There are sample workflows in the `.github/workflows` directory. Two of them are logging tasks to emulate real-world actions being executed that have to be waited. The important workflows are the ones that use the wait-on-check-action.
Expand Down
2 changes: 1 addition & 1 deletion app/services/github_checks_verifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def call

def query_check_status
checks = client.check_runs_for_ref(
repo, ref, {per_page: 100, accept: "application/vnd.github.antiope-preview+json"}
repo, ref, {accept: "application/vnd.github.antiope-preview+json"}
).check_runs
log_checks(checks, "Checks running on ref:")

Expand Down
3 changes: 2 additions & 1 deletion entrypoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
config.allowed_conclusions = allowed_conclusions.split(",").map(&:strip)
config.check_name = check_name
config.check_regexp = check_regexp
config.client = Octokit::Client.new(access_token: token, api_endpoint: api_endpoint)
config.client = Octokit::Client.new(auto_paginate: true)
config.client.access_token = token unless token.empty?
config.ref = ref
config.repo = ENV["GITHUB_REPOSITORY"]
config.verbose = verbose
Expand Down

0 comments on commit 6a601c2

Please sign in to comment.