Code Monkey home page Code Monkey logo

wait-on-check-action's Introduction

Wait On Check Action

StandardRB RSpec tests

Pause a workflow until a job in another workflow completes successfully.

This action uses the Checks API to poll for check results. On success, the action exit allowing the workflow resume. Otherwise, the action will exit with status code 1 and fail the whole workflow.

This is a workaround to GitHub's limitation of non-interdependent workflows ๐ŸŽ‰

You can run your workflows in parallel and pause a job until a job in another workflow completes successfully.

Minimal example

name: Test

on: [push]

jobs:
  test:
    name: Run tests
    runs-on: ubuntu-latest
      steps:
        ...
name: Publish

on: [push]

jobs:
  publish:
    name: Publish the package
    runs-on: ubuntu-latest
    steps:
      - name: Wait for tests to succeed
        uses: lewagon/[email protected]
        with:
          ref: ${{ github.ref }}
          check-name: 'Run tests'
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          wait-interval: 10
      ...

GHE Support

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

name: Publish

on: [push]

jobs:
  publish:
    name: Publish the package
    runs-on: ubuntu-latest
    steps:
      - name: Wait for tests to succeed
        uses: lewagon/[email protected]
        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:

name: Test and publish

on: [push]

jobs:
  test:
    runs-on: ubuntu-latest
    steps: ...

  publish:
    runs-on: ubuntu-latest
    needs: test
    steps: ...

If you can run dependent jobs in a separate workflows in series:

name: Publish

on:
  workflow_run:
    workflows: ['Test']
    types:
      - completed

A real-world scenario

  • Pushes to master trigger a test job to be run against the application code.

  • Pushes to master also trigger a webhook that builds an image on external service such as Quay.

  • Once an image is built, a repository_dispatch hook is triggered from a third-party service. This triggers a deploy job.

  • We don't want the deploy job to start until the master branch passes its test job.

name: Trigger deployment on external event

on:
  # https://github.com/lewagon/quay-github-actions-dispatch
  repository_dispatch:
    types: [build_success]

jobs:
  deploy:
    if: startsWith(github.sha, github.event.client_payload.text)
    name: Deploy a new image
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Wait for tests to succeed
        uses: lewagon/[email protected]
        with:
          ref: master
          check-name: test
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          wait-interval: 20

      - name: Save the DigitalOcean kubeconfig
        uses: digitalocean/action-doctl@master
        env:
          DIGITALOCEAN_ACCESS_TOKEN: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
        with:
          args: kubernetes cluster kubeconfig show my-cluster > $GITHUB_WORKSPACE/.kubeconfig

      - name: Upgrade/install chart
        run: export KUBECONFIG=$GITHUB_WORKSPACE/.kubeconfig && make deploy latest_sha=$(echo $GITHUB_SHA | head -c7)}}

Parameters

Check name

Check name goes according to the jobs.<job_id>.name parameter.

In this case the job's name is 'test':

jobs:
  test:
    runs-on: ubuntu-latest
      steps:
      ...

In this case the name is 'Run tests':

jobs:
  test:
    name: Run tests
    runs-on: ubuntu-latest
      steps:
      ...

In this case the names will be:

  • Run tests (3.6)

  • Run tests (3.7)

jobs:
  test:
    name: Run tests
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python: [3.6, 3.7]

To inspect the names as they appear to the API:

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]'

Running workflow name

If you would like to wait for all other checks to complete you may set running-workflow-name to the name of the current job and not set a check-name parameter.

name: Publish

on: [push]

jobs:
  publish:
    name: Publish the package
    runs-on: ubuntu-latest
    steps:
      - name: Wait for other checks to succeed
        uses: lewagon/[email protected]
        with:
          ref: ${{ github.ref }}
          running-workflow-name: 'Publish the package'
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          wait-interval: 10
      ...

Using running workflow name in reusable workflows

Using this action in a reusable workflow means accepting a constraint that all calling jobs will have the same name. For example, all calling workflows must call their jobs caller (or some more relevant constant) so that if the reused workflow containing the job that uses this action to wait is called callee then the task can successfully wait on caller / callee. Working example follows.

.github/workflows/caller.yml

on:
  push:
jobs:
  caller:
    uses: ./.github/workflows/callee.yml

.github/workflows/callee.yml

on:
  workflow_call:
jobs:
  callee:
    runs-on: ubuntu-latest
    steps:
      - name: Wait for Other Workflows
        uses: lewagon/[email protected]
        with:
          ref: ${{ github.ref }}
          running-workflow-name: 'caller / callee'
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          wait-interval: 10

Allowed conclusions

By default, checks that conclude with either success or skipped are allowed, and anything else is not. You may configure this with the allowed-conclusions option, which is a comma-separated list of conclusions.

name: Publish

on: [push]

jobs:
  publish:
    name: Publish the package
    runs-on: ubuntu-latest
    steps:
      - name: Wait for tests to succeed
        uses: lewagon/[email protected]
        with:
          ref: ${{ github.ref }}
          check-name: 'Run tests'
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          wait-interval: 10
          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)

