Skip to content

Commit

Permalink
Merge branch 'master' into reusable-workflow-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ssaunier authored Feb 16, 2023
2 parents 3035663 + c7af1cc commit f608cd6
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 46 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1.81.0
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7 # Not needed with a .ruby-version file
ruby-version: 3.2

- name: Cache Ruby Gems
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
Expand Down
19 changes: 12 additions & 7 deletions .github/workflows/standardrb-linter.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
name: StandardRB

on: [push]
on:
push:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: StandardRB Linter
uses: andrewmcodes/standardrb-action@v0.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUBY_VERSION: 2.7
- name: Check out the repo
uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
- name: Install StandardRB
run: gem install standard
- name: Run StandardRB
run: standardrb
20 changes: 0 additions & 20 deletions .github/workflows/wait-for-check-without-token.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/wait-on-me.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
delay_seconds:
description: "Time to delay"
required: false
default: "120"
default: "60"
push:

jobs:
Expand All @@ -18,7 +18,7 @@ jobs:
run: echo "$GITHUB_CONTEXT"
- name: Do some busywork
env:
default_delay: "120"
default_delay: "60"
input_delay: ${{ github.event.inputs.delay_seconds }}
run: |
[ "$input_delay" ] && sleep_for="$input_delay" || sleep_for="$default_delay"
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

gem "octokit", "~> 4.25"
gem "activesupport", "~> 6.1.1"
gem "faraday-retry", "~> 2.0"

group :test, :development do
gem "byebug", platforms: [:mri, :mingw, :x64_mingw]
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ GEM
faraday-net_http (~> 2.0)
ruby2_keywords (>= 0.0.4)
faraday-net_http (2.0.3)
faraday-retry (2.0.0)
faraday (~> 2.0)
i18n (1.8.7)
concurrent-ruby (~> 1.0)
minitest (5.14.3)
Expand Down Expand Up @@ -72,11 +74,13 @@ GEM

PLATFORMS
x86_64-darwin-19
x86_64-darwin-22
x86_64-linux

DEPENDENCIES
activesupport (~> 6.1.1)
byebug
faraday-retry (~> 2.0)
octokit (~> 4.25)
rspec
standard
Expand Down
33 changes: 28 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Wait for tests to succeed
uses: lewagon/wait-on-check-action@v1.0.0
uses: lewagon/wait-on-check-action@v1.2.0
with:
ref: ${{ github.ref }}
check-name: 'Run tests'
Expand All @@ -45,6 +45,29 @@ jobs:
...
```

## GHE Support

For GHE support you just need to pass in `api-endpoint` as an input.

```yml
name: Publish

on: [push]

