From 48ce168d99d950bb71f4913edc1aeafcd13233df Mon Sep 17 00:00:00 2001 From: Ezbon Jacob Date: Sun, 3 Apr 2022 23:14:01 -0400 Subject: [PATCH 01/13] feature: add support for ghe --- README.md | 23 +++++++++++++++++++++++ action.yml | 5 +++++ entrypoint.rb | 3 ++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 66b77be..30ab74e 100644 --- a/README.md +++ b/README.md @@ -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.0.0 + with: + ref: ${{ github.ref }} + check-name: 'Run tests' + repo-token: ${{ secrets.GITHUB_TOKEN }} + api-endpoint: https://{YOU_GHE_URL}/api/v3/ + ... +``` ## Alternatives If you can keep the dependent jobs in a single workflow: diff --git a/action.yml b/action.yml index b5333e2..d782063 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -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" diff --git a/entrypoint.rb b/entrypoint.rb index f46855f..5d371d2 100755 --- a/entrypoint.rb +++ b/entrypoint.rb @@ -10,12 +10,13 @@ verbose = ENV["VERBOSE"] wait = ENV["WAIT_INTERVAL"] workflow_name = ENV["RUNNING_WORKFLOW_NAME"] +api_endpoint = ENV['API_ENDPOINT'] || 'https://api.github.com' 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(access_token: token) + config.client = Octokit::Client.new(access_token: token, api_endpoint: api_endpoint) config.ref = ref config.repo = ENV["GITHUB_REPOSITORY"] config.verbose = verbose From b7af3bdcdab1320b1694e76fd45b7e5630102550 Mon Sep 17 00:00:00 2001 From: codezninja Date: Wed, 6 Apr 2022 16:59:32 -0400 Subject: [PATCH 02/13] Fix API_ENDPOINT check if blank MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sébastien Saunier --- entrypoint.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.rb b/entrypoint.rb index 5d371d2..4475aa5 100755 --- a/entrypoint.rb +++ b/entrypoint.rb @@ -10,7 +10,7 @@ verbose = ENV["VERBOSE"] wait = ENV["WAIT_INTERVAL"] workflow_name = ENV["RUNNING_WORKFLOW_NAME"] -api_endpoint = ENV['API_ENDPOINT'] || 'https://api.github.com' +api_endpoint = ENV.fetch("API_ENDPOINT", "").strip.empty? ? "https://api.github.com" : ENV["API_ENDPOINT"] GithubChecksVerifier.configure do |config| config.allowed_conclusions = allowed_conclusions.split(",").map(&:strip) From 8e0c618ce9d3a0491bd85cd8824e7801dfc8b3bd Mon Sep 17 00:00:00 2001 From: Ezbon Jacob Date: Fri, 12 Aug 2022 00:40:29 -0500 Subject: [PATCH 03/13] Update entrypoint.rb Co-authored-by: Matias Albarello <1678497+matiasalbarello@users.noreply.github.com> --- entrypoint.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.rb b/entrypoint.rb index 4475aa5..2cce8b4 100755 --- a/entrypoint.rb +++ b/entrypoint.rb @@ -10,7 +10,7 @@ verbose = ENV["VERBOSE"] wait = ENV["WAIT_INTERVAL"] workflow_name = ENV["RUNNING_WORKFLOW_NAME"] -api_endpoint = ENV.fetch("API_ENDPOINT", "").strip.empty? ? "https://api.github.com" : ENV["API_ENDPOINT"] +api_endpoint = ENV.fetch("API_ENDPOINT", "https://api.github.com") GithubChecksVerifier.configure do |config| config.allowed_conclusions = allowed_conclusions.split(",").map(&:strip) From b666e4441cf03c3efea7df0c1b728a7b6dd78e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Saunier?= Date: Fri, 21 Oct 2022 12:21:43 +0200 Subject: [PATCH 04/13] Fix GHE option --- README.md | 2 +- entrypoint.rb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a9236f5..bdc01f0 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ jobs: ref: ${{ github.ref }} check-name: 'Run tests' repo-token: ${{ secrets.GITHUB_TOKEN }} - api-endpoint: https://{YOU_GHE_URL}/api/v3/ + api-endpoint: YOUR_GHE_API_BASE_URL # Fed to https://octokit.github.io/octokit.rb/Octokit/Configurable.html#api_endpoint-instance_method ... ``` ## Alternatives diff --git a/entrypoint.rb b/entrypoint.rb index b072b88..1793097 100755 --- a/entrypoint.rb +++ b/entrypoint.rb @@ -10,14 +10,15 @@ verbose = ENV["VERBOSE"] wait = ENV["WAIT_INTERVAL"] workflow_name = ENV["RUNNING_WORKFLOW_NAME"] -api_endpoint = ENV.fetch("API_ENDPOINT", "https://api.github.com") +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 From 11c1af1e6d8a48b3796c9d3eec2934c3feb84388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Saunier?= Date: Fri, 21 Oct 2022 12:25:04 +0200 Subject: [PATCH 05/13] Make StandardRB happy --- app/errors/check_conclusion_not_allowed_error.rb | 2 +- app/services/application_service.rb | 4 ++-- app/spec/services/github_checks_verifier_spec.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/errors/check_conclusion_not_allowed_error.rb b/app/errors/check_conclusion_not_allowed_error.rb index b471cdf..1462d34 100644 --- a/app/errors/check_conclusion_not_allowed_error.rb +++ b/app/errors/check_conclusion_not_allowed_error.rb @@ -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 diff --git a/app/services/application_service.rb b/app/services/application_service.rb index 44262b0..48c328e 100644 --- a/app/services/application_service.rb +++ b/app/services/application_service.rb @@ -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 diff --git a/app/spec/services/github_checks_verifier_spec.rb b/app/spec/services/github_checks_verifier_spec.rb index 7b81618..5037b31 100644 --- a/app/spec/services/github_checks_verifier_spec.rb +++ b/app/spec/services/github_checks_verifier_spec.rb @@ -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 From 3a563271c3f8d1611ed7352809303617ee7e54ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Saunier?= Date: Fri, 21 Oct 2022 12:38:20 +0200 Subject: [PATCH 06/13] Update README with latest release --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bdc01f0..79ed39f 100644 --- a/README.md +++ b/README.md @@ -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' @@ -60,7 +60,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' @@ -127,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 @@ -211,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' @@ -235,7 +235,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' From d9bc1ddbf2ad4941d2df03abf5e253bde12e59ac Mon Sep 17 00:00:00 2001 From: Guido Iaquinti <4038041+guidoiaquinti@users.noreply.github.com> Date: Tue, 3 Jan 2023 14:16:54 +0100 Subject: [PATCH 07/13] Update README.md Remove `-i` option from the `curl` command. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 79ed39f..5255dd8 100644 --- a/README.md +++ b/README.md @@ -191,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]' ``` From 2aaf9095eaf8aff3bdcf60f306d6ec10afb191d7 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 14 Feb 2023 20:25:57 +0900 Subject: [PATCH 08/13] Use latest stable versions for ruby/setup-ruby and actions/cache --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index d782063..9ddcc3b 100644 --- a/action.yml +++ b/action.yml @@ -42,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 - name: Cache Ruby Gems - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ${{ github.action_path }} key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} From 325e6682fdc499d97c1f2c0a3a3ce215c0a9e888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Saunier?= Date: Thu, 16 Feb 2023 08:46:37 +0100 Subject: [PATCH 09/13] Add faraday-retry gem + standardrb --fix --- Gemfile | 1 + Gemfile.lock | 4 ++++ app/services/github_checks_verifier.rb | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 848e99f..778209f 100644 --- a/Gemfile +++ b/Gemfile @@ -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] diff --git a/Gemfile.lock b/Gemfile.lock index 6303398..2b76f3e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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 diff --git a/app/services/github_checks_verifier.rb b/app/services/github_checks_verifier.rb index 56f69a2..1156fd1 100644 --- a/app/services/github_checks_verifier.rb +++ b/app/services/github_checks_verifier.rb @@ -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 From 60446b99f49530105d586d10c10127bec6cb196a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Saunier?= Date: Thu, 16 Feb 2023 08:51:09 +0100 Subject: [PATCH 10/13] Bump standardrb action version --- .github/workflows/run-tests.yml | 6 ++--- .github/workflows/standardrb-linter.yml | 24 +++++++++++++------ .../wait-for-check-without-token.yml | 20 ---------------- action.yml | 2 +- 4 files changed, 21 insertions(+), 31 deletions(-) delete mode 100644 .github/workflows/wait-for-check-without-token.yml diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 50314c7..7fd7e03 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -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') }} diff --git a/.github/workflows/standardrb-linter.yml b/.github/workflows/standardrb-linter.yml index 794668e..576cd06 100644 --- a/.github/workflows/standardrb-linter.yml +++ b/.github/workflows/standardrb-linter.yml @@ -1,14 +1,24 @@ name: StandardRB -on: [push] +on: + push: + +permissions: + checks: write + contents: read 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 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2' + bundler-cache: true + - name: Check out the repo + uses: actions/checkout@v3 + - name: standardrb + env: + RUBY_VERSION: '3.2' + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: amoeba/standardrb-action@v2 diff --git a/.github/workflows/wait-for-check-without-token.yml b/.github/workflows/wait-for-check-without-token.yml deleted file mode 100644 index 9db3e9a..0000000 --- a/.github/workflows/wait-for-check-without-token.yml +++ /dev/null @@ -1,20 +0,0 @@ -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!' diff --git a/action.yml b/action.yml index 9ddcc3b..5a79c79 100644 --- a/action.yml +++ b/action.yml @@ -44,7 +44,7 @@ runs: steps: - 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@v3 From 53bd7660e88f8490b5b1ed45b515d36f400efdb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Saunier?= Date: Thu, 16 Feb 2023 09:04:33 +0100 Subject: [PATCH 11/13] Re-trigger master GHA workflows From cdfa600b28cdcb3fdf626cca96ce5fdb5b11c8aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Saunier?= Date: Thu, 16 Feb 2023 09:17:07 +0100 Subject: [PATCH 12/13] standardrb without any external action --- .github/workflows/standardrb-linter.yml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/standardrb-linter.yml b/.github/workflows/standardrb-linter.yml index 576cd06..2b8b2b9 100644 --- a/.github/workflows/standardrb-linter.yml +++ b/.github/workflows/standardrb-linter.yml @@ -3,22 +3,17 @@ name: StandardRB on: push: -permissions: - checks: write - contents: read - jobs: build: runs-on: ubuntu-latest steps: + - name: Check out the repo + uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: ruby-version: '3.2' bundler-cache: true - - name: Check out the repo - uses: actions/checkout@v3 - - name: standardrb - env: - RUBY_VERSION: '3.2' - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: amoeba/standardrb-action@v2 + - name: Install StandardRB + run: gem install standard + - name: Run StandardRB + run: standardrb From 58ae29f91439bdc190c2d387221662a98194f3d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Saunier?= Date: Thu, 16 Feb 2023 09:20:02 +0100 Subject: [PATCH 13/13] Shorter busywork --- .github/workflows/wait-on-me.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wait-on-me.yml b/.github/workflows/wait-on-me.yml index e4244c7..2b8c33f 100644 --- a/.github/workflows/wait-on-me.yml +++ b/.github/workflows/wait-on-me.yml @@ -5,7 +5,7 @@ on: delay_seconds: description: "Time to delay" required: false - default: "120" + default: "60" push: jobs: @@ -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"