Example of use:

name: Wait using check-regexp
on:
  push:

jobs:
  wait-for-check-regexp:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Wait on tests
        uses: lewagon/[email protected]
        with:
          ref: ${{ github.sha }}
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          running-workflow-name: wait-for-check-regexp
          check-regexp: .?-task

Ignore-checks

To selectively filter checks and ignore specific ones, you can specify the ignore-checks option with a list of comma-separated check names to be ignored. Example of use:

name: Wait using check-regexp
on:
  push:

jobs:
  wait-for-check-regexp:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Wait on tests
        uses: lewagon/[email protected]
        with:
          ref: ${{ github.sha }}
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          running-workflow-name: wait-for-check-regexp
          ignore-checks: label1,label2

Wait interval (optional, default: 10)

As it could be seen in many examples, there's a parameter wait-interval, and sets a time in seconds to be waited between requests to the GitHub API. The default time is 10 seconds.

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 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.

A workflow named "wait_omitting-check-name" waits for the two simple-tasks, while the one named "wait_using_check-name" only waits for "simple-task".

wait-on-check-action's People

Contributors

apakottur avatar axtgr avatar billy- avatar codezninja avatar dependabot[bot] avatar ditman avatar eafzali avatar erikerikson avatar guidoiaquinti avatar hsbt avatar joellefkowitz avatar matiasalbarello avatar omkarkhatavkar avatar quetzaluz avatar srodriguezo avatar ssaunier avatar sshane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wait-on-check-action's Issues

Can only run action on Linux?

When using runs-on: windows-latest
I get: Error: Container action is only supported on Linux

Should this combination be supported?

How to use this action to pause a job until the same job in previous workflow runs finished?

Hello,

I have one workflow that might run in parallel multiple times (the same workflow file). I want a job in the workflow to wait until the same job in previous workflow runs finished. I thought I could use this action like that:

deploy:
    name: Deploy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Wait
        uses: lewagon/[email protected]
        with:
          ref: main
          check-name: 'Deploy'
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          wait-interval: 10

But this results in all workflows being stuck (I assume because the job in the workflow is waiting for itself ?).

Can you tell me how I can pause a job until the same job in previous workflow runs finished with this action?
Or is the action only for jobs in different workflows?
If it's not working on a job level can I use it on a workflow level? So pause a workflow until previous workflow runs (same workflow file) finished?

I appreciate any answer and thank you in advance.

When multiple runs exist for the same head, the action should consider only the latest

We're using the wait-on-check action for downstream tests. In particular this means the action is triggered from a commit in one repository and then runs the downstream tests using the current HEAD of another repository. This creates a problem because the action currently looks at all checks for that HEAD โ€“ including those triggered from previous commits to the first repository. To prevent that, I think the action should filter the checks so that only the latest one for each name / ID is taken into account.

not able to trigger workflow in another repo

I tried to use another workflow dispatch and while exploring the issue I had someone advised me to use your dispatch.
I have repo which finished to build the container and in my job I tried to dispatch to another workflow in a different repo
image
Not sure if your action support dispatch to workflow in another repo but this is how I understood based on the comment I mentioned above.
So I am getting this error
image
what do I do wrong?

[Bug] Crash when API limit is reached

I was using this GitHub action when it failed because I reached the API limit. It would be nice if the GitHub Action can wait some time before doing the next query to the API instead of crashing.

/usr/local/bundle/gems/octokit-4.20.0/lib/octokit/response/raise_error.rb:14:in `on_complete': GET https://api.github.com/repos/iblancasa/jaeger-operator/commits/refs/heads/master/check-runs: 403 - API rate limit exceeded for installation ID 6268770. // See: https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting (Octokit::TooManyRequests)
	from /usr/local/bundle/gems/faraday-1.3.0/lib/faraday/middleware.rb:19:in `block in call'
	from /usr/local/bundle/gems/faraday-1.3.0/lib/faraday/response.rb:59:in `on_complete'
	from /usr/local/bundle/gems/faraday-1.3.0/lib/faraday/middleware.rb:18:in `call'
	from /usr/local/bundle/gems/octokit-4.20.0/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
	from /usr/local/bundle/gems/octokit-4.20.0/lib/octokit/middleware/follow_redirects.rb:61:in `call'
	from /usr/local/bundle/gems/faraday-1.3.0/lib/faraday/request/retry.rb:148:in `call'
	from /usr/local/bundle/gems/faraday-1.3.0/lib/faraday/rack_builder.rb:154:in `build_response'
	from /usr/local/bundle/gems/faraday-1.3.0/lib/faraday/connection.rb:492:in `run_request'
	from /usr/local/bundle/gems/faraday-1.3.0/lib/faraday/connection.rb:198:in `get'
	from /usr/local/bundle/gems/sawyer-0.8.2/lib/sawyer/agent.rb:94:in `call'
	from /usr/local/bundle/gems/octokit-4.20.0/lib/octokit/connection.rb:156:in `request'
	from /usr/local/bundle/gems/octokit-4.20.0/lib/octokit/connection.rb:19:in `get'
	from /usr/local/bundle/gems/octokit-4.20.0/lib/octokit/client/checks.rb:68:in `check_runs_for_ref'
	from /app/services/github_checks_verifier.rb:29:in `query_check_status'
	from /app/services/github_checks_verifier.rb:100:in `wait_for_checks'
	from /app/services/github_checks_verifier.rb:20:in `call'
	from /app/services/application_service.rb:5:in `call'
	from /entrypoint.rb:19:in `<main>'