jobs:
publish:
name: Publish the package
runs-on: ubuntu-latest
steps:
- name: Wait for tests to succeed
uses: lewagon/wait-on-check-action@v1.2.0
with:
ref: ${{ github.ref }}
check-name: 'Run tests'
repo-token: ${{ secrets.GITHUB_TOKEN }}
api-endpoint: YOUR_GHE_API_BASE_URL # Fed to https://octokit.github.io/octokit.rb/Octokit/Configurable.html#api_endpoint-instance_method
...
```
## Alternatives

If you can keep the dependent jobs in a single workflow:
Expand Down Expand Up @@ -104,7 +127,7 @@ jobs:
- uses: actions/checkout@v2
- name: Wait for tests to succeed
uses: lewagon/wait-on-check-action@v1.0.0
uses: lewagon/wait-on-check-action@v1.2.0
with:
ref: master
check-name: test
Expand Down Expand Up @@ -168,7 +191,7 @@ jobs:
To inspect the names as they appear to the API:

```bash
curl -i -u username:$token \
curl -u username:$token \
https://api.github.com/repos/OWNER/REPO/commits/REF/check-runs \
-H 'Accept: application/vnd.github.antiope-preview+json' | jq '[.check_runs[].name]'
```
Expand All @@ -188,7 +211,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Wait for other checks to succeed
uses: lewagon/wait-on-check-action@v1.0.0
uses: lewagon/wait-on-check-action@v1.2.0
with:
ref: ${{ github.ref }}
running-workflow-name: 'Publish the package'
Expand Down Expand Up @@ -244,7 +267,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Wait for tests to succeed
uses: lewagon/wait-on-check-action@v1.0.0
uses: lewagon/wait-on-check-action@v1.2.0
with:
ref: ${{ github.ref }}
check-name: 'Run tests'
Expand Down
11 changes: 8 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ inputs:
description: "Seconds to wait between Checks API requests"
required: false
default: "10"
api-endpoint:
description: "Github API Endpoint to use."
required: false
default: ""
running-workflow-name:
description: "Name of the workflow to be ignored (the one who is waiting for the rest)"
required: false
Expand All @@ -38,12 +42,12 @@ inputs:
runs:
using: "composite"
steps:
- uses: ruby/setup-ruby@v1.81.0
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7 # Not needed with a .ruby-version file
ruby-version: 3.2 # Not needed with a .ruby-version file

- name: Cache Ruby Gems
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ github.action_path }}
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
Expand All @@ -68,6 +72,7 @@ runs:
VERBOSE: ${{ inputs.verbose }}
WAIT_INTERVAL: ${{ inputs.wait-interval }}
RUNNING_WORKFLOW_NAME: ${{ inputs.running-workflow-name }}
API_ENDPOINT: ${{ inputs.api-endpoint }}
branding:
icon: "check-circle"
color: "green"
2 changes: 1 addition & 1 deletion app/errors/check_conclusion_not_allowed_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class CheckConclusionNotAllowedError < StandardError
def initialize(allowed_conclusions)
msg = "The conclusion of one or more checks were not allowed. Allowed conclusions are: "\
msg = "The conclusion of one or more checks were not allowed. Allowed conclusions are: " \
"#{allowed_conclusions.join(", ")}. This can be configured with the 'allowed-conclusions' param."
super(msg)
end
Expand Down
4 changes: 2 additions & 2 deletions app/services/application_service.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class ApplicationService
def self.call(*args, &block)
new(*args, &block).call
def self.call(...)
new(...).call
end
end
2 changes: 1 addition & 1 deletion app/services/github_checks_verifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def wait_for_checks
fail_if_requested_check_never_run(all_checks)

until all_checks_complete(all_checks)
plural_part = all_checks.length > 1 ? "checks aren't" : "check isn't"
plural_part = (all_checks.length > 1) ? "checks aren't" : "check isn't"
puts "The requested #{plural_part} complete yet, will check back in #{wait} seconds..."
sleep(wait)
all_checks = query_check_status
Expand Down
2 changes: 1 addition & 1 deletion app/spec/services/github_checks_verifier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
]
allow(service).to receive(:query_check_status).and_return all_checks

expected_msg = "The conclusion of one or more checks were not allowed. Allowed conclusions are: "\
expected_msg = "The conclusion of one or more checks were not allowed. Allowed conclusions are: " \
"success, skipped. This can be configured with the 'allowed-conclusions' param."
expect {
service.call
Expand Down
4 changes: 3 additions & 1 deletion entrypoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
verbose = ENV["VERBOSE"]
wait = ENV["WAIT_INTERVAL"]
workflow_name = ENV["RUNNING_WORKFLOW_NAME"]
api_endpoint = ENV.fetch("API_ENDPOINT", "")

GithubChecksVerifier.configure do |config|
config.allowed_conclusions = allowed_conclusions.split(",").map(&:strip)
config.check_name = check_name
config.check_regexp = check_regexp
config.client = Octokit::Client.new(auto_paginate: true)
config.client.access_token = token unless token.empty?
config.client.api_endpoint = api_endpoint unless /\A[[:space:]]*\z/.match?(api_endpoint)
config.client.access_token = token
config.ref = ref
config.repo = ENV["GITHUB_REPOSITORY"]
config.verbose = verbose
Expand Down

0 comments on commit f608cd6

Please sign in to comment.