Used version: 1.1.1

๐Ÿ™‹โ€โ™‚๏ธ๐Ÿ™‹โ€โ™€๏ธ Contributors Wanted

Dear GitHub community,

This repo has been stale for a few months now, @lewagon can no longer commit anytime to it, having moved away from Docker/Kubernetes/etc., going back to simpler buildpacks-based deployment (Heroku, Scalingo, Dokku, etc.) where this action is no longer needed.

At the moment, the maintainers of this repo are:

image

โ˜๏ธ If you are in that list, please โœ‹ below to confirm your interest into maintaining this repo.

If you would like to get maintainer permissions on this repo and actively contribute on Issue Triage and Pull Requests review / merge / tagging new release, please say it here too!

Thank you ๐Ÿค—

Missing External Checks Statuses

I have a case, where we run the test externally and updated it on the GitHub PR Checks. This GitHub action is unable to find that Check in the list of checks running or in other states. @matiasalbarello Do you know any workaround for this?

Check Name is : Robottelo-Runner

e.g.
omkarkhatavkar/robottelo#50
https://github.com/omkarkhatavkar/robottelo/actions/runs/3854084036/jobs/6567696665

I need a similar approach shown below. to cross-check that all checks are passing on iterating over them

> gh pr checks https://github.com/omkarkhatavkar/robottelo/pull/50
Some checks were not successful
2 failing, 3 successful, 1 skipped, and 0 pending checks

X  Automerge auto-cherry-picked pr  1m13s  https://github.com/omkarkhatavkar/robottelo/actions/runs/3854084036/jobs/6567696665
X  Robottelo-Runner
โœ“  Code Quality (3.8)               9m12s  https://github.com/omkarkhatavkar/robottelo/actions/runs/3849330929/jobs/6558199235
โœ“  Code Quality (3.9)               9m6s   https://github.com/omkarkhatavkar/robottelo/actions/runs/3849330929/jobs/6558199363
โœ“  Enforcing cherrypick labels      2s     https://github.com/omkarkhatavkar/robottelo/actions/runs/3854084009/jobs/6567696500
-  Add author to assignee                  https://github.com/omkarkhatavkar/robottelo/actions/runs/3849330909/jobs/6558199492

verbose:false not working

This is my current setup:

  - name: Wait for packages test/typecheck to complate
    uses: lewagon/[email protected]
    with:
      ref: ${{ github.ref }}
      check-regexp: packages-.*
      repo-token: ${{ secrets.GITHUB_TOKEN }}
      wait-interval: 20
      verbose: false

But still, the action is printing everything.

Question: How do I use it from workflows executed in schedule

Hi there,

I am trying to use this action in my CI project: https://github.com/jparisu/eProsima-CI/blob/56a5ca7399516d89c73f0bf95ba85e131ed842ca/.github/workflows/build_dev_utils.yml#L89
I have 2 workflows: A (build_fastdds) and B (build_dev_utils).
I want both to run in a schedule, so every night they run and upload updated artifacts.
But B requires of A artifact to run, so I want B to wait till A has finished.

I tried this in workflow B:

      - name: Wait for A workflow run to finish
        uses: jparisu/eProsima-CI/external/wait-on-check-action@main
        with:
          check-name: build_fastdds
          ref: main
          repo-token: ${{ secrets.GITHUB_TOKEN }}

But I get the following error: The requested check was never run against this ref, exiting....
You can see a failing run here: https://github.com/jparisu/eProsima-CI/actions/runs/4785475063/jobs/8509467872

Thanks in advance

Windows support

Hi!
I've got windows-based workflow and would like to use this action, but it appears to be linux-only, i.e. Github tells me:

Run lewagon/[email protected]
Error: Container action is only supported on Linux

Could you please add windows support?

missing gemfile running on ubuntu 20.04.3

Hi, I've noticed wait-on-check-action started failing today (9/11). We run on ubuntu. The error output is:

Run bundle install
  bundle install
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
Could not locate Gemfile

I saw there was a merge today that might be a root cause, as I do notice the new logic that installs the bundle instead of running the dockerfile. Just to be sure, I also tried running the previously working sha (5e93735), and it worked. I'm not too familiar with ruby and how gemfiles work, so I'm a bit useless in regards to suggesting a fix here, but it would be much appreciated if you can help resolve the error for the handful of us ubuntu users. Thanks!

Deprecation warnings from dependencies?

Hello team!

We're using lewagon/wait-on-check-action, and we've started seeing deprecation warnings coming from the dependencies of the action in our logs:

ruby/[email protected]

Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using
Environment Files. For more information see:
https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

actions/cache@v2

Warning: The `save-state` command is deprecated and will be disabled soon. Please upgrade to using
Environment Files. For more information see:
https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

Also a warning about "Node.js 12 actions being deprecated" for both of the above:

Node.js 12 actions are deprecated. For more information see:
https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.
Please update the following actions to use Node.js 16: ruby/[email protected], actions/cache@v2

Is this something that we can fix on our end, or is this something that the wait-on-check-action needs to fix?

Thanks!

Add a tag: `v1`

Currently, the tag is 1 or 1.0.0. This goes against the typical standard set on GitHub by prefixing with v (including previous releases).

Consider adding a tag v1

The requested check was never run against this ref

@progapandist if you have a moment can you please help me out?

  • I am explicitly naming my jobs
  • I'm using github.sha
  • It worked when I did everything against master but now it's not working with my default branch set to develop?
  • I'm using @master so that I have latest.

I'm running into the same problem as #7 and using the sha bafe56a6863672c681c3cf671f5e10b20abf2eaa which should have fixed it, so I'm not sure if it was reintroduced or if I'm doing it wrong.

Update: I used @master and github.sha which fixed the issue I was having. However now that I changed my default branch to be develop I'm having issues, see comments further down.

This is my config

  checks:
    name: Wait on "Lint, Test & Build" Workflow
    runs-on: ubuntu-latest
    needs: [verification]

    steps:
      - name: wait on tests
        uses: lewagon/wait-on-check-action@master
        with:
          ref: ${{ github.sha }}
          check-name: Lint, Unit Test & Build
          repo-token: ${{ github.token }}
          wait-interval: 20

This is the workflow that I'm waiting on

name: Lint, Test & Build

on:
  workflow_dispatch:
  repository_dispatch:
    types: [run-lint-test-build]

jobs:
  verification:
    name: Lint, Unit Test & Build
    runs-on: ubuntu-latest

running-workflow-name does not work consistently

From my testing over a couple of weeks, the functionality behind the "running-workflow-name" param is unreliable and will not always wait until all the other checks finish despite what the docs say. It does work most of the time, but there is a race condition. From my observation there is some period of time after a job finishes and another job (with a dependency on the first job) gets queued. If the "wait-on-check-action" just so happens to check the jobs status in that period of time, it will incorrectly conclude that all jobs have finished even though they haven't.

Not working with containers

The workflow below is not working with a node project in a container, please the sample code below:

name: Unit tests
on:
  pull_request:
    branches:
      - development

jobs:

  unit-test:
    #...

  dependency-check:
    #...

  upload-report:
    name: ๐Ÿ”จ Upload report
    runs-on: ubuntu-latest
    container: node:14.17.1-alpine3.12 #non alpine also doesn't work
    needs: [unit-test]
    timeout-minutes: 30
    env:
      ImageOS: ubuntu20 ## Stops error #52, not sure if this is right.

    if: "!contains(toJSON(github.event.head_commit.message), '[skip-ci]')"

    steps:

      - name: ๐Ÿ”จ Install dependencies
        run: apk add tar ruby # Ruby here makes no different

      - name: ๐Ÿ“ฆ Download unit-test reports folder
        uses: actions/download-artifact@v2
        with:
          name: code-coverage-unit-test

      # same error here:
      # - name: Set up Ruby
      #   uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
      #   with:
      #     ruby-version: '2.7'

      - name: ๐Ÿ•’ Wait for dependency-check to complete
        uses: lewagon/[email protected]
        with:
          ref: ${{ github.ref }}
          check-name: 'dependency-check'
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          wait-interval: 10
          
      - name: ๐Ÿ“ฆ Download dependency-check reports folder
        uses: actions/download-artifact@v2
        with:
          name: dependency-check

It's returning this error:

Error: There was an error when attempting to execute the process '/opt/hostedtoolcache/Ruby/2.7.4/x64/bin/gem'. This may indicate the process failed to start. Error: spawn /opt/hostedtoolcache/Ruby/2.7.4/x64/bin/gem ENOENT

Screenshot 2023-02-14 at 19 14 19

Waiting the end of a matrix run

Hello

I have a workflow file like

name: test
on: 
  push:
    branches: 
      - master
jobs: 
  test:
    name: ${{ matrix.os }} py${{ matrix.python-version }}
    runs-on: ${{ matrix.os }} 

    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        python-version: ['3.6','3.7','3.8','3.9']
      max-parallel: 1
      fail-fast: false

    steps:
      - uses: actions/checkout@v2
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip setuptools wheel
          python -m pip install -r requirements.txt
          python -m pip install .

      - name: Run tests
        run: python -m pytest

The issue is that the job names are automatically generated from the OS and python version...
How to wait until all those tests are run ?

Thanks

Add a new parameter `ignore-check-names`

Currently, we can wait for all the jobs to finish, or we can wait for 1. When #35 is implemented that would allow us to wait for N number of checks.

It would be awesome if we could also "wait for everything except for X check(s)" as well. This way we'd can always wait for jobs to complete except for jobs we we'd want to ignore.

Test actions don't wait when run manually

Ping @matiasalbarello :)

Currently, this line doesn't seem to do anything (see https://github.com/lewagon/wait-on-check-action/runs/1725958933?check_suite_focus=true)

What if we make the simple_check action take some considerable time anyway? (and rename it accordingly, like "run for 3 minutes"). This will give us enough time to dispatch "test" actions and see if they work. I love the trigger scripts approach, but IMO testing in GHA's UX is easier and will be the way to go.

WDYT?

Wait on all jobs by omitting running-workflow-name not working for amplify check hook

Hi, i am having issues with waiting on an aws amplify deploy check to complete

name: CI
on:
  pull_request:
    branches: ["master"]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:
    jobs:
      test:
        name: CI Test
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v3
          - name: Wait for amplify preview to deploy
            uses: lewagon/[email protected]
            with:
              ref: ${{ github.ref }}
              repo-token: ${{ secrets.GITHUB_TOKEN }}
              wait-interval: 10
          - uses: actions/setup-node@v2
          ................

I have omitted running-workflow-name: as to force this job to wait for all other jobs, as specifying the amplify job name wasn't working either.

image

Maybe the config is wrong??

Bundler version not supported

I suddenly get this error in my build:

  #10 [base 5/9] RUN gem install bundler
  #10 19.69 ERROR:  Error installing bundler:
  #10 19.69 	The last version of bundler (>= 0) to support your Ruby & RubyGems was 2.4.22. Try installing it with `gem install bundler -v 2.4.22`
  #10 19.69 	bundler requires Ruby version >= 3.0.0. The current ruby version is 2.7.2.137.
  #10 ERROR: process "/bin/sh -c gem install bundler" did not complete successfully: exit code: 1
  ------
   > [base 5/9] RUN gem install bundler:
  19.69 ERROR:  Error installing bundler:
  19.69 	The last version of bundler (>= 0) to support your Ruby & RubyGems was 2.4.22. Try installing it with `gem install bundler -v 2.4.22`
  19.69 	bundler requires Ruby version >= 3.0.0. The current ruby version is 2.7.2.137.
  ------
  Dockerfile:7
  --------------------
     5 |     COPY Gemfile Gemfile
     6 |     COPY Gemfile.lock Gemfile.lock
     7 | >>> RUN gem install bundler
     8 |     RUN bundle config set with 'development test'
     9 |     RUN bundle install --jobs 20 --retry 5
  --------------------
  ERROR: failed to solve: process "/bin/sh -c gem install bundler" did not complete successfully: exit code: 1
  Warning: Docker build failed with exit code 1, back off 4.871 seconds before retry.

Looks like the bundler version must be specified?

Fails when not using `default` branch?

I can't find anywhere in the documentation for this workflow which states that the default branch must be used. I updated my default to be develop and I am using this workflow on my master branch anytime there is a merge. Since making this change I am continuously getting the error The requested check was never run against this ref.

I have verified that the Dispatch job is using the same SHA as the Wait job is using.

Dispatch Config

  verification:
    name: Dispatch - Lint, Test & Build
    runs-on: ubuntu-latest

    steps:
      - name: Repository Dispatch
        uses: peter-evans/repository-dispatch@v1
        with:
          token: ${{ secrets.REPO_ACCESS_TOKEN }}
          repository: ${{ github.repository }}
          event-type: run-lint-test-build
          client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'

Workflow that runs on dispatch

name: Lint, Test & Build

on:
  workflow_dispatch:
  repository_dispatch:
    types: [run-lint-test-build]

jobs:
  verification:
    name: Lint, Format & Build # used for check-name on version.yml
    runs-on: ubuntu-latest

    steps:
      - name: Checkout source code
        uses: actions/checkout@v2
        with:
          ref: ${{ github.event.client_payload.sha }}
      - run: echo using SHA ${{ github.event.client_payload.sha }}

      - name: Setup Node.js
        uses: actions/setup-node@v1
        with:
          node-version: 12

      # https://github.com/marketplace/actions/yarn-install-cache
      - name: Cache yarn dependencies
        uses: c-hive/gha-yarn-cache@v1

      - name: Install dependencies
        run: yarn install

      - name: Lint Code
        run: yarn lint

      - name: Code Format Check
        run: yarn format:check --verbose

      - name: Build
        run: yarn build
        env:
          CI: true

Wait Config

  checks:
    name: Wait on "Lint, Test & Build" Workflow
    runs-on: ubuntu-latest
    needs: [verification]

    steps:
      - name: wait on tests
        uses: lewagon/wait-on-check-action@master
        with:
          ref: ${{ github.sha }}
          check-name: Lint, Unit Test & Build
          repo-token: ${{ github.token }}
          wait-interval: 20

Originally posted by @CWSites in #29 (comment)

Rename master branch to main

This is something that most if not all of github is moving to due to the fact that the branch name of master could mean something bad.

This is why people suggested to github to have it where any future repositories would have main as the default branch name instead of master.

This is a simple and easy fix though.

`lewagon/wait-on-check-action` fails to run due since Bundler `2.5.0` dropped support for Ruby 2.7.

Using this workflow in GitHub actions no longer works as intended. The Dockerfile performs a gem install bundler without specifying a version of it. Bundler 2.5.0 was released over the weekend and dropped support for Ruby 2.7.

To reproduce:

git clone [email protected]:lewagon/wait-on-check-action.git
cd wait-on-check-action/
docker build .

Fails with:

 => ERROR [base 5/9] RUN gem install bundler                                                                                               
------
 > [base 5/9] RUN gem install bundler:
47.06 ERROR:  Error installing bundler:
47.06 	The last version of bundler (>= 0) to support your Ruby & RubyGems was 2.4.22. Try installing it with `gem install bundler -v 2.4.22`
47.06 	bundler requires Ruby version >= 3.0.0. The current ruby version is 2.7.2.137.
------
Dockerfile:7
--------------------
   5 |     COPY Gemfile Gemfile
   6 |     COPY Gemfile.lock Gemfile.lock
   7 | >>> RUN gem install bundler
   8 |     RUN bundle config set with 'development test'
   9 |     RUN bundle install --jobs 20 --retry 5
--------------------

To fix:

Use this command instead in the Dockerfile:

gem install bundler -v 2.4.22

What permissions do the GitHub Actions need?

This GitHub Actions uses the GITHUB_TOKEN. Can you please tell me what permissions are used for this token? If the permissions are only used in certain conditions, e.g. when a certain input is specified, please share that info as well.

At https://github.com/step-security/secure-workflows we are building a knowledge-base (KB) of permissions needed by different GitHub Actions. When developers try to remediate ossf/Scorecards checks, they use the knowledge-base to secure their GitHub Workflows.

Here is an example of how we store KB for an Action:

name: "GH Release"
github-token:
  action-input:
    input: github_token
    is-default: true
  permissions:
    contents: write
    contents-reason: to create GitHub release #Reference: https://github.com/softprops/action-gh-release/blob/fe9a9bd3295828558c7a3c004f23f3bf77d155b2/README.md?plain=1#L70 

Releated Issue:
step-security/secure-repo#270

Error: The environment variable ImageOS must be set ruby/setup-ruby action

I'm running in the following error after the latest update of the action.
I think it's related to this in the new release.
because the ruby-setup action requires the ImageOS to be set for self-hosted runners.
How can this be fixed?

Error logging:

> Run lewagon/wait-on-check-action@master
  with:
    ref: bd8138c7d32e5e0296a3a4fa6f2a8ad080e4fd6d
    repo-token: ***
    check-name: Build base test image
    allowed-conclusions: success,skipped
    wait-interval: 10
    verbose: true
  env:
    POSTGRES_HOST: postgres
    POSTGRES_PORT: 5432
    POSTGRES_PASSWORD: admin
    POSTGRES_USER: postgres
> Run ruby/[email protected]
  with:
    ruby-version: 2.7
    bundler: default
    bundler-cache: false
    working-directory: .
    cache-version: 0
  env:
    POSTGRES_HOST: postgres
    POSTGRES_PORT: 5432
    POSTGRES_PASSWORD: admin
    POSTGRES_USER: postgres
/usr/bin/docker exec  e381481xxx sh -c "cat /etc/*release | grep ^ID"
Error: The environment variable ImageOS must be set

Support for timeout

Hi ! ๐Ÿ‡ซ๐Ÿ‡ท

I am using this action to manually deploy my app, but I don't want to wait, I want to check for the completed status, and if it's ok, release, otherwise, fail.

I didn't manage to find an other existing action to do it, maybe you have suggestions ?

Otherwise, one "hack" could be to support a timeout, and in my case set it to a low value like 10 seconds.

WDYT ?

Fails on summerwind/actions-runner:v2.304.0-ubuntu-22.04-41ebb43

I am running the wait on check action on a self-hosted GH actions runner to a k8s cluster. I recently upgraded to the latest github actions runner, image summerwind/actions-runner:v2.304.0-ubuntu-22.04-41ebb43

The wait-on-check-action step fails at the 'bundle install' step, with the message:

An error occurred while installing byebug (11.1.3), and Bundler cannot continue.
Make sure that gem install byebug -v '11.1.3' --source 'https://rubygems.org/'
succeeds before bundling.

Getting a 'Permission Denied' error with a simple use case

Error:

  Entries removed from PATH to avoid conflicts with default Ruby:
    /Users/automationm2mini/.rvm/gems/ruby-2.7.7-guacamole/bin
    /Users/automationm2mini/.rvm/gems/ruby-2.7.7-guacamole@global/bin
    /Users/automationm2mini/.rvm/rubies/ruby-2.7.7-guacamole/bin
  Entries added to PATH to use selected Ruby:
    /Users/runner/hostedtoolcache/Ruby/3.2.2/arm64/bin
Error: Error: EACCES: permission denied, mkdir '/Users/runner'

My Step:

      - name: Wait for APK to upload
        uses: lewagon/[email protected]
        with:
          ref: ${{ github.ref }}
          check-name: 'Upload apk'
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          wait-interval: 10

Integrate with argocd

Hi I am not sure this lib can support or not?
I am implementing a flow after merge the post sync of argocd will be trigger and running integration test, in that time I also trigger the github action and it will wait for the post sync after post sync some how send the signal to the workflow then we can mark it as failed or pass to trigger rollback or not

When using check-regexp, job fails if no actions were found that match that regex

I have a repo for which different checks are run depending on which files were changed. We needed to enforce that checks pass prior to merging in main, and this action was an excellent solution since it will always be run, and we can use it as a status check for PRs to our protected main branch. We have some cases where no other jobs/workflows are run (e.g. if files that don't matter are changed). In these cases, we get an exit 1 from this action with The requested check was never run against this ref, exiting... and the job fails.

I was able to work around this by adding a "dummy job" above the job that runs this action, so there is always at least one other job for the action to check success for, but I'm wondering if an option could be added that will allow this action to pass with success if no jobs are found that match the regex (something like succeed-on-no-regex-matches: true). I do understand this may not align with the original intent of this action, so no worries if this is a low priority (especially since we also have a working workaround).

The action only waits for 30 checks

We've noticed that in some cases the wait-on-check action is not waiting for all our checks (here).

It seems that some of the method calls in the Checks API might have a per_page parameter that is not being passed and defaults to 30? Docs), so if one has more than 30 checks, the action won't wait for all of them (we currently have 40).

Passing 100 to per_page might work on our repo, but for anybody with more than 100 checks, this action should probably handle pagination in the API (also, just to be on the safe side if the max of 100 changes to a lower value).

The requested check was never run against this ref, exiting...

Hello!

I am using your action to solve a problem I have:

  • Workflow builds api on every push
  • We want e2e workflow to run on PRs to master -> Runs using build artifact

So I set up a new workflow with your action, I used github.sha as ref because it runs in pushes to the PR.

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- master

name: Wait until build is complete
uses: lewagon/[email protected]
with:
ref: ${{ github.sha }} # can be commit SHA or tag too
check-name: build # name of the existing check - omit to wait for all checks
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 15 # seconds

I got this error. Maybe they triggered at the same time and e2e run before build job was started? I dont know if the correct way to implement it is to place some "sleep 15" before your wait on check ๐Ÿค”
The requested check was never run against this ref, exiting...

Thank you for your time!

Can't find `action.yml`

This has been working without an issue until today I got the following error which failed my build. I haven't changed any of my configuration settings, however I noticed that your action was updated within the last week?

Screenshot 2023-02-22 at 3 09 27 PM

Screenshot 2023-02-22 at 3 07 32 PM

Feature: Support for GHE

Is it possible to add Github Enterprise support? Reading the ruby docs, it seems like we just need to configure api_endpoint if an ENV is.

If it's that easy I can open a PR but wanted to confirm first.

Feature request: Improved output when check-name is incorrect.

Currently if check-name is incorrect the output is:

The requested check was never run against this ref, exiting...

Since the action already fetches all check_runs, maybe we can report the names that the user may have meant:

The requested check was never run against this ref.

Checks that ran:
- ...
- ... 

Exiting...

Feature request: Allow a list of check-names.

Currently you can specify a single job name with 'check-name' or you can wait for all checks to pass with 'running-workflow-name'. There are situations when you may want to wait for two jobs to complete in parallel before continuing.

Exception raised on waiting for all jobs to finish

Hi,
We are using this plugin to wait on all checks on pull request to allow dynamic CI jobs with BORS (merge queuing)
The step sometimes fail on:
/usr/bin/docker run --name e4f55beca1679d4d5e9e170cc080dc764b_ec7072 --label 5588e4 --workdir /github/workspace --rm -e INPUT_REF -e INPUT_REPO-TOKEN -e INPUT_WAIT-INTERVAL -e INPUT_RUNNING-WORKFLOW-NAME -e INPUT_CHECK-NAME -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/epsagon-backend/epsagon-backend":"/github/workspace" 5588e4:f55beca1679d4d5e9e170cc080dc764b "" "" "***" "5" "jobs-ended" /entrypoint.rb:23:in query_check_status': undefined method reject' for nil:NilClass (NoMethodError) from /entrypoint.rb:34:in

'`

The step is defined as:
jobs: jobs-ended: runs-on: ubuntu-20.04 steps: - name: Wait on tests uses: lewagon/[email protected] with: ref: ${{ github.event.after }} # can be commit SHA or tag too repo-token: ${{ secrets.GITHUB_TOKEN }} wait-interval: 20 running-workflow-name: "jobs-ended"

Support for MacOS

Hi, awesome project.
Will you ever considered to support MacOS?

Right now we are getting this

Error: Container action is only supported on Linux

Feature request: reduce outputs

The wait-on-check produces a lot of outputs. Sometimes it made the GitHub web UI hang when trying to see the result. It would be nice to have a flag to make the output less verbose.
Maybe something like:

    - name: Wait on all tests
      uses: lewagon/wait-on-check-action@master
      with:
        ref: ${{ github.sha }}
        running-workflow-name: 'xxx'
        repo-token: ${{ secrets.GITHUB_TOKEN }}
        wait-interval: 180 # seconds
        allowed-conclusions: success
        verbose: false

Maybe the output can just be like:

Waited for 312 seconds.

18n 1.1 changed fallbacks to exclude default locale

Hey, I got this issue while using the action:

HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
But that may break your application.

If you are upgrading your Rails application from an older version of Rails:

Please check your Rails app for 'config.i18n.fallbacks = true'.
If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
'config.i18n.fallbacks = [I18n.default_locale]'.
If not, fallbacks will be broken in your app by I18n 1.1.x.

Pipeline exists after that.

What is strange is that I use this action on different repo and it works fine ๐Ÿ‘€

doesn't work on pull requests

The following workflow works fine if I run it on master (with on: [ push, pull_request ]), but it fails to detect any tests when running on the pull request branch. On that branch, it immediately returns, even though tests are still running.

on: [ pull_request ]

jobs:
  automerge:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Wait on tests
      uses: lewagon/wait-on-check-action@master
      with:
        ref: ${{ github.sha }}
        repo-token: ${{ secrets.GITHUB_TOKEN }}
        wait-interval: 10
        running-workflow-name: 'automerge' # HERE
    - name: Step to deploy
      run: echo 'success!'

Sample run: https://github.com/marten-seemann-test/target/runs/1940299479?check_suite_focus=true.
I assume this is because for some reason, it doesn't find any running tests:
image

Any ideas?

Allow skipped checks?

Hi ๐Ÿ‘‹

I have just added some jobs which get skipped on my master branch - and this has caused the wait-on-check action to fail ๐Ÿ™‚

My initial thought is that the action could consider skipped checks a success. What do you think? If this doesn't seem like something you'd want to do, maybe we could add a parameter to control how you want it to behave? Something like allowSkipped or allowStatuses: "success,skipped" or something?

Repo key is required from v1.0.0

When updating from v0.2 to v1.0.0, I noticed that the repo key is a requirement now, is there any reason for this? Accessing the runs for a repo seems to be public still.

The error I get when I don't specify repo-token: https://github.com/commaai/openpilot/runs/6807857911?check_suite_focus=true

/usr/local/bundle/gems/octokit-4.20.0/lib/octokit/response/raise_error.rb:14:in `on_complete': GET https://api.github.com/repos/commaai/openpilot/commits/master/check-runs: 401 - Bad credentials // See: https://docs.github.com/rest (Octokit::Unauthorized)
	from /usr/local/bundle/gems/faraday-1.3.0/lib/faraday/middleware.rb:19:in `block in call'
	from /usr/local/bundle/gems/faraday-1.3.0/lib/faraday/response.rb:59:in `on_complete'
	from /usr/local/bundle/gems/faraday-1.3.0/lib/faraday/middleware.rb:18:in `call'
	from /usr/local/bundle/gems/octokit-4.[20](https://github.com/commaai/openpilot/runs/6807857911?check_suite_focus=true#step:3:21).0/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
	from /usr/local/bundle/gems/octokit-4.20.0/lib/octokit/middleware/follow_redirects.rb:61:in `call'
	from /usr/local/bundle/gems/faraday-1.3.0/lib/faraday/request/retry.rb:148:in `call'
	from /usr/local/bundle/gems/faraday-1.3.0/lib/faraday/rack_builder.rb:154:in `build_response'
	from /usr/local/bundle/gems/faraday-1.3.0/lib/faraday/connection.rb:492:in `run_request'
	from /usr/local/bundle/gems/faraday-1.3.0/lib/faraday/connection.rb:198:in `get'
	from /usr/local/bundle/gems/sawyer-0.8.2/lib/sawyer/agent.rb:94:in `call'
	from /usr/local/bundle/gems/octokit-4.20.0/lib/octokit/connection.rb:156:in `request'
	from /usr/local/bundle/gems/octokit-4.20.0/lib/octokit/connection.rb:19:in `get'
	from /usr/local/bundle/gems/octokit-4.20.0/lib/octokit/client/checks.rb:68:in `check_runs_for_ref'
	from /app/services/github_checks_verifier.rb:[29](https://github.com/commaai/openpilot/runs/6807857911?check_suite_focus=true#step:3:30):in `query_check_status'
	from /app/services/github_checks_verifier.rb:92:in `wait_for_checks'
	from /app/services/github_checks_verifier.rb:20:in `call'
	from /app/services/application_service.rb:5:in `call'
	from /entrypoint.rb:19:in `<main>'

Missing trigger-test-workflows.sh.

In the README it is mentioned that ./github/trigger-scripts/trigger-test-workflows.sh triggers tests to run but the script does not exist.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.